﻿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 VendorSearch(cid) {
    var cityid = 0;
//    if (parseInt($("#" + cid).val()) < 10) {
//        cityid = "0" + parseInt($("#" + cid).val());
//        alert(cityid);
//    }
    //else cityid = parseInt($("#" + cid).val());
    cityid = parseInt($("#" + cid).val());

    if (cityid > 0) { document.location.href = "/Page/Seller/?CID=" + cityid; return false; }

    else return;
}

function ServiceSearch(cid) {
    var cityid = 0;
    if (parseInt($("#" + cid).val()) < 10)
        cityid = parseInt("0" + $("#" + cid).val());
    else cityid = parseInt($("#" + cid).val());

    if (cityid > 0) { document.location.href = "/Page/Service/?CID=" + cityid; return false; }

    else return;
}


//function SendContactForm() {

//    $("#result").text("Mesajınız gönderiliyor...");
//    FormPost("/Content/WebService/ClientSiteWebService.asmx/SendContactMails", ".icerik_container", "#result")
//}

function SendContactForm(Name, Email, Message, SecureCode) {
    try {
        $(".result").text("Gönderiliyor...");
        $('.button_sol, .button_orta, .button_sag').remove();
        $.ajax({
            type: "POST",
            url: "/Content/WebService/ClientSiteWebService.asmx/SendContact",
            data: "{Name:'" + $("#" + Name).val() + "',Email:'" + $("#" + Email).val() + "',Message:'" + $("#" + Message).val() + "',SecureCode:'" + $("#" + SecureCode).val() + "'}",
            contentType: "application/json; charset=utf-8",
            dataType: "json",
            success: function (msg) {
                $(".result").text(msg.d);
            },
            error: function (msg) {
                $(".result").text(msg.d);
            }
        });


    } catch (e) {

    }
    return false;
}

function ClearForm(Container) {
    $(Container + " input").val("");
}

function slideNavigation(navigate) {
    var speed = 200;
    if ($.browser.opera) {
        $('html').animate({
            scrollTop: $(navigate).offset().top
        }, speed);
    }
    else $('html,body').animate({
        scrollTop: $(navigate).offset().top
    }, speed);
}
