/***
Simple OTP + leavebehind banner javascript. Requires SWFObject.js.

At bottom of homepage html (before </body>), added:
   <div id="bannerOTP" style="position:absolute;top:226px;left:137px;z-index:1000;"><div id="bannerOTPFlash"></div></div>
   <SCRIPT type="text/javascript" src="scripts/bannersHome.js"></script>
   
Also make sure there's still a <div id="PromotionalFlash"></div> somewhere, for the leave-behind banner.

***/

var isBannerPromoLoaded = false;

//bannerOTP is the div containing the div that gets replaced by SWFObject. Nesting div's seems to work better with firefox + SWFObject.
var bannerOTP = document.getElementById("bannerOTP");

function loadBanners() {
	//loadBannerOTP();
        loadBannerPromo();
}

function loadBannerOTP() {
    //clear display style, setting back to default (making visible again)
    bannerOTP.style.display = "";
	
    var so = new SWFObject("Flash/CBHS_SummerUpgrade_main_985x596.swf", "bannerOTPFlashSwf", "985", "596", "8", "#FFFFFF");
    so.useExpressInstall('Flash/expressinstall.swf');
    so.addParam("wmode", "transparent");
    so.addParam("allowScriptAccess", "always");
    so.write("bannerOTPFlash");
}

function loadBannerPromo() {
	//only load once (from onBannerOTPFinished)
	if(!isBannerPromoLoaded) {
		//var so = new SWFObject("Flash/CBHS_SummerUpgrade_482x111.swf", "PromotionalFlashSwf", "482", "111", "8", "#FFFFFF");
		var so = new SWFObject("Flash/CBHS_April_482x111.swf", "PromotionalFlashSwf", "482", "111", "8", "#FFFFFF");
		so.useExpressInstall('Flash/expressinstall.swf');
		so.addParam("wmode", "opaque");
		so.addParam("allowScriptAccess", "always");
		so.write("PromotionalFlash");
		
		isBannerPromoLoaded = true;
	}
}

function unloadBannerOTP() {
	bannerOTP.style.display = "none";
}

/****
 Functions called by Flash. Could be done with flash.external.ExternalInterface, but since these are simple method calls,
 it's probably safer to go with "getURL('javascript:methodName();')" in the AS.
****/

function onBannerOTPFinished() {
	unloadBannerOTP();
	loadBannerPromo();
}

// called by PromotionalFlash
function replayBannerOTP() {
	loadBannerOTP();
}

/****/


loadBanners();