﻿/// <reference path="js/jquery-1.2.6-vsdoc.js" />

$(document).ready(function() {
	
	    
    $("#cboxUlke").change(function(){
        if($(this).val()!=1){
            $("#cboxSehir1").val("83");
            $("#cboxSehir1").attr("disabled",true);
        } else {
            $("#cboxSehir1").val("0");
            $("#cboxSehir1").attr("disabled",false);
        }
    });
    
    /*
    $("#captcha").click(function() {
            $("#imgCap").attr('src','/images/progress.gif');
            $("#imgCap").attr('src','Captcha.aspx?id='+Math.random());
    });
    
    $("#errorClose").click(function() {
        $("#error").hide("slow");
    });
    */
    
	$("#error").hide();
	var tmpt;
    $("#rumuzKontrol").click(function() {
        if ($("#txtRumuz").val().length >= 3) {

            var kod = $("#txtRumuz").val();
            var uniKod;
            var turkKod = 'ğğüÜşŞıİöÖçÇ';
            for (var i = 0; i < kod.length; i++) {
                uniKod = kod.charCodeAt(i);
                if ((turkKod.indexOf(kod.charAt(i)) == -1) && ((uniKod < 48) || (uniKod > 57)) && ((uniKod < 65) || (uniKod > 90)) && ((uniKod < 97) || (uniKod > 122))) {  //(turkKod), (0-9), (a-z), (A-Z)
                    alert("Lütfen rumuzunuzda özel karakter ve boşluk kullanmayınız.");
                    return;
                }
            }
            $.ajax({
                type: 'GET',
                url: '/js/ajax.ashx',
                data: 'p=rumuzKontrol&rumuz=' + $("#txtRumuz").val(),
                success: function(veri) {
                    var sonuc = veri.split("|");
                    if (sonuc[0] == "YS")
                        $("#rumuzSonuc").css("color", "green");
                    else
                        $("#rumuzSonuc").css("color", "red");

                    $("#rumuzSonuc").html(sonuc[1]);
                }
            });
        } else {
            $("#rumuzSonuc").css("color", "red");
            $("#rumuzSonuc").html("en az 3 karakter olmalı!");
        }
    });
    
    $("#frmGiris").submit(function() 
    {
    
        var error="<ul><h4 style='margin:1px; padding:1px; color:#FF0000'>Uyarı!</h4>";
        var stop = false;
        
        if($("#txtGirisEposta").val()=="")
        {
            error+="<li>Lütfen <b>eposta</b> giriniz.</li>";
            stop=true;
        }
        
        if($("#txtGirisEposta").val()!="")
        {
            if(!isValidEmailAddress($("#txtGirisEposta").val()))
            {
                error+="<li>Lütfen <b>doğru eposta</b> giriniz.</li>";
                stop=true;
            }
        }
        
        if($("#txtGirisSifre").val()=="")
        {
            error+="<li>Lütfen <b>şifre</b> giriniz.</li>";
            stop=true;
        }
        
        if(stop)
        {   
            error+="</ul>";
			
			tmpt="<table width='100%' border='0' cellpadding='3' cellspacing='3'><tr><td width='9%'><img src='images/uyari.jpg' width='119' height='106' alt='Dikkat' /></td><td width='91%' style='vertical-align:top;'>"+error+"<div onclick='$.modal.close();' style='text-align:center; font-weight:bold; cursor:pointer;'>Kapat</div></td></tr></table>";

			$("#error").html(tmpt);            
			$('#error').modal(); 
            return false;
        }       
        
    });
    
$("#frmKayit").submit(function(){
        
    var error="<ul><h4 style='margin:1px; padding:1px; color:#FF0000'>Uyarı!</h4>";
    var stop = false;
    
    if($("#txtRumuz").val()=="")
    {
        error+="<li>Lütfen <b>rumuz</b> giriniz.</li>";
        stop=true;
    }
    
    if($("#txtEposta").val()=="")
    {
        error+="<li>Lütfen <b>eposta</b> giriniz.</li>";
        stop=true;
    }
    
    if($("#txtEposta").val()!="")
    {
        if(!isValidEmailAddress($("#txtEposta").val()))
        {
            error+="<li>Lütfen <b>doğru eposta</b> giriniz.</li>";
            stop=true;
        }
    }
    
    if($("#txtSifre1").val()=="")
    {
        error+="<li>Lütfen <b>şifre</b> giriniz.</li>";
        stop=true;
    }
    
    if($("#txtSifre2").val()=="")
    {
        error+="<li>Lütfen <b>şifre tekrarı</b> giriniz.</li>";
        stop=true;
    }
    
    if($("#txtSifre1").val()!=$("#txtSifre2").val())
    {
        error+="<li>Lütfen <b>şifre ve şifre tekrarı</b> aynı giriniz.</li>";
        stop=true;
    }
    
    if((!$("#rboxCinsiyet1").attr("checked")) && (!$("#rboxCinsiyet2").attr("checked")))
    {
        error+="<li>Lütfen <b>cinsiyet</b> seçiniz.</li>";
        stop=true;
    }
    
    if($("#cboxGun").val()=="0")
    {
        error+="<li>Lütfen <b>doğum gününüzü</b> seçiniz.</li>";
        stop=true;        
    }
    
    if($("#cboxAy").val()=="0")
    {
        error+="<li>Lütfen <b>doğum ayınızı</b> seçiniz.</li>";
        stop=true;        
    }
    
    if($("#cboxYil").val()=="0")
    {
        error+="<li>Lütfen <b>doğum yılınızı</b> seçiniz.</li>";
        stop=true;        
    }
    
    if($("#cboxUlke").val()=="0")
    {
        error+="<li>Lütfen <b>ülkenizi</b> seçiniz.</li>";
        stop=true;        
    }
    
    if($("#cboxSehir1").val()=="0")
    {
        error+="<li>Lütfen <b>şehir</b> seçiniz.</li>";
        stop=true;        
    }
    
    /*
    if($("#captchaCode").val()=="")
    {
        error+="<li>Lütfen <b>güvenlik kodunu</b> giriniz.</li>";
        stop=true;        
    }
    */
    
    if(!($("#cboxSozlesme").attr("checked")))
    {
        error+="<li>Lütfen <b>sözleşmeyi okudumu</b> işaretleyiniz.</li>";
        stop=true;        
    }        
      
    if(stop)
    {   
        error+="</ul>";
        tmpt="<table width='100%' border='0' cellpadding='3' cellspacing='3'><tr><td width='9%'><img src='images/uyari.jpg' width='119' height='106' alt='Dikkat' /></td><td width='91%' style='vertical-align:top;'>"+error+"<div onclick='$.modal.close();' style='text-align:center; font-weight:bold; cursor:pointer;'>Kapat</div></td></tr></table>";
        $("#error").html(tmpt);
        $("#error").modal();
        //$("#imgCap").attr('src','/images/progress.gif');
        //$("#imgCap").attr('src','Captcha.aspx?id='+Math.random());
        return false;
    }  
    
}); // end submit

});


function favori_ekle(obj,id){
    $.ajax({
        type: 'GET',
        url: '/js/pal.ashx',
        data: 'p=favori_ekle&Id=' + id,
        error: function(){
            alert("Teknik bir hata oluştu işlem yapılamıyor.");
        },
        success: function(veri) {
if (veri == "SESSION") {
                window.location.href = 'http://www.partneralem.com/Giris.aspx';
            } else {
            $("#"+obj).attr("onclick","");
            $("#"+obj).css("cursor","none");
            //$("#"+obj).html(veri);
			alert(veri);
        }
}
    });    
}

function gozkirp(obj,id){
    $.ajax({
        type: 'GET',
        url: '/js/pal.ashx',
        data: 'p=gozkirp&Id=' + id,
        error: function(){
            alert("Teknik bir hata oluştu işlem yapılamıyor.");
        },
        success: function(veri) {
if (veri == "SESSION") {
                window.location.href = 'http://www.partneralem.com/Giris.aspx';
            } else {
            $("#"+obj).attr("onclick","");
            $("#"+obj).css("cursor","none");
            //$("#"+obj).html(veri);
			alert(veri);
        }
}
    });    
}

function durum(id)
{
    var obj = $("#div_durum_status");
    
    obj.show();
    
     obj.ajaxStart(function(){
       $(this).html("<img src='/images/loader.gif' style='vertical-align:middle;' />&nbsp;Durum değişiyor.");
     });

     obj.ajaxComplete(function(event,request, settings){
       $(this).html("Durum değişti.");
     });

    $.ajax({
        type: 'GET',
        url: '/js/pal.ashx',
        data: 'p=uye_durum&Id=' + id,
        error: function(){
            alert("Teknik bir hata oluştu işlem yapılamıyor.");
        },
        success: function(veri)
        {
if (veri == "SESSION") {
                window.location.href = 'http://www.partneralem.com/Giris.aspx';
            } else {
            obj.hide(1000);
            //alert(veri);
}
        }
    });    
}

function isValidEmailAddress(emailAddress) 
{
    var pattern = new RegExp(/^(("[\w-\s]+")|([\w-]+(?:\.[\w-]+)*)|("[\w-\s]+")([\w-]+(?:\.[\w-]+)*))(@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$)|(@\[?((25[0-5]\.|2[0-4][0-9]\.|1[0-9]{2}\.|[0-9]{1,2}\.))((25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\.){2}(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\]?$)/i);
    return pattern.test(emailAddress);
}

function popupAc(url,yatay,dikey)
{
    var ust,sol
    sol= (screen.width - yatay) / 2
    ust= (screen.height - dikey) / 2
    eval('window.open(url,"","width='+yatay+'px,height='+dikey+'px,resizable=0,scrollbars=1,top='+ust+',left='+sol+'")')
}

var spe = 500;
var na = document.all.tags("blink");
var swi = 1;
bringBackBlinky();
function bringBackBlinky() {
    if (swi == 1) {
        sho = "visible";
        swi = 0;
    }
    else {
        sho = "hidden";
        swi = 1;
    }
    for (i = 0; i < na.length; i++) {
        na[i].style.visibility = sho;
    }
    setTimeout("bringBackBlinky()", spe);
}
function textCounter(field,cntfield,maxlimit) {
if (field.value.length > maxlimit) // if too long...trim it!
field.value = field.value.substring(0, maxlimit);
// otherwise, update 'characters left' counter
else
cntfield.value = maxlimit - field.value.length;
}
