    var APP_ROOT = "http://localhost:9080";
    var mode = "DEV";
    if (window.location.href.indexOf("qa.glic.com")!=-1)
    {
    	APP_ROOT = "http://beta.qa.glic.com";
		  mode = "UAT";
    }
    else if (window.location.href.indexOf("aboutemployeebenefits.com")!=-1 || window.location.href.indexOf("glifeweb3")!=-1 || window.location.href.indexOf("glifeweb2")!=-1 || window.location.href.indexOf("glifeweb1")!=-1 || window.location.href.indexOf("guardianlife")!=-1)
    {
    	APP_ROOT = "http://www.guardianlife.com";
			mode = "PROD";
    } 
    else if (window.location.href.indexOf("localhost")!=-1)
    {
    	APP_ROOT = "http://localhost:9081";
    	mode = "LOCAL";
    }
    else if (window.location.href.indexOf("eatwas34")!=-1)
    {
	 APP_ROOT = "http://eatwas34:8080"
	mode = "LOCAL_DEV";
    }
    else 
    {

	APP_ROOT = "http://www.guardianlife.dev";
//APP_ROOT = "http://eatwas34:8080"
//	APP_ROOT = "http://10.72.21.132:9081"
      	mode = "DEV";
    }


		function isIE()
    {
   	 return /msie/i.test(navigator.userAgent) && !/opera/i.test(navigator.userAgent);
    }

		var iframeEle;
		var cSpan;
	  
		function init()
		{
				var blocker = isIE() ? document.getElementById("transBackground") : document.getElementById("blocker") ;
				blocker.style.width = Math.max(document.body.clientWidth,document.body.scrollWidth) + "px";
				blocker.style.height = Math.max(document.body.offsetHeight,document.body.scrollHeight)+ "px";
				createSubmitFrame();	
				createCloseTransSpan();
		}
		function createSubmitFrame()
		{
			if (iframeEle!=null) return;
				var width = 300;
				var height = 250;
			if (!isIE())
			{
				iframeEle = document.createElement("iframe");
				iframeEle.id = "submitFrame";
				iframeEle.name = "submitFrame";
				iframeEle.setAttribute("name","submitFrame");
				iframeEle.width = width;
				iframeEle.height = height;
				iframeEle.frameborder = 0;
				iframeEle.style.border = "0px";
				iframeEle.style.display = "none"
				iframeEle.className = "transBox";
				iframeEle.style.position = "fixed";
				iframeEle.style.left = ((window.innerWidth - width) / 2 )+"px";
				iframeEle.style.top = ((window.innerHeight  - height) / 2)+"px";
				document.body.appendChild(iframeEle);
			}	
		}	
		
		function createCloseTransSpan()
		{
			if (cSpan!=null) return;
			var width = 100;
			if (!isIE())
			{
				cSpan = document.createElement("span");
				cSpan.name = "closeSpan";
				cSpan.id = "closeSpan";
				cSpan.style.display = "none"
				cSpan.onclick = showEditMode;
				cSpan.style.backgroundColor = "white";
				cSpan.className = "closeTransSpan";
				cSpan.style.left = parseInt(iframeEle.style.left)+parseInt(iframeEle.width) - width /2 + "px" ;
				cSpan.style.top = parseInt(iframeEle.style.top)  + "px";
				cSpan.innerHTML = "<b>Close X</b>";
				document.body.appendChild(cSpan);
			}	
		}
		function showEditMode()
		{
			document.getElementById('blocker').style.display='none';
			document.getElementById('submitFrame').style.display='none';
			document.getElementById("closeSpan").style.display = 'none'
			reconstructIframe();
		}
		function showBlocker()
		{
			document.getElementById('blocker').style.display='inline';
			document.getElementById('submitFrame').style.display='inline';
			document.getElementById("closeSpan").style.display = 'inline'
		}

		var Cookie = YAHOO.util.Cookie;  
		function checkDownload(chkId)
		{
			if (checkServerError()) return;
			var chkboxes = document.getElementsByTagName("input");
			for (var i=0;i<chkboxes.length;i++)
			{
				if (chkboxes[i].type=="checkbox")
				{
					chkboxes[i].checked = false;
				}	
			}
			document.getElementById(chkId).checked = true;
			document.getElementById("PDFChk").value = document.getElementById(chkId).value;
		  var cookie = Cookie.get("GEB_COOKIE");
		  if (cookie==null)
		  {
		  	popupEmail();
		  }
		  else
		  {
		 	 	reconstructIframe();
			 	var form = document.forms[0];
			 	form.tbemail.value = cookie;
			 	form.action = APP_ROOT+"/GroupEmployeeBenefits/PDFServlet";
			 	form.submit();
		  }
		}
		
		function checkServerError()
		{
			try
			{
				var l = window.submitFrame.location.href; 
				return false;
			}
			catch(e)
			{
				alert('Server errors.');
				return true;
			}
		}	
		
		function reconstructIframe()
		{
				try
				{
					
					window.submitFrame.src="about:blank";
				}
				catch(e)
				{
						
				}	
		}
		
		
		
		function submitEmail(email)
		{
			var form = document.forms[0];
			document.getElementById("tbemail").value = email;
			form.action = APP_ROOT+"/GroupEmployeeBenefits/PDFServlet";
			document.getElementById("mode").value = mode;
			form.submit();
		}

		function writeBlocker()
		{
			
			if (isIE())
			{
				document.write('<div  id="blocker" style="display:none;z-index:10000;">');
				document.write('<div class="transBackground" id="transBackground"   style="display:inline"></div>');
				document.write('<span class="closeTransSpan" name="closeSpan" id="closeSpan" onclick="showEditMode();"><b>Close X</b></span>');
				document.write('<iframe class="transBox" name="submitFrame" id="submitFrame" frameborder=0 style="display:inline;width:300px;height:250px" src=""/></div> ');
			}
			else
			{
				var  divObj = document.createElement("div");
				divObj.id = "blocker";
				divObj.className = "transBackground";
				divObj.style.display = "none";
				document.body.insertBefore(divObj,document.body.children[0]);
				
			}
			init();
		}
		
		function writePDFForm()
		{
			var content = new Array();
			content.push('<FORM name=GuardianAnytime target="submitFrame"');
			content.push('action=""');
			content.push('method=post><INPUT type=hidden value=webforms'); 
			content.push('name=request.app><INPUT type=hidden'); 
			content.push('value=webforms.display.ganytime.thanks'); 
			content.push('name=request.entry>');
			content.push('<input type="hidden" id="tbemail" name="tbemail"/>');
			content.push('<input type="hidden" id="PDFChk" name="PDFChk"/>');
			content.push('<input type="hidden" id="mode" name="mode"/>');
			content.push('<INPUT type=checkbox value="Spotlight-on-Benefits-and-the-Economy.pdf" style="display:none"');
			content.push('      id="chkEnrollment"        name=chkEnrollment>');
			content.push('<INPUT type=checkbox value="Spotlight-on-Consumer-Driven-Health-Care.pdf" style="display:none"');
			content.push('     id="chkDrivenHlth"         name=chkDrivenHlth>     '); 
			content.push('<INPUT type=checkbox value="Spotlight-on-Group-Critical-Illness-Insurance.pdf" style="display:none"');
			content.push('       id="chkIllness"       name=chkIllness>');
			content.push('<INPUT type=checkbox value="Spotlight-on-Group-Medical.pdf" style="display:none"');
			content.push('       id="chkMedical1"       name=chkMedical1>');
			content.push('<INPUT type=checkbox value="Voice-of-American-Business-Owners-and-Benefits-Decision-Makers-Today.pdf" style="display:none"');
			content.push('       id="chkBenefits"       name=chkBenefits>    ');
			content.push('<INPUT type=checkbox value="Spotlight-on-Group-Life-and-Disability-Insurance.pdf" style="display:none"');
			content.push('      id="chkDisability1"          name=chkDisability1>    ');
			content.push('<INPUT type=checkbox value="Spotlight-on-Dental.pdf" style="display:none"');
			content.push('      id="chkDental1"           name=chkDental1>     ');
			content.push('<INPUT type=checkbox value="Spotlight-on-Group-Disability-and-Critical-Illness-Awareness-Opportunity.pdf" style="display:none"');
			content.push('      id="chkGrpDCIAO"           name=chkGrpDCIAO>     ');
			content.push('<INPUT type=checkbox value="Spotlight-on-Employee-Enrollment-and-Education.pdf" style="display:none"');
			content.push('      id="chkEmpEnrollEdu"           name=chkEmpEnrollEdu>     ');
			content.push('<INPUT type=checkbox value="Spotlight-on-Technology-and-Enrollment.pdf" style="display:none"');
			content.push('      id="chkTechEnroll"           name=chkTechEnroll>     ');
			
			content.push('</FORM>      ');
			document.write(content.join(""));
		}
		
		function popupHTML(width,height,html)
		{
			showBlocker();
			var iframeEle = document.getElementById("submitFrame");
			var cSpan  = document.getElementById("closeSpan");
			iframeEle.style.width = width+"px";
			iframeEle.style.height = height+"px";
			if(!isIE())
			{	
				iframeEle.style.left = ((window.innerWidth - width) / 2 )+"px";
				iframeEle.style.top = ((window.innerHeight  - height) / 2)+"px";
				iframeEle.style.position = "fixed";
				cSpan.style.position = "fixed";
			}	
			else
			{
				iframeEle = document.getElementById("submitFrame");
				iframeEle.style.position = "absolute";
				iframeEle.style.left = ((document.body.clientWidth - width) / 2 + document.body.scrollLeft)+"px";
				iframeEle.style.top = ((document.body.clientHeight - height-Math.max(document.documentElement.scrollTop,document.body.clientHeight /2 - 100)) / 2 + document.documentElement.scrollTop)+"px";
				cSpan.style.position = "absolute";
			}
			cSpan.style.left = parseInt(iframeEle.style.left)+parseInt(iframeEle.style.width) - 100 /2 + "px" ;
			cSpan.style.top = parseInt(iframeEle.style.top)  + "px";
			cSpan.style.backgroundColor = "white";
			var iframe = window.submitFrame;
			iframe.location.href = html;
		}
		
		function popupEmail()
		{
			var width = 300;
			var height = 250;
			popupHTML(width,height,"../reports/email.html");
		}
		function popupSignup(url)
		{
			var width = 750;
			var height = 650;
			popupHTML(width,height,url);

		}
		function popupRegistration(htmlFile)
		{
			var width = 750;
			var height = 400;
			popupHTML(width,height,htmlFile);

		}
		function popupOfficeLocator(htmlFile)
		{
			var width = 400;
			var height = 350;
			popupHTML(width,height,htmlFile);

		}
		
		function resetAll(formName) {
			var f = document.forms[formName];
			
			f.address.value="";
			f.city.value = "";
			f.stateProvince.value = "";
			
			f.postalCode.value = "";
		}
		
		function openSalesOfficeMap()
		{
			var address = document.forms["group"].address.value;
			var city = document.forms["group"].city.value;	
			var state = document.forms["group"].stateProvince.value;
			var zip = document.forms["group"].postalCode.value;
			var countryVal = "US";
			var radiusVal = document.forms["group"].radius.value;
			var str = address+","+city+","+state+" "+zip+" "+countryVal;	
			var radioEle = document.getElementsByName("radioChoice");
			var val = "";
			for( var i = 0; i < radioEle.length; i++ )
			{
				if( radioEle[i].checked == true )
				{
					val = radioEle[i].value;
					break;
				}
			}
			//alert(val);
			var win = window.open("../googleMap/GlicGoogleMap.html?rChoice="+val+"&addr="+escape(str)+"&radius="+radiusVal+"&officeType=1","myWindow","resize=1,width=1000,height=600");
		}
		
		function getGoolgeMapUrl()
		{
			var href = window.location.href;
			if (href.indexOf("/",3)!=-1)
			{
				var aPosition = href.indexOf("/");
				href = href.substring(0,href.indexOf("/",aPosition+2))+"/";
				return href;
			}
			return "";
		}
