function validate_required(field,alerttxt){
	with (field){
	if (value==null||value==""){
	    alert(alerttxt);return false;
    } else {
	    return true;
    }
  }
}

function validate_phone(field){
	with (field){
		error = "";
		var stripped = value.replace(/[\(\)\.\-\ ]/g, '');
		//strip out acceptable non-numeric characters
		if (isNaN(parseInt(stripped))) {
		   error = "The phone number contains illegal characters.";
		   alert(error);return false;
		}
		if (!(stripped.length == 10)) {
			error = "The phone number is the wrong length.\n Make sure you included an area code.\n";
			alert(error);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;}
  }
}

function validate_default(field,defaultVal,alerttxt){
	with (field){
	if (value==null||value==""||value==defaultVal){
	    alert(alerttxt);return false;
    } else {
	    return true;
    }
  }
}


function DoValidation( SurveyForm){

	with (SurveyForm)
	{
  		if (validate_default(txtName,"First Name","Please enter your First Name!")==false)
  		{txtName.focus();return false;}

  		if (validate_default(txtAddress,"Address","Please enter your Address!")==false)
  		{txtAddress.focus();return false;}

  		if (validate_default(txtPhone,"Phone","Please enter your Phone!")==false)
  		{txtPhone.focus();return false;}

  		if (validate_phone(txtPhone)==false)
  		{txtPhone.focus();return false;}

  		if (validate_default(txtEmail,"Email","Please enter your Email!")==false)
  		{txtEmail.focus();return false;}

  		if (validate_email(txtEmail,"Please enter valid Email!")==false)
  		{txtEmail.focus();return false;}

  		if (validate_default(txtPcs,"No. of PCs","Please enter No. of PCs!")==false)
  		{txtPcs.focus();return false;}
	}
}
