var tmr;
var t;
var obj;

function sFa(xloc) {
	obj = gObj();
	sLft();
	shw(true);
	t = 0;
	document.getElementById("fa").innerHTML="<div id='fa_close2' class='fa_close'><table><tr><td height='25' style='background:#333' align='right'><a href='#' class='menu' onclick='hFa()'><font style='color:white;margin-right:5px'>Close</a></td></tr><tr><td align='center' style='background:#EAEAEA'><img src='"+xloc+"' style='border:1px solid #FAFAFA;width:300px'></td></tr></table></div>";
	sTmr();
}

function hFa() {
	t = -100;
	sTmr2();
	return false;
}

function sTmr() {
	tmr = setInterval("fd()",20);
}

function sTmr2() {
	tmr = setInterval("fd2()",20);
}

function clearInterval2() {
clearInterval(tmr);
document.getElementById("fa").innerHTML="<div class='fa_close'></div>";	
}

function clearInterval3() {
clearInterval(tmr);
}

function fd2() {
	
	var amt = Math.abs(t+=10);
	if(amt == 0 || amt == 100) clearInterval2();
	amt = (amt == 100)?99.999:amt;
  	
	obj.style.filter = "alpha(opacity:"+amt+")";
	obj.style.KHTMLOpacity = amt/100;
	obj.style.MozOpacity = amt/100;
	obj.style.opacity = amt/100;
	if(amt == 0) shw(false);
}

function fd() {
	
	var amt = Math.abs(t+=10);
	 		
	if(amt == 0 || amt >= 100) clearInterval3();
	amt = (amt == 100)?99.999:amt;
	obj.style.filter = "alpha(opacity:"+amt+")";
	obj.style.KHTMLOpacity = amt/100;
	obj.style.MozOpacity = amt/100;
	obj.style.opacity = amt/100;
	
	if(amt == 0) shw(false);
}

function sLft() {
	var w = 0;	// set this to 1/2 the width of the fa div defined in the style sheet 
			// there's not a reliable way to retrieve an element's width via javascript!!
					
	//var l = (document.body.innerWidth)? document.body.innerWidth / 2:document.body.offsetWidth / 2;
	var l = 0;
	
	obj.style.left = (l - w +15)+"px";
	obj.style.top = "-7px";
}

function gObj() {
	return document.getElementById("fa");	
}

function shw(b) {
	(b)? obj.className = 'show':obj.className = '';	
}
