﻿
var nullText = "-- Seçiniz --";
var nullTextCity = "-- Şehir Seçiniz --";
var nullTextCounty = "-- İlçe Seçiniz --";
function OnLostFocus(s, e) {
    if (s.GetValue() != "" && s.GetValue() != null)
        return;

    var input = s.GetInputElement();
    input.style.color = "gray";
    if (s.name == "ctl00_Iletisim1_CallBackPanelContact_cmbCitysIletisim") {
        input.value = nullTextCity;
    }
    else if (s.name == "ctl00_Iletisim1_CallBackPanelContact_cmbCountysIletisim") {
        input.value = nullTextCounty;
    }
//    else {
//        input.value = nullText;
//    }

}

function OnGotFocus(s, e) {
    var input = s.GetInputElement();
    if (s.name == "ctl00_Iletisim1_CallBackPanelContact_cmbCitysIletisim") {
        if (input.value == nullTextCity) {
            input.value = "";
            input.style.color = "black";
        }
    }
    else if (s.name == "ctl00_Iletisim1_CallBackPanelContact_cmbCountysIletisim") {
        if (input.value == nullTextCounty) {
            input.value = "";
            input.style.color = "black";
        }
    }
//    else {
//        if (input.value == nullText) {
//            input.value = "";
//            input.style.color = "black";
//        }
//    }

}

function OnInit(s, e) {
    OnLostFocus(s, e);
}


function Validation() {
    var msg = "";
    var filter = /^.+@.+\..{2,3}$/;

    //if (cmbCategories.GetValue() == null) {
    //    msg += "Kategori Seçmelisiniz !\n";
    //}
    //    if (txtAdsoyad.GetText() == "") {
    //        msg += "Ad Soyad Boş Geçilemez !\n";
    //    }
    //    if (txtTelefon.GetText() == "") {
    //        msg += "Telefon Boş Geçilemez !\n";
    //    }
    if (txtEmail.GetText() == "") {
        msg += "Email Boş Geçilemez !\n";
    }
    else {
        if (!filter.test(txtEmail.GetText())) {
            msg += "Email Formatı Uygun Değil !\n"
        }
    }
    if (txtMesaj.GetText() == "") {
        msg += "Mesaj Boş Geçilemez !\n";
    }
    if (msg != "") {
        alert(msg);
        return false;
    }
    else {
        return true;
    }
}
function ValidationForIletisim() {
    var msg = "";
    var filter = /^.+@.+\..{2,3}$/;

    //if (cmbCategories.GetValue() == null) {
    //    msg += "Kategori Seçmelisiniz !\n";
    //}
    if (txtAdsoyadIletisim.GetText() == "") {
        msg += "Ad Soyad Boş Geçilemez !\n";
    }
    if (txtTelefonIletisim.GetText() == "") {
        msg += "Telefon Boş Geçilemez !\n";
    }
    if (txtEmailIletisim.GetText() == "") {
        msg += "Email Boş Geçilemez !\n";
    }
    else {
        if (!filter.test(txtEmailIletisim.GetText())) {
            msg += "Email Formatı Uygun Değil !\n"
        }
    }
    if (txtMesajIletisim.GetText() == "") {
        msg += "Mesaj Boş Geçilemez !\n";
    }
    if (cmbCitysIletisim.GetValue() == null) {
        msg += "İl Seçmelisiniz!\n";
    }
    if (cmbCountysIletisim.GetValue() == null) {
        msg += "İlçe Seçmelisiniz!\n";
    }
    if (msg != "") {
        alert(msg);
        return false;
    }
    else {
        return true;
    }
}

function SendMessage() {
    if (ValidationForIletisim()) {
        //        var Params = "SEND" + "|" + txtAdsoyad.GetText() + "|" + txtTelefon.GetText() + "|" + txtEmail.GetText() + "|" + txtMesaj.GetText();
        CallBackPanelContact.PerformCallback("SEND|" + cmbCountys.GetValue());
    }
}
function GetCountys() {
    CallBackPanelContact.PerformCallback("GETCOUNTY|" + cmbCitys.GetValue());

}
function CallbackPanelEndCallback(s, e) {
    var a = CallBackPanelContact.cpSended
    if (a == true) {
        alert("Mesajınız Başarıyla İletildi...");
    }
}

////////////////////////////////////////////////////////////
///// FOR ADMIN
function DeleteSelectedFunction() {
    CallBackPanelContact.PerformCallback("DELETE");
}
function AddToArchive() {
    CallBackPanelContact.PerformCallback("ADDARCHIVE");
}
function Search() {
    CallBackPanelContact.PerformCallback("SEARCH");
}
function SendAnswer() {
    if (txtDetailAnswer.GetText() == "") {
        alert("Cevap Boş Geçilemez !");
        return;
    }
    gwContact.PerformCallback("SENDANSWER|" + txtDetailAnswer.GetText());
}
function Check() {
    try {
        if (txtDetailAnswer.GetText() != "") {
            document.getElementById("btnSend").disabled = true;
        }
        else {
            document.getElementById("btnSend").disabled = false;
        }
    } catch (e) {

    }

}
