﻿function RegisterNewsletter(_emailid) {
    $(".iletisim_left_box_content .result").html("");
    try {
        var email = $("#" + _emailid).val();
        var errormessage = $("#" + _emailid).attr("ErrorMessage");
        if (!validateEmail(email)) {
            $(".iletisim_left_box_content .result").html(errormessage);
        }
        else {
            $.ajax({
                type: "POST",
                url: "/Content/WebService/ClientSiteWebService.asmx/RegisterNewsletter",
                data: "{Email:'" + email + "'}",
                contentType: "application/json; charset=utf-8",
                dataType: "json",
                success: function (msg) {
                    $(".iletisim_left_box_content .result").html(msg.d);
                },
                error: function (msg) {
                    return false;
                }
            });
        }

    } catch (e) {

    }
    return false;
}

function CallMe(_Name, _Email, _Phone, _Seviye, _Ebulten, _Accept, _Source) {

    if ($("#" + _Name).val() == "Adı ve Soyadı" || $("#" + _Name).val() == "Arkadaşınızın Adı ve Soyadı" || $("#" + _Name).val() == "" || $("#" + _Name).val().length < 2) {
        $(".uyari").text("Lütfen ad alanını doldurunuz !");
        return false;
    }
    if (!$("#" + _Accept).is(":checked")) {
        $(".uyari").text("Lütfen sözleşmeyi onaylayınız");
        return false;
    }
    //    if ($("#" + _Phone).val() == "Telefonu" || $("#" + _Phone).val() == "") {
    //        $(".uyari").text("Lütfen telefon numaranızı giriniz !");
    //        return false;
    //    }
    if ($("#" + _Email).val() == "E-Posta" || $("#" + _Email).val() == "Arkadaşınızın E-Postası") {
        $("#" + _Email).val("-");
    }

    $(".uyari").text("Bilgileriniz gönderiliyor...");

    $.ajax({
        type: "POST",
        url: "/Content/WebService/ClientSiteWebService.asmx/CallMe",
        data: "{Name:'" + $("#" + _Name).val() + "',Email:'" + $("#" + _Email).val() + "',Phone:'" + $("#" + _Phone).val() + "',Seviye:'" + $("#" + _Seviye).is(":checked") + "',Ebulten:'true',Source:'" + _Source + "'}",
        contentType: "application/json; charset=utf-8",
        dataType: "json",
        success: function (msg) {
            $(".uyari").text(msg.d);
            if ($('.ben_container').css('display') == 'none') {
                $("#" + _Email).val("Arkadaşınızın E-Postası");
                $("#" + _Phone).val("Arkadaşınızın Telefonu");
                $("#" + _Name).val("Arkadaşınızın Adı ve Soyadı");
            }
            else {
                $("#" + _Email).val("E-Posta");
                $("#" + _Phone).val("Telefonu");
                $("#" + _Name).val("Adı ve Soyadı");
            }
        },
        error: function (msg) {
            return false;
        }
    });


    return false;
}

function CallMeAdword(_Name, _Email, _Phone, _Seviye, _Ebulten, _Accept, _Source) {

    if ($("#" + _Name).val() == "Adı ve Soyadı" || $("#" + _Name).val() == "" || $("#" + _Name).val().length < 2) {
        $(".uyari").text("Lütfen adınızı giriniz !");
        return false;
    }
    if (!$("#" + _Accept).is(":checked")) {
        $(".uyari").text("Lütfen sözleşmeyi onaylayınız");
        return false;
    }
    //    if ($("#" + _Phone).val() == "Telefonu" || $("#" + _Phone).val() == "") {
    //        $(".uyari").text("Lütfen telefon numaranızı giriniz !");
    //        return false;
    //    }
    if ($("#" + _Email).val() == "E-Posta") {
        $("#" + _Email).val("-");
    }
    if ($("#" + _Email).val() == "E-Posta") {
        $("#" + _Email).val("-");
    }

    $(".uyari").text("Bilgileriniz gönderiliyor...");

    $.ajax({
        type: "POST",
        url: "/Content/WebService/ClientSiteWebService.asmx/CallMe",
        data: "{Name:'" + $("#" + _Name).val() + "',Email:'" + $("#" + _Email).val() + "',Phone:'" + $("#" + _Phone).val() + "',Seviye:'" + $("#" + _Seviye).is(":checked") + "',Ebulten:'true',Source:'" + _Source + "'}",
        contentType: "application/json; charset=utf-8",
        dataType: "json",
        success: function (msg) {
            if (msg.d == "Bilgileriniz bize ulaştı")
                document.location = "/Page/Landing/Confirm.aspx";
        },
        error: function (msg) {
            return false;
        }
    });


    return false;
}


function Landing(_Name, _Email, _Phone, _Seviye) {
    $(".result").text("Bilgileriniz gönderiliyor...");
    $(".btn").remove();

    $.ajax({
        type: "POST",
        url: "/Content/WebService/ClientSiteWebService.asmx/Landing",
        data: "{Name:'" + $("#" + _Name).val() + "',Email:'" + $("#" + _Email).val() + "',Phone:'" + $("#" + _Phone).val() + "'}",
        contentType: "application/json; charset=utf-8",
        dataType: "json",
        success: function (msg) {
            document.location = 'Confirm.aspx';
        },
        error: function (msg) {
            $(".result").text(msg.d);
        }
    });


    return false;
}

$('input.sayi').keydown(function (e) {
    var keyCode = e.keyCode;
    if ((keyCode >= 96 && keyCode < 106) || (keyCode >= 48 && keyCode < 58) || (keyCode == 8) || (keyCode == 9)) {
    }
    else return false;
});


$(function () {

    $('.mag_thumb_back a').lightBox({ fixedNavigation: true });
    $('.inside a').lightBox({ fixedNavigation: false });
    $('.thumb_back a').lightBox({ fixedNavigation: true });
    $('.tescil a').lightBox({ fixedNavigation: true });
    $('.uclu_thumb_liste_container a').lightBox({ fixedNavigation: true });
    $('.kose_dar a').lightBox({ fixedNavigation: true });
    /*$('.item a').lightBox({ fixedNavigation: true });*/
    $('.icerik_dar2 a').lightBox({ fixedNavigation: true });

})


function markaTescil() {
    $('.tescil a').lightBox({ fixedNavigation: true });
    $('.tescil a').click();
}


function showOverlay() {
    $('.overlay_sozlesme').fadeIn(1000);
}
function hideOverlay() {
    $('.overlay_sozlesme').fadeOut(1000);
}

function showBeniAra() {
    $('.beni_ara').css('background-image', 'url(/Content/Images/beni_ara_back3_1.png)');
    $('.ben_container').show();
    $('.arkadas_container').hide();
}

function showArkadasimiAra() {
    $('.beni_ara').css('background-image', 'url(/Content/Images/beni_ara_back3_2.png)');
    $('.arkadas_container').show();
    $('.ben_container').hide();
}

$(document).ready(function () {

    $('#cont').hoverAccordion({ onClickOnly: false, keepHeight: true });
    $('#cont2').hoverAccordion({ onClickOnly: false, keepHeight: true });
});

function radio(str) {

    $("#audio").attr("src", "/Content/Mp3/Player.aspx?file=" + str);
};

$(document).ready(function () {

    $('#cont').hoverAccordion({ onClickOnly: false, keepHeight: true });
    $('#cont2').hoverAccordion({ onClickOnly: false, keepHeight: true });
});




function SaveComment(_message, RUri) {
    $(".overlay_loading").show();
    try {
        $.ajax({
            type: "POST",
            url: (document.location.href.indexOf("clockwork.com.tr") > -1 ? "/facebook/besgundeingilizce/" : "") + "/Content/WebService/ClientSiteWebService.asmx/SaveComment",
            data: "{ Message:'" + $('#' + _message).val() + "'}",
            contentType: "application/json; charset=utf-8",
            dataType: "json",
            success: function (msg) {
                if (msg.d > 0)
                    window.location.href = RUri + "&CID=" + msg.d;
            },
            error: function () {
            }
        });

    } catch (e) {
    }
}

function showTavsiye() {
    $('.overlay_tavsiye').fadeIn(1000);
}
function hideTavsiye() {
    $('.overlay_tavsiye').fadeOut(1000);
}
