﻿
var div1,div2,cf,ca;
var intFade1,intFade2,intFade3;
var tout = 25;
cf=1;
ca=2
function FreezeFade(domId)
{
	obj = document.getElementById(domId);
	var alpha = 10; //Set the initial value of alpha to 0 (invisible)
	setOpacity(domId, alpha);
	document.getElementById("div1").style.display="none";
	document.getElementById("div2").style.display="none";
	document.getElementById("div3").style.display="none";
	//document.getElementById("div4").style.display="none";
	obj.style.display = 'block'; //Un-hide the object before its animation
	clearTimeout(intFade1);
	clearTimeout(intFade2);
	//clearTimeout(intFade3);

}

function FadeScroll()
{

div1="div"+ cf +'';
div2="div"+ ca +'';
FadeInOut();

	if (cf<2)
	{
		cf = cf +1;
		ca= ca+1;
		}
	else if (cf==2)
		{
		cf = cf +1;
		ca= 1;
		}
		else
		{
		 cf=1;
		 ca=ca+1;	
		}
	
//window.setTimeout("FadeScroll",100);
}

function FadeInOut()
{

	fade(div1);
//appear(div2);

}

function setOpacity(domId, val) {
	obj = document.getElementById(domId);
	obj.style.MozOpacity = val;
	obj.style.opacity = val/10;
	obj.style.filter = 'alpha(opacity=' + val*10 + ')';
};
function fade(domId){
	obj = document.getElementById(domId); //Get the Element
	if(obj.style.display == "none") return false; //Return false if the element is already hidden
	var alpha = 10; //Set the initial value of alpha to 10 (Opaque)
	function f(){ //Internal function
		alpha = alpha-.5; //Decrememnt the alpha value
		setOpacity(domId, alpha); //Set the opacity of our element to the specified alpha
		if(alpha > -1){ //If alpha is still bigger than -1 then..
		{	if (alpha==2)
			{
				appear(div2);
			}
			intFade1=setTimeout(f, tout); //..then call the function again after 100 milliseconds
			}
		}else{ //otherwise..
			obj.style.display = 'none'; //..otherwise now that we cant see the element anyways, hide it
				
		}
	}
			intFade1=	setTimeout(f, tout); //This is where we call the f() function for the first time
};

function appear(domId){
	obj = document.getElementById(domId); //Get the element
	obj.style.display="none";
	if(obj.style.display != "none") return false; //Return if it is already being displayed

	var alpha = 0; //Set the initial value of alpha to 0 (invisible)
	setOpacity(domId, alpha);
	obj.style.display = 'block'; //Un-hide the object before its animation
	
	function a(){ //Internal function.

		alpha = alpha+.5; //Increment alpha
		setOpacity(domId, alpha); //Set the opacity of our element to the specified alpha
		if(alpha < 11)
		{
		intFade2=setTimeout(a, tout);
		}
		else
		{
//		alert("visible");
		intFade3=	setTimeout(FadeScroll,timePause);
		}
		/*Till alpha is 10, keep calling the
		a() function after 100 milliseconds */
	}
			intFade2=	setTimeout(a, tout); //This is where we call the a() function for the first time
};