//////////////////////////////EMAIL VALIDATION//////////////////////////////////////////////////////////
function the_mail(control_value)
{
		var emailStr = control_value;
		var emailPat=/^(.+)@(.+)$/
		var specialChars="\\(\\)<>@,;:\\\\\\\"\\.\\[\\]"
		var validChars="\[^\\s" + specialChars + "\]"
		var quotedUser="(\"[^\"]*\")"
		var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/
		var atom=validChars + '+'
		var word="(" + atom + "|" + quotedUser + ")"
		var userPat=new RegExp("^" + word + "(\\." + word + ")*$")
		var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$")
		var matchArray=emailStr.match(emailPat)
		if (matchArray==null) 
		{
			alert("Email address seems incorrect ");
			//eval("document."+form_name+"."+control_name).focus();
			return true;
		}
		var user=matchArray[1]
		var domain=matchArray[2]
		if (user.match(userPat)==null)
		{
			alert("The Email address doesn't seem to be valid.");
			//eval("document."+form_name+"."+control_name).focus();
			return true;
		}
		var IPArray=domain.match(ipDomainPat)
		if (IPArray!=null) 
		{
			for (var i=1;i<=4;i++) 
			{
				if (IPArray[i]>255) 
				{
					alert("Destination IP address is invalid!");
					//eval("document."+form_name+"."+control_name).focus();
					return true;
				}
			}
				 
		}
		var domainArray=domain.match(domainPat)
		if (domainArray==null) 
		{
			alert("The domain name doesn't seem to be valid.");
			//eval("document."+form_name+"."+control_name).focus();
			return true;
		}
		var atomPat=new RegExp(atom,"g")
		var domArr=domain.match(atomPat)
		var len=domArr.length
		if (domArr[domArr.length-1].length<2 || domArr[domArr.length-1].length>3) 
		{
			alert("The address must end in a three-letter domain, or two letter country.");
			//eval("document."+form_name+"."+control_name).focus();
			return true;
		}
		if (len<2) 
		{
			alert("This address is missing a hostname!");
			//eval("document."+form_name+"."+control_name).focus();
			return true;
		}
		return false;
	
}
///////////////////////////////////////////////////////////////////////////////////////////


/*	Supporting ajax function start */	
	function postRequest(strURL,div) {
	var xmlHttp;
          if (window.XMLHttpRequest) { // Mozilla, Safari, ...
		 var xmlHttp = new XMLHttpRequest();
	    }else if (window.ActiveXObject) { // IE
		var xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
	      }
	    xmlHttp.open('POST', strURL, true);
	    xmlHttp.setRequestHeader
              ('Content-Type', 'application/x-www-form-urlencoded');
		xmlHttp.onreadystatechange = function() {
	if (xmlHttp.readyState == 4) {
	       updatepage(xmlHttp.responseText,div);
	      }
	   }
	 xmlHttp.send(strURL);
        }
     function updatepage(str,div){
	document.getElementById(div).innerHTML =str;
        }
/*	Supporting ajax function END */			
		
		
/*	login ajax function start */
function editmenu(type,id,div){
		//alert(div);
document.getElementById(div).innerHTML = "<div class='loadingdic'><img src='images/ajax-loader.gif' border='0' /> &nbsp;Please Wait ...</div>";

	var url="ajaxprocess.php?type="+type+"&id="+id+"";
	
	postRequest(url,div);
	}
/*	login ajax function END */

<!--top menu START -->
function opendownloaddiv(own){
	document.getElementById('opendownloaddiv').style.display='block';
	document.getElementById('clogedownlodbut').style.display='none';
}
<!--top menu END -->

function logintodownload(type,id,div){
	if(document.download.email.value==''){document.getElementById("emaillogin").style.borderColor="#FD0000";return false;}
	if(the_mail(document.download.email.value)){document.getElementById("emaillogin").style.borderColor="#FD0000";return false;}
	if(document.download.password.value==''){document.getElementById("password").style.borderColor="#FD0000";return false;}
	
	var email=document.download.email.value;
	var password=document.download.password.value;
document.getElementById(div).innerHTML = "<div class='loadingdic'><img src='images/ajax-loader.gif' border='0' /> &nbsp;Please Wait ...</div>";
	var url="ajaxprocess.php?type="+type+"&id="+id+"&email="+email+"&password="+password+"";
	postRequest(url,div);
}

function registration(type,id,div){
	
	if(document.downloadreg.email.value==''){document.getElementById("email").style.borderColor="#FD0000";return false;}
	if(the_mail(document.downloadreg.email.value)){document.getElementById("email").style.borderColor="#FD0000";return false;}
	if(document.downloadreg.name.value==''){document.getElementById("name").style.borderColor="#FD0000";return false;}
	if(document.downloadreg.phone.value==''){document.getElementById("phone").style.borderColor="#FD0000";return false;}
	if(document.downloadreg.companyname.value==''){document.getElementById("companyname").style.borderColor="#FD0000";return false;}
	
	
	var email=document.downloadreg.email.value;
	var name=document.downloadreg.name.value;
	var phone=document.downloadreg.phone.value;
	var companyname=document.downloadreg.companyname.value;
	var id=document.downloadreg.id.value;
	
document.getElementById(div).innerHTML = "<div class='loadingdic'><img src='images/ajax-loader.gif' border='0' /> &nbsp;Please Wait ...</div>";
	var url="ajaxprocess.php?type="+type+"&id="+id+"&email="+email+"&name="+name+"&phone="+phone+"&companyname="+companyname+"&id="+id+"";
	postRequest(url,div);
}

function forgotpassword(type,id,div){
	if(document.forgotpass.email.value==''){document.getElementById("emailpass").style.borderColor="#FD0000";return false;}
	if(the_mail(document.forgotpass.email.value)){document.getElementById("emailpass").style.borderColor="#FD0000";return false;}
	var email=document.forgotpass.email.value;
document.getElementById(div).innerHTML = "<div class='loadingdic'><img src='images/ajax-loader.gif' border='0' /> &nbsp;Please Wait ...</div>";
	var url="ajaxprocess.php?type="+type+"&id="+id+"&email="+email+"";
	postRequest(url,div);
	
	}

function showdiv(own){
	document.getElementById(own).style.display='block';
}

function enquirycheck(type,id,div){
	
	if(document.downloadreg.email.value==''){document.getElementById("email").style.borderColor="#FD0000";return false;}
	if(the_mail(document.downloadreg.email.value)){document.getElementById("email").style.borderColor="#FD0000";return false;}
	if(document.downloadreg.name.value==''){document.getElementById("name").style.borderColor="#FD0000";return false;}
	if(document.downloadreg.phone.value==''){document.getElementById("phone").style.borderColor="#FD0000";return false;}
	if(document.downloadreg.companyname.value==''){document.getElementById("companyname").style.borderColor="#FD0000";return false;}
	if(document.downloadreg.message.value==''){document.getElementById("message").style.borderColor="#FD0000";return false;}
	
	var email=document.downloadreg.email.value;
	var name=document.downloadreg.name.value;
	var phone=document.downloadreg.phone.value;
	var message=document.downloadreg.message.value;
	var companyname=document.downloadreg.companyname.value;
	
document.getElementById(div).innerHTML = "<div class='loadingdic'><img src='images/ajax-loader.gif' border='0' /> &nbsp;Please Wait ...</div>";
	var url="ajaxprocess.php?type="+type+"&id="+id+"&email="+email+"&name="+name+"&phone="+phone+"&message="+message+"&companyname="+companyname+"";
	postRequest(url,div);
	
}

