﻿//function UpdateSiteHeader() {
//    $.ajax(
//	{
//		type: "POST",
//		url: "/DirectAction/Home/GetSiteHeader",
//		//data: {  },
//		success: function (result) {
//			$('#site_header_top_menu_ce412c293e634b01b33f681dc7f66f7f').html(result);
//		},
//		error: function (req, status, error) {
//		}
//	});
//}

$(document).ready(function () {
    renderMenu();
//    $('#recall_phone').mask("(999) 999-9999");
    $('.recal_input').each(function () {
        //alert($(this).attr('empty_text'));
        $(this).hint();
        //        InputHelperCreate($(this), $(this).attr('empty_text'));
    });


    $('#recall_submit').click(function () {

        var name = $('#recall_name').val();
        if (name == 'Ваше имя') {
            name = '';
        }

        var phone = $('#recall_phone').val();
        if (phone == 'Ваш телефон') {
            phone = '';
        }

        var message = $('#recall_message').val();
        if (message == 'Ваш вопрос (не обязательно)') {
            message = '';
        }

        $.ajax({
            type: "POST",
            url: "/DirectAction/Tools/Recall",
            data: { Name: name, Phone: phone, Message: message },
            success: function (result) {
                tb_remove();
                alert('Заявка на звонок принята!');
            },
            error: function (req, status, error) {
                alert('К сожалению произошла ошибка, заявка на звонок не принята!');
            }
        });
    });

//    //    if ($("#searchForm .search-box").val() !== "") {
//    //        $("#searchForm label").hide();
//    //    }
//    //    $("#searchForm label").click(function () {
//    //        $(this).fadeOut();
//    //        $("#searchForm .search-box").focus();
//    //    });
//    //    $("#searchForm .search-box").focus(function () {
//    //        $("#searchForm label").fadeOut();
//    //    });
//    //    $("#searchForm .search-box").blur(function () {
//    //        if ($("#searchForm .search-box").val() === "") {
//    //            $("#searchForm label").fadeIn();
//    //        }
//    //    });
//    //    $("#searchForm .go").mousedown(function () {
//    //        if ($("#searchForm .search-box").val() === "") {
//    //            $("#searchForm .search-box").focus();
//    //            return false;
//    //        }
//    //    });
//    //    $("#searchForm .go").click(function () {
//    //        if ($("#searchForm .search-box").val() === "") {
//    //            return false;
//    //        }
//    //    });
//    //    #floor_nav

});

//newsletters_email
function SubscribeUser() {
    $.ajax({
        type: "POST",
        url: "/DirectAction/Tools/SubscribeUser",
        data: { Email: $('#newsletters_email').val() },
        success: function (result) {
            if (result.status == "success") {
                $('#newsletters_email_errors').html('');
                $('#newsletters_email').val('');
                alert('Поздравляем Вы подписаны на новости нашего магазина!');
            }
            else {
                $('#newsletters_email_errors').html(result.error);
            }

        },
        error: function (req, status, error) {
            alert('К сожалению произошла ошибка, приносим извинения!');
        }
    });
}

/**
* @author Remy Sharp
* @url http://remysharp.com/2007/01/25/jquery-tutorial-text-box-hints/
*/
//function InputHelperIn(obj, text) {
//	//если при фокусе значение поля равно значению подсказки, то чистим его и вешаем стили
//	if (obj.value == text) {
//		$(obj)
//				.css({ color: '#000', fontStyle: 'normal' })
//				.val('');
//	}
//}

//function InputHelperOut(obj, text) {
//	//если при потере фокуса значение поля равно пустоте или значению по умолчанию,
//	//то пихаем в него текст подсказки и вешаем стили подсказки
//	if (obj.value == '' || obj.value == text) {
//		$(obj)
//				.css({ color: '#b3b3b3', fontStyle: 'italic' })
//				.val(text);
//	}
//}

//function InputHelperCreate(obj, text) {
//	//вешаем на поле эвенты. На фокус и потерю фокуса.
//	$(obj)
//			.bind('focus', function () {
//				InputHelperIn(this, text);
//			})
//			.bind('blur', function () {
//				InputHelperOut(this, text);
//			});

//	//первоначальный инит
//	InputHelperOut(obj, text);
//}
