(function() {
  var frase, frasi, i, intervallo, n, newss, totali_n;

  intervallo = 0;

  newss = function() {
    var n, precedente;
    if (n > totali_n) n = 0;
    precedente = n - 1;
    return n++;
  };

  frase = function() {
    if (i === 4) clearInterval(intervallo);
    return $("#intestazione").fadeOut(1000, function() {
      var paragrafi, q, singola, totali;
      singola = function() {
        var ritardo;
        if (q < totali) {
          ritardo = q * 40;
          paragrafi[q].delay(ritardo).fadeIn(function() {
            return singola();
          });
          return q++;
        }
      };
      $("#intestazione").show();
      $("#intestazione").html(frasi[i]);
      paragrafi = new Array;
      $("#intestazione").find("p").each(function(i) {
        $(this).hide();
        return paragrafi.push($(this));
      });
      totali = paragrafi.length;
      q = 0;
      singola();
      return i++;
    });
  };

  $(document).ready(function() {
    var attuale, controlla, current, hash, inizializza, news, trackMouse;
    inizializza = function() {
      var ScrollContent, cnt, cntH, diff, handle, handlerH, posX, prop, scroll, toll, win, winH, wrapper;
      ScrollContent = function() {
        var margin, perc;
        handle.css({
          margin: 0,
          left: 0
        });
        perc = Math.ceil(handle.position().top * 100 / (winH - handle.height()));
        margin = ((diff * perc) / 100) + toll;
        return cnt.stop().animate({
          marginTop: -margin
        }, {
          queue: false,
          duration: 400,
          easing: "easeOutCirc"
        });
      };
      $("#bigger").append("<div class=\"ContentScrollBar\"><div class=\"handle\"></div></div>");
      toll = 20;
      win = $("#bigger");
      cnt = $("#into");
      wrapper = $("#bigger");
      scroll = wrapper.find(".ContentScrollBar");
      handle = scroll.children(".handle");
      winH = win.height();
      cntH = cnt.height();
      diff = cntH - winH + toll;
      prop = diff / winH;
      handlerH = Math.round((1 - prop) * scroll.height());
      posX = 340 + cnt.width();
      if (winH > cntH) return;
      scroll.css({
        left: posX
      }).show();
      handle.css({
        height: handlerH
      });
      handle.draggable({
        containment: "parent",
        axis: "y",
        start: function() {
          return scroll.addClass("dragging");
        },
        stop: function() {
          return scroll.removeClass("dragging");
        },
        drag: function(e, ui) {
          return ScrollContent();
        }
      });
      cnt.bind("mousewheel", function(event, delta) {
        var newY, vel;
        vel = Math.abs(delta * 10);
        newY = handle.position().top - (delta * vel);
        if (newY < 0) return;
        if ((handle.height() + newY) > winH) return;
        handle.css("top", newY);
        return ScrollContent();
      });
      wrapper.mouseenter(function(e) {
        if (scroll.hasClass("dragging")) e.preventDefault();
        return scroll.stop().animate({
          left: posX
        }, {
          queue: false,
          duration: 400,
          easing: "easeInOutExpo"
        });
      });
      return wrapper.mouseleave(function(e) {
        if (scroll.hasClass("dragging")) e.preventDefault();
        return scroll.stop().animate({
          left: posX - 17
        }, {
          queue: false,
          duration: 400,
          easing: "easeInOutExpo"
        });
      });
    };
    controlla = function() {
      if ($("#collezioni").hasClass("open")) {
        $("#thumb").css({
          marginLeft: 20
        });
        $("#section").css({
          marginLeft: 180
        });
        $("#inner").css({
          marginLeft: 180
        });
        $("#sidebar").css({
          marginLeft: 701
        });
      }
      if ($("#soluzioni").hasClass("open")) {
        $("#solution").css({
          marginLeft: 20
        });
        $("#section").css({
          marginLeft: 180
        });
        $("#inner").css({
          marginLeft: 180
        });
        return $("#sidebar").css({
          marginLeft: 701
        });
      }
    };
    if ($.browser.msie && $.browser.version.substr(0, 1) < 7) {
      window.location.replace = "http://www.anticasignoria.it/upgrade.html";
    }
    $.backstretch("img/home_bg.jpg");
    if ($.browser.msie && ($.browser.version !== "9.0")) {
      $("#bigger").css({
        display: "none"
      });
    } else {
      $("#bigger").css({
        opacity: 0
      });
    }
    current = $("#menu li").first();
    $("#menu li").each(function(i) {
      $(this).hover((function() {
        if ($(this).attr("id") === "collection") {
          $("#collection").html("<div class=\"back\"></div><font color=\"000\"><b>DeCo</b></font>llection");
        }
        return $(this).find(".back").animate({
          height: "52px"
        }, {
          duration: 200,
          asing: "easeOutExpo"
        });
      }), function() {
        if (!$(this).hasClass("current")) {
          if ($(this).attr("id") === "collection") {
            $("#collection").html("<div class=\"back\"></div><font color=\"f1b700\"><b>DeCo</b></font>llection");
          }
          return $(this).find(".back").stop().animate({
            height: "0"
          }, {
            queue: false,
            duration: 300,
            asing: "easeOutExpo"
          });
        } else {
          return $(this).find(".back").stop().animate({
            height: "52px"
          }, {
            queue: false,
            duration: 300,
            asing: "easeOutExpo"
          });
        }
      });
      return $(this).click(function() {
        if (!$(this).hasClass("current")) {
          current.removeClass("current").stop().find(".back").stop().animate({
            height: "0"
          }, {
            queue: false,
            duration: 300,
            asing: "easeOutExpo"
          });
          if (current.attr("id") === "collection") {
            $("#collection").html("<div class=\"back\"></div><font color=\"f1b700\">DeCo</font>llection");
          }
        }
        current = $(this);
        return current.addClass("current");
      });
    });
    $("#menu2 li").each(function(i) {
      return $(this).click(function() {
        current.removeClass("current").stop().find(".back").stop().animate({
          height: "0"
        }, {
          queue: false,
          duration: 300,
          asing: "easeOutExpo"
        });
        if (current.attr("id") === "collection") {
          return $("#collection").html("<div class=\"back\"></div><font color=\"f1b700\">DeCo</font>llection");
        }
      });
    });
    $("#calde_bubble").hide();
    $("#fredde_bubble").hide();
    $("#neutre_bubble").hide();
    $("#cucina_bubble").hide();
    $("#salotto_bubble").hide();
    $("#bagno_bubble").hide();
    $("#camera_letto_bubble").hide();
    $("#camera_bimbi_bubble").hide();
    $("#ufficio_bubble").hide();
    $("#negozi_bubble").hide();
    $("#sala_riunioni_bubble").hide();
    $("#bar_bubble").hide();
    $("#ristorante_bubble").hide();
    attuale = "";
    $("#calde").hover((function() {
      $("#calde_bubble").fadeIn("fast");
      attuale = $(this).attr("id") + "_bubble";
      return $(this).mousemove(trackMouse);
    }), function() {
      return $("#calde_bubble").fadeOut("fast");
    });
    $("#neutre").hover((function() {
      $("#neutre_bubble").fadeIn("fast");
      attuale = $(this).attr("id") + "_bubble";
      return $(this).mousemove(trackMouse);
    }), function() {
      return $("#neutre_bubble").fadeOut("fast");
    });
    $("#fredde").hover((function() {
      $("#fredde_bubble").fadeIn("fast");
      attuale = $(this).attr("id") + "_bubble";
      return $(this).mousemove(trackMouse);
    }), function() {
      return $("#fredde_bubble").fadeOut("fast");
    });
    $("#fredde2").hover((function() {
      $("#fredde_bubble").fadeIn("fast");
      attuale = $(this).attr("id").substring(0, 6) + "_bubble";
      return $(this).mousemove(trackMouse);
    }), function() {
      return $("#fredde_bubble").fadeOut("fast");
    });
    $("#calde2").hover((function() {
      $("#calde_bubble").fadeIn("fast");
      attuale = $(this).attr("id").substring(0, 5) + "_bubble";
      return $(this).mousemove(trackMouse);
    }), function() {
      return $("#calde_bubble").fadeOut("fast");
    });
    $("#cucina").hover((function() {
      $("#cucina_bubble").fadeIn("fast");
      attuale = $(this).attr("id") + "_bubble";
      return $(this).mousemove(trackMouse);
    }), function() {
      return $("#cucina_bubble").fadeOut("fast");
    });
    $("#salotto").hover((function() {
      $("#salotto_bubble").fadeIn("fast");
      attuale = $(this).attr("id") + "_bubble";
      return $(this).mousemove(trackMouse);
    }), function() {
      return $("#salotto_bubble").fadeOut("fast");
    });
    $("#bagno").hover((function() {
      $("#bagno_bubble").fadeIn("fast");
      attuale = $(this).attr("id") + "_bubble";
      return $(this).mousemove(trackMouse);
    }), function() {
      return $("#bagno_bubble").fadeOut("fast");
    });
    $("#camera_bimbi").hover((function() {
      $("#camera_bimbi_bubble").fadeIn("fast");
      attuale = $(this).attr("id") + "_bubble";
      return $(this).mousemove(trackMouse);
    }), function() {
      return $("#camera_bimbi_bubble").fadeOut("fast");
    });
    $("#camera_letto").hover((function() {
      $("#camera_letto_bubble").fadeIn("fast");
      attuale = $(this).attr("id") + "_bubble";
      return $(this).mousemove(trackMouse);
    }), function() {
      return $("#camera_letto_bubble").fadeOut("fast");
    });
    $("#ufficio").hover((function() {
      $("#ufficio_bubble").fadeIn("fast");
      attuale = $(this).attr("id") + "_bubble";
      return $(this).mousemove(trackMouse);
    }), function() {
      return $("#ufficio_bubble").fadeOut("fast");
    });
    $("#negozi").hover((function() {
      $("#negozi_bubble").fadeIn("fast");
      attuale = $(this).attr("id") + "_bubble";
      return $(this).mousemove(trackMouse);
    }), function() {
      return $("#negozi_bubble").fadeOut("fast");
    });
    $("#sala_riunioni").hover((function() {
      $("#sala_riunioni_bubble").fadeIn("fast");
      attuale = $(this).attr("id") + "_bubble";
      return $(this).mousemove(trackMouse);
    }), function() {
      return $("#sala_riunioni_bubble").fadeOut("fast");
    });
    $("#bar").hover((function() {
      $("#bar_bubble").fadeIn("fast");
      attuale = $(this).attr("id") + "_bubble";
      return $(this).mousemove(trackMouse);
    }), function() {
      return $("#bar_bubble").fadeOut("fast");
    });
    $("#ristorante").hover((function() {
      $("#ristorante_bubble").fadeIn("fast");
      attuale = $(this).attr("id") + "_bubble";
      return $(this).mousemove(trackMouse);
    }), function() {
      return $("#ristorante_bubble").fadeOut("fast");
    });
    trackMouse = function(e) {
      var xPos, yPos;
      if ($("#soluzioni").hasClass("open") || $("#collezioni").hasClass("open")) {
        xPos = e.pageX - 373;
      } else {
        xPos = e.pageX - 210;
      }
      yPos = e.pageY;
      return $("#" + attuale).css({
        marginLeft: xPos + "px",
        marginTop: yPos + "px"
      });
    };
    $("#collection").click(function() {
      if ($("#soluzioni").hasClass("open")) {
        $("#solution").css({
          marginLeft: 20
        });
        $("#soluzioni").removeClass("open");
        $("#thumb").css({
          marginLeft: 180
        });
      } else {
        $("#thumb").stop().animate({
          marginLeft: 180
        }, {
          queue: false,
          duration: 400,
          easing: "easeInOutExpo"
        });
      }
      $("#inner").stop().animate({
        marginLeft: 340
      }, {
        queue: false,
        duration: 400,
        easing: "easeInOutExpo"
      });
      $("#section").stop().animate({
        marginLeft: 340
      }, {
        queue: false,
        duration: 400,
        easing: "easeInOutExpo"
      });
      $("#sidebar").stop().animate({
        marginLeft: 861
      }, {
        queue: false,
        duration: 400,
        easing: "easeInOutExpo"
      });
      $(".ContentScrollBar").stop().animate({
        marginLeft: 160
      }, {
        queue: false,
        duration: 400,
        easing: "easeInOutExpo"
      });
      return $("#collezioni").addClass("open");
    });
    $("#thumb .close").click(function() {
      $("#thumb").stop().animate({
        marginLeft: 20
      }, {
        queue: false,
        duration: 400,
        easing: "easeInOutExpo"
      });
      $("#section").stop().animate({
        marginLeft: 180
      }, {
        queue: false,
        duration: 400,
        easing: "easeInOutExpo"
      });
      $("#inner").stop().animate({
        marginLeft: 180
      }, {
        queue: false,
        duration: 400,
        easing: "easeInOutExpo"
      });
      $("#sidebar").stop().animate({
        marginLeft: 701
      }, {
        queue: false,
        duration: 400,
        easing: "easeInOutExpo"
      });
      $(".ContentScrollBar").stop().animate({
        marginLeft: 0
      }, {
        queue: false,
        duration: 400,
        easing: "easeInOutExpo"
      });
      return $("#collezioni").removeClass("open");
    });
    $("#solutions").click(function() {
      if ($("#collezioni").hasClass("open")) {
        $("#thumb").css({
          marginLeft: 20
        });
        $("#collezioni").removeClass("open");
        $("#solution").css({
          marginLeft: 180
        });
      } else {
        $("#solution").stop().animate({
          marginLeft: 180
        }, {
          queue: false,
          duration: 400,
          easing: "easeInOutExpo"
        });
      }
      $("#inner").stop().animate({
        marginLeft: 340
      }, {
        queue: false,
        duration: 400,
        easing: "easeInOutExpo"
      });
      $("#section").stop().animate({
        marginLeft: 340
      }, {
        queue: false,
        duration: 400,
        easing: "easeInOutExpo"
      });
      $("#sidebar").stop().animate({
        marginLeft: 861
      }, {
        queue: false,
        duration: 400,
        easing: "easeInOutExpo"
      });
      return $("#soluzioni").addClass("open");
    });
    $("#solution .close").click(function() {
      $("#solution").stop().animate({
        marginLeft: 20
      }, {
        queue: false,
        duration: 400,
        easing: "easeInOutExpo"
      });
      $("#section").stop().animate({
        marginLeft: 180
      }, {
        queue: false,
        duration: 400,
        easing: "easeInOutExpo"
      });
      $("#inner").stop().animate({
        marginLeft: 180
      }, {
        queue: false,
        duration: 400,
        easing: "easeInOutExpo"
      });
      $("#sidebar").stop().animate({
        marginLeft: 701
      }, {
        queue: false,
        duration: 400,
        easing: "easeInOutExpo"
      });
      return $("#soluzioni").removeClass("open");
    });
    $("#collezioni .thumb img").each(function(i) {
      $(this).mouseover(function() {
        return $(this).stop().animate({
          opacity: "0.3"
        }, {
          queue: false,
          duration: 400,
          easing: "easeOutExpo"
        });
      });
      $(this).mouseout(function() {
        return $(this).stop().animate({
          opacity: "1"
        }, {
          queue: false,
          duration: 400,
          easing: "easeInOutExpo"
        });
      });
      return $(this).click(function(i) {
        var a_href;
        if ($.browser.msie && ($.browser.version !== "9.0")) {
          $("#bigger").css({
            display: "block"
          });
        } else {
          $("#bigger").css({
            opacity: 1
          });
        }
        a_href = $(this).attr("id");
        return window.location.hash = "/" + a_href;
      });
    });
    $("#collezioni .thumb p").each(function(i) {
      $(this).mouseover(function() {
        return $(this).parent().find("img").stop().animate({
          opacity: "0.3"
        }, {
          queue: false,
          duration: 400,
          easing: "easeOutExpo"
        });
      });
      $(this).mouseout(function() {
        return $(this).parent().find("img").stop().animate({
          opacity: "1"
        }, {
          queue: false,
          duration: 400,
          easing: "easeInOutExpo"
        });
      });
      return $(this).click(function(i) {
        var a_href;
        if ($.browser.msie && ($.browser.version !== "9.0")) {
          $("#bigger").css({
            display: "block"
          });
        } else {
          $("#bigger").css({
            opacity: 1
          });
        }
        a_href = $(this).parent().find("img").attr("id");
        return window.location.hash = "/" + a_href;
      });
    });
    $("#solution li").each(function(i) {
      $(this).mouseover(function() {
        return $(this).stop().animate({
          backgroundColor: "#727171"
        }, {
          queue: false,
          duration: 400,
          easing: "easeOutExpo"
        });
      });
      $(this).mouseout(function() {
        return $(this).stop().animate({
          backgroundColor: "#dedede"
        }, {
          queue: false,
          duration: 400,
          easing: "easeOutExpo"
        });
      });
      return $(this).click(function(i) {
        var a_href;
        if ($.browser.msie && ($.browser.version !== "9.0")) {
          $("#bigger").css({
            display: "block"
          });
        } else {
          $("#bigger").css({
            opacity: 1
          });
        }
        a_href = $(this).attr("id");
        return window.location.hash = "/" + a_href;
      });
    });
    if ("onhashchange" in window) {
      hash = "";
      window.onhashchange = function() {
        var currentAnchor;
        currentAnchor = window.location.hash;
        if ($.browser.msie && ($.browser.version !== "9.0")) {
          $("#bigger").css({
            display: "block"
          });
        } else {
          $("#bigger").css({
            opacity: 1
          });
        }
        if (currentAnchor.indexOf("collezioni") !== -1 || currentAnchor.indexOf("solution") !== -1) {
          hash = window.location.hash.substring(2);
          return $("#bigger").load("" + hash + "index.html", function() {
            var altezza;
            setTimeout(inizializza, 2000);
            altezza = $(window).height();
            $("#into").css({
              top: altezza
            });
            if ($("#collezioni").hasClass("open")) {
              $("#sidebar").css({
                marginLeft: 861
              });
            }
            $("#into").animate({
              top: "25px"
            }, {
              duration: 300,
              asing: "easeInOutExpo"
            });
            if (!$("#collezioni").hasClass("open")) {
              $("#section").css({
                marginLeft: 180
              });
              $("#inner").css({
                marginLeft: 180
              });
            }
            if ($("#soluzioni").hasClass("open")) {
              $("#section").css({
                marginLeft: 340
              });
              return $("#inner").css({
                marginLeft: 340
              });
            }
          });
        } else {
          controlla();
          hash = window.location.hash.substring(2);
          if ($.browser.msie && ($.browser.version !== "9.0")) {
            $("#bigger").css({
              display: "block"
            });
          } else {
            $("#bigger").css({
              opacity: 1
            });
          }
          $("#bigger").load("" + hash + "index.html", function() {
            return setTimeout(inizializza, 2000);
          });
          if ($.browser.msie && ($.browser.version !== "9.0")) {
            return $("#bigger").css({
              display: "block"
            });
          } else {
            return $("#bigger").css({
              opacity: 1
            });
          }
        }
      };
    }
    $("#griglia li").preloader({
      Height: 126,
      Width: 100
    });
    news = new Array();
    news[0] = "<li id=\"0\">4 Novembre Lorem ipsum dolor sit amet, consectetur adipiscing elit.4 Novembre Lorem ipsum dolor sit amet, consectetur adipiscing elit.4 Novembre Lorem ipsum dolor sit amet, consectetur adipiscing elit.4 Novembre Lorem ipsum dolor sit amet, consectetur adipiscing elit.4 Novembre Lorem ipsum dolor sit amet, consectetur adipiscing elit.4 Novembre Lorem ipsum dolor sit amet, consectetur adipiscing elit.4 Novembre Lorem ipsum dolor sit amet, consectetur adipiscing elit.4 Novembre Lorem ipsum dolor sit amet, consectetur adipiscing elit.</li>";
    news[1] = "<li id=\"1\">2 Novembre Lorem ipsum dolor sit amet, consectetur adipiscing elit.</li>";
    news[2] = "<li id=\"2\">1 Novembre Lorem ipsum dolor sit amet, consectetur adipiscing elit.</li>";
    return intervallo = window.setInterval("newss()", 2000);
  });

  n = 0;

  totali_n = 2;

  frasi = new Array();

  frasi[0] = "<p class=\"sx\">La leggerezza impalpabile della materia</p><br><p class=\"dx\">si fonde con i riflessi cangianti della luce</p><br><p class=\"sx\">dando vita ad una finitura</p><br><p class=\"dx\">dall&acute;eleganza senza tempo&nbsp;&nbsp;&nbsp;&nbsp;&nbsp&nbsp;&nbsp;&nbsp;&nbsp;&nbsp&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</p>";

  frasi[1] = "<p class=\"sx\">Osare con i toni pi&uacute; accesi,</p><br><p class=\"dx\">scaldare con le nuances dell&acute;oro,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</p><br><p class=\"sx\">armonizzare con le tinte soft...</p>";

  frasi[2] = "<p class=\"sx\">e l&acute;ambiente prende forma</p><br><p class=\"dx\">in un&acute;atmosfera raffinata&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</p><br><p class=\"sx\">dal fascino sempre attuale.&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</p>";

  frasi[3] = "<a href=\"#/collezioni/chiffon/\"><p class=\"sx\">CHIFFON</p><br><p class=\"sx\">Eleganza Contemporanea</p></a>";

  frasi[4] = "";

  i = 0;

  window.onload = function() {
    var leggi;
    leggi = window.location.hash.substring(2);
    if (leggi !== "") {
      if ($.browser.msie && ($.browser.version !== "9.0")) {
        $("#bigger").css({
          display: "block"
        });
      } else {
        $("#bigger").css({
          opacity: 1
        });
      }
      if (leggi.indexOf("collezioni/") !== -1) {
        $("#sidebar").css({
          opacity: 1
        });
        return $("#bigger").load("" + leggi + "index.html", function() {
          $("#thumb").css({
            marginLeft: 20
          });
          $("#section").css({
            marginLeft: 180
          });
          $("#inner").css({
            marginLeft: 180
          });
          $("#sidebar").css({
            marginLeft: 701
          });
          $("#section #into").css({
            opacity: 1
          });
          return $("#section ").css({
            opacity: 1
          });
        });
      } else {
        $("#" + leggi + "").addClass("current");
        $("#" + leggi + "").find(".back").css({
          height: "60px"
        });
        return $("#bigger").load("" + leggi + "index.html");
      }
    } else {
      $("#intestazione").hide();
      $("#intestazione").fadeIn(5000);
      $("#intestazione").html("<p class=\"sx\"><b>Trama</b> Voluttuosa</p><br /><p class=\"dx\">Delicata <b>Lucentezza&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp&nbsp;&nbsp;&nbsp;&nbsp;</b></p>");
      return intervallo = window.setInterval("frase()", 5000);
    }
  };

}).call(this);

