var tmr;
var t;
var obj;

function closeMyPopup() {
  document.getElementById("faw").style.display = "none";
}

function myPopupRelocate() {
  var scrolledX, scrolledY;
  if( self.pageYOffset ) {
    scrolledX = self.pageXOffset;
    scrolledY = self.pageYOffset;
  } else if( document.documentElement && document.documentElement.scrollTop ) {
    scrolledX = document.documentElement.scrollLeft;
    scrolledY = document.documentElement.scrollTop;
  } else if( document.body ) {
    scrolledX = document.body.scrollLeft;
    scrolledY = document.body.scrollTop;
  }

  var centerX, centerY;
  if( self.innerHeight ) {
    centerX = self.innerWidth;
    centerY = self.innerHeight;
  } else if( document.documentElement && document.documentElement.clientHeight ) {
    centerX = document.documentElement.clientWidth;
    centerY = document.documentElement.clientHeight;
  } else if( document.body ) {
    centerX = document.body.clientWidth;
    centerY = document.body.clientHeight;
  }

  var leftOffset = scrolledX + (centerX - 500) / 2;
  var topOffset = scrolledY + (centerY - 400) / 2;

  document.getElementById("faw").style.top = topOffset + "px";
  document.getElementById("faw").style.left = leftOffset + "px";
}

function sFa() {
	obj = gObj();
	 myPopupRelocate();
  	document.getElementById("faw").style.display = "block";
  	document.body.onscroll = myPopupRelocate;
  	window.onscroll = myPopupRelocate;
  
	//sLft();
	shw(true);
	t = 0;
	sTmr();
	window.setTimeout("closeMyPopup()", 8000);
}

function hFa() {
	t = -100;
	sTmr();
	return false;
	window.setTimeout("closeMyPopup()", 8000);
}

function sTmr() {
	tmr = setInterval("fd()",70);
}

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 = 170;	// set this to 1/2 the width of the faw 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("faw");	
}

function shw(b) {
	(b)? obj.className = 'show':obj.className = '';	
}