var showPrudential = true;//global var updated  in admanproxyrollover,aspx to hide popup prudential
jQuery(document).ready(function($){
	/*<!-- PRUDENTIAL 2011 AD START -->*/
	/*
	2011 PRUDENTIAL AD CAMPAIGN
	- WE SERVE THE AD WITH DART CODE AND RECORD TRACKING PIXEL IN ADMAN
	- TWICE A DAY WE SHOW THE POPUP - TO REGULATE THAT WE CHECK A COOKIE. 
	  THE VALUE OF THE COOKIE IS THE NUMBER OF TIMES VIEWED. IF IT'S 1 THEN DON'T SHOW IT AGAIN.
	- ALL LOGIC OCCURS IN GetPRUDENTIALAd 
	- DART TAG IS HARDCODED IN PAGE FOR 180X150 AND HARDOCDED IN JS FOR 300X250
	- NEED TO RECORD CLICK TRACKING: http://ad.doubleclick.net/clk;237947439;60043615;m?http://www.prudential.com/view/page/public/?chn=Display&src=LPGA&ad=Umbrella&dim=NA
	ADMAN ZONES:
	Close button - 274 - NOT SURE IF NEEDED IN 2011
	Ad (no pop-up) - 262 - http://adman.winnercomm.com/adman/GetAd.aspx?Zone=262
		ADMAN TRACKING PIXEL: http://AdMan.winnercomm.com/AdMan/Clients/6/1816/262/3136.gif
	Pop-up Ad 336x280 - 273 - http://adman.winnercomm.com/adman/GetAd.aspx?Zone=273
		ADMAN TRACKING PIXEL: http://AdMan.winnercomm.com/AdMan/Clients/6/1816/273/3136.gif
		
	HOW TO CALL JS
	GetPRUDENTIALAd (PRIMARY_AD_ID, POPUP_AD_ID)
	
	*/
	//generate a random number for timestamp
	var axel = Math.random() + "";
	var ord = axel * 1000000000000000000;
	
	var GetPRUDENTIALAd_trackingPixelRecored = false;
	
	function GetPRUDENTIALAd(PRIMARY_AD_ID,POPUP_AD_ID){
		//console.log("GetPRUDENTIALAd");
		/*record prmary ad tracking */
		//tracking now taking place inside adman GetPRUDENTIALAd_RecordTrackingPixel(262);
		var c = new Cookie();
		//if they have filled in the form the cookie "showEmailNeverAfterSubmit" has been set which means we don't show the popup
		var showPrudentialAdTwicePerDay = c.get("showPrudentialAdTwicePerDay");	
		if (showPrudentialAdTwicePerDay == ''){
			//show the popup and set the cookie to 0 to indicate we showed it once
			c.set("showPrudentialAdTwicePerDay", "0", 24);//24 hours
			GetPRUDENTIALAd_showPopupAd();
		} else if (showPrudentialAdTwicePerDay == '0'){
			//show the popup and set the cookie to 1 to indicate we showed it twice
			c.set("showPrudentialAdTwicePerDay", "1", 24);//24 hours		
			GetPRUDENTIALAd_showPopupAd();
		} else if (showPrudentialAdTwicePerDay == '1'){
			//don't show the popup don't touch the cookie it will expire in 24 hours then we'll show the ad again
		}
		//$('#prudentialAdZone').html('');
		//use swf object to embed the ad
		//var so = new SWFObject("images/prudential_2011/WIP_Prudential_Leadership_180x150_v02.swf", "oePrudentialAd", "180", "150", "8");
//		so.addParam("wmode","transparent");
//		so.write("prudentialAdZone");
		
	}
	function GetPRUDENTIALAd_RecordTrackingPixel(AD_ID){
		/* 
		Ad (no pop-up) - 262 - http://adman.winnercomm.com/adman/GetAd.aspx?Zone=262
		ADMAN TRACKING PIXEL: http://AdMan.winnercomm.com/AdMan/Clients/6/1816/262/3136.gif
	Pop-up Ad 336x280 - 273 - http://adman.winnercomm.com/adman/GetAd.aspx?Zone=273
		ADMAN TRACKING PIXEL: http://AdMan.winnercomm.com/AdMan/Clients/6/1816/273/3136.gif
		*/
		var trackingPixel_262_MainAd = "http://AdMan.winnercomm.com/AdMan/Clients/6/1816/262/3136.gif";
		var trackingPixel_273_PopupAd = "http://AdMan.winnercomm.com/AdMan/Clients/6/1816/273/3136.gif";
		var trackingPixel = trackingPixel_262_MainAd;
		if ((AD_ID) == 273){
			trackingPixel = trackingPixel_273_PopupAd;
		}
		try {			
				new Asset.image(trackingPixel);
		}
		catch(e){}
	}
	//jQuery(document).ready(function() {
	//  $('popupAd').hide().slideToggle(500);
	  //toggle the componenet with class msg_body
	 
	//});
	
	function GetPRUDENTIALAd_showPopupAd(){
		if (showPrudential == true){
			var popupHTML = '<div style="text-align:right; color:#fff; font-weight:bold; font-size:10px; font-family: verdana, arial; height:15px">[ <a href="javascript:closePrudential();" style="color:#fff; font-weight:bold; font-size:10px; font-family: verdana, arial; ">close</a> ]</div><iframe scrolling="No" height="250" frameborder="0" width="300" vspace="0" hspace="0" marginheight="0" marginwidth="0" src="http://adman.winnercomm.com/adman/GetAd.aspx?Zone=273&amp;Task=Get&amp;Browser=NETSCAPE6&amp;X=1300126187975"></iframe>';
			
			//write the popup to the div
			$('#PRUDENTIAL_PopupAd').html(popupHTML);
			//show the popup
			$('#PRUDENTIAL_PopupAd').animate({
				width: "300px",
				height: "265px",
				top: "272px",
				left: "691px",
				fontSize: "3em",
				borderWidth: "10px"
			  }, 1900 );
		
			//hide this in 15 seconds
			setTimeout(GetPRUDENTIALAd_hidePopupAd, 10000);
		}
	}
	function GetPRUDENTIALAd_hidePopupAd(){
		//console.log("GetPRUDENTIALAd_hidePopupAd");
		$('#PRUDENTIAL_PopupAd').fadeOut('slow');
	}
	
	//$('#prudentialAdZone').click(function(e){
	//	$('#light').hide();
	//	$('#fade').hide();
	//	return false;
	//});
	GetPRUDENTIALAd(262, 273);//called on dom ready with adman zones
	/*<!-- PRUDENTIAL 2011 AD END -->*/
});

function closePrudential(){
	jQuery('#PRUDENTIAL_PopupAd').fadeOut('slow');
}


