//BB_ this script contains parts to be executed not just defined
//so must be placed in the body of the document

//Also Note: the images needed for the conveyor are ALL written into the documents HTML tree
//there are no-rollovers displaying yet unseen images and so NO image preloading need take place!
//the conveyor is fully ready to go when the onload event of the document is triggered

//Specify the slider's width (in pixels)
var sliderwidth="500px"
//Specify the slider's height
var sliderheight="60px"
//configure background color:
slidebgcolor="#EAEAEA"
//speed
var slidespeed = 1;
//width, now specified absolutely
var actualwidth = 1564; //991;

/* BB_ **************** make the html to fill the products conveyor table *******************/
		var leftrightslide=new Array()
		var finalslide=''
		var spacer = '<td><img src="../images/spacer.gif" width="5" height="1"></td>';
		leftrightslide[0]='<tr><td><a href="http://www.camelbak.com" target="_blank"><img src="../images/productlogos/conveyor/camelbak_conveyor.gif" width="91" height="60"></a></td>';
		leftrightslide[1]=spacer;
		leftrightslide[2]='<td><a href="http://www.campagnolo.com" target="_blank"><img src="../images/productlogos/conveyor/campagnolo_conveyor.gif" width="135" height="60"></a></td>';
		leftrightslide[3]=spacer;
		leftrightslide[4]='<td><a href="http://www.parktool.com" target="_blank"><img src="../images/productlogos/conveyor/parktool_conveyor.gif" width="81" height="60"></a></td>';
		leftrightslide[5]=spacer;
		leftrightslide[6]='<td><a href="http://www.mavic.com" target="_blank"><img src="../images/productlogos/conveyor/mavic_conveyor.gif" width="96" height="60"></a></td>';
		leftrightslide[7]=spacer;
		leftrightslide[8]='<td><a href="http://www.cateye.com" target="_blank"><img src="../images/productlogos/conveyor/cateye_conveyor.gif" width="71" height="60"></a></td>';
		leftrightslide[9]=spacer;
		leftrightslide[10]='<td><a href="http://www.cinelli.it/eng" target="_blank"><img src="../images/productlogos/conveyor/cinelli_conveyor.gif" width="106" height="60"></a></td>';
		leftrightslide[11]=spacer;
		leftrightslide[12]='<td><a href="http://www.shimano.com" target="_blank"><img src="../images/productlogos/conveyor/shimano_conveyor.gif" width="126" height="60"></a></td>';
		leftrightslide[13]=spacer;
		leftrightslide[14]='<td><a href="http://www.marzocchi.com" target="_blank"><img src="../images/productlogos/conveyor/marzocchi_conveyor.gif" width="79" height="60"></a></td>';
		leftrightslide[15]=spacer;
		leftrightslide[16]='<td><a href="http://www.hopetech.com" target="_blank"><img src="../images/productlogos/conveyor/hope_conveyor.gif" width="102" height="60"></a></td>';
		leftrightslide[17]=spacer;
		leftrightslide[18]='<td><a href="http://www.giro.com" target="_blank"><img src="../images/productlogos/conveyor/giro_conveyor.gif" width="54" height="60"></a></td>';
		leftrightslide[19]=spacer;

		leftrightslide[20]='<td><a href="http://www.www.itm.it" target="_blank"><img src="../images/productlogos/conveyor/ITM_conveyor.gif" width="110" height="60"></a></td>';
		leftrightslide[21]=spacer;
		
		leftrightslide[22]='<td><a href="http://www.www.fizik.it" target="_blank"><img src="../images/productlogos/conveyor/fizik_conveyor.gif" width="112" height="60"></a></td>';
		leftrightslide[23]=spacer;

		leftrightslide[24]='<td><a href="http://www.lashelmets.com" target="_blank"><img src="../images/productlogos/conveyor/LAS_conveyor.gif" width="108" height="60"></a></td>';
		leftrightslide[25]=spacer;

		leftrightslide[26]='<td><a href="http://www.fullspeedahead.com" target="_blank"><img src="../images/productlogos/conveyor/FSA_conveyor.gif" width="130" height="60"></a></td>';
		leftrightslide[27]=spacer;

		leftrightslide[28]='<td><a href="http://www.northwave.it" target="_blank"><img src="../images/productlogos/conveyor/northwave_conveyor.gif" width="88" height="60"></a></td>';
		leftrightslide[29]=spacer;

		
/****************************************************/

	var copyspeed=slidespeed
	leftrightslide='<table border=0 cellpadding=0 cellspacing=0>'+leftrightslide.join(" ")+'</table>'
	var iedom=document.all||document.getElementById
	if (iedom)
		//BB_ this line positions temporary span way out of doc window (it is only used to get a width)
		//but is not used in this version because actualWidth is specified absolutely
		//document.write('<span id="temp" style="visibility:hidden;position:absolute;top:-100px;left:-9000px">'+leftrightslide+'</span>')
		var cross_slide, ns_slide

	/* BB_ Put initial HTML into conveyor
	 *
	 */
	function fillup(){
		if (iedom){
			cross_slide=document.getElementById? document.getElementById("test2") : document.all.test2
			cross_slide2=document.getElementById? document.getElementById("test3") : document.all.test3
			cross_slide.innerHTML=cross_slide2.innerHTML=leftrightslide
			
			//BB_ the code below has been taken out becuause all netscape 6x and 7x browsers calc the
			//actual width to be an astronomic value! IE and Mozilla work as expected though.

			 //actualwidth=document.all? cross_slide.offsetWidth : document.getElementById("temp").offsetWidth
			      //.offsetWidth seems to get the display width of the <div> tag contents
		}
		else if (document.layers){
			ns_slide=document.ns_slidemenu.document.ns_slidemenu2;
			ns_slide2=document.ns_slidemenu.document.ns_slidemenu3;
			ns_slide.document.write(leftrightslide);
			ns_slide.document.close();
			actualwidth=ns_slide.document.width;
			ns_slide2.left=actualwidth+0;
			ns_slide2.document.write(leftrightslide);
			ns_slide2.document.close();
		}
		//BB_ Go!!!!
		lefttime=setInterval("slideleft()",30);
	}


	/* BB_ move both conveyor layers to the left, or re-stack them
	 * in a one-potato two-potato style to give seemless conveyor
	 *
	 */
	function slideleft(){
		if (iedom){
			if (parseInt(cross_slide.style.left)>(actualwidth*(-1)+8))
				//BB_ move layer 1 left
				cross_slide.style.left=parseInt(cross_slide.style.left)-copyspeed+"px";
			else
			    //BB_ put layer 1 to the right of layer 2
				cross_slide.style.left=parseInt(cross_slide2.style.left)+actualwidth+0+"px";
			if (parseInt(cross_slide2.style.left)>(actualwidth*(-1)+8))
				//BB_ move layer 2 left
				cross_slide2.style.left=parseInt(cross_slide2.style.left)-copyspeed+"px";
			else 
				//BB_ put layer 2 to the right of layer 1 (exe by default when conveyor starts)
				cross_slide2.style.left=parseInt(cross_slide.style.left)+actualwidth+0+"px";
		}
		else if (document.layers){
			if (ns_slide.left>(actualwidth*(-1)+8))
				ns_slide.left-=copyspeed;
			else
				ns_slide.left=ns_slide2.left+actualwidth+0;
				if (ns_slide2.left>(actualwidth*(-1)+8))
					ns_slide2.left-=copyspeed;
				else
					ns_slide2.left=ns_slide.left+actualwidth+0;
		}
	}
	
	/* BB_ **************  write the HTML for the control into the document **************/
	if (iedom||document.layers){
		with (document){
			write('<table border="0" cellspacing="0" cellpadding="0"><tr><td>');
			
			if (iedom){
				write('<div style="position:relative;width:'+sliderwidth+';height:'+sliderheight+';overflow:hidden">');
				write('<div style="position:absolute;width:'+sliderwidth+';height:'+sliderheight+';background-color:'+slidebgcolor+'" onMouseover="copyspeed=0" onMouseout="copyspeed=slidespeed">');
				write('<div id="test2" style="position:absolute;left:0px;top:0px"></div>');
				write('<div id="test3" style="position:absolute;left:-2000px;top:0px"></div>');
				write('</div></div>')
			}
			else if (document.layers){
				//BB_ note: you cant actually stop the conveyor in Netscape 4.x (which uses the layers part of this code)
				write('<ilayer width='+sliderwidth+' height='+sliderheight+' name="ns_slidemenu" bgColor='+slidebgcolor+'>');
				write('<layer name="ns_slidemenu2" left=0 top=0></layer>');
				write('<layer name="ns_slidemenu3" left=0 top=0></layer>');
				write('</ilayer>');
			}
			write('</td></tr></table>');
		}
	}

