var pageRendered = false;
window.onload= function(){pageRendered = true;};
var STTAFINTRO = {

	introDivCreated: false,
	introDivId: 'widgetContainer',
	
	// custom variables
	stItemname: '',
	marginProps: '',
	showIntroDiv: function(stItemname)
	{
		
		if(typeof(STTAFFUNC)=="undefined"){
			window.setTimeout('STTAFINTRO.showIntroDiv()',1000);
			return;
		}
		if(!pageRendered){
			return ;
		}
		if (STTAF.isHideFlashSelected) {
		      STTAFFUNC.hideFlashObjects();
        	}
		// initialise the custom variables
		
		STTAFINTRO.stItemname = (stItemname!= null) ? stItemname : '' ;
		
		STTAFINTRO.createIntroDiv();
		STTAFINTRO.createOverlay();
		STTAFINTRO.positionDiv(STTAFINTRO.introDivId);
		document.getElementById(STTAFINTRO.introDivId).style.display= "block";
		
	},
	
	createIntroDiv: function()
	{
		if(STTAFINTRO.introDivCreated)
		{
			return;
		}
		
		var stIntroDiv = document.createElement('div');
		stIntroDiv.setAttribute('id', STTAFINTRO.introDivId);
		stIntroDiv.style.width='479px';
		stIntroDiv.style.height='544px';
		stIntroDiv.style.position='absolute';
		stIntroDiv.style.zIndex='99999';
		
		var introDivData =	'<table width="471" border="0" align="center" cellpadding="0" cellspacing="0" style=" width:471px; height:226px; border: solid 1px #CCCCCC;background-color: #FFFFFF;"><tr><td height="71" valign="top"><img src="http://content.socialtwist.com/themes/2009080322302-7/images/FF_logoHeader_479x71.gif" width="479"                height="71"/></td></tr><tr><td valign="middle"> <table width="90%" border="0" align="center" cellpadding="0" cellspacing="5">  <tr><td style="font:12px Arial, Helvetica, sans-serif; color:#666666; line-height:1.7em;">You are                        leaving FamilyFun.com. To continue, please click the button below to use our tell-a-friend                        feature.</td>  </tr>  <tr><td align="left">&nbsp;</td>  </tr>  <tr><td align="left"> <table width="200" border="0" align="left" cellpadding="0" cellspacing="0">  <tr><td width="105"><img                                        src="http://content.socialtwist.com/themes/2009080322302-7/images/continue.jpg"                                        width="105" height="44" onclick="STTAFINTRO.continueAction();" style="cursor:pointer;"/></td><td width="115" align="center"                                    style="font:bold 12px Arial, Helvetica, sans-serif; color:#517f0a;cursor:pointer;" onclick="STTAFINTRO.hideIntroDiv();">No Thanks </td></tr>  </table></td>  </tr></table></td></tr></table>';	
		
		stIntroDiv.innerHTML = introDivData;
		document.body.appendChild(stIntroDiv);
		
		STTAFINTRO.introDivCreated = true;
	},

	createOverlay: function(){
		// lets create the overlay
				
		// in order to avoid showing overlay div twise..
		var overLayDiv = document.getElementById("st-overlay");
		if(overLayDiv && overLayDiv != null){
			return;
		}
		var bodyStyle = document.body.style;
		
		var overlay = document.createElement('div');
		overlay.setAttribute('id', 'st-overlay');
		var ocs = overlay.style;
		//var isIE6 = (window.external && typeof window.XMLHttpRequest == "undefined");
		if(navigator.appName == 'Microsoft Internet Explorer') {
			ocs.position = 'absolute';
			ocs.height = "2000px";
			//ocs.overflow = "hidden";
			STTAFINTRO.setMargins();
		} else {
			ocs.position = 'fixed';
			ocs.height = '100%';
		}
		ocs.zIndex = 9990;
		ocs.top = 0;
		ocs.left = 0;
		ocs.width = "100%";
		ocs.backgroundColor = 'black';
		ocs.filter = 'alpha(opacity: 75)';
		ocs.MozOpacity = 0.75;
		ocs.opacity = 0.75;
		
		
		document.body.insertBefore(overlay, document.body.firstChild);
	},

	positionDiv: function(divId){
		var divObj = document.getElementById(divId);
		var h = (STTAFFUNC.GetHeight() / 2) - (546 / 2);
		var w = (STTAFFUNC.GetWidth() / 2) - (481 / 2);
		
		divObj.style.left = w + "px";
		divObj.style.top = h + "px";
	},
	
	hideIntroDiv: function()
	{
		document.getElementById(STTAFINTRO.introDivId).style.display= "none";
		document.getElementById('st-overlay').parentNode.removeChild(document.getElementById('st-overlay'));
		STTAFINTRO.setBackMargins();
		if (STTAF.isHideFlashSelected) {
	            STTAFFUNC.showFlashObjects();
        	}
	},
	
	continueAction: function()
	{
		if(!pageRendered){
			return;
		}
		
		document.getElementById(STTAFINTRO.introDivId).style.display = "none";
		
		STTAFFUNC.cw(this, {id:'2009080322302-7', link: window.location, title: document.title, custom:{'itemname':STTAFINTRO.stItemname} });
		
		STTAFINTRO.setCloseEvent();
	},
	
	setCloseEvent: function() {
		STTAFFUNC.closeEventFunc = function() {
			STTAFINTRO.setBackMargins();
			document.getElementById('st-overlay').parentNode.removeChild(document.getElementById('st-overlay'));
			
		}
	},
	setBackMargins: function(){
		if(navigator.appName == 'Microsoft Internet Explorer') {
			var bodyStyle = document.body.style;
				
			bodyStyle.marginLeft = STTAFINTRO.marginProps[0];
			bodyStyle.marginTop =  STTAFINTRO.marginProps[1];
			bodyStyle.marginRight = STTAFINTRO.marginProps[2];
			bodyStyle.marginBottom = STTAFINTRO.marginProps[3];
	
		}
	},
	//ie takes default margins if we don't specify.so overlay div is not covering the complete page.
	//so,we are storing intial margin values in an array
	//and change all margins to 0 while showing the overlay div
	//and revert back margin values to old values while closing the overlay div.
	setMargins: function(){
		var bodyStyle = document.body.style;
		STTAFINTRO.marginProps = new Array();
		STTAFINTRO.marginProps[0] = bodyStyle.marginLeft;
		STTAFINTRO.marginProps[1] = bodyStyle.marginTop;
		STTAFINTRO.marginProps[2] = bodyStyle.marginRight;
		STTAFINTRO.marginProps[3] = bodyStyle.marginBottom;
		
		bodyStyle.marginLeft = 0;
		bodyStyle.marginTop = 0;
		bodyStyle.marginRight = 0;
		bodyStyle.marginBottom = 0;
	}
	
	
}	