function emailvalidation(entered, alertbox)
{
// E-mail Validation by Henrik Petersen / NetKontoret
// Explained at www.echoecho.com/jsforms.htm
// Please do not remove this line and the two lines above.
with (entered)
{
apos=value.indexOf("@");
dotpos=value.lastIndexOf(".");
lastpos=value.length-1;
if (apos<1 || dotpos-apos<2 || lastpos-dotpos<2 || lastpos-dotpos<2)
	{
		if (alertbox) 
			{
			 alert(alertbox);
			 } 
			return false;
		}
else {
	return true;
	}
}
}

function valuevalidation(entered, min, max, alertbox, datatype)
{
// Value Validation by Henrik Petersen / NetKontoret
// Explained at www.echoecho.com/jsforms.htm
// Please do not remove this line and the two lines above.
with (entered)
{
checkvalue=parseFloat(value);
if (datatype)
{smalldatatype=datatype.toLowerCase();
if (smalldatatype.charAt(0)=="i") {checkvalue=parseInt(value)};
}
if ((parseFloat(min)==min && checkvalue<min) || (parseFloat(max)==max && checkvalue>max) || value!=checkvalue)
{if (alertbox!="") {alert(alertbox);} return false;}
else {return true;}
}
}


function digitvalidation(entered, min, max, alertbox, datatype)
{
// Digit Validation by Henrik Petersen / NetKontoret
// Explained at www.echoecho.com/jsforms.htm
// Please do not remove this line and the two lines above.
with (entered)
{
checkvalue=parseFloat(value);
if (datatype)
{
	smalldatatype=datatype.toLowerCase();
	if (smalldatatype.charAt(0)=="i")
	{
		checkvalue=parseInt(value); 
		if (value.indexOf(".")!=-1) 
			{
				checkvalue=checkvalue+1
			}
	};
}
if ((parseFloat(min)==min && value.length<min) || (parseFloat(max)==max && value.length>max) || value!=checkvalue)
{if (alertbox!="") {alert(alertbox);} return false;}
else {return true;}
}
}


function emptyvalidation(entered, alertbox)
{
// Emptyfield Validation by Henrik Petersen / NetKontoret
// Explained at www.echoecho.com/jsforms.htm
// Please do not remove this line and the two lines above.
with (entered)
{
if (value==null || value=="")
{if (alertbox!="") {alert(alertbox);} return false;}
else {return true;}
}
}

function formvalidation(thisform)
{
// This function checks the entire form before it is submitted
// Note: This function needs to be customized to fit your form

	with (thisform)
	{
		
		
	if (emailvalidation	(email,"Not a valid email.")==false) 
		{
			email.focus(); 
			return false;
		};
		
		if (emailcheck (email, email2, "Emails doesn't match. Please re-type your email.")==false) 
		{
			email2.focus(); 
			return false;
		};
		
		if (emptyvalidation(name,"Name field must not be empty.")==false)
		{
			name.focus();
			return false;
		};

		if (emptyvalidation(city,"City must not be empty.")==false)
		{
			city.focus();
			return false;
		};
		
		if (emptyvalidation(state,"Select a state")==false)
		{
			state.focus();
			return false;
		};
		
		if (emptyvalidation(Number_of_Adults,"Enter number of Adults.")==false)
		{
			Number_of_Adults.focus();
			return false;
		};
		
		if (emptyvalidation(Number_of_Children,"Enter number of Children.")==false)
		{
			Number_of_Children.focus();
			return false;
		};
		
	//if (emptyvalidation(comments,"Don't leave the comments box blank.")==false)
	//	{
	//		comments.focus();
	//		return false;
	//	};
	}
}


function formvalidation2(thisform)
{
// This function checks the entire form before it is submitted
// Note: This function needs to be customized to fit your form

	with (thisform)
	{
	
	if (emptyvalidation(name,"Name field must not be empty.")==false)
		{
			name.focus();
			return false;
		};
	
	if (emailvalidation	(email,"Not a valid email.")==false) 
		{
			email.focus(); 
			return false;
		};
	if (emptyvalidation(comments,"Don't leave the comments box blank.")==false)
		{
			comments.focus();
			return false;
		};
	}

}



function validate_radiobox (entered, alertbox)
{
	course=false;
	
	with (entered)
	{
		i=0;
		for (i=0;i<entered.length;i++) 
		{
		if (entered[i].checked) 
			course=true;
			
		}
		if (!course) {
				if (alertbox) 
				{
				 alert(alertbox);
				 } 
				return false;
			}
		else {
		return true;
		}
	}
}


function emailcheck(entered, entered2, alertbox)
{
// E-mail Validation by Henrik Petersen / NetKontoret
// Explained at www.echoecho.com/jsforms.htm
// Please do not remove this line and the two lines above.

if ((entered.value) != (entered2.value))
			{
			 alert(alertbox);
			 return false;
			 } 

else {
	return true;
	}

}
