/*-- Global Popup function --*/

function popUp(page, name, w, h, scroll) {
	name = "foo";
	page = page.split(" ").join("%20");
	var winl = (screen.width - w) / 2;
	var wint = (screen.height - h) / 2;
	winprop = 'height='+h+',width='+w+',top='+wint+',left='+winl+',scrollbars='+scroll+',resizable=yes';
	win = window.open(page, name, winprop);
	win.focus();
}

/*-- Global Event Load function --*/

function addBodyEvent(event,action) {
	var onEvent="on"+event;
	if (window.addEventListener) {
		window.addEventListener(event, action, false);
	} else if (document.addEventListener) {
		document.addEventListener(event, action, false);
	} else if (window.attachEvent) {
		window.attachEvent(onEvent, action);
	} else if (document.getElementById) {
		document.onEvent=action;
	}
}

/*-- Chat function --*/

function displayHelpWindow1(code){
	// SALES TEMPLATE USES BUSINESS APP AND CALLROUTCODE 15. TEMPLATE NAME IS EMBARQSALES
	var dt = new Date();
	var gURL="https://ecare.embarq.com/netagent/scripts/srvgate.dll?Action=1000&RouteIdent=Embarqsales&EMAGIC=on";
	var Width = 600;
	var Height = 450;
	var winLeft = (screen.width - Width)/2;
	var winTop = 0;
	var feature = "toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=" + Width +",height=" + Height + ",top=" + winTop +',left='+ winLeft;
	var win = window.open("","WebInteractionHelp",feature);
	if(top.name==null || top.name=="")top.name="WIBrowserShare"+(new Date()).getTime();
	if(win != null && win.bHelpInProgress != null ) return;
	win = window.open(gURL + "&t=" + dt.getTime(),"WebInteractionHelp",feature);
}

/*-- Login Remember Me functionality --*/

function validations(){ //Creating the cookie for 6 months
	if(document.forms['loginForm'].elements['rememberMe'].checked){
	createLoginCookie(6*30*24*60*60*1000);
	}else{
	createLoginCookie(-1);
	}
return true;
}

function createLoginCookie(time){
	var date = new Date();
	date.setTime(date.getTime()+time);
	var expires = "; expires="+date.toGMTString();
	document.cookie = "USERID="+document.forms['loginForm'].elements['USER'].value+expires+"; path=/";
	document.cookie = "REMEMBERME="+document.forms['loginForm'].elements['rememberMe'].value+expires+"; path=/";
}

function readLoginCookie(){
	if(document.forms['userTypeForm']) {
		document.forms['userTypeForm'].elements['accountType'].selectedIndex = 0;
	}
	var userId = "USERID=";
	var remMe = "REMEMBERME=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++){
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(userId) == 0){
			document.forms['loginForm'].elements['USER'].value = c.substring(userId.length,c.length);
		}
		if (c.indexOf(remMe) == 0){
			document.forms['loginForm'].elements['rememberMe'].checked = c.substring(remMe.length,c.length);
		}
	}
}