/******************************************************/
/*              LANDING PAGE FUNCTIONS                */
/******************************************************/
gDebug.keyboard = false;
//gProps.gofar.init = 45;

// supress javascript error "flash_id" //
function stopError(msg,url,l){
	return true;
}
//window.onerror = stopError;

function initLandingPage(){
	//alert("writeLanding")
	var w = '';
	
	var lContent = document.getElementById("landing_content");
	if(lContent){
		lContent = lContent.innerHTML;
	}else{
		alert("landing_content object not found in initLandingPage()");
		return;
	}
	
	var lContainer = document.getElementById("landing_wrapper_top");
	if(lContainer){
		
		
		//var lCreate = document.createElement("div");
		//lCreate.id = "flash_content";
		//lContainer.insertBefore(lCreate,lContainer.firstChild);
		var lCreate = document.createElement("div");
		lCreate.id = "landing_top_right_flash";
		lCreate.innerHTML = lContent;
		lContainer.insertBefore(lCreate,lContainer.lastChild);
		lContainer.style.background = "url(/media/images/landing_page/image.jpg) 0px 0px no-repeat";
		lContainer.style.height = "313px";
		/*	
		if(gProps.flash.use_flash && gProps.flash.available){
			
			var lPath = '';
			
			lPath += gPaths.flash + "av_player/av_player.swf?";
			lPath += "p_video=" + gPaths.video + "landing_page_oa.flv";
			lPath += "&p_width=482";
			lPath += "&p_height=312";
			if(gDebug.tools){
				lPath += "&p_auto_play=false";
			}
			lPath += "&p_hide_controls=true";
			lPath += "&p_image_over=" + gPaths.images + "landing_page/video_corner.png";
			var so = new SWFObject(lPath, "flv_id", "482", "312", "8", "#000000");
			so.addParam("wmode", "transparent");
			so.addParam("allowScriptAccess", "always");
			so.write("flash_content");

			// IE needs this line to prevent <form></form> error //
			// http://kb.adobe.com/selfservice/viewContent.do?externalId=kb400730&sliceId=1 //
			if(gBrowser.vendor == "IE"){
				var lFlash = document.getElementById("flv_id");
				window.flv_id = lFlash;
			}
			
		}
		*/
		
		if(gProps.flash.use_flash && gProps.flash.flex){
			lContainer.innerHTML = "";
			lContainer.style.background = "none";
			var lCreate = document.createElement("div");
			lCreate.id = "flash_content";
			//lCreate.style.left = "-1px";
			lContainer.appendChild(lCreate);
					
			var lPath = '';
			var lSWF = gPaths.flash + "hero_spot/";
			lPath += lSWF + "hero_spot.swf?";
			//lPath += lSWF + "hero_spot_1212.swf?";
			lPath += "pVideoPath=" + gPaths.video;
			lPath += "&pXML=" + lSWF + "media/xml/" + gProps.hero_spot.xml;
			lPath += "&pAssetsPath=" + gProps.hero_spot.assets;
			
			// Get pStatus //
			var lStatus = "signup";
			if(gUsers.type.toLowerCase() == "v"){
				if(gUsers.pFN){
					lStatus = "login";	
				}
			}else{
				lStatus = "none";
			}

			lPath += "&pStatus=" + lStatus;
			//alert(lPath)
			var so = new SWFObject(lPath, "flv_id", "970", "313", "9", "#000000");
			so.addParam("wmode", "transparent");
			so.addParam("allowScriptAccess", "always");
			so.addParam("base", lSWF);
			so.write("flash_content");
	
		}
		
		
	}else{
		alert("landing_wrapper_top object not found in initLandingPage()");
	}
	// This is the login link //
	var lDiv = document.getElementById("links_nav_utility_login");
	if(lDiv){
		lDiv.style.display = 'block';
	}

	/* SSK - removed with re-design 20110810 - removed dropdown select list //
	if(gBrowser.ie6){
		var lSelect = document.getElementById("condition_selector");
		if(lSelect && lSelect.options && lSelect.options.length){
			lSelect.style.display = "none";
			var lContainer = lSelect.parentNode;
			var lA = document.createElement("a");
			var lP = document.createElement("p");
			for(var x = 1; x<lSelect.options.length; x++){
				var lLink = lP.cloneNode(true);
				lLink.className = (x != lSelect.options.length-1)? "blockLinks" : "";
				var lHref = lA.cloneNode(true);
				lHref.className = "bodyLinks";
				lHref.href = lSelect.options[x].value;
				lHref.innerHTML = lSelect.options[x].text;
				lLink.appendChild(lHref);
				lContainer.appendChild(lLink);
			}
			
			lContainer.style.position = "relative";
			lContainer.style.width = "auto";
		}
		
	}else{
		gForms.ie_width(["condition_selector"])
	}
	*/
}

function initLoginPage(){
	var lContainer = document.getElementById("login_wrapper_top");
	if(lContainer){
		// load the background image Male/Female //
		var lImage = "n";
		if(gProps.cookie_net.GN){
			switch(gProps.cookie_net.GN){
				case "1":
					lImage = "m";
					break;
				case "2":
					lImage = "f";
					break;
			}
		}
		lContainer.style.background = "#b1dfff url(/media/images/landing_page/image_" + lImage + ".jpg) 0px 0px no-repeat";
	}else{
		alert("login_wrapper_top object not found in initLoginPage()");
	}
	
	
	
	//PMG_Validator();
	
}

function heroSpotExecute(pType){
	var lLoc = false;
	var lTrack = true;
	switch(pType){
		case "eating_well":
			lLoc = "/01_plan/nutrition/index.aspx";
			break;
		case "getting_fit":
			lLoc = "/01_plan/activity/index.aspx";
			break;
		case "caregiving":
			lLoc = "/05_care/index.aspx";
			break;
		case "partnership":
			lLoc = "/06_exchange/index.aspx";
			break;
		case "diabetes":
			lLoc = "/common/article.aspx?ID=140";
			break;
		case "hbp":
			lLoc = "/common/article.aspx?ID=165";
			break;
		case "cholesterol":
			lLoc = "/common/article.aspx?ID=122";
			break;
		case "healthy_living":
			lLoc = "/01_plan/index.aspx";
			break;
		case "espanol":
			lLoc = getSpanishURL();
			break;
		case "cbc":
			dashboardClick({id:"calories_burned"});
			break;
		case "benefits":
			gLightBox.init({div:"login_benefits"});
			lTrack = false;
			break;
		case "login":
			gLightBox.init({div:"login_panel"});
			lTrack = false;
			break;
		case "signup":
			lTrack = false;
			gLightBox.init({div:"sign_up"});
			break;
		case "about_webmd":
			gLightBox.init({div:"WebMD"});
			lTrack = false;
			break;
		case "20110701":
			leavingMerckEngage({track_name:"just_walk"});
			break;
		case "20110801":
			location.href = "01_plan/index.aspx?lb=hcc_plan_screenings";
			break;
		case "cholesterol_tracker":
			lLoc = "/01_plan/trackers/tracker.aspx?menuID=HDL";
			break;
		case "bmi_tracker":
			lLoc = "/01_plan/trackers/tracker.aspx?menuID=WMI";
			break;
		case "browse_recipes":
			lLoc = "/01_plan/nutrition/library_mp.aspx";
			break;
		case "meal_planner":
			lLoc = "/01_plan/nutrition/planner_mp.aspx?MODE=edit";
			break;
		case "adherence_estimator":
			lLoc = "/rxforhealth/adherence-estimator.aspx";
			break;
		case "go_red":
			lLoc = {loc:"http://www.goredforwomen.org/Tell5"};
			break;
		default:
			var lVideo = pType.split(":")[1];
			// check to see if a video reached the end //
			if(lVideo){
				// track that the video reached completion //
				pType = lVideo;
			}else{
				
				var lArticle = pType.split("_")[0];
				if(lArticle == "article"){
					lLoc = "/common/article.aspx?ID=" + pType.split("_")[1];
					break;
				}
			
				alert("pType = " + pType + "\nNot defined in heroSpotExecute()");
			}
			break;
	}
	
	// track the Hero Spot calls //
	if(lTrack){
		var lObj = {track_name:"HS_" + pType};
		trackClick(lObj);
	}
	
	// for links that re-direct //
	if(lLoc){
		if(typeof(lLoc) == "string"){
			location.href = lLoc;
		}else{
			if(typeof(lLoc) == "object"){
				PMG_newWindow(lLoc);
			}
		}
	}
}


/* shows the e-mail mail channel */
function initAR_enrollment(p){

	clearPopupValidation(p);
	
	var lType = document.getElementById("channel_pref");
	var lTags = null;
	
	if(lType){
		lTags = lType.getElementsByTagName("input");
	}
	
	if(lTags){
		var lPanel = document.getElementById("language_profile");
		lPanel.style.display = "none";
		for(var x = 0; x<lTags.length; x++){
			lTags[x].onclick = function(){
				if(this.checked){
					if(this.value == "2"){
						lPanel.style.display = "block";
					}else{
						lPanel.style.display = "none";
					}
				}
			}
			
			lTags[x].onclick();
		
		}
	}
}
