﻿
function checkContact2(type)
{
	
if(type=='sub'){ 

var	contact_name=document.getElementById('sup_contact_name').value;
var	company=document.getElementById('sup_company').value;
var	email=document.getElementById('sup_email').value;
var	phone=document.getElementById('sup_phone').value;
var	comment='';
	
}

if(type=='reg'){
var	contact_name=document.getElementById('contact_name').value;
var	company=document.getElementById('company').value;
var	email=document.getElementById('email').value;
var	phone=document.getElementById('phone').value;
var	comment=document.getElementById('comment').value;

}


	
	
	
	  if(!contact_name){alert("We need the contact name not to be blank."); return false;}
	  if(!company){alert("We need the company not to be blank."); return false;}
	  if(!email){alert("We need the email not to be blank."); return false;}
	  if(!phone){alert("We need the phone not to be blank."); return false;}
	  
	  
	  
		var str=email;
		var at="@"
		var dot="."
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)
		
		if (str.indexOf(at)==-1){
		   alert("Invalid E-mail ID")
		   return ;
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		   alert("Invalid E-mail ID")
		   return ;
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		    alert("Invalid E-mail ID")
		    return ;
		}

		 if (str.indexOf(at,(lat+1))!=-1){
		    alert("Invalid E-mail ID")
		    return ;
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		    alert("Invalid E-mail ID")
		    return ;
		 }

		 if (str.indexOf(dot,(lat+2))==-1){
		    alert("Invalid E-mail ID")
		    return ;
		 }
		
		 if (str.indexOf(" ")!=-1){
		    alert("Invalid E-mail ID")
		    return ;
		 }
		 

	  sendMail(contact_name, company, email, phone, comment,type);
	  if(type=='sub')
		{
			HideContent('submitButtons'); HideContent('submitBuyerContact');HideContent('spansuppliercart'); ShowContent('postSubSend'); 
			ShowContent('okButton');
		}
}


