<!--

viewer = null;


function popFAQ(page,DaName,w,h,scroll)        
{        
	tempWindow = window.open(page,DaName,"scrollbars="+scroll+",resizable=no,width="+w+",height="+h+",status=no,location=no,toolbar=no,menubar=no");
	tempWindow.focus();      
}

function popFAQ2(page,DaName,w,h,scroll)
{
        tempWindow = window.open(page,DaName,"scrollbars="+scroll+",resizable=no,width="+w+",height="+h+",status=yes,location=no,toolbar=no,menubar=no");
        tempWindow.focus();
}














function popReplace(page)
{
        tempWindow = window.open(page,"CheckReplace","scrollbars=yes,resizable=no,width=600,height=400,status=no,location=no,toolbar=no,menubar=yes");
        tempWindow.focus();
}








function popExitInside()
{
	javOpen("http://www.expresstaxrefund.com/askExit.cgi", "ExitWin", 400,300,"no");
}










function MoveFocus(psForm1, psForm2, len)
{
//onkeyup="MoveFocus(form1.value, document.form2.name, 5)">
if (psForm1.length == len)
{
psForm2.focus();
}
}











function javOpen(page,DaName,w,h,scroll)        
{        
	tmpViewer = window.open(page,DaName,"scrollbars="+scroll+",resizable=no,width="+w+",height="+h+",status=no,location=no,toolbar=no,menubar=no");
	tmpViewer.focus();      
	return tmpViewer;
}


function isEinValid ( ein ) {

	
        valideins = new String("01,02,03,04,05,06,11,10,12,13,14,15,16,20,21,22,23,24,25,26,27,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,80,81,82,83,84,85,86,87,88,90,91,92,93,94,95,96,97,98,99");    

        valideins = valideins.split(",");
              
        valid = false;
         for ( i = 0; i < valideins.length; i++ ) {
             if ( ein == valideins[i] )
               {
                 valid = true;  
                 break;
               }    
         }

	return valid;

}

function isSocialValid ( number ) {
				ree = /\D/;

				if (number.length != 9 || number.search(ree) != -1 ){
        	return false;
        }
      
				//test if social is within valid ranges.
        test_soc = false;
        //first test standard social ranges
        if(number >= 1010001 && number <= 699999999){
        	test_soc = true;
        }else if(number >= 700010001 && number <= 733999999){
        	test_soc = true;
        }else if(number >= 750010001 && number <= 763999999){
        	test_soc = true;
        }else if(number >= 764010001 && number <= 899999999){
        	test_soc = true;
        //next test if it is a valid ITIN range.
        }else if(number >= 900700000 && number <= 999889999){
        	test_soc = true;
        //finally test if a valid ATIN
        }else if(number >= 900930000 && number <= 999939999){
        	test_soc = true;
        }
        
        //if social range test fails, return error
        if(test_soc == false){
        	return false;
        }
        
        
        repetition = false;
        for ( i=0 ; i < 8 ; i++ ) {
            if ( number.charAt(i) == number.charAt(i+1) || number == "123456789" || number == "987654321" ) {
                     repetition = true;
            }
            else
            {
                repetition = false;
                break;
            }
        }

         // if the social has repetition
         if ( repetition )
         {
                return false;
         }        

	return true;
}



function isValidZip( state, zipcode )

{
        statestr = new String(state[state.selectedIndex].value);
        zip      = parseInt(zipcode.value,10);


        if( statestr.toUpperCase() == "AL" && 
                (zip >= 35000 && zip <= 36999) )
        {
                return true;
        } 
        else if( statestr.toUpperCase() == "AK" && 
                (zip >= 99500 && zip <= 99999) )
        {
                return true;
        }
        else if( statestr.toUpperCase() == "AZ" && 
                (zip >= 85000 && zip <= 86599) )
        {
                return true;
        }
        else if( statestr.toUpperCase() == "AR" && 
                ((zip >= 71600 && zip <= 72999) || zip == 75502) )
        {
                return true;
        }
        else if( statestr.toUpperCase() == "CA" && 
                ((zip >= 90000 && zip <= 90899) || (zip >= 91000 && zip <= 96199)) )
        {
                return true;
        }
        else if( statestr.toUpperCase() == "CO" && 
                (zip >= 80000 && zip <= 81699) )
        {
                return true;
        }
        else if( statestr.toUpperCase() == "CT" && 
                ( (zip >= 6000 ) && (zip <= 6999 ) ) ) // 0 in front
        {
                return true;
        }
        else if( statestr.toUpperCase() == "DE" && 
                (zip >= 19700 && zip <= 19999) )
        {
                return true;
        }
        else if( statestr.toUpperCase() == "DC" && 
                (zip >= 20000 && zip <= 20599) )
        {
                return true;
        }
        else if( statestr.toUpperCase() == "FL" && 
                ((zip >= 32000 && zip <= 33999) || (zip >= 34100 && zip <= 34299) ||
                (zip >= 34400 && zip <= 34499) || (zip >= 34600 && zip <= 34799) ||
                (zip >= 34900 && zip <= 34999)) )
        {
                return true;
        }
        else if( statestr.toUpperCase() == "GA" && 
                ((zip >= 30000 && zip <= 31999) || (zip >= 37900 && zip <= 39999)) )
        {
                return true;
        }
        else if( statestr.toUpperCase() == "HI" && 
                (zip >= 96700 && zip <= 96899) )
        {
                return true;
        }
        else if( statestr.toUpperCase() == "ID" && 
                (zip >= 83200 && zip <= 83899) )
        {
                return true;
        }
        else if( statestr.toUpperCase() == "IL" && 
                (zip >= 60000 && zip <= 62999) )
        {
                return true;
        }
        else if( statestr.toUpperCase() == "IN" && 
                (zip >= 46000 && zip <= 47999) )
        {
                return true;
        }
        else if( statestr.toUpperCase() == "IA" && 
                (zip >= 50000 && zip <= 52899) )
        {
                return true;
        }
        else if( statestr.toUpperCase() == "KS" && 
                (zip >= 66000 && zip <= 67999) )
        {
                return true;
        }
        else if( statestr.toUpperCase() == "KY" && 
                ((zip >= 40000 && zip <= 42799) || zip == 45275) )
        {
                return true;
        }
        else if( statestr.toUpperCase() == "LA" && 
                ((zip >= 70000 && zip <= 71499) || zip == 71749) )
        {
                return true;
        }
        else if( statestr.toUpperCase() == "ME" && 
                ((zip >= 3900 && zip <= 4999) || zip == 3801) ) // 0 in front
        {
                return true;
        }
        else if( statestr.toUpperCase() == "MD" && 
                (zip >= 20600 || zip <= 21999 || zip == 20331) )
        {
                return true;
        }
        else if( statestr.toUpperCase() == "MA" && 
                ((zip >= 1000 && zip <= 2799) || (zip >= 5500 && zip <= 5599)) ) // 0 in front
        {
                return true;
        }
        else if( statestr.toUpperCase() == "MI" && 
                (zip >= 48000 && zip <= 49999) )
        {
                return true;
        }
        else if( statestr.toUpperCase() == "MN" && 
                (zip >= 55000 && zip <= 56799) )
        {
                return true;
        }
        else if( statestr.toUpperCase() == "MS" && 
                (zip >= 38600 && zip <= 39799) )
        {
                return true;
        }
        else if( statestr.toUpperCase() == "MO" && 
                (zip >= 63000 && zip <= 65899) )
        {
                return true;
        }
        else if( statestr.toUpperCase() == "MT" && 
                (zip >= 59000 && zip <= 59999) )
        {
                return true;
        }
        else if( statestr.toUpperCase() == "NE" && 
                (zip >= 68000 && zip <= 69399) )
        {
                return true;
        }
        else if( statestr.toUpperCase() == "NV" && 
                (zip >= 88900 && zip <= 89899) )
        {
                return true;
        }
        else if( statestr.toUpperCase() == "NH" && 
                (zip >= 3000 && zip <= 3999) ) //0 in front
        {
                return true;
        }
        else if( statestr.toUpperCase() == "NJ" && 
                (zip >= 7000 && zip <= 8999) ) // 0 in front
        {
                return true;
        }
        else if( statestr.toUpperCase() == "NM" && 
                (zip >= 87000 && zip <= 88499) )
        {
                return true;
        }
        else if( statestr.toUpperCase() == "NY" && 
                ((zip >= 400 && zip <= 599) || zip == 6390 || // 00 , 00, 0  in order
                (zip >= 10000 && zip <= 14999)) )
        {
                return true;
        }
        else if( statestr.toUpperCase() == "NC" && 
                (zip >= 27000 && zip <= 28999) )
        {
                return true;
        }
        else if( statestr.toUpperCase() == "ND" && 
                (zip >= 58000 && zip <= 58899) )
        {
                return true;
        }
        else if( statestr.toUpperCase() == "OH" && 
                (zip >= 43000 && zip <= 45999) )
        {
                return true;
        }
        else if( statestr.toUpperCase() == "OK" && 
                ((zip >= 73000 && zip <= 73299) || (zip >= 73400 && zip <= 74999)) )
        {
                return true;
        }
        else if( statestr.toUpperCase() == "OR" && 
                (zip >= 97000 && zip <= 97999) )
        {
                return true;
        }
        else if( statestr.toUpperCase() == "PA" && 
                (zip >= 15000 && zip <= 19699) )
        {
                return true;
        }
        else if( statestr.toUpperCase() == "RI" && 
                (zip >= 2800 && zip <= 2999) ) // 0 in front
        {
                return true;
        }
        else if( statestr.toUpperCase() == "SC" && 
                (zip >= 29000 && zip <= 29999) )
        {
                return true;
        }
        else if( statestr.toUpperCase() == "SD" && 
                (zip >= 57000 && zip <= 57799) )
        {
                return true;
        }
        else if( statestr.toUpperCase() == "TN" && 
                (zip >= 37000 && zip <= 38599) )
        {
                return true;
        }
        else if( statestr.toUpperCase() == "TX" && 
                ((zip >= 73300 && zip <= 73399) || zip == 73949 ||
                (zip >= 75000 && zip <= 79999)) )
        {
                return true;
        }
        else if( statestr.toUpperCase() == "UT" && 
                (zip >= 84000 && zip <= 84799) )
        {
                return true;
        }
        else if( statestr.toUpperCase() == "VT" && 
                ((zip >= 5000 && zip <= 5499) || (zip >= 5600 && zip <= 5999)) ) // 0 in front
        {
                return true;
        }
        else if( statestr.toUpperCase() == "VA" && 
                ((zip >= 20100 && zip <= 20199) || zip == 20041 || zip == 20301 || 
                zip == 20370 || (zip >= 22000 && zip <= 24699) ) )
        {
                return true;
        }
        else if( statestr.toUpperCase() == "WA" && 
                ((zip >= 98000 && zip <= 98699) || (zip >= 98800 && zip <= 99499)) )
        {
                return true;
        }
        else if( statestr.toUpperCase() == "WV" && 
                (zip >= 24700 && zip <= 26899) )
        {
                return true;
        }
        else if( statestr.toUpperCase() == "WI" && 
                ((zip >= 53000 && zip <= 54999) || zip == 49936) )
        {
                return true;
        }
        else if( statestr.toUpperCase() == "WY" && 
                (zip >= 82000 && zip <= 83199) )
        {
                return true;
        }
        else
        {
                alert("Your State and Zip code do not correspond !");
                return false;
        }

    return true;
}


function highLight ( eName ) {
         document.getElementById(eName).style.backgroundColor = "#61B531";//"#E97231";
         document.getElementById(eName).focus();
}


function clearHighLights () {
        for(i=0; i < document.getElementsByTagName("input").length; i++){
                document.getElementsByTagName("input").item(i).style.backgroundColor ="";
        }
        for(i=0; i < document.getElementsByTagName("select").length; i++){
                document.getElementsByTagName("select").item(i).style.backgroundColor ="";
        }
}






function trimAll( strValue ) {
/************************************************
DESCRIPTION: Removes leading and trailing spaces.

PARAMETERS: Source string from which spaces will
  be removed;

RETURNS: Source string with whitespaces removed.
*************************************************/
 var objRegExp = /^(\s*)$/;

    //check for all spaces
    if(objRegExp.test(strValue)) {
       strValue = strValue.replace(objRegExp, '');
       if( strValue.length == 0)
          return strValue;
    }

   //check for leading & trailing spaces
   objRegExp = /^(\s*)([\W\w]*)(\b\s*$)/;
   if(objRegExp.test(strValue)) {
       //remove leading and trailing whitespace characters
       strValue = strValue.replace(objRegExp, '$2');
    }
  return strValue;
}

function removeCurrency( strValue ) {
/************************************************
DESCRIPTION: Removes currency formatting from
  source string.

PARAMETERS:
  strValue - Source string from which currency formatting
     will be removed;

RETURNS: Source string with commas removed.
*************************************************/
  var objRegExp = /\(/;
  var strMinus = '';

  //check if negative
  if(objRegExp.test(strValue)){
    strMinus = '-';
  }

  objRegExp = /\)|\(|[,]/g;
  strValue = strValue.replace(objRegExp,'');
  if(strValue.indexOf('$') >= 0){
    strValue = strValue.substring(1, strValue.length);
  }
  return strMinus + strValue;
}


function cleanAmount(theField){
	//try {
		var theObj = document.getElementById(theField);
		if(theObj){
			theObj.value = trimAll(theObj.value);
			theObj.value = removeCurrency(theObj.value);
		}
	//}catch(E){}
}

function isNumValid (value) {

	reSp = /\s/g;
	num = new String(value);
	num.replace(reSp,"");
	decimal = num.split(".");
	re = /\./g;

	if ( num.search(reSp) != -1 ) {
                alert("ERROR: You must provide a numerical value: Spaces are not allowed.");
                return false;

        }

	if ( isNaN(num) ) {
		alert("ERROR: You must provide a numerical value: No invalid characters ($ or ,)");
		return false;
	}

	if ( num.search(re) != -1 ) {
		if ( decimal[0].length < 1 ) {
			alert("ERROR: You have entered an amount less than a dollar! Please leave this field blank.");
			return false;
		}

		if ( decimal[1].length != 2 ) {
			alert("ERROR: You must have 2 digits following a decimal.");
			return false;
		}
  	}

	 if ( (parseInt(num,10) <= 0) || (num.charAt(0) == "0") ){ 
		alert("ERROR: You have entered an amount less than a dollar! Please leave this field blank." );
		return false; 
	}
  return true;

}

function isValidCurrency(theFieldName, allowZeros){

	var nNum = 0;					// Total numbers for currency value.
	var nDollarSign = 0;	// Total times a dollar sign occurs.
	var nDecimal = 0;			// Total times a decimal point occurs.
	var nCommas = 0;			// Total times a comma occurs.
	var txtLen;						// Length of string passed.
	var xTxt;							// Assigned object passed.
	var sDollarVal;				// Assigned dollar amount with or without commas.
	var bComma;				
	var decPos = 0;						// Assigned value of numbers or positions after decimal point.
	var nNumCount = 0;		// Total number between commas.
	var i;								// For forloop indexing.
	var x;								// Assigned each indivual character in string.

	var theObject = null; // the object
	
	//check if object exists, if so, set the object, if not, return true;
	if(document.getElementById(theFieldName)){
		theObject = document.getElementById(theFieldName);
		theObject.value = trimAll(theObject.value); // clean spaces from field.
	}else{
		return true;
	}

	// Set the xTxt variable to the object passed to this function.
	xTxt = theObject.value;
	
	// Assign the length of the string to txtLen.
	txtLen = xTxt.length

	for(i = 0; i < txtLen; i++){

		// Assign charater in substring to x.
		x = xTxt.substr(i, 1);

		if(x == "$")
			nDollarSign = nDollarSign + 1; // Sum total times dollar sign occurs.
		else if(x == ".")
			nDecimal = nDecimal + 1; // Sum total times decimal point occurs.
		else if(x == ",")
			nCommas = nCommas + 1; // Sum total times comma occurs.
		else if(parseInt(x) >= 0 || parseInt(x) <= 9)
			nNum = nNum + 1; // If the character is a number sum total times a number occurs.
		else
		{
			// Error occurs if any other character value is in the string
			// other then the valid characters.

			alert("ERROR: You have entered an invalid dollar amount!\n\nPlease enter only: Dollar" +
				  " Signs, Commas, Decimal Points, and numbers!");
			return false;
		} // end else
	} // end for

	if(nDollarSign > 1){
		alert("ERROR: You have entered more then one dollar sign!\nPlease only enter one!");
		return false;
	} // end if

	if(nDecimal > 1){
		alert("ERROR: You have entered more then one decimal point!\nPlease only enter one!");
		return false;
	} // end if

	if(nDollarSign == 1){
		// Make sure dollar sign in the first character in string
		// if there is a dollar sign present.
		if(xTxt.indexOf("$") != 0){
			alert("ERROR: The dollar sign you entered is not in the correct position!");
			return false;
		} // end if
	}// end if

	if(nDecimal == 1){
		// Get the number of numbers after the decimal point in
		// the string if there is a decimal point present
		decPos = (txtLen - 1) - xTxt.indexOf(".");

		// Floating point cannot be more then two.
		// Valid format after decimal point.
		/**********************************/
		/*   $#.##, $#.#, $.#, $#., $.##  */
		/**********************************/

		if(decPos > 2){
			alert("ERROR: The decimal point you entered is not in the correct position!");
			return false;
		} // end if
	} // end if

	if(nCommas == 0){
		// If no commas are present value is a valid US
		// currency.
		theObject.value = removeCurrency(theObject.value);
		if(parseInt(theObject.value,10) == 0){
			if(!allowZeros){
				theObject.value = "";
			}
			return true;
		}else{
			return isNumValid(theObject.value);
		}
	}else{
		// Get total number of dollar number(s), removing
		// floating point numbers or cents.
		nNum = nNum - decPos;

		// Determine if dollar sign is in string so to be 
		// removed.

		// After determining dollar sign, assign sDollarVal
		// numbers and comma(s)
		if(xTxt.indexOf("$", 0) == 0)
			sDollarVal = xTxt.substr(1, (nNum + nCommas));
		else
			sDollarVal = xTxt.substr(0, (nNum + nCommas));


		// Determine if a zero is the first number or if a
		// comma is the first or last character in the string.

		if(sDollarVal.lastIndexOf("0", 0) == 0 ){
			alert("ERROR: You cannot start the dollar amount out with a zero!");
			return false;
		}else if(sDollarVal.lastIndexOf(",", 0) == 0){
			alert("ERROR: You cannot start the dollar amount out with a comma!");
			return false;
		}else if(sDollarVal.indexOf(",", (sDollarVal.length - 1)) == (sDollarVal.length - 1)){
			alert("ERROR: You cannot end the dollar amount with a comma!");
			return false;
		}else{
			// Initialize bComma indicating a comma has not been
			// occured yet.

			bComma = false;

			for(i = 0; i < sDollarVal.length; i++){
				// Assign charater in substring to x.
				x = sDollarVal.substr(i, 1);

				if(parseInt(x) >= 0 || parseInt(x) <= 9){
					// If x is a number add one to the number counter.
					nNumCount = nNumCount + 1;

					// Sense comma(s) are present number counter cannot
					// be more then three before the first or next comma.
					if(nNumCount > 3){
						alert("ERROR: You have a mis-placed comma!");
						return false;
					} // end if
				}else{
					// If the number counter is less then three and
					// the comma indicator is true the comma is either
					// mis-placed or there are not enough values.
					if(nNumCount != 3 && bComma){
						alert("ERROR: You have a mis-placed comma!");
						return false;
					} // end if

					// Reset the number counter back to zero.
					nNumCount = 0;

					// Set the comma indicator to true indicating
					// that the first comma has been found and that
					// there now MUST be three numbers after each
					// comma until the loop hits the end.

					bComma = true;
				} // end if
			} // end for

			// Determine if after the loop ended that there
			// was a total of three final numbers after the
			// last comma.
			if(nNumCount != 3 && bComma){
				alert("ERROR: You have a mis-placed comma!");
				return false;
			} // end if
		} // end if
	} // end if

	// Return true indicating that the value is a valid
	// currency.
	theObject.value = removeCurrency(theObject.value);
	if(parseInt(theObject.value,10) == 0){
		if(!allowZeros){
			theObject.value = "";
		}
		return true;
	}else{
		return isNumValid(theObject.value);
	}
}



function isValidPercent(theFieldName){
	var nNum = 0;					// Total numbers for currency value.
	var nDecimal = 0;			// Total times a decimal point occurs.
	var txtLen;						// Length of string passed.
	var xTxt;							// Assigned object passed.
	var sDollarVal;				// Assigned dollar amount with or without commas.
	var nNumCount = 0;		// Total number between commas.
	var i;								// For forloop indexing.
	var x;								// Assigned each indivual character in string.

	var theObject = null; // the object
	
	//check if object exists, if so, set the object, if not, return true;
	if(document.getElementById(theFieldName)){
		theObject = document.getElementById(theFieldName);
		theObject.value = trimAll(theObject.value); // clean spaces from field.
	}else{
		return true;
	}

	// Set the xTxt variable to the object passed to this function.
	xTxt = theObject.value;
	
	// Assign the length of the string to txtLen.
	txtLen = xTxt.length

	for(i = 0; i < txtLen; i++){

		// Assign charater in substring to x.
		x = xTxt.substr(i, 1);

		if(x == ".")
			nDecimal = nDecimal + 1; // Sum total times decimal point occurs.
		else if(parseInt(x) >= 0 || parseInt(x) <= 9)
			nNum = nNum + 1; // If the character is a number sum total times a number occurs.
		else
		{
			// Error occurs if any other character value is in the string
			// other then the valid characters.

			alert("ERROR: You have entered an invalid percent value!\nPlease enter only: " +
				  "Numbers between 0 and 9 and a decimal point if applicable!");
			return false;
		} // end else
	} // end for

	if(nDecimal > 1){
		alert("ERROR: You have entered more then one decimal point!\nPlease only enter one!");
		return false;
	} // end if

	// Return true indicating that the value is a valid percent value
	theObject.value = removeCurrency(theObject.value);
	if(parseInt(theObject.value,10) == 0){
		theObject.value = "";
		return true;
	}else{
		return true;
	}
}


function setInputBoxHandlers() {
	try {
		var theObj = null;
		//find every input box whether it be type password or not
		for(i=0; i < document.getElementsByTagName("input").length; i++){
			theObj = document.getElementsByTagName("input")[i];
			if(theObj.type == "text" || theObj.type == "password"){
				theObj.onfocus = setInputOnFocus;
				theObj.onblur = setInputOnBlur;
			}
		}
		for(i=0; i < document.getElementsByTagName("select").length; i++){
			theObj = document.getElementsByTagName("select")[i];
			theObj.onfocus = setInputOnFocus;
			theObj.onblur = setInputOnBlur;
		}		
	}catch(E){}
}


function setInputOnFocus(){
	this.style.backgroundColor = "#cfe3fe";
}

function setInputOnBlur(){
	this.style.backgroundColor = "#ffffee";
	try{
		this.value = trimAll(this.value);
	}catch(E){}
}


function trimInvalids(theValue){
 		var objRegExp = /[\-\=\+\_\)\(\*\&\^\%\$\#\@\!\~\\]/;

    //check for all spaces
    if(objRegExp.test(theValue)) {
       theValue = theValue.replace(objRegExp, '');
       if( theValue.length == 0)
          return "";
    }
    return theValue;
}


function ReportJsError(errMsg, errScript, errLine){
		http_report = false;
		if (window.XMLHttpRequest) { // Mozilla, Safari,...
    	http_report = new XMLHttpRequest();
      if (http_report.overrideMimeType) {
      	http_report.overrideMimeType('text/xml');
        // See note below about this line
      }                
		} else if (window.ActiveXObject) { // IE  
    	try {
      	http_report = new ActiveXObject("Msxml2.XMLHTTP");
      } catch (e) {                 
      	try {
        	http_report = new ActiveXObject("Microsoft.XMLHTTP");
        } catch (e) {}
      }
    }

    end_url = "report_js.cgi"
    http_report.open('POST', end_url, true);
    http_report.send("errMsg=" + escape(errMsg) + "&errScript=" + escape(errScript) + "&errLine=" + escape(errLine) + "&");
  	return true;
}

//comment this line out when finished debugging
window.onerror = ReportJsError;

//-->
