$(function(){
  if ($.browser.mozilla || $.browser.msie) {
    $(".digifotosidebox")
      .hover(function() {
        $(this).addClass("digifotosidebox_hover");
      }, function() {
        $(this).removeClass("digifotosidebox_hover");
      })

    $(".digifotocontentbox")
      .hover(function() {
        $(this).addClass("digifotocontentbox_hover");
      }, function() {
        $(this).removeClass("digifotocontentbox_hover");
      })
  }

  $(".digifotosidebox")
    .bind("click", function(event) {
      var linkelem = $("a", this)
      var linkto   = linkelem.attr("href");

      if (linkto == "#") {
/*        if ($.browser.msie) {
          linkelem.get(0).click();
        } else {*/
          linkelem.trigger("click");
/*        }*/
      } else {
        window.open(linkto, '_blank');
      }

      return false;
    })
    .find("a")
    .bind("click", function(event) {
      event.stopPropagation();
    });

  $(".digifotocontentbox:not(#windowsbox)")
    .bind("click", function() {
      var linkelem = $("a", this)
      var linkto   = linkelem.attr("href");

      if (linkto == "#") {
        if ($.browser.msie) {
          linkelem.get(0).click();
        } else {
          linkelem.trigger("click");
        }
      } else {
        window.open(linkto, '_blank');
      }

      return false;
    })
    .find("a")
    .bind("click", function(event) {
      event.stopPropagation();
    });

  $(".digifotobutton")
    .bind("click", function() {
      var animspeed = 100;
      $("#clientbox").fadeOut(animspeed, function() {
        $("#windowsbox").fadeOut(animspeed, function() {
          $("#giftbox").fadeOut(animspeed, function() {
            $("#cardbox").fadeOut(animspeed, function() {
              $("#calendarbox").fadeOut(animspeed, function() {
                $("#posterbox").fadeOut(animspeed, function() {
                  $("#photobooksidebox").fadeOut(animspeed, function() {
                    $("#photosidebox").fadeOut(animspeed, function() {

                      $("#photoinfobox").fadeIn(animspeed, function() {
                        $("#htmlwizardbox").fadeIn(animspeed, function() {
                          $("#jswizardbox").fadeIn(animspeed, function() {
                            $("#ftpwizardbox").fadeIn(animspeed, function() {
                              $("#photopricelist").fadeIn(animspeed, function() {
                                $(".digifototitle")
                                  .removeClass("digifototitle")
                                  .addClass("digifotophototitle");
                              });
                            });
                          });
                        });
                      });

                    });
                  });
                });
              });
            });
          });
        });
      });
    });

  $(".backbutton")
    .bind("click", function() {
      $(".view2").fadeOut("normal");
      $(".view1").fadeIn("normal");

      $(".digifotophototitle")
        .removeClass("digifotophototitle")
        .addClass("digifototitle");

      return false;
    });

  $("#windowsbox,.windowsbutton")
    .bind("click", function() {
      var animspeed = 100;
      $("#clientbox").fadeOut(animspeed, function() {
        $("#windowsbox").fadeOut(animspeed, function() {
          $("#giftbox").fadeOut(animspeed, function() {
            $("#cardbox").fadeOut(animspeed, function() {
              $("#calendarbox").fadeOut(animspeed, function() {
                $("#posterbox").fadeOut(animspeed, function() {
                  $("#photobooksidebox").fadeOut(animspeed, function() {
                    $("#photosidebox").fadeOut(animspeed, function() {

                      $("#windowsinfobox").fadeIn(animspeed, function() {
                        $("#winxpbox").fadeIn(animspeed, function() {
                          $("#win7box").fadeIn(animspeed, function() {
                            $("#mediacenterbox").fadeIn(animspeed, function() {
                              $(".digifototitle")
                                .removeClass("digifototitle")
                                .addClass("digifotowintitle");
                            });
                          });
                        });
                      });

                    });
                  });
                });
              });
            });
          });
        });
      });

      return false;
    });

  $(".backbutton2")
    .bind("click", function() {
      $(".view3").fadeOut("normal");
      $(".view1").fadeIn("normal");

      $(".digifotowintitle")
        .removeClass("digifotowintitle")
        .addClass("digifototitle");

      return false;
    });
});
