/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  *
  * Title : 		Form Validation Example
  * Author : 		Vito Tardia
  * URL : 			http://www.vtardia.com
  *
  * Description :	Includes functions from HackerJournal magazine
  *					(http://www.hackerjournal.it)
  *				- 	filled
  *				- 	canSubmit
  *
  * Created : 	27/03/2006
  * Modified : 	27/11/2006
  *
 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/

	var info;

	//Attach an "onLoad" event to the current window
	window.onload = init;
	
	//Initialization function
	function init() {
		//Attaching the onSubmit event to the login form
		info = document.getElementById('info');
		info.onsubmit = function () {
			return canSubmit(this);
		}
		
		//Setting focus to the user field
		info.username.focus();
	}

	function filled(field) {
		if (field.value == "" || field.value == null) {
			return false;
		} else {
			return true;
		}
	}
	
	function canSubmit(form) {
		if (!filled(form.fname)) {
			alert("Please enter your First Name.");
			form.fname.focus();
			return false;
		}

		if (!filled(form.lname)) {
			alert("Please enter your Last Name.");
			form.lname.focus();
			return false;
		}

	if (!filled(form.email)) {
			alert("Please enter your Email ID.");
			form.email.focus();
			return false;
		}


		if (!filled(form.contactno)) {
			alert("Please enter your Contact No.");
			form.contactno.focus();
			return false;
		}

		if (!filled(form.service)) {
			alert("Please select Services from list");
			form.service.focus();
			return false;
		}

		return true;
	}


/*
if(PageForm.email.value=="")
	{
		alert("Please Enter Your  Valid Email address.");
		PageForm.email.focus();
		return false;
	}
	

if (validate_email(email,"Not a valid E-mail Address!")==false)
  {email.focus();return false}



function validate_email(field,alerttxt)
{
with (field)
{
apos=value.indexOf("@")
dotpos=value.lastIndexOf(".")
if (apos<1||dotpos-apos<2) 
  {alert(alerttxt);return false}
else {return true}
}
} 
*/