function E(x) {
    return document.getElementById(x);
}
function Git(url) {
    return document.location.href = url;
}
function CAdd(id) {
    Git("/ekle/?sepet&uid=" + id + "&rf=as&ec=1");
}
function Geri() {
    history.back();
}

function GizleGoster(nesne) {
    if (E(nesne).style.display == 'block') E(nesne).style.display = 'none';
    else E(nesne).style.display = 'block';
}

var _buttonClickSleep;
function ButtonClickSleep(btn) {
    _buttonClickSleep = btn;
    setTimeout("ButtonClickSleepTimeOut()", 10);
}
function ButtonClickSleepTimeOut() {
    _buttonClickSleep.disabled = true;
}

function IslemSor(btn) {
    var _result = confirm('Bu islemi yapmak istedigine emin misin?');
    if (_result) ButtonClickSleep(btn);
    return _result;
}
function IslemSor() {
    return confirm('Bu islemi yapmak istediginize emin misiniz?');
}

function VisibleTF_Kargo(x) {
    var dbxKargoFirmaTex = "- Varsayilan Firmayi Kullan -";
    if (E('ctl00_Cph1_cbxUcretsizKargo').checked) {
        E('ctl00_Cph1_dbxKargoFirma').disabled = true;
        E('ctl00_Cph1_dbxKargoFirma').options[0].text = "Kargo Ucretsiz";
        E('ctl00_Cph1_dbxKargoFirma').selectedIndex = 0;
    }
    else {
        E('ctl00_Cph1_dbxKargoFirma').disabled = false;
        E('ctl00_Cph1_dbxKargoFirma').options[0].text = dbxKargoFirmaTex;        
    }
}
function SecilileriSil() {
    var ml = document.aspnetForm, sayi = 0, _return = false;
    for (var i = 0; i < ml.elements.length; i++) {
        var e = ml.elements[i];
        if ((e.name.indexOf("cbxItemSelect") != -1) && (e.type == 'checkbox') && (e.checked)) {
            sayi++;
        }
    }
    if (sayi == 0) {
        alert("Lutfen once secim yap.");
        _return = false;
    }
    else {
        _return = confirm("Bu islemi yapmak istediginden emin misiniz?");
    }
    return _return;
}

function EvetHayir() { return confirm("Bu islemi yapmak istediginden emin misiniz?"); }

function CbxTumunuSec() {
    var ml = document.aspnetForm;
    for (var i = 0; i < ml.elements.length; i++) {
        var e = ml.elements[i];
        if ((e.name.indexOf("cbxItemSelect") != -1) && (e.type == 'checkbox')) {
            e.checked = document.forms[0].cbxTumunuSec.checked;
        }
    }
}
function FnkFiyat(e) {
    var f = ".";

    if (f == "") {
        e = e + "";
    }
    else {
        if (f == " ") {
            e = e.replace(/ /g, "") + "";
        } else {
            if (f == ".") {
                e = e.replace(/\./g, "") + "";
            } else {
                if (f == ",") {
                    e = e.replace(/,/g, "") + "";
                }
            }
        }
    }
    var c = "";
    if (e.length > 3) {
        while (e.length > 3) {
            c = f + e.substr(e.length - 3) + c;
            e = e.substr(0, e.length - 3)
        } c = e + c
    } else { c = e } if (!c || c == "NaN")
    { c = ""; }
    return c;
}
function FnkFiyat2(e) {
    var f = ",";

    if (f == "") {
        e = e + "";
    }
    else {
        if (f == " ") {
            e = e.replace(/ /g, "") + "";
        } else {
            if (f == ".") {
                e = e.replace(/\./g, "") + "";
            } else {
                if (f == ",") {
                    e = e.replace(/,/g, "") + "";
                }
            }
        }
    }
    var c = "";
    if (e.length > 3) {
        while (e.length > 3) {
            c = f + e.substr(e.length - 3) + c;
            e = e.substr(0, e.length - 3)
        } c = e + c
    } else { c = e } if (!c || c == "NaN")
    { c = ""; }
    return c;
}
function FnkUcretBirimi() {
    e = E('ctl00_Cph1_dbxUcretBirimi').options[E('ctl00_Cph1_dbxUcretBirimi').selectedIndex].text;
    var _ub = e.substring(e.indexOf('(') + 1, e.length - 1);
    E('sp_UrunMaliyetFiyat').innerHTML = _ub;
    E('sp_UrunBayiFiyat').innerHTML = _ub;
    E('sp_UrunSkFiyat').innerHTML = _ub;
}
function FnkFiyatSuz(e) {
    var geriDon = e;
    if (e.indexOf(".") != 1)
        geriDon = e.replace(".", "");
    if (geriDon.indexOf(",,") != 1)
        geriDon = geriDon.replace(",,", ",");
    return geriDon;
}
function RegKontrol(pattern, value) {
    r = new RegExp(pattern, "g");
    return r.test(value);
} 

function EpostaKontrol(eposta) {
    patternEposta = "^" + "([abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0-9_\.\-]+)" + "@" + "([abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0-9_\.\-]+)" + "[\.]" + "([abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0-9_\.\-]+)" + "$";
    if (!RegKontrol(patternEposta, eposta)) {
        return false;
    }
    return true;
}

var _tbxTavEposta = "";
function TavEpostaEkle() {
    var eposta = E('tbxTavEposta').value;
    if (!EpostaKontrol(eposta)) {
        alert("Lutfen gecerli bir e-posta adresi girin.");
        E('tbxTavEposta').select();
        return false;
    }
    else {
        if (_tbxTavEposta.indexOf(eposta) != -1) {
            E('tbxTavEposta').select();
            alert("Bu e-posta daha once girilmis.");
            return false;
        }
        _tbxTavEposta += eposta + ",";
        E('div_tavEposta').innerHTML += eposta + "&nbsp;&nbsp;&nbsp;<a class=\"l_tumResimler\" href=\"javascript:;\" onclick=\"TavEpostaEkleSil('" + eposta + "');\">sil</a><br />";
        E('tbxTavEposta').value = "";
        E('tbxTavEposta').focus();
    }    
}

function TavEpostaEkleSil(eposta) {
    _tbxTavEposta = _tbxTavEposta.replace(eposta + ",", "");
    TavEpostaEkle2();
}

function TavEpostaEkle2() {
    E('div_tavEposta').innerHTML = "";
    var arry_TavEposta = _tbxTavEposta.split(',');
    for (var i = 0; i < arry_TavEposta.length - 1; i++) {
        E('div_tavEposta').innerHTML += arry_TavEposta[i] + "&nbsp;&nbsp;&nbsp;<a class=\"l_tumResimler\" href=\"javascript:;\" onclick=\"TavEpostaEkleSil('" + arry_TavEposta[i] + "');\">sil</a><br />";
    }
}
function TavButtonClick() {
    E('tbxTavEpostalarID').value = _tbxTavEposta;
}

function PencereAc(pencere, p_width, p_top) {
    var e_width = screen.width;
    var p_left = (e_width - p_width) / 2;
    E(pencere).style.left = p_left + "px";
    E(pencere).style.width = p_width + "px";
    E(pencere).style.top = p_top + "px";
    E(pencere).style.display = "block";
    E(pencere).style.filter = "";
    E(pencere).style.opacity = "";
    anim_ = 90;
}

var p_kapat = true;
function PencereKapat(div_id) {
    if (p_kapat) {
        p_kapat = false;
        pencereInterval_ = setInterval('PencereAnim_("' + div_id + '")', 40);
    }
}

var anim_ = 90;
function PencereAnim_(div_id) {
    anim_ = anim_ - 10;
    if (anim_ <= 0) {
        clearInterval(pencereInterval_);
        E(div_id).style.display = "none";
        p_kapat = true;
    }
    E(div_id).style.filter = "alpha(opacity=" + anim_ + ")";
    E(div_id).style.opacity = "." + (anim_ / 10);
}

var button_kapat = true;
var _btnAnim = 0;
function ButtonClass(_id) {
    if (button_kapat) {
        button_kapat = false;
        _btnAnim = 0;
        button_interval = setInterval('ButtonAnim("' + _id + '")', 60);
    }
}

function ButtonAnim(_id) {
    _btnAnim++;
    var _class = null;
    if (_btnAnim % 2 == 0) { _class = "button_b2"; }
    else { _class = "button_b"; }
    if (_btnAnim > 5) {
        clearInterval(button_interval);
        button_kapat = true;
    }
    E(_id).className = _class;
}
