﻿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 SearchRestaurants(URL, CityID, TownID, Type) {
    try {

        CID = $("#" + CityID).val();
        TID = $("#" + TownID).val();

        if (Type == "City") TID = 0;

        if (CID != "") URL += EncodeUri($("#" + CityID + " [value='" + CID + "']").text()) + "/"; else URL += "http://www.cemilusta.com.tr/-/";
        if (TID != "") URL += EncodeUri($("#" + TownID + " [value='" + TID + "']").text()) + "/"; else URL += "http://www.cemilusta.com.tr/-/";
        if (CID != "") URL += EncodeUri(CID) + "/"; else URL += "http://www.cemilusta.com.tr/0/";
        if (TID != "") URL += EncodeUri(TID) + "/"; else URL += "http://www.cemilusta.com.tr/0/";
        $(".restaurant_types img[Selected=true]").each(function (index, element) {
            URL += EncodeUri((index > 0 ? ";" : "") + $(element).attr("alt").trim());
        });
        document.location.href = URL;
    } catch (e) {

    }
}

function InitSearch(ControlID) {

    var inputWdith = '72px';
    var inputWdithReturn = '45px';

    $('#' + ControlID).focus(function () {
        $(this).animate({
            width: inputWdith
        }, 400)
    });

    $('#' + ControlID).blur(function () {
        if ($(this).val() == '') {
            $(this).animate({
                width: inputWdithReturn
            }, 500);
        }
    });
}
function ShowPreLoading() {
    $('.preloading').css('display', 'block');
}
function HidePreLoading() {
    $('.preloading').css('display', 'none');
}

$(window).load(function () {
	$('ul.navmenu-h').superfish();
    $('.preloading img').css('margin-top', ($(window).height() - 120) / 2);
    /* top Menü*/
    $('ul.sf-menu').superfish();
    $('ul.sf-menu > li > ul > li a, ul.sf-menu > li > ul > li').unbind();
    $('ul.sf-menu > li > ul > li ul').css('height', '0px');

    $('ul.sf-menu > li > ul > li ').mouseenter(function () {

        var checkElement = $(this).find("ul");
        checkElement.css({ display: 'block', visibility: 'visible' });


        checkElement.stop(true, false).animate({ height: '60px' }, 400, 'swing');
    });

    $('ul.sf-menu > li > ul > li').mouseleave(function () {

        var checkElement = $(this).find("ul");
        checkElement.stop(true, false).animate({ height: '0px' }, 400, 'swing', function () { $(this).css({ display: 'none', visibility: 'hidden' }); });
    });

});


function NumberControl() {
    $('.number').keydown(function (e) {
        var keyCode = e.charCode;
        alert(keyCode);
        isNumeric(keyCode);
    });
}

function isNumeric(value) {
    if (value == null || !value.toString().match(/^[-]?\d*\.?\d*$/)) return false;
    return true;
}
