// CREDITS:
// Image Scroller 2.03 with double-fade effect
// By Peter Gehrig
// Copyright (c) 2003 Peter Gehrig. All rights reserved.
// Permission given to use the script provided that this notice remains as is.
// Additional scripts can be found at http://www.24fun.com
// info@24fun.com
// 9/6/2002

// IMPORTANT:
// If you add this script to a script-library or script-archive
// you have to add a highly visible link to
// http://www.24fun.com on the webpage
// where this script will be featured




var Imgcounter = 7;
var totalimgs = 21;

// URLs of slides
var slideurl = new Array();
slideurl[0] = "http://www.mgmelectricalsurplus.com/images/products/west3ph1view3.jpg";
slideurl[1] = "http://www.mgmelectricalsurplus.com/images/products/mcgraw3ph1view1.jpg";
slideurl[2] = "http://www.mgmelectricalsurplus.com/images/products/87PhotoPath1.jpg";
slideurl[3] = "http://www.mgmelectricalsurplus.com/images/products/cbBoiler1img1.jpg";
slideurl[4] = "http://www.mgmelectricalsurplus.com/images/products/106PhotoPath1.jpg"
slideurl[5] = "http://www.mgmelectricalsurplus.com/images/products/west3ph2view1.jpg";
slideurl[6] = "http://www.mgmelectricalsurplus.com/images/products/54PhotoPath1.jpg";
slideurl[7] = "http://www.mgmelectricalsurplus.com/images/products/53PhotoPath6.jpg";
slideurl[8] = "http://www.mgmelectricalsurplus.com/images/products/93PhotoPath1.jpg";
slideurl[9] = "http://www.mgmelectricalsurplus.com/images/products/90PhotoPath1.jpg";
slideurl[10] = "http://www.mgmelectricalsurplus.com/images/products/182PhotoPath1.jpg";
slideurl[11] = "http://www.mgmelectricalsurplus.com/images/products/55PhotoPath1.jpg";
slideurl[12] = "http://www.mgmelectricalsurplus.com/images/products/222PhotoPath1.jpg";
slideurl[13] = "http://www.mgmelectricalsurplus.com/images/products/52PhotoPath1.jpg";
slideurl[14] = "http://www.mgmelectricalsurplus.com/images/products/97PhotoPath1.jpg";
slideurl[15] = "http://www.mgmelectricalsurplus.com/images/products/111PhotoPath1.jpg";
slideurl[16] = "http://www.mgmelectricalsurplus.com/images/products/196PhotoPath1.jpg";
slideurl[17] = "http://www.mgmelectricalsurplus.com/images/products/92PhotoPath1.jpg";
slideurl[18] = "http://www.mgmelectricalsurplus.com/images/products/190PhotoPath1.jpg";
slideurl[19] = "http://www.mgmelectricalsurplus.com/images/products/95PhotoPath1.jpg";
slideurl[20] = "http://www.mgmelectricalsurplus.com/images/products/234PhotoPath1.jpg";
slideurl[21] = "http://www.mgmelectricalsurplus.com/images/products/216PhotoPath1.jpg";
slideurl[22] = "http://www.mgmelectricalsurplus.com/images/products/65PhotoPath1.jpg";



// comments displayed below the slides
var slidecomment = new Array();
slidecomment[0] = "Westinghouse";
slidecomment[1] = "McGraw-Edison";
slidecomment[2] = "Westinghouse";
slidecomment[3] = "Cleaver-Brooks";
slidecomment[4] = "Reliance";
slidecomment[5] = "Westinghouse";
slidecomment[6] = "Marathon";
slidecomment[7] = "GM - EMD";
slidecomment[8] = "Cummins";
slidecomment[9] = "Pennsylvania";
slidecomment[10] = "OIC";
slidecomment[11] = "Tamper";
slidecomment[12] = "OmegaPak";
slidecomment[13] = "Square-D";
slidecomment[14] = "General Electric";
slidecomment[15] = "Acme";
slidecomment[16] = "Square-D";
slidecomment[17] = "ABB";
slidecomment[18] = "Westinghouse";
slidecomment[19] = "Marathon";
slidecomment[20] = "US Motors";
slidecomment[21] = "EM";
slidecomment[22] = "Westinghouse";

// links for each slide
var slidelink = new Array();
slidelink[0] = "http://www.mgmelectricalsurplus.com/Details/Transformers/Substation/14.php";
slidelink[1] = "http://www.mgmelectricalsurplus.com/Details/Transformers/Substation/12.php";
slidelink[2] = "http://www.mgmelectricalsurplus.com/Details/Transformers/Substation/87.php";
slidelink[3] = "http://www.mgmelectricalsurplus.com/Details/Boilers/Dual%20Fuel/16.php";
slidelink[4] = "http://www.mgmelectricalsurplus.com/Details/Motors/AC%20Induction%20-%20Squirrel%20Cage/106.php";
slidelink[5] = "http://www.mgmelectricalsurplus.com/Details/Transformers/Substation/15.php";
slidelink[6] = "http://www.mgmelectricalsurplus.com/Details/Generators/Generator%20Ends/54.php";
slidelink[7] = "http://www.mgmelectricalsurplus.com/Details/Generators/Industrial%20Diesel/53.php";
slidelink[8] = "http://www.mgmelectricalsurplus.com/Details/Generators/Natural%20Gas/93.php";
slidelink[9] = "http://www.mgmelectricalsurplus.com/Details/Transformers/Substation/90.php";
slidelink[10] = "http://www.mgmelectricalsurplus.com/Details/Miscellaneous/Valves/182.php";
slidelink[11] = "http://www.mgmelectricalsurplus.com/Details/Motors/AC%20Induction%20-%20Squirrel%20Cage/55.php";
slidelink[12] = "http://www.mgmelectricalsurplus.com/Details/Motor%20Control/Variable%20Frequency%20Drives/222.php";
slidelink[13] = "http://www.mgmelectricalsurplus.com/Details/Circuit%20Breakers/Molded%20Case/52.php";
slidelink[14] = "http://www.mgmelectricalsurplus.com/Details/Motors/AC%20Synchronous/97.php";
slidelink[15] = "http://www.mgmelectricalsurplus.com/Details/Transformers/Dry%20Type%20-%203%20Phase/111.php";
slidelink[16] = "http://www.mgmelectricalsurplus.com/Details/Switches/Fusible%20Disconnect/196.php";
slidelink[17] = "http://www.mgmelectricalsurplus.com/Details/Transformers/Substation/92.php";
slidelink[18] = "http://www.mgmelectricalsurplus.com/Details/Busways/Bus%20Plugs/190.php";
slidelink[19] = "http://www.mgmelectricalsurplus.com/Details/Generators/Generator%20Ends/95.php";
slidelink[20] = "http://www.mgmelectricalsurplus.com/Details/Motors/AC%20Induction%20-%20Squirrel%20Cage/234.php";
slidelink[21] = "http://www.mgmelectricalsurplus.com/Details/Motors/AC%20Induction%20-%20Squirrel%20Cage/216.php";
slidelink[22] = "http://www.mgmelectricalsurplus.com/Details/Motors/AC%20Induction%20-%20Squirrel%20Cage/65.php";

// targets of the links. Allowed values: "_parent", "_top", "_blank", "_self"
var slidetarget = new Array();
for(i = 0; i < 8; i ++){
slidetarget[i] = "_parent";
}


// the width of the slideshow (pixels)
var scrollerwidth=600

// the height of the slideshow (pixels)
var scrollerheight=125

// width of the transparent zones (pixels)
var translayerszone=10

// font-attributes for the comments
var slidefont="Arial"
var slidefontcolor="black"
var slidefontsize="2"

// background-color of webpage 
var pagebgcolor="#DDDDDD"


var numimgsatatime = 7;

// do not edit below this line
var translayerswidth=1
var translayersmax=Math.floor(translayerszone/translayerswidth)
var translayersleftpos=0
var translayersopacity=100
var translayersfactor=100/translayersmax
var translayerswidthall=translayersmax*translayerswidth
var allpicturewidth
var distancepictopic=0
var scrollerleft=0
var scrollertop=0
var pause=15
var step=1
var newstep=step
var clipleft,clipright,cliptop,clipbottom
var i_picture=0
var timer
var picturecontent=""
var ns4=document.layers?1:0
var ns6=document.getElementById&&!document.all?1:0 
var ie=document.all?1:0
var browserinfos=navigator.userAgent 
var opera=browserinfos.match(/Opera/)  

var preloadedimages=new Array()
for (i=0;i<numimgsatatime;i++){
	preloadedimages[i]=new Image()
	preloadedimages[i].src=slideurl[i]
}

function init() {
    if (ie) {
		allpicturewidth=document.all.picturediv.offsetWidth
		document.all.picturediv.style.posTop=scrollertop
        document.all.picturediv.style.posLeft=scrollerleft+scrollerwidth
		clipleft=0
		clipright=0
		cliptop=0
		clipbottom=scrollerheight
		document.all.picturediv.style.clip ="rect("+cliptop+" "+clipright+" "+clipbottom+" "+clipleft+")"
		document.all.picturediv.style.visibility="visible"
		scrollpicture()
		
    }
	if (ns6) {
		allpicturewidth=document.getElementById('emptypicturediv').offsetWidth
		document.getElementById('picturediv').style.top=scrollertop
        document.getElementById('picturediv').style.left=scrollerleft+scrollerwidth
		clipleft=0
		clipright=0
		cliptop=0
		clipbottom=scrollerheight
		document.getElementById('picturediv').style.clip ="rect("+cliptop+" "+clipright+" "+clipbottom+" "+clipleft+")"
		document.getElementById('picturediv').style.visibility="visible"
		scrollpicture()  
    }
	if (ns4) {
		allpicturewidth=document.roof.document.picturediv.document.width
		document.roof.document.picturediv.top=scrollertop
		document.roof.document.picturediv.left=scrollerleft+scrollerwidth
		document.roof.document.picturediv.clip.left=0
		document.roof.document.picturediv.clip.right=0
		document.roof.document.picturediv.clip.top=0
		document.roof.document.picturediv.clip.bottom=scrollerheight
		document.roof.document.picturediv.visibility="visible"
        scrollpicture()
    }
}

function scrollpicture() {
    if (ie) {
		if (document.all.picturediv.style.posLeft>=scrollerleft-allpicturewidth) {
			document.all.picturediv.style.posLeft-=step
			clipright+=step
			if (clipright>scrollerwidth) {
				clipleft+=step
			}
			document.all.picturediv.style.clip ="rect("+cliptop+" "+clipright+" "+clipbottom+" "+clipleft+")"		
			var timer=setTimeout("scrollpicture()",pause)
		}
		else {
			resetposition()
		}
	}
	if (ns6) {
		if (parseInt(document.getElementById('picturediv').style.left)>=scrollerleft-allpicturewidth) {
	document.getElementById('picturediv').style.left=parseInt(document.getElementById('picturediv').style.left)-step
			clipright+=step
			if (clipright>scrollerwidth) {
				clipleft+=step
			}
			document.getElementById('picturediv').style.clip ="rect("+cliptop+" "+clipright+" "+clipbottom+" "+clipleft+")"		
			var timer=setTimeout("scrollpicture()",pause)
		}
		else {
			resetposition()
		}
	}
   if (ns4) {
		if (document.roof.document.picturediv.left>=scrollerleft-allpicturewidth) {
			document.roof.document.picturediv.left-=step
			document.roof.document.picturediv.clip.right+=step
			if (document.roof.document.picturediv.clip.right>scrollerwidth) {
				document.roof.document.picturediv.clip.left+=step
			}
			var timer=setTimeout("scrollpicture()",pause)
		}
		else {
			resetposition()
		}
	}
}

function onmsover(celnum) {
	step=0;
	//extra style info
	document.getElementById(celnum).style.border = "black 1px solid";
	
}
function onmsout(celnum) {
	step=newstep;
	
	document.getElementById(celnum).style.border = "0";
	
}


function swapURL(){

for (i=Imgcounter;i<Imgcounter + numimgsatatime;i++){
	preloadedimages[i]=new Image()
	preloadedimages[i].src=slideurl[i]
}
for (i=Imgcounter;i<Imgcounter + numimgsatatime;i++){
document.getElementById('imge' + (i-Imgcounter)).src = slideurl[i];
document.getElementById('alnk' + (i-Imgcounter)).href = slidelink[i];
document.getElementById('comme' + (i-Imgcounter)).innerHTML = slidecomment[i];
}
if(Imgcounter == totalimgs - numimgsatatime){
Imgcounter = 0;
}
else{
Imgcounter = Imgcounter + numimgsatatime;
}

}


function resetposition() {

swapURL();

	if (ie) {
        document.all.picturediv.style.posLeft=scrollerleft+scrollerwidth
		clipleft=0
		clipright=0
		document.all.picturediv.style.clip ="rect("+cliptop+" "+clipright+" "+clipbottom+" "+clipleft+")"
        scrollpicture()
	}
	if (ns6) {
		allpicturewidth=document.getElementById('emptypicturediv').offsetWidth
        document.getElementById('picturediv').style.left=scrollerleft+scrollerwidth
		clipleft=0
		clipright=0
		document.getElementById('picturediv').style.clip ="rect("+cliptop+" "+clipright+" "+clipbottom+" "+clipleft+")"
        scrollpicture()
	}
	if (ns4) {
		document.roof.document.picturediv.left=scrollerleft+scrollerwidth
		document.roof.document.picturediv.clip.left=0
		document.roof.document.picturediv.clip.right=0
        scrollpicture()
	}
}

picturecontent=""
picturecontent+="<table cellpadding=2 cellspacing=0 width=500>"
picturecontent+="<tr>"
for (i=0;i<=numimgsatatime-1;i++) {
	picturecontent+='<td align="center" id="cellNum' + i + '">'
	picturecontent+='<a id="alnk' + i + '" href="'+slidelink[i]+'" target="'+slidetarget[i]+'" onMouseOver="javascript:onmsover(\'cellNum' + i + '\')" onMouseOut="javascript:onmsout(\'cellNum' + i + '\')">'
	picturecontent+='<img src="'+slideurl[i]+'" border=0 width=100 height=100 id="imge' + i + '"></a>'
	picturecontent+="</td>"
}
picturecontent+="</tr>"
picturecontent+="<tr>"
for (i=0;i<=numimgsatatime-1;i++) {
	picturecontent+='<td align="center">'
	picturecontent+="<font id=\"comme" + i + "\" face=\""+slidefont+"\" color=\""+slidefontcolor+"\" size="+slidefontsize+">"
	picturecontent+=slidecomment[i]
	picturecontent+="</font>"
	picturecontent+="</td>"
}
picturecontent+="</tr>"
picturecontent+="</tr></table>"

if (ie || ns6) {
	document.write('<div style="position:relative;width:'+scrollerwidth+'px;height:'+scrollerheight+'px;overflow:hidden">')
	document.write('<div id="picturediv" style="position:absolute;top:0px;left:0px;height:'+scrollerheight+'px;visibility:hidden">'+picturecontent+'</div>')
	if (ie && !opera) {
		for (i=0;i<=translayersmax;i++) {
		document.write('<span ID="trans'+i+'" style="position:absolute;top:0px;left:'+translayersleftpos+'px;width:'+translayerswidth+'px;height:'+scrollerheight+'px;background-color:'+pagebgcolor+';filter:alpha(opacity='+translayersopacity+');overflow:hidden"> </span>')
		translayersleftpos+=translayerswidth
		translayersopacity-=translayersfactor
		}
		translayersleftpos=scrollerwidth-translayersleftpos
		for (ii=0;ii<=translayersmax;ii++) {
		document.write('<span ID="trans'+ii+'" style="position:absolute;top:0px;left:'+translayersleftpos+'px;width:'+translayerswidth+'px;height:'+scrollerheight+'px;background-color:'+pagebgcolor+';filter:alpha(opacity='+translayersopacity+');overflow:hidden"> </span>')
		translayersleftpos+=translayerswidth
		translayersopacity+=translayersfactor
		}
	}
	if (ns6 && !opera) {
		for (i=0;i<=translayersmax-1;i++) {
		document.write('<span ID="transleft'+i+'" style="position:absolute;top:0px;left:'+translayersleftpos+'px;width:'+translayerswidth+'px;height:'+scrollerheight+'px;background-color:'+pagebgcolor+';-moz-opacity:'+translayersopacity/100+';overflow:hidden"> </span>')
		translayersleftpos+=translayerswidth
		translayersopacity-=translayersfactor
		if (translayersopacity<0) {translayersopacity=0.001}
		}
		translayersleftpos=scrollerwidth-translayersleftpos
		translayersopacity=0.001
		for (i=0;i<=translayersmax-1;i++) {
		document.write('<span ID="transright'+i+'" style="position:absolute;top:0px;left:'+translayersleftpos+'px;width:'+translayerswidth+'px;height:'+scrollerheight+'px;background-color:'+pagebgcolor+';-moz-opacity:'+translayersopacity/100+';"> </span>')
		translayersleftpos+=translayerswidth
		translayersopacity+=translayersfactor
		}
	}
	document.write('</div>')
	document.write('<div id="emptypicturediv" style="position:absolute;top:0px;left:0px;height:'+scrollerheight+'px;visibility:hidden">'+picturecontent+'</div>')

	window.onload=init
}

if (ns4) {
	document.write('<ilayer name="roof" width='+scrollerwidth+' height='+scrollerheight+'>')
	document.write('<layer name="picturediv" width='+scrollerwidth+' height='+scrollerheight+' visibility=hide>'+picturecontent+'</layer>')
	document.write('</ilayer>')
	window.onload=init
}