//scroller init values
var borderColor = "#000000"
var backgroundColor = "#FFFFFF"
var scrollerWidth = 281;
var scrollerTop = 128;
var scrollerLeft = 281;
var scrollerHeight = 143;
var scrollerSpeed = 50;
var scrollerStep = 1;
var rightBorderWidth = 16;
var distBetween=30
var scrollerText = "<FONT CLASS='small'><B><img SRC='graphics/clr_dot.gif' HEIGHT='1' WIDTH='1'>ANCHOR PRODUCTS & SERVICES</B><BR><img SRC='graphics/clr_dot.gif' HEIGHT='4' WIDTH='1'><BR> <A href='seals.htm'><b>Seals</b></A><BR><img SRC='graphics/clr_dot.gif' HEIGHT='4' WIDTH='1'>" +
"<br><img SRC='graphics/clr_dot.gif' HEIGHT='1' WIDTH='8'>Mechanical Seals, Oil Seals, O-Rings, Valve<br><img SRC='graphics/clr_dot.gif' HEIGHT='1' WIDTH='8'>& Pump Packing, Hydraulic Seals & More!<BR><img SRC='graphics/clr_dot.gif' HEIGHT='4' WIDTH='1'><br> <A href='gaskets.htm'><b>Gaskets</b></A>" +
"<br><img SRC='graphics/clr_dot.gif' HEIGHT='1' WIDTH='8'>Garlock®, Thermoseal® {Klinger®}," +
"<br><img SRC='graphics/clr_dot.gif' HEIGHT='1' WIDTH='8'>Gore-Tex®, Spiralwound, Cloth, Tape, Wick," +
"<br><img SRC='graphics/clr_dot.gif' HEIGHT='1' WIDTH='8'>Rubber Products, Expansion Joints & More!<BR><img SRC='graphics/clr_dot.gif' HEIGHT='4' WIDTH='1'><br> <A href='nozzles.htm'><b>Nozzles</b></A>" +
"<br><img SRC='graphics/clr_dot.gif' HEIGHT='1' WIDTH='8'>Industrial Spray Nozzles - Authorized Delavan<br><img SRC='graphics/clr_dot.gif' HEIGHT='1' WIDTH='8'>Distributor<BR><img SRC='graphics/clr_dot.gif' HEIGHT='4' WIDTH='1'><br> <A href='misc.htm'><b>Miscellaneous Products</b></A>" +
"<br><img SRC='graphics/clr_dot.gif' HEIGHT='1' WIDTH='8'>Tools, Lubricants, Adhesives, Compounds," +
"<br><img SRC='graphics/clr_dot.gif' HEIGHT='1' WIDTH='8'>Coatings, Gauge & Lubricator Glass, Teflon®" +
"<br><img SRC='graphics/clr_dot.gif' HEIGHT='1' WIDTH='8'>Sealants, Graphite Powder & More!<BR><img SRC='graphics/clr_dot.gif' HEIGHT='4' WIDTH='1'><br> <A href='service.htm'><b>Service & Support</b></A>" +
"<BR><img SRC='graphics/clr_dot.gif' HEIGHT='1' WIDTH='8'>EDI, e-mail, Bar Coding, Credit Cards," +
"<BR><img SRC='graphics/clr_dot.gif' HEIGHT='1' WIDTH='8'>Training & Much, Much More!" +
"<BR><img SRC='graphics/clr_dot.gif' HEIGHT='4' WIDTH='1'>" +
"<BR><img SRC='graphics/clr_dot.gif' HEIGHT='1' WIDTH='3'><A href='contact.htm'><b>Contact Us!</b></A>" +
"<br><img SRC='graphics/clr_dot.gif' HEIGHT='1' WIDTH='8'>Contact Your Anchor Representative";


//getting browser type
var ns = (navigator.appName.toLowerCase().indexOf("netscape")!=-1)?1:0;
var ns6 = (document.getElementById && ns)?1:0;
var ie = (document.all)?1:0;
//creating scroller divs

var sufix = 0;
if (ns6) sufix = "px";

// START: fixing the page content for NS on resize >>>
RegenerateNS();
function RegenerateNS(){
	if (ns) setTimeout("window.onresize=Regenerate",500);
}
function Regenerate(){
	window.location.reload();
}
// <<< END: fixing the page content for Netscape on resize

scrollStatus = 1;
oldScrollStatus = 1;
scrollDirection = 0;
scrollID = 0;

//buttons images
var imagesName = new Array("btn_down_1.gif","btn_down_2.gif","btn_down_3.gif","btn_stop_1.gif","btn_stop_2.gif","btn_stop_3.gif","btn_up_1.gif","btn_up_2.gif","btn_up_3.gif")
var imagesObj = new Array()

for(var i = 0; i < imagesName.length; i++)
{
	imagesObj[i] = new Image();
	imagesObj[i].src = "Images/" + imagesName[i];
}

if(ns6 || ie)
{
	document.write("<DIV id='scrollerContainer' style='position:absolute; visibility:visible; width:"+ scrollerWidth +"px; height:"+ scrollerHeight +"px; left:" + scrollerLeft + "px; top:" + scrollerTop + "px; overflow:hidden;z-index:1'>");
	document.write("<TABLE border=0 cellspacing=0 cellpadding=0><TR><TD bgcolor="+ borderColor +" height="+ scrollerHeight +" width="+ (scrollerWidth-rightBorderWidth) +"><IMG src='Images/pixel.gif'></TD><TD width="+ rightBorderWidth +" bgcolor="+ borderColor +" valign=middle align=center>");
	document.write("<A href='javascript:void(null)' onmouseout='changeImage(1,6);checkScroll();' onmouseover='changeImage(1,7)' onmousedown='changeImage(1,8); scrollManual(1)' onmouseup='changeImage(1,7);stopScrollManual()'><IMG src='Images/btn_up_1.gif' border=0 name='scroller_img_1'></A><BR><IMG src='Images/pixel.gif' height=5 width=1><BR><A href='javascript:changeScrollStatus()' onmouseout='changeImage(2,3)' onmouseover='changeImage(2,4)'><IMG src='Images/btn_stop_1.gif' border=0 name='scroller_img_2'></A><BR><IMG src='Images/pixel.gif' height=5 width=1><BR><A href='javascript:void(null)' onmouseout='changeImage(3,0);checkScroll();' onmouseover='changeImage(3,1)' onmousedown='changeImage(3,2); scrollManual(2)' onmouseup='changeImage(3,1); stopScrollManual()'><IMG src='Images/btn_down_1.gif' border=0 name='scroller_img_3'></A></TD></TR></TABLE>");
		document.write("<DIV id='scroller1' style='position:absolute; visibility:visible; width:"+ (scrollerWidth - rightBorderWidth - 2)  +"px; height:"+ (scrollerHeight - 4) +"px; left:2px; top:2px; overflow:hidden; clip:rect(0," + (scrollerWidth - rightBorderWidth - 2) + ","+ (scrollerHeight - 4) +",0); z-index:1'>");
			document.write("<TABLE border=0 cellspacing=0 cellpadding=0><TR><TD height="+ (scrollerHeight - 4) +" width="+ (scrollerWidth - rightBorderWidth - 2)+" bgcolor="+ backgroundColor +"><IMG src='Images/pixel.gif'></TD></TR></TABLE>");
			document.write("<DIV id='scroller2' style='position:absolute; visibility:visible; width:"+ (scrollerWidth - rightBorderWidth - 2)  +"px; left:0px; top:"+ scrollerHeight +"px; overflow:hidden;z-index:1'>");
				document.write("<TABLE border=0 cellspacing=0 cellpadding=0><TR><TD width="+ (scrollerWidth - rightBorderWidth - 2)+" bgcolor="+ backgroundColor +">"+ scrollerText +"</TD></TR></TABLE>");
			document.write("</DIV>");
			document.write("<DIV id='scroller3' style='position:absolute; visibility:visible; width:"+ (scrollerWidth - rightBorderWidth - 2)  +"px; left:0px; top:"+ scrollerHeight +"px; overflow:hidden;z-index:1'>");
				document.write("<TABLE border=0 cellspacing=0 cellpadding=0><TR><TD width="+ (scrollerWidth - rightBorderWidth - 2)+" bgcolor="+ backgroundColor +">"+ scrollerText +"</TD></TR></TABLE>");
			document.write("</DIV>");
		document.write("</DIV>");
	document.write("</DIV>");

}
else
{
	document.write("<LAYER id='scrollerContainer' position=absolute visibility=visible width="+ scrollerWidth +" height="+ scrollerHeight +" left=" + scrollerLeft + " top=" + scrollerTop + " overflow=hidden z-index=1>");
	document.write("<TABLE border=0 cellspacing=0 cellpadding=0><TR><TD bgcolor="+ borderColor +" height="+ scrollerHeight +" width="+ (scrollerWidth- rightBorderWidth) +"><IMG src='Images/pixel.gif'></TD><TD width="+ rightBorderWidth +" bgcolor="+ borderColor +" valign=middle align=center>");
	document.write("<A href='javascript:void(null)' onmouseout='changeImage(1,6);checkScroll();' onmouseover='changeImage(1,7)' onmousedown='changeImage(1,8); scrollManual(1)' onmouseup='changeImage(1,7);stopScrollManual()'><IMG src='Images/btn_up_1.gif' border=0 name='scroller_img_1'></A><BR><IMG src='Images/pixel.gif' height=5 width=1><BR><A href='javascript:changeScrollStatus()' onmouseout='changeImage(2,3)' onmouseover='changeImage(2,4)'><IMG src='Images/btn_stop_1.gif' border=0 name='scroller_img_2'></A><BR><IMG src='Images/pixel.gif' height=5 width=1><BR><A href='javascript:void(null)' onmouseout='changeImage(3,0);checkScroll();' onmouseover='changeImage(3,1)' onmousedown='changeImage(3,2); scrollManual(2)' onmouseup='changeImage(3,1); stopScrollManual()'><IMG src='Images/btn_down_1.gif' border=0 name='scroller_img_3'></A></TD></TR></TABLE>");
		document.write("<LAYER id='scroller1' position=absolute visibility=visible width="+ (scrollerWidth - rightBorderWidth - 2) + " height="+ (scrollerHeight - 4) +" left=2 top=2 overflow=hidden clip=rect(0,0," + (scrollerWidth - rightBorderWidth - 2) + ","+ (scrollerHeight - 4) +") z-index=1>");
			document.write("<TABLE border=0 cellspacing=0 cellpadding=0><TR><TD height="+ (scrollerHeight - 4) +" width="+ (scrollerWidth - rightBorderWidth - 2)+" bgcolor="+ backgroundColor +"><IMG src='Images/pixel.gif'></TD></TR></TABLE>");
			document.write("<LAYER id='scroller2' position=absolute visibility=visible width="+ (scrollerWidth - rightBorderWidth - 2)  +" left=0 top="+ scrollerHeight +" z-index=1>");
				document.write("<TABLE border=0 cellspacing=0 cellpadding=0><TR><TD width="+ (scrollerWidth - rightBorderWidth -2)+" bgcolor="+ backgroundColor +">"+ scrollerText +"</TD></TR></TABLE>");
			document.write("</LAYER>");
			document.write("<LAYER id='scroller3' position=absolute visibility=visible width="+ (scrollerWidth - rightBorderWidth - 2)  +" left=0 top="+ scrollerHeight +" z-index=1>");
				document.write("<TABLE border=0 cellspacing=0 cellpadding=0><TR><TD width="+ (scrollerWidth - rightBorderWidth -2)+" bgcolor="+ backgroundColor +">"+ scrollerText +"</TD></TR></TABLE>");
			document.write("</LAYER>");
		document.write("</LAYER>");
	document.write("</LAYER>");
}

//scroller object height(InnerHTML height)
var scollerObjHeight, scollerObjHeight3;

//scroller div object
var scrollerObj, scrollerObj3;

//scroller functions
function startScroller()
{
	//getting scroller object height(InnerHTML height)
	if (ns6) {
		scollerObjHeight = document.getElementById('scroller2').offsetHeight;
		scollerObjHeight3 = document.getElementById('scroller3').offsetHeight;
	} else if (ns) {
		scollerObjHeight = parseInt(document.layers['scrollerContainer'].document.layers['scroller1'].document.layers['scroller2'].clip.height);
		scollerObjHeight3 = parseInt(document.layers['scrollerContainer'].document.layers['scroller1'].document.layers['scroller3'].clip.height);
	 } else {
	 	scollerObjHeight = parseInt(document.all['scroller2'].clientHeight);
		scollerObjHeight3 = parseInt(document.all['scroller3'].clientHeight);
	}
	
	//getting scroller div object
	if (ns6) {
		scrollerObj = document.getElementById('scroller2').style;
		scrollerObj3 = document.getElementById('scroller3').style;
	} else if (ns) {
		scrollerObj = document.layers['scrollerContainer'].document.layers['scroller1'].document.layers['scroller2'];
		scrollerObj3 = document.layers['scrollerContainer'].document.layers['scroller1'].document.layers['scroller3'];
	} else {
		scrollerObj = document.all['scroller2'].style;
		scrollerObj3 = document.all['scroller3'].style;
	}
	scrollerObj.top = (scrollerHeight + 5) + sufix;
	scrollerObj3.top = parseInt(scrollerObj.top) + parseInt(scollerObjHeight)+distBetween + sufix;
	
	scrollID++; 
	runScroller(scrollID);
}

function runScroller(tmpScrollID)
{
	if (tmpScrollID != scrollID) return;
	if(scrollStatus == 1)
	{
		if (parseInt(scrollerObj.top)>-1*scollerObjHeight) {
			scrollerObj.top = (parseInt(scrollerObj.top) - scrollerStep) + sufix
		} else {
			scrollerObj.top = parseInt(scrollerObj3.top) + parseInt(scollerObjHeight3)+distBetween + sufix;
		}
		if (parseInt(scrollerObj3.top)>-1*scollerObjHeight3) {
			scrollerObj3.top = (parseInt(scrollerObj3.top) - scrollerStep) + sufix;
		} else {
			scrollerObj3.top = parseInt(scrollerObj.top) + parseInt(scollerObjHeight)+distBetween + sufix;
		}
		setTimeout("runScroller("+ tmpScrollID +")",scrollerSpeed);
	}
	else
	{
		if(scrollDirection > 0)
		{
			if(scrollDirection == 2) 
			{
				if (parseInt(scrollerObj.top) > -1 * scollerObjHeight) {
					scrollerObj.top = (parseInt(scrollerObj.top) - scrollerStep*8) + sufix;
				} else {
					scrollerObj.top = parseInt(scrollerObj3.top) + parseInt(scollerObjHeight3)+distBetween + sufix;
				}
				if (parseInt(scrollerObj3.top) > -1 * scollerObjHeight3) {
					scrollerObj3.top = (parseInt(scrollerObj3.top) - scrollerStep*8) + sufix;
				} else {
					scrollerObj3.top = parseInt(scrollerObj.top) + parseInt(scollerObjHeight)+distBetween + sufix;
				}
				
			}	
			else
			{
				if (parseInt(scrollerObj.top) <  scollerObjHeight) {
					scrollerObj.top = (parseInt(scrollerObj.top) + scrollerStep*8) + sufix;
				} else {
					scrollerObj.top = parseInt(scrollerObj3.top)-parseInt(scollerObjHeight)-distBetween+sufix;
				}
				if (parseInt(scrollerObj3.top) <  scollerObjHeight3) {
					scrollerObj3.top = (parseInt(scrollerObj3.top) + scrollerStep*8) + sufix;
				} else {
					scrollerObj3.top = parseInt(scrollerObj.top)-parseInt(scollerObjHeight3)-distBetween+sufix;
				}
			}	 
			setTimeout("runScroller("+ tmpScrollID +")",parseInt(scrollerSpeed/2));
		}
	}
}

function changeImage(imgObjIndex,imgPathindex)
{
	if ((imgObjIndex == 2) && (scrollStatus == 0)) return;
	if(ns6 || ie) eval("document.images['scroller_img_"+ imgObjIndex +"']").src = imagesObj[imgPathindex].src;
	else eval("document.layers['scrollerContainer'].document.images['scroller_img_"+ imgObjIndex +"']").src = imagesObj[imgPathindex].src;
}

function changeScrollStatus()
{
	if(scrollStatus == 0)
	{ 
		scrollStatus = 1;
		changeImage(2,4);
		scrollID++; 
		runScroller(scrollID);
	}	
	else 
	{
		changeImage(2,5);
		scrollStatus = 0;
	}	
}

function scrollManual(tmp_scrollDirection)
{
	oldScrollStatus = scrollStatus;
	scrollStatus = 0;
	scrollDirection = tmp_scrollDirection;
	scrollID++; 
	runScroller(scrollID);
}

function stopScrollManual()
{
	scrollDirection = 0;
	scrollStatus = oldScrollStatus;
	scrollID++; 
	runScroller(scrollID);
}

function checkScroll()
{
	if (scrollDirection != 0) stopScrollManual();
}