//<!--
	
  
var submitcount=0;
var count=0;
var cnt=0;
function ValidateForm() {
	count=0;
	var submitcount=0;
	var f = document.login;
	field=f._JS;
	field.value="T";
	field=f._PRE;
	if (field.value == "T"){
		var retValue = preProcess();
		if (retValue == false) return false;
	}
	
	field = f.i_recip_login;
	if (isBlank(field, "Email Address")) return false;
	
	
	field = f.i_recip_password;
	if (isBlank(field, "Password")) return false;
	
	SetCookie("E",f.i_recip_login.value);
	SetCookie("P",f.i_recip_password.value);
	

	field=f._POST;
	if (field.value == "T"){
		retValue = postProcess();
		if (retValue == false) return false;
	}
	else {
		// submit the form
		if (submitcount < 1) {
      		submitcount++;
      	} else {
      		//alert("This form has already been submitted.  Thanks!");
      		return false;
      	}
	}
 	return true;
 	
 }

function trimLeft(s) {
	var whitespaces = " \t\n\r";
	for(n = 0; n < s.length; n++) { if (whitespaces.indexOf(s.charAt(n)) == -1) return (n > 0) ? s.substring(n, s.length) : s; }
	return("");
}

function trimRight(s){
	var whitespaces = " \t\n\r";
	for(n = s.length - 1; n  > -1; n--) { if (whitespaces.indexOf(s.charAt(n)) == -1) return (n < (s.length - 1)) ? s.substring(0, n+1) : s; }
	return("");
}

function trim(s) {return ((s == null) ? "" : trimRight(trimLeft(s))); }

function isBlank(field, strBodyHeader) {
	strTrimmed = trim(field.value);
	if (strTrimmed.length > 0) return false;
	alert("\"" + strBodyHeader + "\" is a required field. Please type a value.");
	field.focus();
	return true;
}


function isEmail(field, strBodyHeader) {
	var strMsg = ""; var chAt  = '@'; var chDot = '.'; var chSpace = ' '; var strEmailAddr = trim(field.value);
	if (strEmailAddr.length == 0) return true;
	if (strEmailAddr.indexOf(chSpace) == -1) {
		var iFirstAtPos = strEmailAddr.indexOf(chAt);
		var iLastAtPos = strEmailAddr.lastIndexOf(chAt);
		if (iFirstAtPos > 0 && iFirstAtPos < (strEmailAddr.length - 1) && iFirstAtPos == iLastAtPos) {
			// look for '.' there must be at least one char between '@' and '.'
			var iDotPos = strEmailAddr.indexOf(chDot, iFirstAtPos + 1);
			if (iDotPos > (iFirstAtPos + 1) && iDotPos < (strEmailAddr.length - 1)) return true;
		}
	}
	alert("Error: Invalid email address. Please type a valid email address for field \"" + strBodyHeader + "\".");
	field.focus();
	return false;
}

function getUrl(flag){
	var flag=ValidateForm();
	var f = document.login;
	var url1="";
	if(flag){
		if(f.i_recip_remid.checked=='true'&& readCookie("check")=='yes'){
 	
        f.i_recip_login.value=readCookie("E");
        f.i_recip_password.value=readCookie("P");
        cnt=cnt+1;
     
 		}
 		f.i_emailgeneric.value=""+f.i_recip_login.value;
		url1="http://forms.sirius.com/asbs/servlet/SS?F=2755872&E="+readCookie("E")+"&P="+readCookie("P");
location.href=url1;
		//f.ThankYouURL.id="!*"+url1+"*!";
		//f.ThankYouURL.value=url1;
		//return true;
	}
	return false;
}
function setVal(){

	var f = document.login;
	if(f.i_recip_remid.checked==true){
		f.i_recip_remid.value='yes';
		SetCookie("check",f.i_recip_remid.value);
	}else{
		SetCookie("check",'no');
		}
	}
	

function checkCount(){
	
	var f = document.login;
	
		if(readCookie("count")=='1'&& readCookie("check")=='yes'){
			
			f.i_recip_login.value=readCookie("E");
        f.i_recip_password.value=readCookie("P");
        f.i_recip_remid.checked=true;   
      }else{
      	f.i_recip_login.value="";
        f.i_recip_password.value="";

      	}
            
			cnt=cnt+1;

}




/*function checkthis()
{
 var f = document.login;
 count=readCookie("count");
 count=count+1;
 	if(f.i_recip_remid.checked == true || count>1){
 	
        f.i_recip_login.value=readCookie("E");
        alert("EMAIL: "+f.i_recip_login.value);
        f.i_recip_password.value=readCookie("P");
 		}
 		else{
 		
    		f.i_recip_login.value="";
        f.i_recip_password.value="";
    	}
    	
 
}*/


function getValue(){
	var f = document.login;
	var val= f.i_recip_login.value;
	var expdate = new Date ();
	FixCookieDate (expdate); 
	expdate.setTime (expdate.getTime() + (24 * 60 * 60 * 1000)); // 24 hrs from now
	SetCookie("E",val,expdate,"http://qasubs.britemoon.com/asbs/servlet/SS?F=1548652");
	}	
function getCookie(){
	var f = document.login;
		f.i_recip_login.value=readCookie("E");
	}
function SetCookie (name,value,expires,path,domain,secure) {
  document.cookie = name + "=" + escape (value) +
    ((expires) ? "; expires=" + expires.toGMTString() : "") +
    ((path) ? "; path=" + path : "") +
    ((domain) ? "; domain=" + domain : "") +
    ((secure) ? "; secure" : "");
}
function readCookie(name)
{
  var ca = document.cookie.split(';');
  var nameEQ = name + "=";
  for(var i=0; i < ca.length; i++) {
    var c = ca[i];
    while (c.charAt(0)==' ') c = c.substring(1, c.length); //delete spaces
    if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length, c.length);
    }
  return null;
}

function eraseCookie(name)
{
  SetCookie(name, 0);
}

function FixCookieDate (date) {
  var base = new Date(0);
  var skew = base.getTime(); // dawn of (Unix) time - should be 0
  if (skew > 0)  // Except on the Mac - ahead of its time
    date.setTime (date.getTime() - skew);
}
/*
var expdate = new Date ();
FixCookieDate (expdate); // Correct for Mac date bug - call only once for given Date object!
expdate.setTime (expdate.getTime() + (24 * 60 * 60 * 1000)); // 24 hrs from now 
SetCookie ("ccpath", "http://www.hidaho.com/colorcenter/", expdate);
SetCookie ("ccname", "hIdaho Design ColorCenter", expdate);
SetCookie ("tempvar", "This is a temporary cookie.");
SetCookie ("ubiquitous", "This cookie will work anywhere in this domain",null,"/");
SetCookie ("paranoid", "This cookie requires secure communications",expdate,"/",null,true);
SetCookie ("goner", "This cookie must die!");
document.write (document.cookie + "<br>");
DeleteCookie ("goner");
document.write (document.cookie + "<br>");
document.write ("ccpath = " + GetCookie("ccpath") + "<br>");
document.write ("ccname = " + GetCookie("ccname") + "<br>");
document.write ("tempvar = " + GetCookie("tempvar") + "<br>");
*/

//<!--------  End Validation Script ------------->

//-->