function postForm(PForm,url)
{
if (formValidation(PForm)){return false;}
if(PForm=='RegisterForm'){var form1 = document.RegisterForm;}
if(PForm=='LoginForm'){var form1 = document.LoginForm;}
	var postRequest = new String("");
	var n,v;

for(var i=0;i<form1.elements.length;i++)
	{
		n = form1.elements[i].name;
		v = form1.elements[i].value;
		postRequest += escape(n) + '=' + escape(v) + '&';
	}


 document.getElementById("membershipStatusDIV").innerHTML="Lütfen bekleyin."
var xmlhttp = new_xmlhttp();
	xmlhttp.open("POST",url,true);
	xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded;charset=iso-8859-9");
	xmlhttp.send(postRequest);
	xmlhttp.onreadystatechange = function() 
	{
		if (xmlhttp.readyState == 4 && xmlhttp.status == 200) 
		{ 	
			if(xmlhttp.responseText == "0"){
				document.getElementById("membershipStatusDIV").innerHTML="Yanl&#305;&#351; giden bir&#351;eyler var.";
				if(PForm=='RegisterForm'){
					opacity('RegisterFormErrorDIV', 0, 100, 500);
				}
				if(PForm=='LoginForm'){
					document.getElementById("membershipStatusDIV").innerHTML="e-mail adresiniz veya &#351;ifreniz yanl&#305;&#351; olabilir mi?";
					}
				
			}else{
				
				if(PForm=='RegisterForm'){
					document.getElementById("membershipStatusDIV").innerHTML="Pörfekto!";
					opacity('RegisterFormDIV', 100, 0, 100);
					opacity('RegisterFormOKDIV', 0, 100, 500);
				}
				if(PForm=='LoginForm'){
					document.getElementById("membershipStatusDIV").innerHTML="Pörfekto!";
					opacity('LoginFormDIV', 100, 0, 100);
					opacity('LoginFormOKDIV', 0, 100, 100);
					setTimeout("opacity('LoginFormOKDIV', 100, 0, 2000)",1000);
					}
				document.getElementById("MembershipButtonsDIV").innerHTML='&nbsp;&nbsp;&nbsp;<a href="LogOut.asp" class="register" >&Ccedil;&#305;k&#305;&#351;</a>&nbsp;&nbsp;&nbsp;'+" Ho&#351;geldin "+xmlhttp.responseText+"!";
				
				}
		}
		else
		{
			document.getElementById("membershipStatusDIV").innerHTML="Ba&#287;lant&#305; hatas&#305;."
			}
	}
return false;
}

function new_xmlhttp()
{
	var xmlhttp;
if (window.XMLHttpRequest)
  {xmlhttp=new XMLHttpRequest()}

else if (window.ActiveXObject)
  {xmlhttp=new ActiveXObject("Microsoft.XMLHTTP")}

	return xmlhttp;
}



function formValidation(formID){
var FormValidationError=0;
if(formID=='LoginForm'){
document.LoginForm.email.style.border="1px solid black";
document.LoginForm.Password.style.border="1px solid black";

	if (document.LoginForm.email.value == ""){
		document.LoginForm.email.style.border="1px solid red";
		FormValidationError=1;
		}

	if (document.LoginForm.Password.value == ""){
		document.LoginForm.Password.style.border="1px solid red";
		FormValidationError=1;
		}
}
if(formID=='RegisterForm'){
	document.RegisterForm.CustomerName.style.border="1px solid black";
	document.RegisterForm.Password2.style.border="1px solid black";
	document.RegisterForm.email.style.border="1px solid black";
	document.RegisterForm.Password.style.border="1px solid black";
	
	if (document.RegisterForm.email.value == ""){
		document.RegisterForm.email.style.border="1px solid red";
		FormValidationError=1;
		}

	if (document.RegisterForm.Password.value == ""){
		document.RegisterForm.Password.style.border="1px solid red";
		FormValidationError=1;
		}
	
	if (document.RegisterForm.CustomerName.value == ""){
		document.RegisterForm.CustomerName.style.border="1px solid red";
		FormValidationError=1;
		}
	if (document.RegisterForm.Password2.value == ""){
		document.RegisterForm.Password2.style.border="1px solid red";
		FormValidationError=1;
		}

	if (document.RegisterForm.Password2.value != document.RegisterForm.Password.value){
		document.RegisterForm.Password.style.border="1px solid red";
		document.RegisterForm.Password2.style.border="1px solid red";
		FormValidationError=1;
		}

}
if (FormValidationError==1){
	return true;
	}
}

function isEnter(whichForm,whichURL){
var keycode = event.keyCode;
  if(keycode == 13){
		postForm(whichForm,whichURL);
  }
 }