function mailFormSubmit(){
	if(	checkEmail(document.forms['email'].emailaddress, 'Email Address') &&
		checkEmail(document.forms['email'].Vemailaddress, 'Verify Email Address') &&
		checkVerifyEmail(document.forms['email'].emailaddress, document.forms['email'].Vemailaddress) &&
		checkStringExt(document.forms['email'].firstname, 'First Name') &&
		checkStringExt(document.forms['email'].lastname, 'Last Name') &&
		checkZip(document.forms['email'].zip, 'Zip Code')
	){
		window.open('/homes/insertRegistration.asp?firstName=' + document.forms['email'].firstname.value + '&lastName=' + document.forms['email'].lastname.value + '&emailAddress=' + document.forms['email'].emailaddress.value + '&zip=' + document.forms['email'].zip.value + '&phone=' + document.forms['email'].phone.value,'form','width=600,height=450');
	}	
}
function contactFormSubmit(){
	if(	checkStringExt(document.forms['contactUsForm'].first, 'First Name') &&
		checkStringExt(document.forms['contactUsForm'].last, 'Last Name') &&
		checkZip(document.forms['contactUsForm'].zip2, 'Zip Code') &&
		checkEmail(document.forms['contactUsForm'].email, 'Email Address')
	){
		window.open('/homes/submitContact.asp?first=' + document.forms['contactUsForm'].first.value + '&last=' + document.forms['contactUsForm'].last.value + '&address1=' + document.forms['contactUsForm'].address1.value + '&address2=' + document.forms['contactUsForm'].address2.value + '&city=' + document.forms['contactUsForm'].city.value + '&state=' + document.forms['contactUsForm'].state.value + '&zip=' + document.forms['contactUsForm'].zip2.value + '&phone=' + document.forms['contactUsForm'].phone.value + '&email=' + document.forms['contactUsForm'].email.value + '&newhomes=' + document.forms['contactUsForm'].newhomes.value + '&newhallranch=' + document.forms['contactUsForm'].newhallranch.value + '&businessjobs=' + document.forms['contactUsForm'].businessjobs.value + '&valencianewhomes=' + document.forms['contactUsForm'].valencianewhomes.value + '&newhallland=' + document.forms['contactUsForm'].newhallland.value + '&communityofvalencia=' + document.forms['contactUsForm'].communityofvalencia.value + '&recreation=' + document.forms['contactUsForm'].recreation.value + '&environmental=' + document.forms['contactUsForm'].environmental.value + '&TextBoxUserCode=' + document.forms['contactUsForm'].TextBoxUserCode.value + '&comments=' + document.forms['contactUsForm'].comments.value,'form','width=450,height=200');
	}	
}
function mailEffect(){
	if($('homeThankYou'))
		var thankYou = 'homeThankYou';
	else
		var thankYou = 'siteThankYou';
	new Effect.Appear(thankYou, {afterFinish: function(){
		document.forms['email'].emailaddress.value = 'Email';
		document.forms['email'].firstname.value = 'First Name';
		document.forms['email'].lastname.value = 'Last Name';
		document.forms['email'].zip.value = 'Zip Code';	
	}});
	new Effect.Fade(thankYou, {queue:'end',delay:1.0});	
}


function getDefaultFieldValues(element){
	var returner = '';
	switch(element.name){
		case 'firstname':
			returner = 'First Name';
			break;
		case 'lastname':
			returner = 'Last Name';
			break;
		case 'emailaddress':
			returner = 'Email';
			break;
		case 'Vemailaddress':
			returner = 'Email Verification';
			break;
		case 'zip':
			returner = 'Zip Code';
			break;	
		case 'phone':
			returner = 'Phone Number';
			break;			
	}
	return returner;
}

function contactEffect(){
	new Effect.Appear('contactThankYou', {afterFinish: function(){
		document.forms['contactUsForm'].reset();
	}});
	new Effect.Fade('contactThankYou', {queue:'end', delay:1.0});
	new Effect.Fade('contactContainer', {queue:'end',duration:0.2});
	new Effect.Fade('mapBG', {queue:'end',duration:0.2});
}

function mailFormFocus(element){
	var def_value = getDefaultFieldValues(element);
	if(element.value == def_value)
		element.value = '';
}

function mailFormBlur(element){
	var def_value = getDefaultFieldValues(element);
	if(!element.value)
		element.value = def_value;
}