
///i think the crux is distinguishing betqween seperate cross_slide variables
//need to make sure copy speed gets reset
//http://logicbox.net/jquery/simplyscroll/custom.html

var copyspeed = new Array();
var cross_slide2 = new Array();
var cross_slide = new Array();
var lefttime = new Array();

//gap between slideshow rotation in pixels
var slideshowgap='';
     
function fillup(leftrightslide, slideshowgap, c, stc){



if (document.getElementById("test2_"+c) != null) {
	
	
	cross_slide[c]= document.getElementById("test2_"+c);
	
}



if (document.getElementById("test3_"+c) != null) {
	
cross_slide2[c]= document.getElementById("test3_"+c);
	
}

cross_slide[c].innerHTML=cross_slide2[c].innerHTML=leftrightslide;

var actualwidth= cross_slide[c].offsetWidth;

cross_slide2[c].style.left=(actualwidth+slideshowgap)+"px";




lefttime[c]=setInterval("slideleft("+c+", "+actualwidth+")", stc);
}
//window.onload=fillup
/*
5119 0,-1, -2, -3, -4, -5 ...-5111

-5112 + 5119 = 8;




*/
//slide left function


function slideleft(c, actualwidth){
var newgap = actualwidth + 100;




if (parseInt(cross_slide[c].style.left)>(actualwidth*(-1)+8)) {

//this moves our fist div to the left
cross_slide[c].style.left=parseInt(cross_slide[c].style.left)-copyspeed[c]+"px";


} else {
	
	
	
cross_slide[c].style.left=(parseInt(cross_slide2[c].style.left)+newgap)+"px";




}







if (parseInt(cross_slide2[c].style.left)>(actualwidth*(-1)+8)) {

//this moves our second div test3 to the left
cross_slide2[c].style.left=parseInt(cross_slide2[c].style.left)-copyspeed[c]+"px";

} else {

cross_slide2[c].style.left=parseInt(cross_slide[c].style.left)+actualwidth+slideshowgap+"px";




}

}//end function





function writeMarquee(sliderwidth, sliderheight, c, slidespeed) {



if (document.getElementById('scroll_'+c) != null) {


var mydiv = document.getElementById('scroll_'+c);



mydiv.innerHTML += '<div style="overflow:hidden;"><div style="width:'+sliderwidth+';height:'+sliderheight+';overflow:hidden;"><div id="main_'+c+'" style="overflow:hidden; position:absolute;width:3000px;height:'+sliderheight+'" onMouseover="copyspeed['+c+']=0;" onMouseout="copyspeed['+c+']='+slidespeed+';"><div id="test2_'+c+'" style="position:absolute;left:0px;top:0px;"></div><div id="test3_'+c+'" style="position:absolute;left:-10000px;top:0px; margin-left:50px;"></div></div></div></div>';

}

}//end function



function getArray(div) {
var div = div;
if (document.getElementById(div) != null) {

var content = document.getElementById(div).innerHTML;


return content;
}

}



function addLoadEvent(func) {
  var oldonload = window.onload;
  if (typeof window.onload != 'function') {
    window.onload = func;
  } else {
    window.onload = function() {
      oldonload();
      func();
    }
  }
}




function initiateScroll() {

if (document.getElementById('scrollcontent') != null) {
 
 if(!document.getElementsByTagName) return false;
 
var mainDiv = document.getElementById('scrollcontent');
var rows = mainDiv.getElementsByTagName("div");
     
     for (var i=0; i<rows.length; i++) {
     
     	//Specify the slider's width (in pixels)
		var sliderwidth="4000px";
		//Specify the slider's height
		var sliderheight="40px";
		
		//Specify the slider's slide speed (larger is faster 1-10)
		var slidespeed='1';
		
		
		if (i == '1') {
			
			var setintervaltime = '50';
			//var bg = '#660000';
			
		} else if (i == '2') {
			
			var setintervaltime = '20';
			//var bg = '#120330';
			
		} else if (i == '3') {
			
			var setintervaltime = '30';
			//var bg = '#890330';
			
			} else if (i == '4') {
				
				var setintervaltime = '40';
				//var bg = '#406723';
				} else if (i == '5') {
		
					var setintervaltime = '20';
		var bg = '#909045';
		} else {
			
			var setintervaltime = '30';
			//var bg = '#347856';
		}
		
		
		copyspeed[i]=slidespeed;

		
     //now with each entry, start up the scroll
	 //this is the div like myText
	 
	 //the getarray function is just grabbing the contents
     var leftrightslide = '<nobr>'+getArray(rows[i].id)+'</nobr>';
     
     
     
    
		//leftrightslide='<nobr>'+leftrightslide+'</nobr>';


		//iedom=document.all||document.getElementById
		//if (iedom)
		//Not Sure what or where this is doing
		
	//if (document.getElementById('temp_'+i) != null) {
	
	//document.getElementById('temp_'+i).innerHTML = leftrightslide;
	
	//}
	
		
var actualwidth='';
//var margintop = i + 10;
	//i thinks we need to empty the old one?
	//or create unique fields
	
     writeMarquee(sliderwidth, sliderheight, i, slidespeed);
     fillup(leftrightslide, slideshowgap, i, setintervaltime);
     
     
     
     
     }//end forloop


}//end if exists
}//end function







addLoadEvent(initiateScroll);
