// JavaScript Document

var scrollWidth = 0;
function startScroll()
{
	if(document.getElementById("scroll"))
	{
		if(document.getElementById("scroll").clientWidth > scrollWidth)
			scrollWidth = document.getElementById("scroll").clientWidth;			
		if(document.getElementById("scroll").offsetWidth > scrollWidth)
			scrollWidth = document.getElementById("scroll").offsetWidth;		
	}	
	scrollMe(0);
}
function scrollMe(num)
{
	if(num < (-scrollWidth) )
		num = 1000;
	document.getElementById("scroll").style.left = (num - 1) + 'px';
	setTimeout("scrollMe("+ (num-1)+")",20);
}

function fadeClose(div,value)
{
	var obj = $(div);
	if(!(value))
		value = 100;
	setOpacity(obj,value);
	
	value = value-4;
	if(value<=0)
	{
		obj.style.display='none';
		setOpacity(obj,100);
		return;
	}	
	setTimeout('fadeClose("'+div+'",'+value+')',10);
}


function fadeOpen(div,value)
{
	var obj = $(div);	
	if(value==0)
	{
		setOpacity(obj,0);
		obj.style.display='block';
	}
	else
	{
		setOpacity(obj,value);
	}	
	
	value = value+3;
	if(value>=100)
	{
		setOpacity(obj,100);
		return;
	}	
	setTimeout('fadeOpen("'+div+'",'+value+')',10);
}


function setOpacity(elem, opacityAsInt)
{
    var opacityAsDecimal = opacityAsInt;
    
    if (opacityAsInt > 100)
        opacityAsInt = opacityAsDecimal = 100; 
    else if (opacityAsInt < 0)
        opacityAsInt = opacityAsDecimal = 0; 
    
    opacityAsDecimal /= 100;
    if (opacityAsInt < 1)
        opacityAsInt = 1; // IE7 bug, text smoothing cuts out if 0
    
    elem.style.opacity = (opacityAsDecimal);
    elem.style.filter  = "alpha(opacity=" + opacityAsInt + ")";
}

///function $(el){ return document.getElementById(el); }

function slideShow(next,total)
{
	if(next==1)
	{
		fadeClose('image'+total);		
		setTimeout('fadeOpen("image1",0)',700);		
		setTimeout("slideShow(2,"+total+")",5000);	
		return;
	}
	
	if(next==total)
	{
		fadeClose('image'+(total-1));		
		setTimeout('fadeOpen("image'+total+'",0)',700);		
		setTimeout("slideShow(1,"+total+")",5000);	
		return;	
	}
	
	
	fadeClose('image'+(next-1));		
	setTimeout('fadeOpen("image'+next+'",0)',700);		
	setTimeout("slideShow("+(next+1)+","+total+")",5000);	
	

}

