function NewWindow(mypage, myname, w, h, scroll) {
		var winl = (screen.width - w) / 2;
		var wint = (screen.height - h) / 2;
		winprops = 'height='+h+',width='+w+',top='+wint+',left='+winl+',scrollbars='+scroll+',resizable'
		win = window.open(mypage, myname, winprops)

		if (parseInt(navigator.appVersion) >=4) { win.window.focus(); }
	}



function checknum(numfieldArray,numfieldDisplayArray,form){
	var i = 0;
	var strValidChars = "0123456789.-";
	var strChar;
	var blnResult = true;
for(i=0; i<numfieldArray.length; i++){
strString = eval("form." + numfieldArray[i] + ".value")

//  test strString consists of valid characters listed above
	for (a = 0; a < strString.length  && blnResult == true; a++)
	{
	strChar = strString.charAt(a);
	if (strValidChars.indexOf(strChar) == -1)
	{
	alert("The field " + numfieldDisplayArray[i] + " must be a numeric.");
	blnResult = false;
					}
				}
			return blnResult;
		}
	}

function checkForm()
{
	//contactname required check
	if (document.Entry.contactname.value == null || document.Entry.contactname.value.length == 0)
	{
		alert("\nYou must provide a value for the Contact Name field");
		document.Entry.contactname.focus();
		return false;
	}
	//Borrower Name required check
	if (document.Entry.borrowername.value == null || document.Entry.borrowername.value.length == 0)
	{
		alert("\nYou must provide a value for the Borrower Name field");
		document.Entry.borrowername.focus();
		return false;
	}
	//companyname required check
	if (document.Entry.companyname.value == null || document.Entry.companyname.value.length == 0)
	{
		alert("\nYou must provide a value for the Company Name field");
		document.Entry.companyname.focus();
		return false;
	}
	
	//city required check
	if (document.Entry.city.value == null || document.Entry.city.value.length == 0)
	{
		alert("\nYou must provide a value for the City field");
		document.Entry.city.focus();
		return false;
	}
	
	//contact via
	if ((document.Entry.contact_via.options[document.Entry.contact_via.selectedIndex].value==""))
	{
		alert("\nYou must provide a value for the Contact Me Via field");
		document.Entry.contact_via.focus();
		return false;
	}
	
	//state required check
	if ((document.Entry.state.options[document.Entry.state.selectedIndex].value==""))
	{
		alert("\nYou must provide a value for the state field");
		document.Entry.state.focus();
		return false;
	}
	
	//Phone required check
	if (document.Entry.Phone.value == null || document.Entry.Phone.value.length == 0)
	{
		alert("\nYou must provide a value for the Phone field");
		document.Entry.Phone.focus();
		return false;
	}
	//fax required check
	if (document.Entry.fax.value == null || document.Entry.fax.value.length == 0)
	{
		alert("\nYou must provide a value for the Fax field");
		document.Entry.fax.focus();
		return false;
	}
	
	//email required check
	if (document.Entry.email.value == null || document.Entry.email.value.length == 0)
	{
		alert("\nYou must provide a value for the Email field");
		document.Entry.email.focus();
		return false;
	}
	//email email check
	if (!e(document.Entry.email.value))
	{
		alert("Please include a proper e-mail address, of the form id@domain.zzz or id@domain.xx.zzz.");
		document.Entry.email.focus();
		return false;
	}
	//financing required check
	if (document.Entry.financing.value == null || document.Entry.financing.value.length == 0)
	{
		alert("\nYou must provide a value for the Amount of Financing Required field");
		document.Entry.financing.focus();
		return false;
	}
	//finance_type required check
	if (document.Entry.finance_type.value == null || document.Entry.finance_type.value.length == 0)
	{
		alert("\nYou must provide a value for the Type of Financing Required field");
		document.Entry.finance_type.focus();
		return false;
	}
	//property_type required check
	if ((document.Entry.property_type.options[document.Entry.property_type.selectedIndex].value==""))
	{
		alert("\nYou must provide a value for the Choose the Property Type for Your Loan. field");
		document.Entry.property_type.focus();
		return false;
	}
	//location required check
	if (document.Entry.location.value == null || document.Entry.location.value.length == 0)
	{
		alert("\nYou must provide a value for the Property Location field");
		document.Entry.location.focus();
		return false;
	}
	//location maxlength check
	if(eval("document.Entry.location.value.length") > 200){
		message="the field Property Location  can be no longer than 200 characters\nCurrent length equals "+ eval("document.Entry.location.value.length");
		alert(message);
		return false;
	}
	
	
	
	//narrative required check
	if (document.Entry.narrative.value == null || document.Entry.narrative.value.length == 0)
	{
		alert("\nYou must provide a value for the Enter a brief property narrative  field");
		document.Entry.narrative.focus();
		return false;
	}
	//narrative maxlength check
	if(eval("document.Entry.narrative.value.length") > 500){
		message="the field Enter a brief property narrative   can be no longer than 500 characters\nCurrent length equals "+ eval("document.Entry.narrative.value.length");
		alert(message);
		return false;
	}
	// Pressnall Dupe Stopper
	if ( typeof ( formSubmission ) == "number" )
	{
		return false;
	}
	formSubmission = 1;
}
function checkreq(reqfieldArray,reqfieldDisplayArray,form){ 
var i = 0;
for(i=0; i<reqfieldArray.length; i++){
	if(eval("form." + reqfieldArray[i] + ".value") == ''){
	alert("The field " + reqfieldDisplayArray[i] + " must be completed to continue.");
	eval("form." + reqfieldArray[i] + ".focus()");
	return false;
}}return true;}

function checkdate(datefieldArray,datefieldDisplayArray,form){
var i = 0;
for(i=0; i<datefieldArray.length; i++){
if(eval("form." + datefieldArray[i] + ".value") != ''&& eval("form." + datefieldArray[i] + ".value") != 'mm/dd/yyyy' ){
	var testYear = eval("form." + datefieldArray[i] + ".value.lastIndexOf('/') + 1");
	var testMonth = eval("form." + datefieldArray[i] + ".value.indexOf('/')");
	var testDay1 = eval("form." + datefieldArray[i] + ".value.indexOf('/')+1");
	var testDay2 = eval("form." + datefieldArray[i] + ".value.lastIndexOf('/')");
	var lenboy = 10;
	if(!isDate(eval("form." + datefieldArray[i] + ".value.substring(testYear,lenboy)"),
		eval("form." + datefieldArray[i] + ".value.substring(0, testMonth)"),
		eval("form." + datefieldArray[i] + ".value.substring(testDay1,testDay2)"))){
		alert("The field " + datefieldDisplayArray[i] + " must be a real date formatted like: mm/dd/yyyy");
		//alert("The date must be a real date formatted like: mm/dd/yyyy");
		eval("form." + datefieldArray[i] + ".focus()");
	return false; 
	}}}return true;}
	
	
function checknum(numfieldArray,numfieldDisplayArray,form){
	var i = 0; 
	var strValidChars = "0123456789.-";
	var strChar;
	var blnResult = true;

for(i=0; i<numfieldArray.length; i++){
strString = eval("form." + numfieldArray[i] + ".value")

//  test strString consists of valid characters listed above
   for (i = 0; i < strString.length  && blnResult == true; i++)
      {
      strChar = strString.charAt(i);
      if (strValidChars.indexOf(strChar) == -1)
         {
		 alert("The field " + numfieldDisplayArray[i] + " must be a numeric.");
         blnResult = false;
         }
      }
   return blnResult;
   }

}



function makeArray(n) {
   for (var i = 1; i <= n; i++) {
      this[i] = 0
   } 
   return this
}

var daysInMonth = makeArray(12);
daysInMonth[1] = 31;
daysInMonth[2] = 29;   // must programmatically check this
daysInMonth[3] = 31;
daysInMonth[4] = 30;
daysInMonth[5] = 31;
daysInMonth[6] = 30;
daysInMonth[7] = 31;
daysInMonth[8] = 31;
daysInMonth[9] = 30;
daysInMonth[10] = 31;
daysInMonth[11] = 30;
daysInMonth[12] = 31;

function daysInFebruary (year)
{   // February has 29 days in any year evenly divisible by four,
    // EXCEPT for centurial years which are not also divisible by 400.
    return (  ((year % 4 == 0) && ( (!(year % 100 == 0)) || (year % 400 == 0) ) ) ? 29 : 28 );
}

function isMonth (s)
{   
	if (s > 0 && s < 13) return true;
	return false; 
}

function isDay (s)
{   
	if (s > 0 && s < 32) return true;
	return false; 
}

function isDate (year, month, day)
{   
	// get rid of '0' in the month if there is one
	if (month.substring(0, 1) == "0")
		month = month.substring(1, 2);

	// catch invalid months and days.
    if (! isMonth(month)) return false;
	if (! isDay(day)) return false;

    // catch invalid days, except for February
    if (day > daysInMonth[month]) return false; 

    if ((month == 2) && (day > daysInFebruary(year))) return false;

    return true;
}

function validateDate(date) {

	var testMonth = date.substring(0, date.indexOf("/"));
	var testDay = date.substring(date.indexOf("/")+1, date.lastIndexOf("/"));
	var testYear = date.substring(date.lastIndexOf("/") + 1,date.length);
	
	if (!isNumber(testMonth)) {
		alert("Please enter a valid 2-digit month for all dates.");
		return false;
		}	
	if (!isNumber(testDay)) {
		alert("Please enter a valid 2-digit day for all dates.");
		return false;
		}	
	if (!isNumber(testYear) || (testYear.length < 4)) {
		alert("Please enter a valid 4-digit year for all dates.");
		return false;
		}
		
	// validate the date
	if (!isDate(testYear, testMonth, testDay)) {
		alert("A date entered is not valid.");
		return false;
		}
		
	return true;

}

// this function returns the full year for a given date
function getFullYear(d) 
{
	var y = d.getYear();
	if (y < 1000) y += 1900;
	return y;
}

// Comparing two dates -- return true if day2 >= day1
// assuming here that both date are valid
function dateCompare(day1, month1, year1, day2, month2, year2)
{
	if(month1 < 10){
		month1 = month1.substring(1,2);
	} 
	if(month2 < 10){
		month2 = month2.substring(1,2);
	} 
	
	if (parseInt(year2) > parseInt(year1)){
		return true;
	}
	
	if (parseInt(year2) == parseInt(year1))
	{
		if (parseInt(month2) > parseInt(month1)){
			return true;
		}
		if (parseInt(month2) == parseInt(month1))
		{
			if (parseInt(day2) >= parseInt(day1)){
				return true;
			} else {
				return false;
			}
		}
		if (parseInt(month2) < parseInt(month1)){
			return false;
		}
	}
	
	if (parseInt(year2) < parseInt(year1)){
		return false;
	}
		
	return true;
}

// Returns true if character c is a digit 
// (0 .. 9).
function isDigit (c)
{   
	return ((c >= "0") && (c <= "9"))
}

function isNumber(s)

{   var i;

    // Search through string's characters one by one
    // until we find a non-numeric character.
    // When we do, return false; if we don't, return true.
    for (i = 0; i < s.length; i++)
    {   
        // Check that current character is number.
        var c = s.charAt(i);

        if (!isDigit(c)) return false;
    }

    // All characters are numbers.
    return true;
}

function isPhoneNumber(phoneNumber){
	// returns true for 10-digit phone number value
	// ignores all whitespace characters and standard phone delimiters:  ( ) - . 
	var ignoreChar = /[\s()-.]/g;
	var strippedNumber = phoneNumber.replace(ignoreChar,"");
	
	if (isNaN(strippedNumber)){
		return false;
	}else if (strippedNumber.length == 10){
		return true;
	}else{
		return false;
	}
}

function isZipCode(zipCode){
	// returns true for 5-digit or 9-digit zip code
	// ignores all whitespace and hyphen characters
	var ignoreChar = /[\s-]/g;
	var strippedZip = zipCode.replace(ignoreChar,"");
	
	if (isNaN(strippedZip)){
		return false;
	}else if (strippedZip.length == 5 || strippedZip.length == 9){
		return true;
	}else{
		return false;
	}
}

function HourCompare(hour1,hour2){
	//alert(hour1);
	//alert(hour1.substring(0,2) + " " + hour1.substring(3,5));
	if(hour2.substring(0,2) > hour1.substring(0,2)){
		return true;
	} else {
		return false;
	}
	
	if(hour2.substring(0,2) == hour1.substring(0,2)){
		if(hour2.substring(5,2) > hour1.substring(5,2)){
			return true;
		} else {
			return false;
		}
	}
}

function e(s) {

	rex=true;

	if (window.RegExp) 
	{st="a";ex=new RegExp(st);
		if (st.match(ex)) {
		r1=new RegExp("(@.*@)|(\\.\\.)|(@\\.)|(^\\.)");
		r2=new RegExp("^.+\\@(\\[?)[a-zA-Z0-9\\-\\.]+\\.([a-zA-Z]{2,3}|[0-9]{1,3})(\\]?)$");
		b=(!r1.test(s)&&r2.test(s));
		}
		else 
		{rex=false;
		}
	} 
	else
	{	rex=false;
	}
	if(!rex) b=(s.indexOf("@")>0 && s.indexOf(".")>0 && s!="" && s!="enter e-mail");
	return (b);
}
