// First Place Condos - Ryan McCoy

// Google Code

//<![CDATA[
function load() {


//]]>


// Add / Remove Values using Get ID
	
// Start First Name Input Hover
	if(document.getElementById("txtFirstName")) { 
			// Grab the test box
			var fn = document.getElementById("txtFirstName");
			// Attach Focus event handler
			fn.onfocus = function ()
			{
				fn.value = "";
			}
			// Attach Blur event handler
			fn.onblur = function ()
			{
				if(fn.value == "")
				{
					fn.value = fn.defaultValue;
				}
			}
	}
	
	else {
		return false;	
	}

// Start Last Name Input Hover
	if(document.getElementById("txtLastName")) { 
			// Grab the test box
			var ln = document.getElementById("txtLastName");
			// Attach Focus event handler
			ln.onfocus = function ()
			{
				ln.value = "";
			}
			// Attach Blur event handler
			ln.onblur = function ()
			{
				if(ln.value == "")
				{
					ln.value = ln.defaultValue;
				}
			}
	}
	
	else {
		return false;	
	}
	
// Start Company Input Hover
	if(document.getElementById("txtCompany")) { 
			// Grab the test box
			var co = document.getElementById("txtCompany");
			// Attach Focus event handler
			co.onfocus = function ()
			{
				co.value = "";
			}
			// Attach Blur event handler
			co.onblur = function ()
			{
				if(co.value == "")
				{
					co.value = co.defaultValue;
				}
			}
	}
	
	else {
		return false;	
	}
	
// Start Address Input Hover
	if(document.getElementById("txtAddress")) { 
			// Grab the test box
			var ad = document.getElementById("txtAddress");
			// Attach Focus event handler
			ad.onfocus = function ()
			{
				ad.value = "";
			}
			// Attach Blur event handler
			ad.onblur = function ()
			{
				if(ad.value == "")
				{
					ad.value = ad.defaultValue;
				}
			}
	}
	
	else {
		return false;	
	}

// Start city Input Hover
	if(document.getElementById("txtCity")) { 
			// Grab the test box
			var ci = document.getElementById("txtCity");
			// Attach Focus event handler
			ci.onfocus = function ()
			{
				ci.value = "";
			}
			// Attach Blur event handler
			ci.onblur = function ()
			{
				if(ci.value == "")
				{
					ci.value = ci.defaultValue;
				}
			}
	}
	
	else {
		return false;	
	}
	
// Start zip Input Hover
	if(document.getElementById("txtZip")) { 
			// Grab the test box
			var zi = document.getElementById("txtZip");
			// Attach Focus event handler
			zi.onfocus = function ()
			{
				zi.value = "";
			}
			// Attach Blur event handler
			zi.onblur = function ()
			{
				if(zi.value == "")
				{
					zi.value = zi.defaultValue;
				}
			}
	}
	
	else {
		return false;	
	}
	
// Start email Input Hover
	if(document.getElementById("txtEmail")) { 
			// Grab the test box
			var em = document.getElementById("txtEmail");
			// Attach Focus event handler
			em.onfocus = function ()
			{
				em.value = "";
			}
			// Attach Blur event handler
			em.onblur = function ()
			{
				if(em.value == "")
				{
					em.value = em.defaultValue;
				}
			}
	}
	
	else {
		return false;	
	}
	
// Start phone Input Hover
	if(document.getElementById("txtPhoneNumber")) { 
			// Grab the test box
			var ph = document.getElementById("txtPhoneNumber");
			// Attach Focus event handler
			ph.onfocus = function ()
			{
				ph.value = "";
			}
			// Attach Blur event handler
			ph.onblur = function ()
			{
				if(ph.value == "")
				{
					ph.value = ph.defaultValue;
				}
			}
	}
	
	else {
		return false;	
	}

// Start fax Input Hover
	if(document.getElementById("txtFaxNumber")) { 
			// Grab the test box
			var fa = document.getElementById("txtFaxNumber");
			// Attach Focus event handler
			fa.onfocus = function ()
			{
				fa.value = "";
			}
			// Attach Blur event handler
			fa.onblur = function ()
			{
				if(fa.value == "")
				{
					fa.value = fa.defaultValue;
				}
			}
	}
	
	else {
		return false;	
	}

// Start comments Input Hover
	if(document.getElementById("txtComments")) { 
			// Grab the test box
			var com = document.getElementById("txtComments");
			// Attach Focus event handler
			com.onfocus = function ()
			{
				com.value = "";
			}
			// Attach Blur event handler
			com.onblur = function ()
			{
				if(com.value == "")
				{
					com.value = com.defaultValue;
				}
			}
	}
	
	else {
		return false;	
	}


// End Function
}

// Validate Fields

function Validate()
{
form = document.frmContact
 
if (form.txtFirstName.value == "" || form.txtFirstName.value == "First Name"){
 		alert("Please enter a \"First Name\".");
    	form.txtFirstName.focus();		
		return false
 	}
	  
if (form.txtLastName.value == "" || form.txtLastName.value == "Last Name"){
 		alert("Please enter a \"Last Name\".");
    	form.txtLastName.focus();		
		return false
 	}		

if (form.txtEmail.value=="" || form.txtEmail.value == "Email"){
 		alert("Please enter an \"Email\".");
    	form.txtEmail.focus();			
		return false
 	}
	
    var str  = form.txtEmail.value; 
    var name  = form.txtEmail;
    var errMsg = "Please enter a valid email address."     

   var newString = str.match(/\b(^(\S+@).+((\.com)|(\.net)|(\.edu)|(\.mil)|(\.gov)|(\.org)|(\.ca)|(\.uk)|(\..{2,2}))$)\b/gi);
   
   if (!newString){  
    alert(errMsg) ; 
    form.txtEmail.focus();   
    return false; 
   }

if (form.txtPhoneNumber.value.match(/^[0-9]{3}-[0-9]{3}-[0-9]{4,}$/)){
     //return(true);
}
else{
 alert("Telephone Format: 999-999-9999");
 form.txtPhoneNumber.focus();
 return false;
 }

if (form.txtFaxNumber.value != "" && form.txtFaxNumber.value != "Fax Number"){

	if (form.txtFaxNumber.value.match(/^[0-9]{3}-[0-9]{3}-[0-9]{4,}$/)){
		//return(true);
	}
	
	else {
	alert("Please enter a valid \"Fax Number\".");
	form.txtFaxNumber.focus();		
	return false;
 	}
}
	  
if (form.txtZip.value != "" && form.txtZip.value != "Zip"){

	if (form.txtZip.value.match(/^[0-9]{5}$/)){
     //return(true);
    }
	
	else if (form.txtZip.value.match(/^[0-9]{5}-[0-9]{4}$/)){
     //return(true);
    }
	
	else {
	alert("Please enter a valid \"Zip\".");
	form.txtZip.focus();		
	return false;
 	}
}
}