$(document).ready(function()
{
	theForm=document.login_form;
	$("#login_form").submit(function()
	{
		if(theForm.adsoyad.value == "Name & Surname"  ) {
		 alert("Please write your name and your last name.");
		 theForm.adsoyad.focus();
		 return(false);
	}
	
	if(theForm.adsoyad.value == ""  ) {
		 alert("Please write your name and your last name.");
		 theForm.adsoyad.focus();
		 return(false);
	}
	
	if(theForm.eposta.value == "E-Mail Address"  ) {
		 alert("Please e-mail address.");
		 theForm.eposta.focus();
		 return(false);
	}
	
	if(theForm.eposta.value == ""  ) {
		 alert("Please e-mail address.");
		 theForm.eposta.focus();
		 return(false);
	}
	if(!eposta_kontrol(theForm.eposta.value)) {
		alert("Please enter a valid email!");
		theForm.eposta.focus();
		return(false);
	}
	
	function eposta_kontrol(str) {
	   return (str.indexOf(".") > 2) && (str.indexOf("@") > 0);
	}

		$.post("eliste.asp",{ adsoyad:$('#adsoyad').val(),eposta:$('#eposta').val(),rand:Math.random() } ,function(data)
        {
		  if(data=='yes') //login bilgisi doğru ise
		  {
			alert("Record is taken. Thanks");
			theForm.adsoyad.value = "Name & Surname";
			theForm.eposta.value = "E-Mail Address";
		  }
		  else if(data=='no') 
		  {
			alert("Already Registered.");
          }
        });
 		return false; //not to post the  form physically
	});
});

