function check() {
	error=0;
 	if (document.form1.T1.value=='') {
 		document.form1.T1.style.background='#FF0000';error=1;
	} else {
	    document.form1.T1.style.background='#FFFFFF';
	}
	if (document.form1.T2.value=='') {
 		document.form1.T2.style.background='#FF0000';error=1;
	} else {
	    document.form1.T2.style.background='#FFFFFF';
	}
	if (document.form1.T4.value=='') {
 		document.form1.T4.style.background='#FF0000';error=1;
	} else {
	    document.form1.T4.style.background='#FFFFFF';
	}
   	if (document.form1.S1.value=='') {
 		document.form1.S1.style.background='#FF0000';error=1;
	} else {
	    document.form1.S1.style.background='#FFFFFF';
	}
	//preveri ali je email pravilne oblike
	email=document.form1.T3.value;
	//if (error==0) {
	 	if ((email!=null)&&(email!="")) {
    	 	if (echeck(email)==false) {
    			document.form1.T3.style.background='#FF0000';error=1;
			} else {
			    document.form1.T3.style.background='#FFFFFF';
			}
		}
	//}
	if (error==0) {
	    document.form1.submit();
	}
}


function echeck(str) {

		var at="@"
		var dot="."
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)
		if (str.indexOf(at)==-1){
		   return false
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		   return false
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		    return false
		}

		 if (str.indexOf(at,(lat+1))!=-1){
		    return false
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		    return false
		 }

		 if (str.indexOf(dot,(lat+2))==-1){
		    return false
		 }

		 if (str.indexOf(" ")!=-1){
		    return false
		 }

 		 return true
	}

function ValidateForm(){
	var emailID=document.frmSample.txtEmail

	if ((emailID.value==null)||(emailID.value=="")){
		alert("Please Enter your Email ID")
		emailID.focus()
		return false
	}
	if (echeck(emailID.value)==false){
		emailID.value=""
		emailID.focus()
		return false
	}
	return true
}

