// JavaScript Document

function validate(){
var email1=document.getElementById("email").value;
var email2=document.getElementById("email2").value;
var emailv=document.getElementById("emailv").value;
var fname=document.getElementById("fname").value;
var lname=document.getElementById("lname").value;
var phone=document.getElementById("phone").value;
var location=document.getElementById("location").value;
var program=document.getElementById("program").value;
var stripped = phone.replace(/[\(\)\.\-\ ]/g, '');
var numericExpression = /^[0-9]+$/;
var AtPos = email1.indexOf("@");
var StopPos = email1.lastIndexOf(".");
var suffix = email1.substring(email1.lastIndexOf('.')+1);
submitOK="true";

if (location==""){
	document.getElementById("sch").style.display="inline";
	submitOK="false";
}

if (program==""){
	document.getElementById("pro").style.display="inline";
	submitOK="false";
}

if (fname==""){
	document.getElementById("fna").style.display="inline";
	submitOK="false";
}

if (lname==""){
	document.getElementById("lna").style.display="inline";
	submitOK="false";
}

//email validation function--------------------------->

if (email1==""){
	document.getElementById("ema").style.display="inline";
	submitOK="false";
}

if (email2==""){
	document.getElementById("vema").style.display="inline";
	submitOK="false";
}

if (email1!=email2){
	document.getElementById("ema").style.display="inline";
	document.getElementById("vema").style.display="inline";
	submitOK="false";
}

if (AtPos == -1 || StopPos == -1) {
	document.getElementById("ema").style.display="inline";
	document.getElementById("vema").style.display="inline";
	submitOK="false";
}

if (AtPos == 0) {
	document.getElementById("ema").style.display="inline";
	document.getElementById("vema").style.display="inline";
	submitOK="false";
}

if (StopPos < AtPos) {
	document.getElementById("ema").style.display="inline";
	document.getElementById("vema").style.display="inline";
	submitOK="false";
}

if (StopPos - AtPos == 1) {
	document.getElementById("ema").style.display="inline";
	document.getElementById("vema").style.display="inline";
	submitOK="false";
}

if (suffix.length <= 1 || suffix.length >= 10) {
	document.getElementById("ema").style.display="inline";
	document.getElementById("vema").style.display="inline";
	submitOK="false";
}
if (emailv!=""){
	submitOK="false";
}
//phone validation function--------------------------->

if (!(stripped.match(numericExpression))) {
	document.getElementById("pho").style.display="inline";
	submitOK="false";
}

if (isNaN(parseInt(stripped))) {
	document.getElementById("pho").style.display="inline";
	submitOK="false";
}

if (phone==""){
	document.getElementById("pho").style.display="inline";
	submitOK="false";
}

if (!(stripped.length == 10)) {
	document.getElementById("pho").style.display="inline";
	submitOK="false";
}

if (submitOK=="false"){
 return false;
 }

}
 
function clear_loc(){
	document.getElementById("sch").style.display="none";
}

function clear_prog(){
	document.getElementById("pro").style.display="none";
}

function clear_fname(){
	document.getElementById("fna").style.display="none";
}

function clear_lname(){
	document.getElementById("lna").style.display="none";
}

function clear_email01(){
	document.getElementById("ema").style.display="none";
}

function clear_email02(){
	document.getElementById("vema").style.display="none";
}

function clear_phone(){
	document.getElementById("pho").style.display="none";
}

