//fade out, get a url, then fade back in
var theurl;
var current_opacity = 100;
var co = 1;
var timer;
var thediv;
var fadeBackIn = false;



function fadeOutAndIn(div_id, url){
	//after 10 seconds,
	pause();
	theurl = url;
	thediv = div_id;
	fadeBackIn = true;
	fadeOut(div_id); 	
}

function getUrl(){
	if(theurl){ajax(theurl, cb_fadeIn);}
}

function cb_fadeIn(val){
	el = document.getElementById(thediv);
	el.innerHTML = val;
	current_opacity = 0;
	co = 0;
	fadeIn();	
}

function fadeOut(){	
	
		el = document.getElementById(thediv);		
		el.style.filter = "alpha(opacity="+current_opacity+")";
		el.style.opacity = co;		
		current_opacity = current_opacity-5;
		co = co - .1		
		if(current_opacity<10){
			el.style.filter = "alpha(opacity="+0+")";
			el.style.opacity = 0.0;
			current_opacity = 0;
			clearTimeout(timer);
			getUrl();
			if(fadeBackIn){
				fadeIn();
			}			
		}		
		else{timer = setTimeout("fadeOut()",50);}	
}

function pause(){
	timer = setTimeout("resume()",2000);	
}

function resume(){
	
}

function fadeIn(){	
	
		el = document.getElementById(thediv);		
		el.style.filter = "alpha(opacity="+current_opacity+")";
		el.style.opacity = co;		
		current_opacity = current_opacity+5;
		co = co + .1		
		if(current_opacity>100){
			el.style.filter = "alpha(opacity="+0+")";
			el.style.opacity = 1.0;
			current_opacity = 100;
			clearTimeout(timer);
			if(fadeBackIn){
				pause();
			}
			return;				
		}		
		else{timer = setTimeout("fadeIn()",50);}	
}
