	function emailcheck(str) {
		var at="@"
		var dot="."
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr || str.indexOf(at,(lat+1))!=-1 || str.indexOf(" ")!=-1){
		   alert("Wrong e-mail!")
		   return false
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr || str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot || str.indexOf(dot,(lat+2))==-1){
		    alert("Wrong e-mail!")
		    return false
		}

		if (lstr<5) {
			alert("Wrong e-mail!");
			return false;
		}		
 		 return true					
	}
	
	function initRequest() {
     if (window.XMLHttpRequest) {
         return new XMLHttpRequest();
     } else if (window.ActiveXObject) {
         isIE = true;
         return new ActiveXObject("Microsoft.XMLHTTP");
     }
	}
	
	function submitForm() {
		var url = "newsletter.php";
		var req = initRequest();
		if(!emailcheck(document.contform_news.email.value)) return false;
		
		req.onreadystatechange = function() {
			if (req.readyState == 4)
				if (req.status == 200) {
					document.getElementById('contactformdiv_news').innerHTML=req.responseText;
				}
		};
    req.open("POST", url, true);
    req.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
		req.send("email="+document.contform_news.email.value);
	}
	function submitForm2() {
		var url = "news.php";
		var req = initRequest();
		if(!emailcheck(document.contform_com.email.value)) return false;
		
		
		req.onreadystatechange = function() {
			if (req.readyState == 4)
				if (req.status == 200) {
					document.getElementById('contactformdiv_com').innerHTML=req.responseText;
				}
		};
    req.open("POST", url, true);
    req.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
		req.send('lname='+document.contform_com.lname.value+'&fname='+document.contform_com.fname.value+'&email='+document.contform_com.email.value+'&address='+document.contform_com.address.value+'&city='+document.contform_com.city.value+'&pcode='+document.contform_com.pcode.value+'&phone='+document.contform_com.phone.value+'&comments='+document.contform_com.comments.value);
	}
	
	function submitForm3() {
		var url = "news.php";
		var req = initRequest();
		if(!emailcheck(document.contform_sub.email.value)) return false;
		
		
		req.onreadystatechange = function() {
			if (req.readyState == 4)
				if (req.status == 200) {
					document.getElementById('contactformdiv_sub').innerHTML=req.responseText;
				}
		};
    req.open("POST", url, true);
    req.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
		req.send('lname='+document.contform_sub.lname.value+'&fname='+document.contform_sub.fname.value+'&email='+document.contform_sub.email.value+'&address='+document.contform_sub.address.value+'&city='+document.contform_sub.city.value+'&pcode='+document.contform_sub.pcode.value+'&phone='+document.contform_sub.phone.value+'&comments='+document.contform_sub.comments.value);
	}
	
	function submitForm4() {
		var url = "unsubscribe.php";
		var req = initRequest();
		if(!emailcheck(document.unsubscribeform.email.value)) return false;
		
		
		req.onreadystatechange = function() {
			if (req.readyState == 4)
				if (req.status == 200) {
					document.getElementById('unsubscribeformdiv').innerHTML=req.responseText;
				}
		};
    req.open("POST", url, true);
    req.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
		req.send('email='+document.unsubscribeform.email.value);
	}


