var tmr;
var t;
var obj;

function sFa() {
	//alert("In Javascript Doc");
	obj = gObj();
	sLft();
	var visited = checkCookie();
	if(visited == true)  //If cookie is not set
	{
		setCookie('visit_flag',1,15);	
		shw(true);
	}
	else	//If cookie is already set
	{
		shw(false);
	}
	t = 0;
	sTmr();
}

function hFa() {
	t = -100;
	sTmr();
	return false;
}

function sTmr() {
	tmr = setInterval("fd()",20);
}

function fd() {
	var amt = Math.abs(t+=10);
	if(amt == 0 || amt == 100) clearInterval(tmr);
	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 = 160;	// 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;

	obj.style.left = (l - w)+"px";
}

function gObj() {
	return document.getElementById("fa");	
}

function shw(b) {
	(b)? obj.className = 'show':obj.className = 'hide';	
}


//Getting the Cookie Element Value
function getCookie(c_name)
{
	if (document.cookie.length>0)
	  {
	  c_start=document.cookie.indexOf(c_name + "=");
	  if (c_start!=-1)
		{
		c_start=c_start + c_name.length+1;
		c_end=document.cookie.indexOf(";",c_start);
		if (c_end==-1) 
		c_end=document.cookie.length;
		var cookie_val = unescape(document.cookie.substring(c_start,c_end));
		 if(cookie_val == "")
		  return "awerae";
		 else
		  return unescape(document.cookie.substring(c_start,c_end));
		}		
	  }
	  else
	return "";
}

//checking the Cookies is set or not
function checkCookie()
{
	//alert("In Check Cookie Function");	
	address = getCookie('visit_flag');
	//alert(address);
	if (parseInt(address) == 1)
	{
		 return false;
	}
	else
	{		
	 		return true;
	}
}

//Setting the cookies value
function setCookie(c_name,value,expiredays)
{
	var exdate = new Date();
	var exdatetime = exdate.getTime(); // Time In miliSeconds 
	var postdatetime = exdatetime + (expiredays*1000*60*60*24); // Times in MiliSeconds
	var postdate = new Date(postdatetime);
	document.cookie=c_name+ "=" +escape(value)+ ";expires="+postdate.toGMTString()+"; path=/";
}