// this is for IE6
// drop downs won't work in IE 6 without it
// to add drop downs, set new ul id to nav# where # is 1 greater than latest current drop down ul id
// then change # in    for (x=0; x<#; x++)  to the new id #
startList = function() {
	if (document.all&&document.getElementById) {
		for (x=0; x<1; x++) {
			navRoot = document.getElementById("nav"+x);
			for (i=0; i<navRoot.childNodes.length; i++) {
				node = navRoot.childNodes[i];
				if (node.nodeName=="LI") {
					node.onmouseover=function() {
						this.className+=" over";
	  				}
	  				node.onmouseout=function() {
	  					this.className=this.className.replace(" over", "");
	   				}
	   			}
	  		}
		}
 	}
}
window.onload=startList;
	
function checkLogin() {
	var err = 0;
	var err_txt = "";
	var msg_txt = "";
	var intro_msg = "\n\rThe following information is required: ";
	if (document.login.login_email.value == "" ) {
		err++;
		msg_txt += "\n\r\tEmail";
	}
	if (document.login.login_password.value == "" ) {
		err++;
		msg_txt += "\n\r\tPassword";
	}
	if (err > 0) {
		if (msg_txt != "") {
			err_txt = intro_msg+msg_txt+"\n\r"+err_txt;
		}
		alert(err_txt);
		return false;
	}  else {
		return true;
	}
}

	
	
/*** DHTML phone number validation script. Courtesy of SmartWebby.com (http://www.smartwebby.com/dhtml/) */
var digits = "0123456789"; // Declaring required variables
var phoneNumberDelimiters = "()- "; // non-digit characters which are allowed in phone numbers
// characters which are allowed in international phone numbers
var validWorldPhoneChars = phoneNumberDelimiters + "+"; // (a leading + is OK)
var minDigitsInIPhoneNumber = 10; // Minimum no of digits in an international phone no.

function isInteger(s){
	var i;
	for (i = 0; i < s.length; i++) {
		var c = s.charAt(i); // Check that current character is number.
		if (((c < "0") || (c > "9"))) return false;
	}
	return true;// All characters are numbers.
}

function stripCharsInBag(s, bag) {
	var i;
	var returnString = "";
	// Search through string's characters one by one.
	// If character is not in bag, append to returnString.
	for (i = 0; i < s.length; i++) {
		var c = s.charAt(i); // Check that current character isn't whitespace.
		if (bag.indexOf(c) == -1) returnString += c;
	}
	return returnString;
}

function checkInternationalPhone(strPhone){
	s=stripCharsInBag(strPhone,validWorldPhoneChars);
	return (isInteger(s) && s.length >= minDigitsInIPhoneNumber);
}
/* END SMARTYWEB CODE */

/*** DHTML email validation script. Courtesy of SmartWebby.com (http://www.smartwebby.com/dhtml/) */
function echeck(str) {
	var at="@"
	var dot="."
	var lat=str.indexOf(at)
	var lstr=str.length
	var ldot=str.indexOf(dot)
	if (str.indexOf(at)==-1) return false;
	if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr) return false;
	if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr) return false;
	if (str.indexOf(at,(lat+1))!=-1) return false;
	if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot) return false;
	if (str.indexOf(dot,(lat+2))==-1) return false;
	if (str.indexOf(" ")!=-1) return false;
	return true;
}


function checkContact() {
	var err = 0;
	var err_txt = "";
	var msg_txt = "";
	var intro_msg = "\n\rThe following information is required: ";

	if (document.contact.name.value == "") {
		err++;
		msg_txt += "\n\r\tName";
	}
	if (document.contact.email.value == "") {
		err++;
		msg_txt += "\n\r\tEmail";
	} else if (echeck(document.contact.email.value)==false) {
		err++;
		msg_txt += "\n\r\tA valid email addess is required.";
	}
	if (document.contact.phone.value == "") {
		err++;
		msg_txt += "\n\r\tPhone";
	} else if (checkInternationalPhone(document.contact.phone.value)==false){
		err++;
		msg_txt += "\n\r\tValid phone number format is required. Please include area code.";
	}
	if (document.contact.property.value == "") {
		err++;
		msg_txt += "\n\r\tProperty";
	}
	if (err > 0) {
		if (msg_txt != "") {
			err_txt = intro_msg+msg_txt+"\n\r"+err_txt;
		}
		alert(err_txt);
		return false;
	}  else {
		return true;
	}
}
