function payform() {
	var email = document.forms.formpay.custom.value;
	var sessid = document.forms.formpay.sessid.value;
	if(email == "") {
		alert('Empty field "E-Mail". Download link will be send to this E-Mail address after Payment Complete!');
		return false;
	}
	
	if(!is_email(email)) {
		alert('Invalid field "E-Mail". Download link will be send to this E-Mail address after Payment Complete!!');
		return false;
	}
	
	ajaxCall(sessid, email);
	document.forms.formpay.submit();
}

function is_email(thismail) {
	var str = thismail;
	var filter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i;
	if (filter.test(str)) {
		return true;
	} else {
		return false;
	}
}

function ajaxCall(sessid, email) {
	var xmlHttp;
	try {
		// Firefox, Opera 8.0+, Safari
		xmlHttp=new XMLHttpRequest();
	}
	catch (e) {
		// Internet Explorer
		try {
			xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch (e) {
			try {
				xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
			} 
			catch (e) {
				alert("Your browser does not support AJAX!");
				return false;
			}
		}
	}
	
	xmlHttp.open("GET","index.php?action=new_order&sessid="+sessid+"&email="+email,false);
	//xmlHttp.open("GET","http://localhost/affiliate/yoga3/index.php?action=new_order",false);
	xmlHttp.send(null);
}