var number=Random(1);
var target=999;
var aissStr = "BC200804";
var popUpStatus=fGetCookie(aissStr);
var cookieTest;

function hideInvite()
{
	document.getElementById("AISSinvite").style.visibility = "hidden";
}
function Random(maxvalue)
{
	var randscript=-1;
	while (randscript < 0 || randscript > maxvalue || isNaN(randscript))
		randscript=parseInt(Math.random()*(maxvalue));
	return (randscript+1);
}
function fSetCookie(name, value)
{
     var argumentList  = fSetCookie.arguments;
     var argumentCount = fSetCookie.arguments.length;
     var cookieString  = name + "=" + escape(value) + ";path=/;domain=parenting.com";
	 //var cookieString  = name + "=" + escape(value) + ";";
     var factor = 24 * 60 * 60 * 1000;
     var xDate = new Date();
     if (argumentCount > 2){
       xDate.setTime(xDate.getTime() + factor * argumentList[2]);
       cookieString += ";expires=" + xDate.toGMTString()}	   
     document.cookie = cookieString
}
function fGetCookie(name)
{
     var searchString = name + "=";
     var searchLength = searchString.length;
     var cookieLength = document.cookie.length;
     var position     = 0;
     var endString, pointer;
     while(position < cookieLength)
	 {
       pointer = position + searchLength;
       if (document.cookie.substring(position, pointer) == searchString)
	   {
         endString = document.cookie.indexOf (";", pointer);
         if (endString == -1)
		 {
		 	endString = cookieLength;
		 }
         return unescape(document.cookie.substring(pointer, endString));
	   }
       position = document.cookie.indexOf(" ", position) + 1;
       if (position == 0)
	   {
	   	break;
	   }
	 }
   return null;
}
//document.write("<iframe src='launch.asp' name='AISSframe' id='AISSframe' width='1' height='1' marginwidth='0' marginheight='0' scrolling='no' frameborder='0'></iframe>");

function doAISSObj()
{
	var isIE  = (navigator.appVersion.indexOf("MSIE") != -1) ? true : false;
	var isWin = (navigator.appVersion.toLowerCase().indexOf("win") != -1) ? true : false;
	var isOpera = (navigator.userAgent.indexOf("Opera") != -1) ? true : false;
	var AISSstr = "<div style='position:absolute; z-index:2000; top:235px; left:0px; width:100%' align='center' id='AISSinvite'>";
		
	if (isIE && isWin && !isOpera)
	{
		AISSstr += "<object";
		AISSstr += " classid='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000' codebase='http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0' width='500' height='500' id='AISSinnerInvite' align='middle'>";
		AISSstr += "<param ";
		AISSstr += "name='allowScriptAccess' value='always' />";
		AISSstr += "<param ";
		AISSstr += "name='movie' value='http://www.tsgonline.com/studies/BC/INVITES/200804/parenting_tsg_200804.swf' />";
		AISSstr += "<param ";
		AISSstr += "name='menu' value='false' />";
		AISSstr += "<param ";
		AISSstr += "name='quality' value='high' />";
		AISSstr += "<param ";
		AISSstr += "name='wmode' value='transparent' />";
		AISSstr += "<param ";
		AISSstr += "name='bgcolor' value='#ffffff' />";	
		AISSstr += "</object>";
	}
	else
	{
		AISSstr += "<embed src='http://www.tsgonline.com/studies/BC/INVITES/200804/parenting_tsg_200804.swf' menu='false' quality='high' wmode='transparent' bgcolor='#ffffff' width='500' height='500' name='AISSinnerInvite' align='middle' allowScriptAccess='always' type='application/x-shockwave-flash' pluginspage='http://www.macromedia.com/go/getflashplayer'>";
	}
	
	AISSstr += "</div>";
	document.write(AISSstr);
}

if (popUpStatus == null)
{
	if (target == number)
	{		
		fSetCookie("aissTest","test",1)
		cookieTest = fGetCookie("aissTest");
		
		if (cookieTest != null)
		{
			doAISSObj();
			fSetCookie(aissStr,"NoPopUp",90)
		}
	}
	else
	{
		fSetCookie(aissStr,"NoPopUp",30)
	}
}