﻿/// <reference path="jquery-1.3-vsdoc.js" />

$(document).ready(function() {
    IMAGE.rollover.init();
});

IMAGE = {};

IMAGE.rollover =
{
    init: function() {
        this.preload();

        $(".ro").hover(
         function() { $(this).attr('src', IMAGE.rollover.newimage($(this).attr('src'))); },
         function() { $(this).attr('src', IMAGE.rollover.oldimage($(this).attr('src'))); }
      );
    },

    preload: function() {
        $(window).bind('load', function() {
            $('.ro').each(function(key, elm) { $('<img>').attr('src', IMAGE.rollover.newimage($(this).attr('src'))); });
        });
    },

    newimage: function(src) {
        return src.substring(0, src.search(/(\.[a-z]+)$/)) + '_o' + src.match(/(\.[a-z]+)$/)[0];
    },

    oldimage: function(src) {
        return src.replace(/_o\./, '.');
    }
};

$(document).ready(function() {
    $("div.product_title").hover(function() {
        $(this).addClass("product_title_selected");
    }, function() {
        $(this).removeClass("product_title_selected");
    });
});

$(document).ready(function() {
    $("div.product_title").click(function() {
        $("div.product_title").each(function(i) {
            $(this).find("div.hidden").hide();
            $(this).removeClass("product_title_preview");
        });
        $(this).addClass("product_title_preview");
        $(this).removeClass("product_title_selected");
        $(this).find("div.hidden").show();
    });
});

$(document).ready(function() {
    $("div.product_title_products").click(function() {
        $.ajax({ type: "POST", url: "ProductPage.aspx", data: { Id: $(this).find("input.hidden_field").val() },
            success: function(data) {
                $("div.right").html(data);
                $('a.screenshot').lightBox({
                    overlayBgColor: '#000',
                    overlayOpacity: 0.6,
                    imageLoading: 'App_Themes/BHM/Graphics/lightbox-ico-loading.gif',
                    imageBtnClose: 'App_Themes/BHM/Graphics/lightbox-btn-close.gif',
                    imageBtnPrev: 'App_Themes/BHM/Graphics/lightbox-btn-prev.gif',
                    imageBtnNext: 'App_Themes/BHM/Graphics/lightbox-btn-next.gif',
                    containerResizeSpeed: 350,
                    txtImage: 'Obrazek',
                    txtOf: 'z'
                });
                $("img.screenshot_thumb").click(function() {
                    $(document).find("img.screenshot_main").attr("src", $(this).attr("src"));
                    $(document).find("a.screenshot").attr("href", $(this).attr("src"));
                });
            } 
        });
    });
});


$(document).ready(function() {
    var id = $(document).getUrlParam("Id");
    if (id != null) {
        $('input[value='+id+']').click();
    }
});

$(document).ready(function() {
    $("img.image_button").click(function() {
        $(document).find("div.login").removeClass("hidden_box");
    });
});

$(document).ready(function() {
    $("div.logo").click(function() {
        window.location = "Default.aspx";
    });
});

$(document).ready(function() {
    $("div.content_main").css("min-height", $(window).height() - 278);
    $("div.left_content_shadow").css("min-height", $("div.content_main").height());
    $("div.right_content_shadow").css("min-height", $("div.content_main").height());
});

$(document).ready(function() {
    $(window).resize(function() {
        $("div.content_main").css("min-height", $(window).height() - 278);
        $("div.left_content_shadow").css("min-height", $("div.content_main").height());
        $("div.right_content_shadow").css("min-height", $("div.content_main").height());
   });
});