function validate(){

var bool=0;
		if(document.form1.tname.value==""){
		var div = document.getElementById('name');
		div.style.visibility='visible' ;
		document.form1.tname.focus();
		bool=1;
		}
		else{
			var div = document.getElementById('name');
		div.style.visibility='hidden' ;
		}
	 	if(document.form1.temail.value==""){
					var div1 = document.getElementById('email');
		div1.style.visibility='visible' ;
		document.form1.temail.focus();
		bool=1;
		}
				else{
			var div = document.getElementById('email');
		div.style.visibility='hidden' ;
		}
		if(document.form1.temail.value!="" && echeck(document.form1.temail.value)==false ){
			
		
		var div12 = document.getElementById('emailvalid');
		div12.style.visibility='visible' ;
		document.form1.temail.focus();

		bool=1;
		}
		else{
			var div = document.getElementById('emailvalid');
		div.style.visibility='hidden' ;
		}
		if(document.form1.tcontactno.value!="" && isNaN(document.form1.tcontactno.value)){
			
			var div2 = document.getElementById('contactno');
			div2.style.visibility='visible' ;
			document.form1.tcontactno.focus();
			bool=1;
		}
		else{
			var div = document.getElementById('contactno');
		div.style.visibility='hidden' ;
		}		
	 if(document.form1.tmedium[0].checked==false && document.form1.tmedium[1].checked==false &&document.form1.tmedium[2].checked==false){
			
		
			var div3 = document.getElementById('medium');
			div3.style.visibility='visible' ;
			bool=1;
		}
		else{
			var div = document.getElementById('medium');
		div.style.visibility='hidden' ;
		}	
		if(document.form1.tconsult.value==""){

			var div4= document.getElementById('consult');
		div4.style.visibility='visible' ;
		document.form1.tconsult.focus();
		bool=1;
		}
		else{
			var div = document.getElementById('consult');
		div.style.visibility='hidden' ;
		}
		if(document.form1.img1.value!=""){
			var div = document.getElementById('image1');
			if(valid_emailid(document.form1.img1.value)==false){
				document.form1.img1.focus();
				div.style.visibility='visible' ;
				bool=1;
			}
			else
				div.style.visibility='hidden' ;
				
		}
				if(document.form1.img2.value!=""){
			var div = document.getElementById('image2');
			if(valid_emailid(document.form1.img2.value)==false){
				document.form1.img2.focus();
				div.style.visibility='visible' ;
				bool=1;
			}
			else
				div.style.visibility='hidden' ;
				
		}
				if(document.form1.img3.value!=""){
			var div = document.getElementById('image3');
			if(valid_emailid(document.form1.img3.value)==false){
				document.form1.img3.focus();
				div.style.visibility='visible' ;
				bool=1;
			}
			else
				div.style.visibility='hidden' ;
				
		}
				if(document.form1.img4.value!=""){
			var div = document.getElementById('image4');
			if(valid_emailid(document.form1.img4.value)==false){
				document.form1.img4.focus();
				div.style.visibility='visible' ;
				bool=1;
			}
			else
				div.style.visibility='hidden' ;
				
		}
				if(document.form1.img5.value!=""){
			var div = document.getElementById('image5');
			if(valid_emailid(document.form1.img5.value)==false){
				document.form1.img5.focus();
				div.style.visibility='visible' ;
				bool=1;
			}
			else
				div.style.visibility='hidden' ;
				
		}
				if(document.form1.img6.value!=""){
			var div = document.getElementById('image6');
			if(valid_emailid(document.form1.img6.value)==false){
				document.form1.img6.focus();
				div.style.visibility='visible' ;
				bool=1;
			}
			else
				div.style.visibility='hidden' ;
				
		}
		
if(bool==1)
	return false;
else
	return true;
}

function valid_emailid(imgpath){
	
	var upimg=imgpath.toLowerCase();
	var finddot=upimg.lastIndexOf('.',upimg.length);
	var contain=upimg.substring(finddot+1,upimg.length);
	var arr=new Array('jpeg','jpg','gif','png','pjpeg','pjpg','bmp'); //add file extensions here
 
	var res = "no";
	
	for(i=0;i<=arr.length-1;i++)
	{
		if(arr[i]==contain)
		res="yes";
	}
	
	if(res=="yes")
		return true;
	else
		return false;
}

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){
		    alert("Invalid E-mail ID")
		    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					
	}
