function VerifyCheckBox(checkBoxElement)
{
	if (checkBoxElement.checked)	checkBoxElement.value = 'true';
	else checkBoxElement.value = 'false';
}

function ValidateData(theForm)
{
	if (theForm.contactDate.value != "")
	{
		return (false);
	}

	if (theForm.FirstName.value == "")
	{
		alert('Please, enter your first name.');
		theForm.FirstName.focus();
		return (false);
	}

	if (theForm.LastName.value == "")
	{
		alert('Please, enter your last name.');
		theForm.LastName.focus();
		return (false);
	}

	if (theForm.Phone.value == "")
	{
		alert('Please, enter your phone.');
		theForm.Phone.focus();
		return (false);
	}


	if ((theForm.Email.value == "") || (theForm.Email.value == 'Email'))
	{
		alert('Please, enter your email.');
		theForm.Email.focus();
		return (false);
	}
	else
	{
		if(!ValidateEmail(theForm.Email.value))
		{
			alert("Please check the emails address");
			theForm.Email.focus();
			return false;
		}
	}

	if ((theForm.ReplyByPhone.checked==false) && (theForm.ReplyByEmail.checked==false))
	{
		alert('Please, select how would you like us to reply.');
		theForm.ReplyByPhone.focus();
		return (false);
	}

	CheckValues(theForm);
	
	if (theForm.BlemishScar.checked)
	{		
		return (true);
	}
	if (theForm.Blepharoplasty.checked)
	{		
		return (true);
	}
	if (theForm.Botox.checked)
	{
		return (true);
	}
	if (theForm.BreastAugmentation.checked)
	{
		return (true);
	}
	if (theForm.Browlift.checked)
	{
		return (true);
	}
	if (theForm.CheekImplants.checked)
	{
		return (true);
	}
	if (theForm.CheekLift.checked)
	{
		return (true);
	}
	if (theForm.ChinImplant.checked)
	{
		return (true);
	}
	if (theForm.Dermabrasion.checked)
	{		
		return (true);
	}
	if (theForm.Facelift.checked)
	{
		return (true);
	}
	if (theForm.FacialLiposuction.checked)
	{
		return (true);
	}
	if (theForm.HairTransplantation.checked)
	{
		return (true);
	}
	if (theForm.LaserHairRemoval.checked)
	{
		return (true);
	}		
	if (theForm.LaserSkinResurfacing.checked)
	{
		return (true);
	}		
	if (theForm.LipAugmentation.checked)
	{
		return (true);
	}		
	if (theForm.NeckLiposuction.checked)
	{
		return (true);
	}		
	if (theForm.Otoplasty.checked)
	{
		return (true);
	}
	if (theForm.Rhinoplasty.checked)
	{
		return (true);
	}
	if (theForm.TatooRemoval.checked)
	{
		return (true);
	}
	if (theForm.Thermage.checked)
	{
		return (true);
	}
	if (theForm.WrinkleFillers.checked)
	{
		return (true);
	}
		

	alert('Please, select a procedure.');
	return (false);
}


function ValidateDataContact(theForm)
{
	if (theForm.txtFirstName.value == "")
	{
		alert('Please, enter your first name.');
		theForm.txtFirstName.focus();
		return (false);
	}

	if (theForm.txtLastName.value == "")
	{
		alert('Please, enter your last name.');
		theForm.txtLastName.focus();
		return (false);
	}

	if ((theForm.radMale.checked==false) && (theForm.radFemale.checked==false))
	{
		alert('Please, select your gender.');
		theForm.radMale.focus();
		return (false);
	}
	
	if (theForm.txtEmail.value == "")
	{
		alert('Please, enter your email.');
		theForm.txtEmail.focus();
		return (false);
	}

	if (theForm.txtAddress.value == "")
	{
		alert('Please, enter your address.');
		theForm.txtAddress.focus();
		return (false);
	}
	
	if (theForm.txtCity.value == "")
	{
		alert('Please, enter your city.');
		theForm.txtCity.focus();
		return (false);
	}
	
	if (theForm.cboState.value == "")
	{
		alert('Please, choose your state.');
		theForm.cboState.focus();
		return (false);
	}
	
	if (theForm.cboCountry.value == "")
	{
		alert('Please, choose your country.');
		theForm.cboCountry.focus();
		return (false);
	}

	if (theForm.txtPhoneNumber.value == "")
	{
		alert('Please, enter your phone number.');
		theForm.txtPhoneNumber.focus();
		return (false);
	}
	
	CheckValuesContact(theForm);

	if (theForm.chkBleph2.checked)
	{		
		return (true);
	}
	if (theForm.chkHair2.checked)
	{		
		return (true);
	}
	if (theForm.chkRhino2.checked)
	{
		return (true);
	}
	if (theForm.chkLaser.checked)
	{
		return (true);
	}
	if (theForm.chkFace2.checked)
	{
		return (true);
	}
	if (theForm.chkScar2.checked)
	{
		return (true);
	}
	if (theForm.chkForehead2.checked)
	{
		return (true);
	}
	if (theForm.chkSkin2.checked)
	{		
		return (true);
	}
	if (theForm.chkOto2.checked)
	{
		return (true);
	}
	if (theForm.chkWrinkle2.checked)
	{
		return (true);
	}
	if (theForm.chkImplants2.checked)
	{
		return (true);
	}
	if (theForm.chkMento2.checked)
	{
		return (true);
	}				

	alert('Please, select a procedure.');
	return (false);
}



function CheckValues(theForm)
{
	if (theForm.BlemishScar.checked)
	{
		theForm.BlemishScar.value = 'true';
	}
	else
	{
		theForm.BlemishScar.value = 'false';
	}
	
	if (theForm.Blepharoplasty.checked)
	{		
		theForm.Blepharoplasty.value = 'true';
	}
	else
	{
		theForm.Blepharoplasty.value = 'false';
	}
	
	if (theForm.Botox.checked)
	{
		theForm.Botox.value = 'true';
	}
	else
	{
		theForm.Botox.value = 'false';
	}
	
	if (theForm.BreastAugmentation.checked)
	{
		theForm.BreastAugmentation.value = 'true';
	}
	else
	{
		theForm.BreastAugmentation.value = 'false';
	}	
	
	if (theForm.Browlift.checked)
	{
		theForm.Browlift.value = 'true';
	}
	else
	{
		theForm.Browlift.value = 'false';
	}	
	
	if (theForm.CheekImplants.checked)
	{
		theForm.CheekImplants.value = 'true';
	}
	else
	{
		theForm.CheekImplants.value = 'false';
	}
	
	if (theForm.CheekLift.checked)
	{
		theForm.CheekLift.value = 'true';
	}
	else
	{
		theForm.CheekLift.value = 'false';
	}
	
	if (theForm.ChinImplant.checked)
	{
		theForm.ChinImplant.value = 'true';
	}
	else
	{
		theForm.ChinImplant.value = 'false';
	}
	
	if (theForm.Dermabrasion.checked)
	{		
		theForm.Dermabrasion.value = 'true';
	}
	else
	{
		theForm.Dermabrasion.value = 'false';
	}
	
	if (theForm.Facelift.checked)
	{
		theForm.Facelift.value = 'true';
	}
	else
	{
		theForm.Facelift.value = 'true';
	}
	
	if (theForm.FacialLiposuction.checked)
	{
		theForm.FacialLiposuction.value = 'true';
	}
	else
	{
		theForm.FacialLiposuction.value = 'false';
	}
	
	if (theForm.HairTransplantation.checked)
	{
		theForm.HairTransplantation.value = 'true';
	}
	else
	{
		theForm.HairTransplantation.value = 'false';
	}
	
	if (theForm.LaserHairRemoval.checked)
	{
		theForm.LaserHairRemoval.value = 'true';
	}	
	else
	{
		theForm.LaserHairRemoval.value = 'false';
	}
		
	if (theForm.LaserSkinResurfacing.checked)
	{
		theForm.LaserSkinResurfacing.value = 'true';
	}
	else
	{
		theForm.LaserSkinResurfacing.value = 'false';
	}
		
	if (theForm.LipAugmentation.checked)
	{
		theForm.LipAugmentation.value = 'true';
	}
	else
	{
		theForm.LipAugmentation.value = 'false';
	}
	
	if (theForm.NeckLiposuction.checked)
	{
		theForm.NeckLiposuction.value = 'true';
	}
	else
	{
		theForm.NeckLiposuction.value = 'false';
	}	
	
	if (theForm.Otoplasty.checked)
	{
		theForm.Otoplasty.value = 'true';
	}
	else
	{
		theForm.Otoplasty.value = 'false';
	}
	
	if (theForm.Rhinoplasty.checked)
	{
		theForm.Rhinoplasty.value = 'true';
	}
	else
	{
		theForm.Rhinoplasty.value = 'false';
	}
	
	if (theForm.TatooRemoval.checked)
	{
		theForm.TatooRemoval.value = 'true';
	}
	else
	{
		theForm.TatooRemoval.value = 'false';
	}
	
	if (theForm.Thermage.checked)
	{
		theForm.Thermage.value = 'true';
	}
	else
	{
		theForm.Thermage.value = 'false';
	}
	
	if (theForm.WrinkleFillers.checked)
	{
		theForm.WrinkleFillers.value = 'true';
	}
	else
	{
		theForm.WrinkleFillers.value = 'false';
	}
}

function CheckValuesContact(theForm)
{
	if (theForm.chkBleph2.checked)
	{
		theForm.chkBleph2.value = 'true';
	}
	else
	{
		theForm.chkBleph2.value = 'false';
	}
	
	if (theForm.chkHair2.checked)
	{		
		theForm.chkHair2.value = 'true';
	}
	else
	{
		theForm.chkHair2.value = 'false';
	}
	
	if (theForm.chkRhino2.checked)
	{
		theForm.chkRhino2.value = 'true';
	}
	else
	{
		theForm.chkRhino2.value = 'false';
	}
	
	if (theForm.chkLaser.checked)
	{
		theForm.chkLaser.value = 'true';
	}
	else
	{
		theForm.chkLaser.value = 'false';
	}	
	
	if (theForm.chkFace2.checked)
	{
		theForm.chkFace2.value = 'true';
	}
	else
	{
		theForm.chkFace2.value = 'false';
	}

	
	if (theForm.chkScar2.checked)
	{
		theForm.chkScar2.value = 'true';
	}
	else
	{
		theForm.chkScar2.value = 'false';
	}
	
	if (theForm.chkForehead2.checked)
	{
		theForm.chkForehead2.value = 'true';
	}
	else
	{
		theForm.chkForehead2.value = 'false';
	}
	
	if (theForm.chkSkin2.checked)
	{		
		theForm.chkSkin2.value = 'true';
	}
	else
	{
		theForm.chkSkin2.value = 'false';
	}
	
	if (theForm.chkOto2.checked)
	{
		theForm.chkOto2.value = 'true';
	}
	else
	{
		theForm.chkOto2.value = 'true';
	}
	
	if (theForm.chkWrinkle2.checked)
	{
		theForm.chkWrinkle2.value = 'true';
	}
	else
	{
		theForm.chkWrinkle2.value = 'false';
	}
	
	if (theForm.chkImplants2.checked)
	{
		theForm.chkImplants2.value = 'true';
	}
	else
	{
		theForm.chkImplants2.value = 'false';
	}
	
	if (theForm.chkMento2.checked)
	{
		theForm.chkMento2.value = 'true';
	}	
	else
	{
		theForm.chkMento2.value = 'false';
	}
}

function ValidateEmail(incoming) 
{
	var emailstring = incoming;
	var ampIndex = emailstring.indexOf("@");
	var afterAmp = emailstring.substring((ampIndex + 1), emailstring.length);
	// find a dot in the portion of the string after the ampersand only
	var dotIndex = afterAmp.indexOf(".");
	// determine dot position in entire string (not just after amp portion)
	dotIndex = dotIndex + ampIndex + 1;
	// afterAmp will be portion of string from ampersand to dot
	afterAmp = emailstring.substring((ampIndex + 1), dotIndex);
	// afterDot will be portion of string from dot to end of string
	var afterDot = emailstring.substring((dotIndex + 1), emailstring.length);
	var beforeAmp = emailstring.substring(0,(ampIndex));
	//var email_regex = /^\w(?:\w|-|\.(?!\.|@))*@\w(?:\w|-|\.(?!\.))*\.\w{2,3}/ 
	// index of -1 means "not found"
	
	if ((emailstring.indexOf("@") != "-1") &&
		(emailstring.indexOf(".") != "-1") &&
		(emailstring.length > 5) &&
		(afterAmp.length > 0) &&
		(beforeAmp.length > 1) &&
		(afterDot.length > 1) //&&
		//(email_regex.test(emailstring))
		) 
	{
		return true;
	} 
	else {
		return false;
	}
}
