var width1 //image width1
var height1 //image height1
var seconds1 = 4 //number of seconds1 before next image
var pause1 = seconds1 * 1000

var fadeimages1 = new Array()

var ie41=document.all
var dom1=document.getElementById
var curpos1 = 3
var degree1 = 10
var curcanvasB = "canvasA"
var curimageindex1
var nextimageindex1

function HomeRotation(paths)
{	
	fadeimages1 = paths.split(',')
	
	width1='742px'
	height1='190px'
	curimageindex1 = Math.floor(Math.random()*fadeimages1.length)
	nextimageindex1 = Math.floor(Math.random()*fadeimages1.length)

	DoRotate()
}

function SubpageRotate(paths)
{	
	fadeimages1 = paths.split(',')
	width1='742px'
	height1='140px'
	curimageindex1 = Math.floor(Math.random()*fadeimages1.length)
	nextimageindex1 = Math.floor(Math.random()*fadeimages1.length)
	
	DoRotate()
}


function DoRotate()
{
	var preloadedimages1 = new Array()
	
	/*for (c=0; c<fadeimages1.length; c++)
	{
		preloadedimages1[c] = new Image()
		preloadedimages1[c].src = fadeimages1[c]
	}*/
	
	if (ie41||dom1)
		document.write('<div style="position:relative;width:' + width1 + '; height:' + height1 + '; overflow:hidden;"><div id="canvasA" style="position:absolute; width:' + width1 + '; height:' + height1 + '; top:0; left:0; filter:alpha(opacity=10); -moz-opacity:10"></div><div id="canvasB" style="position:absolute; width:' + width1 + '; height:' + height1 + '; top:0; left:0; filter:alpha(opacity=10); -moz-opacity:10; visibility:hidden"></div></div>')
	else
		document.write('<img name="defaultslide" src="'  + fadeimages1[Math.random()*fadeimages1.length-1] + '">')
	
	if (ie41||dom1)
		window.onload=startit2
	else
		setInterval("rotateimage2()",pause1)
}

/*
this method produces the fading effect of the image.
the curpos1 variable is set to the opacity level of the fading.
*/
function fadepic1()
{
	if (curpos1 < 100)
	{
		curpos1 += 3
		if (temp1obj1.filters)
			temp1obj1.filters.alpha.opacity = curpos1
		else if (temp1obj1.style.MozOpacity)
			temp1obj1.style.MozOpacity = curpos1/101
		}
	else
	{
		clearInterval(dropslide1)
		nextcanvas1 = (curcanvasB == "canvasA")? "canvasA" : "canvasB"
		temp1obj1=ie41? eval("document.all." + nextcanvas1) : document.getElementById(nextcanvas1)
		temp1obj1.innerHTML = insertimage2(nextimageindex1)
		nextimageindex1 = (nextimageindex1<fadeimages1.length-1)? nextimageindex1 + 1 : 0
		var temp1obj12=ie41? eval("document.all." + nextcanvas1) : document.getElementById(nextcanvas1)
		temp1obj12.style.visibility = "hidden"
		
		setTimeout("rotateimage2()",pause1)
	}
}

function insertimage2(i)
{
	var temp1container1 = fadeimages1[i] != ""? '<img src="'+fadeimages1[i]+'" border="0">' : ""
	return temp1container1
}

function rotateimage2()
{
	if (ie41||dom1)
	{
		resetit1(curcanvasB)
		var crossobj1 = temp1obj1=ie41? eval("document.all." + curcanvasB) : document.getElementById(curcanvasB)
		crossobj1.style.zIndex++
		temp1obj1.style.visibility = "visible"
		var temp1 = 'setInterval("fadepic1()",50)'
		dropslide1 = eval(temp1)
		curcanvasB = (curcanvasB == "canvasA")? "canvasB" : "canvasA"
	}
	else
		document.images.defaultslide.src = fadeimages1[curimageindex1]
		curimageindex1 = (curimageindex1 < fadeimages1.length-1)? curimageindex1 + Math.floor(Math.random()*fadeimages1.length-1) : 0
}

/*
this allows for a smoth transition when the new 
image is loaded, so the image doesn't blink.
*/
function resetit1(what1)
{
	curpos1 = 4
	var crossobj1=ie41? eval("document.all." + what1) : document.getElementById(what1)
		if (crossobj1.filters)
			crossobj1.filters.alpha.opacity = curpos1
		else if (crossobj1.style.MozOpacity)
			crossobj1.style.MozOpacity = curpos1/101
}

function startit2()
{
	var crossobj1=ie41? eval("document.all." + curcanvasB) : document.getElementById(curcanvasB)
	crossobj1.innerHTML = insertimage2(curimageindex1)
	rotateimage2()
}
	
	
	
	
	