<!--
var vbCRLF = String.fromCharCode(13,10);
var localDest = 0;

function navTo(){
	localDest = 1;
}

function landingPageNavTo(url){
	document.location.href = "../includes/recordLandingPageNav.asp?nextPage="+url;
}
function valNumeric(obj_element, changeColor, reqElementLength, isRequired) 
{ var isValid = true; 
	var validcharacters = "1234567890"; 
	var str = obj_element.value; 
	var elementLength = str.length; 
  
	if(isRequired || elementLength > 0 ) 
	{ 
		if(reqElementLength != elementLength) 
		isValid = false; 
	else 
		for(var i = 0 ; i < elementLength ; i++) 
		if( validcharacters.lastIndexOf( str.charAt(i) ) == -1) 
		isValid = false; 
	} 

	if(isValid && changeColor) 
	obj_element.style.borderColor="";
	else if(!isValid && changeColor) 
	obj_element.style.borderColor="#ff0000";

	if(!isValid) 
	validated = false; 

	return isValid; 
}

function fn_VerifyOptOut()
{
	var emlVal;
	var isTAChecked, isPartnerChecked;
	var msg;
	
	msg = "";
	
	isTAChecked = document.form1.chkBxOptOut.checked;
	isPartnerChecked = false;	//document.form1.chkBxOptOut[1].checked;
	emlVal = document.getElementById("txtBxOptOutEmail").value;
	
	if ((isTAChecked == false) && (isPartnerChecked == false))
	{
		document.form1.chkBxOptOut.style.backgroundColor="#ff0000";
		//document.form1.chkBxOptOut[1].style.backgroundColor="#ff0000";
		msg += "- Check the box to unsubscribe." + vbCRLF;
	}
	else
	{
		document.form1.chkBxOptOut.style.backgroundColor="#ffffff";
		//document.form1.chkBxOptOut[1].style.backgroundColor="#ffffff";
	}
	
	if (emlVal == "")
	{
		document.getElementById("txtBxOptOutEmail").style.backgroundColor="#ff0000";
		msg += "- Valid email address." + vbCRLF;
	}
	else if (checkValidsemail(emlVal) == false)
	{
		document.getElementById("txtBxOptOutEmail").style.backgroundColor="#ff0000";
		msg += "- Valid email address." + vbCRLF;
	}
	else
	{
		document.getElementById("txtBxOptOutEmail").style.backgroundColor="#ffffff";
	}
	
	if (msg != "")
	{
		msg = "Please resolve the errors below and resubmit:" + vbCRLF + vbCRLF + msg;
		alert(msg);
	}
	else
	{
		if (confirm("Are you sure you want to unsubscribe?"))
		{
			document.form1.action = "privacy_policy.asp";
			document.form1.submit();
		}
	}
}

var phone_field_length=0;
function TabNext(obj,event,len,next_field) {
	if (event == "down") {
		phone_field_length=obj.value.length;
		}
	else if (event == "up") {
		if (obj.value.length != phone_field_length) {
			phone_field_length=obj.value.length;
			if (phone_field_length == len) {
				next_field.focus();
			}
		}
	}
}

function trim(str){
	re = / /gi;
	newstr=str.replace(re, "-");
	return(newstr);
}
//function trim(str){
//return str.replace(/^\s*([\S\s]*?)\s*$/, '$1');
//}

function fn_IsMonetary(strVal){

	re = /$/gi;
	strNew=strVal.replace(re, "");

	re = /,/gi;
	strNew=strNew.replace(re, "");

	if (isNaN(strNew))
		return (0);
	else
		return (1);

}

function stripPunc(str){

	re = /,/gi;
	newstr = str.replace(re, "");
	re = /'/gi;
	newstr = newstr.replace(re, "");
	return(newstr);
}
function setCookie(name, value, expires)
{
	document.cookie= name + "=" + escape(value) + "; expires=Sat, 31 Dec 2010 20:47:11 UTC";
}
function getCookie(name)
{
    var dc = document.cookie;
    var prefix = name + "=";
    var begin = dc.indexOf("; " + prefix);
    if (begin == -1)
    {
        begin = dc.indexOf(prefix);
        if (begin != 0) return null;
    }
    else
    {
        begin += 2;
    }
    var end = document.cookie.indexOf(";", begin);
    if (end == -1)
    {
        end = dc.length;
    }
    return unescape(dc.substring(begin + prefix.length, end));
}
function deleteCookie(name)
{
    if (getCookie(name))
    {
        document.cookie = name + "=" ;
    }
}
function checkCookie(){
	var formViewed = 0;
	formViewed = getCookie("CaseReviewForm");
	if (formViewed == 0 && localDest == 0){
		openTopTen();
	}
}

function openTopTen(){
	var h1, w1;
	h1 = screen.height;
	h1 = (h1/2) - 141;
	w1 = screen.width;
	w1 = (w1/2) - 178;
	
	window.open("top_ten.htm","","height=282,width=356,left="+w1+",top="+h1+",status=no");

}

function verFastForm(){

	var dataMissing = 0,msg = "";
	if (document.form1.name.value == ""){
		dataMissing = 1;
		msg += "- Name" + vbCRLF;
	}
	if (document.form1.email.value == ""){
		dataMissing = 1;
		msg += "- Email" + vbCRLF;
	}
	if (document.form1.area.value == "" || document.form1.pre.value == "" || document.form1.suff.value == ""){
		dataMissing = 1;
		msg += "- Phone Number" + vbCRLF;
	}
	if (dataMissing == 1){
	
		msg = "Please complete the following field(s) before proceeding:" + vbCRLF + msg;
		alert(msg); }
	else{
		document.form1.submit();
	}

}

function popUp(URL, width, height) {
  window.open(URL, 'popup', 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=1,width='+width+',height='+height+'');
}

function doTrafficLogout()
{
	document.location.href = "../TrafficTracker/logout.asp";
}


	window.onload = function() {
	}
	
	window.onunload = function() {
    checkCookie();    
	}	
	
	

function checkValidsemail(str){

	//CHECK FOR NONE FIRST
	eml = str.toLowerCase();
	if (eml == "none" )
		return true;

	var at="@"
	var dot="."
	var lat=str.indexOf(at)
	var lstr=str.length
	var ldot=str.indexOf(dot)
	if (str.indexOf(at)==-1){
//	   alert("Invalid E-mail ID")
	   return false
	}

	if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
//	   alert("Invalid E-mail ID")
	   return false
	}

	if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
//		alert("Invalid E-mail ID")
		return false
	}

	 if (str.indexOf(at,(lat+1))!=-1){
//		alert("Invalid E-mail ID")
		return false
	 }

	 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
//		alert("Invalid E-mail ID")
		return false
	 }

	 if (str.indexOf(dot,(lat+2))==-1){
//		alert("Invalid E-mail ID")
		return false
	 }

	 if (str.indexOf(" ")!=-1){
//		alert("Invalid E-mail ID")
		return false
	 }

	 return true
}


function valEmail(obj_element, changeColor)
{	var isValid = true;
	var temp = 0;
	var str = obj_element;
	var elementLength = str.length;
	var cnt = 0;
	var cnt2 = 0;
	var cnt3 = 0;
	var i = 0;
//	if(str.toLowerCase() == "none")
//		return isValid;
	
	for (i=0;i<=elementLength;i++){
		if(str.charAt(i)=="@"){
			cnt = cnt + 1;
			if(cnt > 1){
				isValid = false;
				}
		}
		if(str.charAt(i)=="."){
			if((str.charAt(i+1)==".") || (str.charAt(i-1)==".")){
				cnt2 = cnt2 + 1;
				if(cnt2 > 1){
					isValid = false;
				}
			}	
		}
		if(str.charAt(i)==" "){
			cnt3 = cnt3 + 1;
			if(cnt3 > 0){
				isValid = false;
				}
		}
		
	}	
	
	
	if(elementLength > 0 )
	{	temp = str.lastIndexOf("@");
		if(temp < 1)
			isValid = false;
		else
		{	str = str.substring(temp, elementLength);
			elementLength = str.length;
			if(elementLength > 1)
			{	str = str.substring(1, elementLength);
				elementLength -= 1;
				temp = str.lastIndexOf(".");
				if(temp < 1)
					isValid = false;
				else if( (elementLength - temp -1) < 2 )
					isValid = false;
			}
			else
				isValid = false;
		}	
	}
	else
		isValid = false;
	
	if(isValid && changeColor)
		obj_element.style.borderColor="";
	else if(!isValid && changeColor)
		obj_element.style.borderColor="#ff0000";
	
	return isValid
}



function isFloat(str, maxDecimalPlaces){
	//here we replace the $ character and check length of remaining string
	if(str.lastIndexOf("$") > 0)
		return false;
	else
		str = str.replace("$", "");
	if(str.length == 0)
		return false;
		
	//here wwe check for two or more decimal points and more decimal places than the value passed in
	var tempArray = str.split(".");
	if(tempArray.length > 2)
		return false;
	else if(tempArray.length == 2 && tempArray[tempArray.length-1].length > maxDecimalPlaces)
		return false;
	else
		str = tempArray[0];
	
	//now we check the remaining string for misplaced commas and invalid characters
	tempArray = str.split(",");
	if( isNaN(tempArray[0]) )
		return false;
		
	var temp;
	if(tempArray.length > 1)
		for(temp = 1; temp < tempArray.length; temp++)
		{
			if( isNaN(tempArray[temp]) || tempArray[temp].length != 3 )
				return false;
		}
		
	return true;
}

//-->

