﻿jQuery(function () {

    jQuery(".megamenu").megamenu({
        show_method: 'simple',
        hide_method: 'simple'
    });

    jQuery('#body').corner();

    /*var name = $("#name"),
    email = $("#email"),
    company = $("#company"),
    position = $("#position"),
    phone = $("#phone"),
    target = $("#target"),
    message = $("#message"),

    allFields = $([]).add(name).add(email).add(company).add(phone).add(position).add(target).add(message);*/

    $("#login-form").dialog({
        height: 280,
        width: 335,
        autoOpen: false,
        modal: true,
        resizable: false,
        buttons: {
            "Войти": function () {
                $("#login_alert").html("");
                if ($("#login_name").val() == "") {
                    $("#login_alert").html("Введите адрес эл. почты.");
                    return;
                }

                if ($("#login_password").val() == "") {
                    $("#login_alert").html("Введите пароль.");
                    return;
                }

                var f = $("#login_data");
                var serializeForm = f.serialize();
                $.post("/account/logon", serializeForm, function (result, status) {
                    if (result.Success) {
                        $(this).dialog("close");
                        location.href = location.href;
                    } else {
                        $("#login_alert").html(result.Message);
                    }
                }, "json");

             

            },
            "Отмена": function () {
                $(this).dialog("close");
            }
        },
        close: function () {
            $("#login_name").val("");
            $("#login_password").val("");
            $("#login_alert").html("");
            $("#login_remember").attr('checked', false);
        }
    });

    $('#login-form').live('keyup', function (e) {
        if (e.keyCode == 13) {
            $(':button:contains("Войти")').click();
        }
    });
}
);



function SearchClear(obj) {
    if (obj.value == 'Поиск...')
        obj.value = "";
}

function SearchFill(obj) {
    if (obj.value == "")
        obj.value = "Поиск...";
}
function OnSearchSubmit() {
    if (document.getElementById("SearchText").value == "Поиск...") {
        document.getElementById("SearchText").value = "";
    }
}


function LogOn() {
    $("#login-form").dialog("open");

}

function LogOff() {
    $.post("/account/logoff", null, function (result, status) {
        if (result.Success) {
            location.href = location.href;
        } 
    }, "json");

}



/* Russian (UTF-8) initialisation for the jQuery UI date picker plugin. */
/* Written by Andrew Stromnov (stromnov@gmail.com). */
jQuery(function ($) {
    $.datepicker.regional['ru'] = {
        closeText: 'Закрыть',
        prevText: '&#x3c;Пред',
        nextText: 'След&#x3e;',
        currentText: 'Сегодня',
        monthNames: ['Январь', 'Февраль', 'Март', 'Апрель', 'Май', 'Июнь',
		'Июль', 'Август', 'Сентябрь', 'Октябрь', 'Ноябрь', 'Декабрь'],
        monthNamesShort: ['Янв', 'Фев', 'Мар', 'Апр', 'Май', 'Июн',
		'Июл', 'Авг', 'Сен', 'Окт', 'Ноя', 'Дек'],
        dayNames: ['воскресенье', 'понедельник', 'вторник', 'среда', 'четверг', 'пятница', 'суббота'],
        dayNamesShort: ['вск', 'пнд', 'втр', 'срд', 'чтв', 'птн', 'сбт'],
        dayNamesMin: ['Вс', 'Пн', 'Вт', 'Ср', 'Чт', 'Пт', 'Сб'],
        weekHeader: 'Нед',
        dateFormat: 'dd.mm.yy',
        firstDay: 1,
        isRTL: false,
        showMonthAfterYear: false,
        yearSuffix: ''
    };
    $.datepicker.setDefaults($.datepicker.regional['ru']);
});

