$(document).ready(function() {
    if (window.location.pathname.toLowerCase() == '/nb-no/nyheter.aspx') {
        $("#news").css("color", "#B91E1E");
        $("#products").css("color", "#4D4D4D");
    }
    RegisterHover();

});
function RegisterHover() {
    // register for grid
    $("ul.thumb li div.all").hover(function() {
        $(this).css('z-index', '1000'); /*Add a higher z-index value so this image stays on top*/
        $(this).find('.mainItem').addClass("hover").stop() /* Add class of "hover", then stop animation queue buildup*/
		.animate({
		    marginTop: '-93px', /* The next 4 lines will vertically align this image */
		    marginLeft: '-110px',
		    top: '20%',
		    left: '20%',
		    width: '240px', /* Set new width */
		    height: '300px', /* Set new height */
		    padding: '15px'
		}, 200); /* this value of "200" is the speed of how fast/slow this hover animates */
        //$(this).find('.mainContent').css("float", "right");
        $(this).find('.mainItem').css("background", "#f0f0f0");
        $(this).find('.mainItem').css("border", "1px solid #D5D5D5");
        $(this).find('.sizeColorContent').css("display", "block");
        $(this).find('.thumbnailItem').css("display", "block");
    }, function() {
        $(this).find('.sizeColorContent').css("display", "none");
        $(this).find('.thumbnailItem').css("display", "none");
        $(this).find('.mainItem').css("border", "none");
        $(this).find('.mainItem').css("background", "none");
        //$(this).find('.mainContent').css("float", "none");

        var originImage = $(this).find(".originImage").html();
        //alert(originImage);
        originImage = originImage.replace("&amp;", "&");
        $(this).find(".imgDetail").attr({ src: originImage });
        $(this).css({ 'z-index': '0' });
        $(this).find('.mainItem').removeClass("hover").stop()  /* Remove the "hover" class , then stop animation queue buildup*/
		.animate({
		    marginTop: '0', /* Set alignment back to default */
		    marginLeft: '0',
		    top: '0',
		    left: '0',
		    width: '175px', /* Set width back to default */
		    height: '300px', /* Set height back to default */
		    padding: '5px'
		}, 400);
    });
    $(".thumbnailItem a").click(function() {
        var mainImage = $(this).attr("href"); //Find Image Name
        $(this).parent().parent().find(".mainContent").find("img.imgDetail").attr({ src: mainImage });
        return false;
    });

    //register for list
    $(".allList").hover(function() {
        $(this).css('z-index', '1000'); /*Add a higher z-index value so this image stays on top*/
        $(this).find('.mainListItem').addClass("hover").stop() /* Add class of "hover", then stop animation queue buildup*/
		.animate({
		    marginTop: '-93px', /* The next 4 lines will vertically align this image */
		    marginLeft: '-110px',
		    top: '20%',
		    left: '20%',
		    width: '200px', /* Set new width */
		    height: '210px', /* Set new height */
		    padding: '15px'
		}, 200); /* this value of "200" is the speed of how fast/slow this hover animates */

        $(this).find('.mainListItem').css("background", "#f0f0f0");
        $(this).find('.mainListItem').css("border", "1px solid #D5D5D5");
        $(this).find('.sizeColorContentList').css("display", "block");
        $(this).find('.thumbnailItem').css("display", "block");
        $(this).find('.discountListView').css("left", "110px");
        //$(this).find('.discountListView').css("*left", "110px");

    }, function() {
        $(this).find('.sizeColorContentList').css("display", "none");
        $(this).find('.thumbnailItem').css("display", "none");
        $(this).find('.mainListItem').css("border", "none");
        $(this).find('.mainListItem').css("background", "none");
        $(this).find('.discountListView').css("left", "110px");

        var originImage = $(this).find(".originImage").html();
        $(this).find(".imgDetail").attr({ src: originImage });
        $(this).css({ 'z-index': '0' });
        $(this).find('.mainListItem').removeClass("hover").stop()  /* Remove the "hover" class , then stop animation queue buildup*/
		.animate({
		    marginTop: '0', /* Set alignment back to default */
		    marginLeft: '0',
		    top: '0',
		    left: '0',
		    width: '175px', /* Set width back to default */
		    height: '210px', /* Set height back to default */
		    padding: '5px'
		}, 400);
    });
    $(".thumbnailItem a").click(function() {
        var mainImage = $(this).attr("href"); //Find Image Name
        $(this).parent().parent().find(".imageProduct").find("img.imgDetail").attr({ src: mainImage });
        return false;
    });
}

Sys.WebForms.PageRequestManager.getInstance().add_endRequest(EndRequest);
function EndRequest(sender, args) {
    RegisterHover();
}
