$(document).ready(function() {



    $.fn.wait = function(time, type) {
        time = time || 2000; type = type || "fx"; return this.queue(type, function() {
            var self = this; setTimeout(function() { $(self).dequeue(); }, time);
        });
    };
    $("#mainback")
        .wait(2000)
		.animate({ opacity: "0.3", height: "433px" }, "fast")
		.animate({ opacity: "0.7" }, "fast")
		.animate({ opacity: "1" }, "fast")
    $(".footer")
        .wait(2200)
		.animate({ height: "85px" }, "slow")
    $(".nav")
		.wait(3000)
		.animate({ opacity: "1" }, "fast")
	$("#video")
		.wait(3000)
		.animate({ opacity: "0.9" }, "fast")
    $(".warkont")
		.wait(3000)
		.animate({ opacity: "0.9" }, "fast")
    $("#AutostartVideo")
		.wait(3000)
		.animate({ opacity: "1", height: "293px" }, "fast")

    $("#navfirsta").mouseover(function(event) {
        $("#navsec1").show()
    });
    $("#navfirsta").mouseout(function(event) {
        $("#navsec1").hide()
    });
    $("#navsec1").mouseover(function(event) {
        $("#navsec1").show()
    });
    $("#navsec1").mouseout(function(event) {
        $("#navsec1").hide()
    });
    $("#navsec1").click(function(event) {
        $("#navsec1").animate({ opacity: "hide" }, "slow");
    });


    $("#navfirstb").mouseover(function(event) {

        $("#navsec2").show()
    });
    $("#navfirstb").mouseout(function(event) {
        $("#navsec2").hide()
    });
    $("#navsec2").mouseover(function(event) {
        $("#navsec2").show()
    });
    $("#navsec2").mouseout(function(event) {
        $("#navsec2")
           .hide()
    });
    $("#navsec2").click(function(event) {
        $("#navsec2")
           .animate({ opacity: "hide" }, "slow");
    });


   $("#navfirstc").mouseover(function(event) {
        $("#navsec3")
           .show()
    });
    $("#navfirstc").mouseout(function(event) {
        $("#navsec3")
           .hide()
    });
    $("#navsec3").mouseover(function(event) {
        $("#navsec3")
		   .show()
    });
    $("#navsec3").mouseout(function(event) {
        $("#navsec3")
           .hide()
    });
    $("#navsec3").click(function(event) {
        $("#navsec3")
           .animate({ opacity: "hide" }, "slow");
    });


    $("#navfirstd").mouseover(function(event) {
        $("#navsec4")
           .show()
    });
    $("#navfirstd").mouseout(function(event) {
        $("#navsec4")
           .hide()
    });
    $("#navsec4").mouseover(function(event) {
        $("#navsec4")
		   .show()
    });
    $("#navsec4").mouseout(function(event) {
        $("#navsec4")
           .hide()
    });
    $("#navsec4").click(function(event) {
        $("#navsec4")
           .animate({ opacity: "hide" }, "slow");
    });

    $(".dynamicpage").click(function(event) {
        $("#navsec1")
           .animate({ opacity: "hide" }, "slow");
        $("#navsec2")
           .animate({ opacity: "hide" }, "slow");
        /*$("#navsec3")
           .animate({ opacity: "hide" }, "slow");*/
        $("#navsec4")
           .animate({ opacity: "hide" }, "slow");
    });


    function hideTexts() {
        $("#textBack")
        .animate({ height: "0px", width: "0px" }, "fast")
		.animate({ height: "301px", width: "552px" }, "slow")
		$("#guts")
          .hide()
        $("#tt1")
          .hide()
        $("#tt2")
          .hide()
        $("#tt3")
          .hide()
	    $("#tt4")
          .hide()
        $("#ttb1")
          .hide()
        $("#ttb2")
          .hide()
        $("#ttb3")
          .hide()
        $("#ttb4")
          .hide()
        $("#ttb5")
          .hide()
        $("#ttb6")
          .hide()
        $("#ttb7")
          .hide()
        $("#ttb8")
          .hide()
        $("#ttb9")
          .hide()
        $("#ttb10")
          .hide()
        $("#ttc1")
          .hide()
        $("#ttc2")
          .hide()
        $("#ttc3")
          .hide()
        $("#ttd1")
          .hide()
        $("#ttd2")
          .hide()
        $("#ttd3")
          .hide()
        $("#ttd4")
          .hide()
        $("#ttd5")
          .hide()
        $("#ttd6")
          .hide()
        $("#ttk1")
          .hide()
        $("#ttk2")
          .hide()

        hidePhoto();
    }

    function hidePhoto() {
        $("#galleryphoto")
        .animate({ height: "0px", width: "0px" }, "fast")
    }
    function showPhoto() {
        $("#galleryphoto")
        .animate({ height: "270px", width: "552px" }, "fast")
    }


    $("#minphoto").click(function(event) {
        hidePhoto()
    });

    $("#1-1-1").click(function(event) {
        hidePhoto();
        $(this).delay(200, function() { $("#photoitself").attr({ src: "http://www.swiss-white.ch/img/1-1-1.jpg" }) });
        $(this).delay(500, function() { showPhoto() });
    });

    $("#1-1-2").click(function(event) {
        hidePhoto();
        $(this).delay(200, function() { $("#photoitself").attr({ src: "http://www.swiss-white.ch/img/1-1-2.jpg" }) });
        $(this).delay(500, function() { showPhoto() });
    });

    $("#1-1-3").click(function(event) {
        hidePhoto();
        $(this).delay(200, function() { $("#photoitself").attr({ src: "http://www.swiss-white.ch/img/1-1-3.jpg" }) });
        $(this).delay(500, function() { showPhoto() });
    });

    $("#1-1-4").click(function(event) {
        hidePhoto();
        $(this).delay(200, function() { $("#photoitself").attr({ src: "http://www.swiss-white.ch/img/1-1-4.jpg" }) });
        $(this).delay(500, function() { showPhoto() });
    });

    $("#1-1-5").click(function(event) {
        hidePhoto();
        $(this).delay(200, function() { $("#photoitself").attr({ src: "http://www.swiss-white.ch/img/1-1-5.jpg" }) });
        $(this).delay(500, function() { showPhoto() });
    });

    $("#2-1-1").click(function(event) {
        hidePhoto();
        $(this).delay(200, function() { $("#photoitself").attr({ src: "http://www.swiss-white.ch/img/2-1-1.jpg" }) });
        $(this).delay(500, function() { showPhoto() });
    });

    $("#2-1-2").click(function(event) {
        hidePhoto();
        $(this).delay(200, function() { $("#photoitself").attr({ src: "http://www.swiss-white.ch/img/2-1-2.jpg" }) });
        $(this).delay(500, function() { showPhoto() });
    });

    $("#2-2-1").click(function(event) {
        hidePhoto();
        $(this).delay(200, function() { $("#photoitself").attr({ src: "http://www.swiss-white.ch/img/2-2-1.jpg" }) });
        $(this).delay(500, function() { showPhoto() });
    });

    $("#2-6-1").click(function(event) {
        hidePhoto();
        $(this).delay(200, function() { $("#photoitself").attr({ src: "http://www.swiss-white.ch/img/2-6-1.jpg" }) });
        $(this).delay(500, function() { showPhoto() });
    });

    $("#2-6-2").click(function(event) {
        hidePhoto();
        $(this).delay(200, function() { $("#photoitself").attr({ src: "http://www.swiss-white.ch/img/2-6-2.jpg" }) });
        $(this).delay(500, function() { showPhoto() });
    });

    $("#2-6-3").click(function(event) {
        hidePhoto();
        $(this).delay(200, function() { $("#photoitself").attr({ src: "http://www.swiss-white.ch/img/2-6-3.jpg" }) });
        $(this).delay(500, function() { showPhoto() });
    });

    $("#2-6-4").click(function(event) {
        hidePhoto();
        $(this).delay(200, function() { $("#photoitself").attr({ src: "http://www.swiss-white.ch/img/2-6-4.jpg" }) });
        $(this).delay(500, function() { showPhoto() });
    });

    $("#2-8-1").click(function(event) {
        hidePhoto();
        $(this).delay(200, function() { $("#photoitself").attr({ src: "http://www.swiss-white.ch/img/2-8-1.jpg" }) });
        $(this).delay(500, function() { showPhoto() });
    });

    $("#2-9-1").click(function(event) {
        hidePhoto();
        $(this).delay(200, function() { $("#photoitself").attr({ src: "http://www.swiss-white.ch/img/2-9-1.jpg" }) });
        $(this).delay(500, function() { showPhoto() });
    });

    $("#2-9-2").click(function(event) {
        hidePhoto();
        $(this).delay(200, function() { $("#photoitself").attr({ src: "http://www.swiss-white.ch/img/2-9-2.jpg" }) });
        $(this).delay(500, function() { showPhoto() });
    });

    $("#3-1-1").click(function(event) {
        hidePhoto();
        $(this).delay(200, function() { $("#photoitself").attr({ src: "http://www.swiss-white.ch/img/3-1-1.jpg" }) });
        $(this).delay(500, function() { showPhoto() });
    });

    $("#1-2-1").click(function(event) {
        hidePhoto();
        $(this).delay(200, function() { $("#photoitself").attr({ src: "http://www.swiss-white.ch/img/1-2-1.jpg" }) });
        $(this).delay(500, function() { showPhoto() });
    });

    $("#1-2-2").click(function(event) {
        hidePhoto();
        $(this).delay(200, function() { $("#photoitself").attr({ src: "http://www.swiss-white.ch/img/1-2-2.jpg" }) });
        $(this).delay(500, function() { showPhoto() });
    });
    $("#1-2-3").click(function(event) {
        hidePhoto();
        $(this).delay(200, function() { $("#photoitself").attr({ src: "http://www.swiss-white.ch/img/1-2-3.jpg" }) });
        $(this).delay(500, function() { showPhoto() });
    });

    $("#1-3-1").click(function(event) {
        hidePhoto();
        $(this).delay(200, function() { $("#photoitself").attr({ src: "http://www.swiss-white.ch/img/1-3-1.jpg" }) });
        $(this).delay(500, function() { showPhoto() });
    });
    $("#1-3-2").click(function(event) {
        hidePhoto();
        $(this).delay(200, function() { $("#photoitself").attr({ src: "http://www.swiss-white.ch/img/1-3-2.jpg" }) });
        $(this).delay(500, function() { showPhoto() });
    });


    function backgr1() {
        $("#mainback2")
                .animate({ height: "0px" }, "fast")
        $("#mainback3")
                .animate({ height: "0px" }, "fast")
        $("#mainback")
                .animate({ height: "433px" }, "slow")
    }


    function backgr2() {
        $("#mainback")
                .animate({ height: "0px" }, "fast")
        $("#mainback3")
                .animate({ height: "0px" }, "fast")
        $("#mainback2")
                .animate({ height: "433px" }, "slow")
    }


    function backgr3() {
        $("#mainback")
                .animate({ height: "0px" }, "fast")
        $("#mainback2")
                .animate({ height: "0px" }, "fast")
        $("#mainback3")
                .animate({ height: "433px" }, "slow")
    }

    $("#mintext").click(function(event) {
        $("#textBack")
           .animate({ height: "0px", width: "0px" }, "fast")
    });

    $("#navsmall1a").click(function(event) {
        backgr1();
        hideTexts();
        $("#tt1")
             .animate({ opacity: "show" }, "slow");
        $(this).delay(410, function() { $("#guts").animate({ opacity: "show" }, "slow") });
    });
    $("#navsmall1b").click(function(event) {
        backgr1();
        hideTexts();
        $("#tt2")
             .animate({ opacity: "show" }, "slow");
        $(this).delay(410, function() { $("#guts").animate({ opacity: "show" }, "slow") });
    });
    $("#navsmall1c").click(function(event) {
        backgr1();
        hideTexts();
        $("#tt3")
             .animate({ opacity: "show" }, "slow");
        $(this).delay(410, function() { $("#guts").animate({ opacity: "show" }, "slow") });
    });
    $("#navsmall1d").click(function(event) {
        backgr1();
        hideTexts();
        $("#tt4")
             .animate({ opacity: "show" }, "slow");
        $(this).delay(410, function() { $("#guts").animate({ opacity: "show" }, "slow") });
    });


    $("#navsmall2a").click(function(event) {
        backgr2();
        hideTexts();
        $("#ttb1")
             .animate({ opacity: "show" }, "slow");
        $(this).delay(410, function() { $("#guts").animate({ opacity: "show" }, "slow") });
    });
    $("#navsmall2b").click(function(event) {
        backgr2();
        hideTexts();
        $("#ttb2")
             .animate({ opacity: "show" }, "slow");
        $(this).delay(410, function() { $("#guts").animate({ opacity: "show" }, "slow") });
    });
    $("#navsmall2c").click(function(event) {
        backgr2();
        hideTexts();
        $("#ttb3")
             .animate({ opacity: "show" }, "slow");
        $(this).delay(410, function() { $("#guts").animate({ opacity: "show" }, "slow") });
    });
    $("#navsmall2d").click(function(event) {
        backgr2();
        hideTexts();
        $("#ttb4")
             .animate({ opacity: "show" }, "slow");
        $(this).delay(410, function() { $("#guts").animate({ opacity: "show" }, "slow") });
    });
    $("#navsmall2e").click(function(event) {
        backgr2();
        hideTexts();
        $("#ttb5")
             .animate({ opacity: "show" }, "slow");
        $(this).delay(410, function() { $("#guts").animate({ opacity: "show" }, "slow") });
    });
    $("#navsmall2f").click(function(event) {
        backgr2();
        hideTexts();
        $("#ttb6")
             .animate({ opacity: "show" }, "slow");
        $(this).delay(410, function() { $("#guts").animate({ opacity: "show" }, "slow") });
    });
    $("#navsmall2g").click(function(event) {
        backgr2();
        hideTexts();
        $("#ttb7")
             .animate({ opacity: "show" }, "slow");
        $(this).delay(410, function() { $("#guts").animate({ opacity: "show" }, "slow") });
    });
    $("#navsmall2h").click(function(event) {
        backgr2();
        hideTexts();
        $("#ttb8")
             .animate({ opacity: "show" }, "slow");
        $(this).delay(410, function() { $("#guts").animate({ opacity: "show" }, "slow") });
    });
    $("#navsmall2i").click(function(event) {
        backgr2();
        hideTexts();
        $("#ttb9")
             .animate({ opacity: "show" }, "slow");
        $(this).delay(410, function() { $("#guts").animate({ opacity: "show" }, "slow") });
    });
    $("#navsmall2j").click(function(event) {
        backgr2();
        hideTexts();
        $("#ttb10")
             .animate({ opacity: "show" }, "slow");
        $(this).delay(410, function() { $("#guts").animate({ opacity: "show" }, "slow") });
    });


    $("#navsmall3a").click(function(event) {
        backgr3();
        hideTexts();
        $("#ttc1")
             .animate({ opacity: "show" }, "slow");
        $(this).delay(410, function() { $("#guts").animate({ opacity: "show" }, "slow") });
    });
    $("#navsmall3b").click(function(event) {
        backgr3();
        hideTexts();
        $("#ttc2")
             .animate({ opacity: "show" }, "slow");
        $(this).delay(410, function() { $("#guts").animate({ opacity: "show" }, "slow") });
    });
    $("#navsmall3c").click(function(event) {
        backgr3();
        hideTexts();
        $("#ttc3")
             .animate({ opacity: "show" }, "slow");
        $(this).delay(410, function() { $("#guts").animate({ opacity: "show" }, "slow") });
    });


    $("#navsmall4a").click(function(event) {
        backgr1();
        hideTexts();
        $("#ttd1")
             .animate({ opacity: "show" }, "slow");
        $(this).delay(410, function() { $("#guts").animate({ opacity: "show" }, "slow") });
    });
    $("#navsmall4b").click(function(event) {
        backgr1();
        hideTexts();
        $("#ttd2")
             .animate({ opacity: "show" }, "slow");
        $(this).delay(410, function() { $("#guts").animate({ opacity: "show" }, "slow") });
    });
    $("#navsmall4c").click(function(event) {
        backgr1();
        hideTexts();
        $("#ttd3")
             .animate({ opacity: "show" }, "slow");
        $(this).delay(410, function() { $("#guts").animate({ opacity: "show" }, "slow") });
    });
    $("#navsmall4d").click(function(event) {
        backgr1();
        hideTexts();
        $("#ttd4")
             .animate({ opacity: "show" }, "slow");
        $(this).delay(410, function() { $("#guts").animate({ opacity: "show" }, "slow") });
    });
    $("#navsmall4e").click(function(event) {
        backgr1();
        hideTexts();
        $("#ttd5")
             .animate({ opacity: "show" }, "slow");
        $(this).delay(410, function() { $("#guts").animate({ opacity: "show" }, "slow") });
    });
    $("#navsmall4f").click(function(event) {
        backgr1();
        hideTexts();
        $("#ttd6")
             .animate({ opacity: "show" }, "slow");
        $(this).delay(410, function() { $("#guts").animate({ opacity: "show" }, "slow") });
    });


    $(".contw").click(function (event) {
        $("#AutostartVideo")
            .animate({ height: "0px", width: "0px" }, "fast");
        $(this).delay(500, function () {
            var v2 = document.getElementsByTagName('embed')[1];
            if (!(typeof (v2) == "undefined")) { v2.parentNode.removeChild(v2); }
        });
        $(".kontakt")
            .animate({ height: "0px", width: "0px" }, "fast");
        $(".warumc")
            .animate({ height: "268", width: "350" }, "fast");
    });
    $(".warumc").click(function(event) {
        $(".warumc")
            .animate({ height: "0", width: "0" }, "fast");
    });


    $("#closek").click(function(event) {
        $(".kontakt")
            .animate({ height: "0", width: "0" }, "fast");
    });


    $("#plus").click(function (event) {
        $("#AutostartVideo")
            .animate({ height: "0px", width: "0px" }, "fast");
        $(this).delay(500, function () {
            var v2 = document.getElementsByTagName('embed')[1];
            if (!(typeof (v2) == "undefined")) { v2.parentNode.removeChild(v2); }
        });
        $(".warumc")
            .animate({ height: "0", width: "0" }, "fast");
        $(".kontakt")
            .animate({ height: "268px", width: "350px" }, "fast");
    });

    $(".aboutus").click(function (event) {
        backgr3();
        $("#AutostartVideo")
            .animate({ height: "0px", width: "0px" }, "fast");
        $(this).delay(500, function () {
            var v2 = document.getElementsByTagName('embed')[1];
            if (!(typeof (v2) == "undefined")) { v2.parentNode.removeChild(v2); }
        });
        $(".warumc")
            .animate({ height: "0", width: "0" }, "fast");
        hideTexts();
        $(".kontakt")
            .animate({ height: "268px", width: "350px" }, "fast");
        $("#ttk2")
             .animate({ opacity: "show" }, "slow");
    });

    $(".einladungsbrief").click(function(event) {
        backgr3();
        hideTexts();
        $("#ttk1")
             .animate({ opacity: "show" }, "slow");
    });

    $(".mailsender").click(function(event) {
        backgr3();
        hideTexts();
        $("#ttk2")
             .animate({ opacity: "show" }, "slow");
    });

    $("#closeautostart").click(function (event) {
        $("#AutostartVideo")
            .animate({ height: "0px", width: "0px" }, "fast");
        $(this).delay(500, function () {
            var v2 = document.getElementsByTagName('embed')[1];
            if (!(typeof (v2) == "undefined")) { v2.parentNode.removeChild(v2); }
        });
    });

});
