$(function(){
var kullanici=0;
var mail=0;
var sifred=0;
var tsifre=0;
var anlasma=0;
$.fn.isEmail=function() {
		var email=/^[A-Za-z0-9]+([_\.-][A-Za-z0-9]+)*@[A-Za-z0-9]+([_\.-][A-Za-z0-9]+)*\.([A-Za-z]){2,4}$/i;
		return email.test($(this).val());
	}
$('#sec').click(function(){
if($('#sec').attr('checked')){
anlasma=1;
}else{
anlasma=0;
}
if((kullanici==1)&(mail==1)&(sifred==1)&(tsifre==1)&(anlasma==1)){
$("#kayit").attr("disabled","");
}
else{
$("#kayit").attr("disabled","disabled");
}
})

$("#regkullanici").blur(function(){

var kadi=$("#regkullanici").val();
var islem='kadi';
if(kadi.length<6){
$("#kullanici").html('<img src="tema/images/cancel.png" width="12" height="12" />')
}else{
$.post("sayfalar/kutular/islemler.php",{kadi:kadi,islem:islem},
function(response){
if (response=='true'){
$("#kullanici").html('<img src="tema/images/ok.png" width="12" height="12" />');
kullanici=1;
}
else{
$("#kullanici").html('<img src="tema/images/cancel.png" width="12" height="12" />')
kullanici=0;
}
})
}	
if((kullanici==1)&(mail==1)&(sifred==1)&(tsifre==1)&(anlasma==1)){
$("#kayit").attr("disabled","");
}
else{
$("#kayit").attr("disabled","disabled");
}
});
$("#regmail").blur(function(){
if(! $("#regmail").isEmail()){
	$("#dmail").html('<img src="tema/images/cancel.png" width="12" height="12" />');
	mail=0;
}else{
$("#dmail").html('<img src="tema/images/ok.png" width="12" height="12" />');
mail=1;
}
if((kullanici==1)&(mail==1)&(sifred==1)&(tsifre==1)&(anlasma==1)){
$("#kayit").attr("disabled","");
}
else{
$("#kayit").attr("disabled","disabled");
}

});

$("#regsifre").blur(function(){
var sifre=$("#regsifre").val();
if(sifre.length<4){
$("#sfre").html('<img src="tema/images/cancel.png" width="12" height="12" />');
sifred=0;
}else{
$("#sfre").html('<img src="tema/images/ok.png" width="12" height="12" />');
sifred=1;
}
if((kullanici==1)&(mail==1)&(sifred==1)&(tsifre==1)&(anlasma==1)){
$("#kayit").attr("disabled","");
}
else{
$("#kayit").attr("disabled","disabled");
}

});
$("#regstekrar").blur(function(){
if($("#regsifre").val()!=$("#regstekrar").val()){
$("#dtsfre").html('<img src="tema/images/cancel.png" width="12" height="12" />');
tsifre=0;
}else{
if($("#tsifre").val()==''){
$("#dtsfre").html('<img src="tema/images/cancel.png" width="12" height="12" />');
tsifre=0;
}else{
$("#dtsfre").html('<img src="tema/images/ok.png" width="12" height="12" />');
tsifre=1;
}
}
if((kullanici==1)&(mail==1)&(sifred==1)&(tsifre==1)&(anlasma==1)){
$("#kayit").attr("disabled","");
}
else{
$("#kayit").attr("disabled","disabled");
}
});
if((kullanici==1)&(mail==1)&(sifred==1)&(tsifre==1)&(anlasma==1)){
$("#kayit").attr("disabled","");
}
else{
$("#kayit").attr("disabled","disabled");
}

$("#kayit").click(function(){
var regkullanic=$("#regkullanici").val();
var regmai=$("#regmail").val();
var regsifr=$("#regsifre").val();
var adsoya=$("#adsoyad").val();
var regdtari=$("#regdtarih").val();
var regstekra=$("#regstekrar").val();
var sec='';
if(anlasma==1){
sec='true';

}else{
sec='false';
}
$.post("kutuphane/kayitisi.php",{regkullanic:regkullanic,regmai:regmai,regsifr:regsifr,adsoya:adsoya,regdtari:regdtari,sec:sec,regstekra:regstekra},function(response){
})
						   })
});
function giris(showhide){
    if(showhide == "show"){
        document.getElementById('popupbox').style.visibility="visible"; /* If the function is called with the variable 'show', show the login box */
		setTimeout("document.getElementById('pop').innerHTML = 'Kay&#305;t Oldugunuz &#304;&ccedil;in Te&#351;ekk&uuml;r Ederiz Y&ouml;nlendiriliyorsunuz!.. L&uuml;tfen Bekleyin 4'", 1000);
		setTimeout("document.getElementById('pop').innerHTML = 'Kay&#305;t Oldugunuz &#304;&ccedil;in Te&#351;ekk&uuml;r Ederiz Y&ouml;nlendiriliyorsunuz!.. L&uuml;tfen Bekleyin 3'", 2000);
		setTimeout("document.getElementById('pop').innerHTML = 'Kay&#305;t Oldugunuz &#304;&ccedil;in Te&#351;ekk&uuml;r Ederiz Y&ouml;nlendiriliyorsunuz!.. L&uuml;tfen Bekleyin 2'", 3000);
		setTimeout("document.getElementById('pop').innerHTML = 'Kay&#305;t Oldugunuz &#304;&ccedil;in Te&#351;ekk&uuml;r Ederiz Y&ouml;nlendiriliyorsunuz!.. L&uuml;tfen Bekleyin 1'", 4000);
		setTimeout("location = 'index.php'", 5000);
		}else if(showhide == "hide"){
        document.getElementById('popupbox').style.visibility="hidden"; /* If the function is called with the variable 'hide', hide the login box */
    }
	
return false;
  }