$(document).ready(function(){
        var n = 0;


        var wPage = document.documentElement.clientWidth;
        var hPage = document.documentElement.clientHeight;

        $("#scrollerContent #page_1 img").css("width", wPage);
        $("#scrollerContent #page_1 img").css("height", "auto");
        $("#scrollerContent #page_1 img").css("position", "relative");

        var imageHeight = $("#scrollerContent #page_1 img").css("height");

        if ((-hPage/4) + imageHeight < hPage) {
            $("#scrollerContent #page_1 img").css("top", -hPage/4);
        } else {
            $("#scrollerContent #page_1 img").css("top", -hPage/6);
        }

        $("#left").fadeOut("slow");


        window.onresize = function () {
            wPage = document.documentElement.clientWidth;
            $("#scrollerContent #page_1 img").css("width", wPage);
            $("#scrollerContent #page_1 img").css("height", "auto");
            $("#gallery").css("width", wPage);
            $("#gallery").css("height", document.documentElement.clientHeight);

        }

        $("#right").click(function() {
            w_1 = $("#page_1").css("width");
            w_2 = $("#page_2").css("width");
            
            $("#product_title").fadeOut("slow");

            switch(n) {
                case 0:
                        $("#left").show();
                        $("#right").show();
                        var posX = 1*(w_1.substring(0, w_1.length-2));
                break;

                case 1:
                        $("#left").show();
                        $("#right").css("display", "block");
                        $("#right").fadeOut("slow");
                        var posX = 1*(w_1.substring(0, w_1.length-2)) + 1*(w_2.substring(0, w_2.length-2)) + 12;
                        $("#page_3_third").animate({"right": "0"}, "slow");
                break;
            }

            if (n < 2) {
                n++;
                $("#scrollerContent").animate({"left": "-"+posX}, "slow");
            }
        });

        $("#left").click(function() {
            switch(n) {
                case 1:
                        var posX = 0;
                        $("#left").show();
                        $("#left").css("display", "block");
                        $("#left").fadeOut("slow");

                        $("#product_title").show();
                break;

                case 2:
                        //posX = 1*(w_1.substring(0, w_1.length-2)) + 1*(w_2.substring(0, w_2.length-2));
                        var posX = 1*(w_1.substring(0, w_1.length-2));
                        $("#right").show();
                break;
            }


            if (n > 0) {
                n--;
                $("#scrollerContent").animate({"left": "-"+posX}, "slow");
                $("#page_3_third").animate({"right": "-280px"}, "slow");
            }
        });

        $("a.lightbox_image").fancybox();
        /* This does open the 'Rivenditori' box on rollover without having bugs on IE! */
        /*

        $("li.rivenditori_item").hover(
              function(){
      			$("#rivenditori_box").css("display", "block");
                  $("#rivenditori_box").css("left", "600px");
              }
          );

          $("li.rivenditori_item").mouseleave(
              function(){
                  $("#rivenditori_box").css("display", "none");
              }
          );
        */
        /* */

         /* This does open the 'Cataloghi' boxes on rollover without having bugs on IE! */

        $("#catalogo_pdf1").hover(
              function(){
      			$("#catalogo_pdf1 .cat_form").css("display", "block");
              }
          );

          $("#catalogo_pdf1").mouseleave(
              function(){
                  $("#catalogo_pdf1 .cat_form").css("display", "none");
              }
          );

        $("#catalogo_pdf2").hover(
              function(){
      			$("#catalogo_pdf2 .cat_form").css("display", "block");
                //$("#cat_form").css("left", "600px");
              }
          );

          $("#catalogo_pdf2").mouseleave(
              function(){
                  $("#catalogo_pdf2 .cat_form").css("display", "none");
              }
          );

        $("#catalogo_pdf3").hover(
              function(){
      			$("#catalogo_pdf3 .cat_form").css("display", "block");
                //$("#cat_form").css("left", "600px");
              }
          );

          $("#catalogo_pdf3").mouseleave(
              function(){
                  $("#catalogo_pdf3 .cat_form").css("display", "none");
              }
          );

        $("#catalogo_pdf4").hover(
              function(){
      			$("#catalogo_pdf4 .cat_form").css("display", "block");
                //$("#cat_form").css("left", "600px");
              }
          );

          $("#catalogo_pdf4").mouseleave(
              function(){
                  $("#catalogo_pdf4 .cat_form").css("display", "none");
              }
          );

        $("#catalogo_pdf5").hover(
              function(){
      			$("#catalogo_pdf5 .cat_form").css("display", "block");
                //$("#cat_form").css("left", "600px");
              }
          );

          $("#catalogo_pdf5").mouseleave(
              function(){
                  $("#catalogo_pdf5 .cat_form").css("display", "none");
              }
          );
        /* */
});

if (screen.width < 1360) {
		    _appendToImg = "small";
            $(document).ready(function() {
                $("div.product_var_2 p").css("width", "200px");
            });
        } else if (screen.width >= 1360 && screen.width < 1600) {
		    _appendToImg = "medium";
            $(document).ready(function() {
                $("div.product_var_2 p").css("width", "270px");
            });
        } else {
		    _appendToImg = "big";
		}
		
/*FUMETTI*/

$(function() {	
	$('.red_heart').mouseover(function() {
		$("#tooltip").fadeIn(400);
	});
});
$(function() {	
	$('.red_heart').mouseout(function() {
		$("#tooltip").fadeOut(400);
	});
});
$(function() {	   
    $(".red_heart img").click(function () { 
	  $("#added").show(400).delay(1500).hide(400);
    });
});
$(function() {	
	$('.my_klou img').mouseover(function() {
		$("#tooltip2").show(400).delay(1500).hide(400);
	});
});
$(function() {	
	$('.my_blog img').mouseover(function() {
		$("#tooltip2").show(400).delay(1500).hide(400);
	});
});

// BROKEN LINKS

$(document).ready(function(){

$("a.broken_link").click(function() {
  return false;
});
});
