/***********************************************
* Pausing updown message scroller- © Dynamic Drive DHTML code library (www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit Dynamic Drive at http://www.dynamicdrive.com/ for full source code
***********************************************/
//Webscope
//define speed in pixels
var movespeed = '3';

//configure the below five variables to change the style of the scroller
var scrollerdelay='1000' //delay between msg scrolls. 3000=3 seconds.
var scrollerwidth='130px'
var scrollerheight='300px'
var scrollerbgcolor=''
//set below to '' if you don't wish to use a background image
var scrollerbackground=''
var statusStyle = "color: #224EA7; font-size: 10px; line-height: 9px; font-family: Verdana, Arial, Helvetica; text-decoration: none;";

//configure the below variable to change the contents of the scroller

var messages=new Array()
		messages[0]="11/22/11<br> <br>Welcome to ASL's new state of the art website.  You will find anything you could want on this website.<br>From overbed, sconces,  pendants, drums, exterior, all the way to utility, you will find it all here.   Browse our catalog, dynamic scroller, or just search for the fixture you want using our quick product search option above.  "
		messages[1]="7/7/2011: <br> <br>NEW PRODUCT OFFERING !!!!!!!!!<br><br>AN EXCITING AND EXTENSIVE OFFERING OF CUT OFF LUMINAIRES AND CAGED BULKHEAD LUMINAIRES ARE NOW AVAILABLE.  <br>ASK YOUR LOCAL SALES REPRESENTATIVES FOR THIS UNIQUE OFFERING AND PRICING.  "
		messages[2]="3-5-11<br><br>!!!!!!NEW PRODUCTS!!!!!!  <br>ASL HAS A BRAND NEW LINE OF DARK SKY COMPLIANT FIXTURES. SPECIFICATION SHEETS ARE AVAILABLE ONLINE UNDER THE SPEC'S SECTION OF OUR WEBSITE. ASK YOUR LOCAL REP FOR DETAILS OR CONTACT ASL AT 800-369-1101   "
		messages[3]="11/11/2011  <br>Did you know that all ASL fixtures are manufactured in the United States, and can be manufactured to meet the “Made in America” clause in the new stimulus bill?  <br>Just add \"MIA” to your quote request and we will take care of the rest.  <br>Thanks the ASL TEAM <br>!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!  <br>"
		messages[4]="<br>Great News!!!!  ASL now has all of the specification sheets for the styles in the new catalog available online.  Just click on the resource menu above and chose the specification sheet option at the top of the page to see a listing of the ones that are available.  If you do not see what you are looking for, feel free to contact us or submit a request online. This is just one way ASL is lighting your way. "
		messages[5]="ASL is happy to announce that the new GU24 technology is now available in all of our new fixtures!  Choose GU24 technology and give YOUR customer's the world's easiest to maintain compact flourescent technology!"
		messages[6]="ASL is happy to announce that the new LED technology is now available in all of our new fixtures!  Choose LED technology and give YOUR customer's the opportunity to reduce their monthy electric costs!"
///////Do not edit pass this line///////////////////////
// some new variables
var running = 0;
var stopped = 0;
var stopCompleted = 0;
var scrollForward = 1;
var topLayer;
var bottomLayer;

var ie=document.all
var dom=document.getElementById

if (messages.length>2)
	i=2
else
	i=0

function move1(whichlayer){
	tlayer=eval(whichlayer)
	if (tlayer.top>0&&tlayer.top<=5){
		tlayer.top=0
		setTimeout("move1(tlayer)",scrollerdelay)
		setTimeout("move2(document.main.document.second)",scrollerdelay)
		return
	}
	if (tlayer.top>=tlayer.document.height*-1){
		tlayer.top-=5
		setTimeout("move1(tlayer)",50)
	}
	else{
		tlayer.top=parseInt(scrollerheight)
		tlayer.document.write(messages[i])
		tlayer.document.close()
		if (i==messages.length-1)
			i=0
		else
			i++
	}
}

function move2(whichlayer){
	tlayer2=eval(whichlayer)
	if (tlayer2.top>0&&tlayer2.top<=5){
		tlayer2.top=0
		setTimeout("move2(tlayer2)",scrollerdelay)
		setTimeout("move1(document.main.document.first)",scrollerdelay)
		return
	}
	if (tlayer2.top>=tlayer2.document.height*-1){
		tlayer2.top-=5
		setTimeout("move2(tlayer2)",50)
	}
	else{
		tlayer2.top=parseInt(scrollerheight)
		tlayer2.document.write(messages[i])
		tlayer2.document.close()
		if (i==messages.length-1)
			i=0
		else
			i++
	}
}

function move3(whichdiv){
	tdiv=eval(whichdiv)
	if (parseInt(tdiv.style.top)>0&&parseInt(tdiv.style.top)<=5){
		tdiv.style.top=0+"px"
		if (stopped == 1) {switchButton(1); return;}
		setTimeout("move3(tdiv)",scrollerdelay)
		setTimeout("move4(second2_obj)",scrollerdelay)
		return
	}
	if (parseInt(tdiv.style.top)>=tdiv.offsetHeight*-1){
		if (stopped == 1 && parseInt(tdiv.style.top) == 0) {switchButton(1); return;}
		if (stopped == 1 && parseInt(tdiv.style.top) == parseInt(scrollerheight)) {switchButton(1); return;}
		tdiv.style.top=parseInt(tdiv.style.top)-movespeed+"px"
		setTimeout("move3(tdiv)",50)
	}
	else{
		tdiv.style.top=parseInt(scrollerheight)
		tdiv.innerHTML=messages[i]
		itemStatus();
		if (i==messages.length-1)
			i=0
		else
			i++
	}
}

function move4(whichdiv){
	tdiv2=eval(whichdiv)
	if (parseInt(tdiv2.style.top)>0&&parseInt(tdiv2.style.top)<=5){
		tdiv2.style.top=0+"px"
		if (stopped == 1) {switchButton(1); return;}
		setTimeout("move4(tdiv2)",scrollerdelay)
		setTimeout("move3(first2_obj)",scrollerdelay)
		return
	}
	if (parseInt(tdiv2.style.top)>=tdiv2.offsetHeight*-1){
		if (stopped == 1 && parseInt(tdiv2.style.top) == 0) {switchButton(1); return;}
		if (stopped == 1 && parseInt(tdiv2.style.top) == parseInt(scrollerheight)) {switchButton(1); return;}
		tdiv2.style.top=parseInt(tdiv2.style.top)-movespeed+"px"
		setTimeout("move4(second2_obj)",50)
	}
	else{
		tdiv2.style.top=parseInt(scrollerheight)
		tdiv2.innerHTML=messages[i]
		itemStatus();
		if (i==messages.length-1)
			i=0
		else
			i++
	}
}

function startscroll(){
	// make sure function doesn't fun twice
	if (running != 0)
		return

	running++

	if (ie||dom){
		first2_obj=ie? first2 : document.getElementById("first2")
		second2_obj=ie? second2 : document.getElementById("second2")
		move3(first2_obj)
		second2_obj.style.top=scrollerheight
		second2_obj.style.visibility='visible'
		switchButton(0);
		document.getElementById("itemStatus").innerHTML = '<span id="itemStatus" style="' + statusStyle + '">  1 of ' + messages.length + '</span>';
	}
	else if (document.layers){
		document.main.visibility='show'
		move1(document.main.document.first)
		document.main.document.second.top=parseInt(scrollerheight)+5
		document.main.document.second.visibility='show'
	}
}

function itemStatus() {
	document.getElementById("itemStatus").innerHTML = '<span id="itemStatus" style="' + statusStyle + '">' + (i==0?messages.length:i) + ' of ' + messages.length + '</span>';
}

function stopScroll() {
	stopped = 1;
	switchButton(2);
}

function restartScroll() {
	if (stopped == 0 ) {return;}
	stopped = 0;
	if (scrollForward == 0) {
		if (i==messages.length-1) {
			i=1;
		} else if (i==messages.length-2) {
			i=0;
		} else {
			i=i+2
		}
	}

	move3(first2_obj);
	move4(second2_obj);

	switchButton(0);
	scrollForward = 1;
	stopCompleted = 0;
}

function switchButton(what) {
	if (what==0) {
		document.getElementById("startstop").innerHTML = '<a href="javascript:stopScroll();"><img src="/images/right_now_hold.gif" name="right_now_hold" border="0" align="absmiddle" width="65" height="7" alt="Pause Scroll" onMouseOver="scrollIconSwap(\'right_now_hold\',this,0);" onMouseOut="scrollIconSwap(\'right_now_hold\',this,1);"></a>';
		document.getElementById("nextbutton").innerHTML = '<a href="javascript:nextScroll();"><img src="/images/right_now_forward.gif" name="right_now_forward" border="0" align="absmiddle" width="7" height="9" alt="Next Item" onMouseOver="scrollIconSwap(\'right_now_forward\',this,0);" onMouseOut="scrollIconSwap(\'right_now_forward\',this,1);"></a>';
		document.getElementById("backbutton").innerHTML = '<a href="javascript:backScroll();"><img src="/images/right_now_back.gif" name="right_now_back" border="0" align="absmiddle" width="7" height="9" alt="Previous Item" onMouseOver="scrollIconSwap(\'right_now_back\',this,0);" onMouseOut="scrollIconSwap(\'right_now_back\',this,1);"></a>';
	} else if (what==1) {
		first2_top=parseInt(document.getElementById("first2").style.top)
		second2_top=parseInt(document.getElementById("second2").style.top)
		if ((first2_top != 0 && first2_top != parseInt(scrollerheight)) || (second2_top != 0 && second2_top != parseInt(scrollerheight))) {
			setTimeout("switchButton(1)",50)
			return;
		}
		document.getElementById("startstop").innerHTML = '<a href="javascript:restartScroll();"><img src="/images/right_now_scroll.gif" name="right_now_scroll" border="0" align="absmiddle" width="65" height="7" alt="Resume Scroll" onMouseOver="scrollIconSwap(\'right_now_scroll\',this,0);" onMouseOut="scrollIconSwap(\'right_now_scroll\',this,1);"></a>';
		document.getElementById("nextbutton").innerHTML = '<a href="javascript:nextScroll();"><img src="/images/right_now_forward.gif" name="right_now_forward" border="0" align="absmiddle" width="7" height="9" alt="Next Item" onMouseOver="scrollIconSwap(\'right_now_forward\',this,0);" onMouseOut="scrollIconSwap(\'right_now_forward\',this,1);"></a>';
		document.getElementById("backbutton").innerHTML = '<a href="javascript:backScroll();"><img src="/images/right_now_back.gif" name="right_now_back" border="0" align="absmiddle" width="7" height="9" alt="Previous Item" onMouseOver="scrollIconSwap(\'right_now_back\',this,0);" onMouseOut="scrollIconSwap(\'right_now_back\',this,1);"></a>';
		stopCompleted = 1;
	} else if (what==2) {
		document.getElementById("startstop").innerHTML = '<img src="/images/right_now_wait.gif" border="0" align="absmiddle" width="65" height="7" alt="Please Wait...">';
		document.getElementById("nextbutton").innerHTML = '<img src="/images/right_now_forward.gif" name="right_now_forward" border="0" align="absmiddle" width="7" height="9" alt="Next Item">';
		document.getElementById("backbutton").innerHTML = '<img src="/images/right_now_back.gif" name="right_now_back" border="0" align="absmiddle" width="7" height="9" alt="Previous Item">';
	}
}

function nextScroll() {
	if (stopped == 0) {	stopScroll(); }
	if (stopCompleted == 0) {
		setTimeout("nextScroll()",50)
		return;
	}
	if (parseInt(document.getElementById("first2").style.top)==0) {
		topLayer = document.getElementById("first2");
		bottomLayer = document.getElementById("second2");
	} else {
		bottomLayer = document.getElementById("first2");
		topLayer = document.getElementById("second2");
	}
	if (scrollForward == 0) {
		if (i==messages.length-1) {
			i=1;
		} else if (i==messages.length-2) {
			i=0;
		} else {
			i=i+2
		}
	}
	eval(topLayer).innerHTML = (i==0?messages[messages.length-1]:messages[i-1]);
	eval(bottomLayer).innerHTML = messages[i];
	itemStatus();
	scrollForward = 1;
	if (i==messages.length-1) {
		i=0;
	} else {
		i++;
	}
}

function backScroll() {
	if (stopped == 0) {	stopScroll(); }
	if (stopCompleted == 0) {
		setTimeout("backScroll()",50)
		return;
	}
	if (parseInt(document.getElementById("first2").style.top)==0) {
		topLayer = document.getElementById("first2");
		bottomLayer = document.getElementById("second2");
	} else {
		bottomLayer = document.getElementById("first2");
		topLayer = document.getElementById("second2");
	}
	if (scrollForward == 1) {
		if (i==0) {
			i=messages.length-2;
		} else if (i==1) {
			i=messages.length-1;
		} else {
			i=i-2
		}
	}
	eval(topLayer).innerHTML = (i==0?messages[messages.length-1]:messages[i-1]);
	eval(bottomLayer).innerHTML = messages[i];
	itemStatus();
	scrollForward = 0;
	if (i==0) {
		i=messages.length-1;
	} else {
		i--;
	}
}

function scrollIconSwap(iconImg, what, which) {
	var imgPath = "/images/";
	if (which == 0) {
		what.src = imgPath + iconImg + "_over.gif";
	} else {
		what.src = imgPath + iconImg + ".gif";
	}
}

window.onload=startscroll

