function clickButton(e, buttonid) { var evt = e ? e : window.event; var bt = document.getElementById(buttonid); if (bt) { if (evt.keyCode == 13) { bt.click(); return false; } } }
function detectIE6() { var browser = navigator.appName; if (browser == "Microsoft Internet Explorer") { var b_version = navigator.appVersion; var re = /\MSIE\s+(\d\.\d\b)/; var res = b_version.match(re); if (res[1] <= 6) { return true; } } return false; }

//function menu_on(obj){obj.style.color='#ced9f9';}
//function menu_out(obj){obj.style.color='white';}
function tab_on(obj) { document.getElementById(obj).className = 'MenuTabHover'; }
function tab_out(obj) { document.getElementById(obj).className = 'MenuTabLink'; }
function HideModalPopup() { $find("ModalBehaviour").hide(); $('select', 'object', 'embed').each(function () { $(this).show(); /*.style.visibility = 'visible'*/ }); }
function HideModalPopup2() { $find("ModalBehaviour2").hide(); $('select', 'object', 'embed').each(function (node) { node.style.visibility = 'visible' }); }
function open_printable_version(link) { var win = "menubar=no,location=no,resizable=yes,scrollbars=yes"; newWin = window.open(link, 'perintableWin', win); newWin.focus(); }
function SelMenu(obj) {
    $(obj).prev("ul.SubMenu").removeClass("DN").addClass("DB");
}
function deSelMenu(obj) {
    $(obj).prev("ul.SubMenu").removeClass("DB").addClass("DN");
}
function SelMenuSub(obj) {
    $(obj).removeClass("DN").addClass("DB");
}
function deSelMenuSub(obj) {
    $(obj).removeClass("DB").addClass("DN");
}

$(document).ready(function () {
    $("span.MainMenu").hover(function () { $(this).addClass("span-hover"); }, function () { $(this).removeClass("span-hover"); });
})

function SizeChanged(size) {
    var container = $(size).closest("div.InfoProduct");
    var sizeId = $(size).val();
    var productId = $(size).parent().parent().find(".hfProdId").val();
    var isPainting = container.find("input:checkbox").attr("checked");
    if (isPainting == null) isPainting = false;
    UpdatePrice(productId, sizeId, isPainting);
}
function PaintingChecked(chkPainting) {
    var container = $(chkPainting).closest("div.InfoProduct");  
    var isPainting = $(chkPainting).attr("checked");
    var sizeId = container.find("div.prodinf").find("select").val();
    var productId = container.find(".hfProdId").val();
    if (isPainting == null) isPainting = false;
    UpdatePrice(productId, sizeId, isPainting);
}

function UpdatePrice(productId, sizeId, isPainting) {
    $.ajax({
        url: '../GetPrice.ashx',
        dataType: "html",
        cache: false,
        data: { product: productId, size: sizeId, isPainting: isPainting},
        success: function (data) {
            $("." + productId).html(data);
        }
    });
}

function Popup() {
    //фон
    var background = $("div.background_popup");
    background.css("height", $("body").height());
    background.css("opacity", 0.3);
    background.show();
    //popup
    var modal = $("div.popup");
    modal.show();
    modal.css("top", (($(window).height() - $(modal).height()) / 2) + "px"); /*($(window).height() - $(modal).height() - 60) / 2 + $(window).scrollTop());*/
    // var win = $(window);
    $(modal).css("left", ($(window).width() - $(modal).width()) / 2 + $(window).scrollLeft() + "px");

    $(modal).find(".close").click(function () {
        modal.hide();
        background.hide();
    });
}

function PropChange(property, prop) {
    var productId = $(property).val();

    $.ajax({
        url: '/GetAdditionalPrice.ashx',
        dataType: "html",
        cache: false,
        data: { product: productId },
        success: function (data) {
            $("." + prop + "price").html(data);
        }
    });
}
