// JavaScript Document
$(document).ready(function(){

    if ($.browser.msie) {
        //alert( $.browser.version );
    }
    
    var blank = new Image();
    blank.src = '../blank.gif';
    
    var outObj;
    var inObj;
    
    $(document).ready(function(){
        var badBrowser = (/MSIE ((5\.5)|6|7|8)/.test(navigator.userAgent) && navigator.platform == "Win32");
        if (badBrowser) {
            outObj = {
                left: "-=400"
            };
            inObj = {
                left: "0"
            };
        }
        else {
            outObj = {
                left: "-=400",
                opacity: "0"
            };
            inObj = {
                left: "0",
                opacity: "1"
            };
        }
    });
    
    
    $('ul#homeslide').innerfade({
        speed: 1000,
        timeout: 5000,
        type: 'sequence',
        containerheight: '220px'
    });
    $('ul#aboutslide').innerfade({
        speed: 1000,
        timeout: 5000,
        type: 'sequence',
        containerheight: '220px'
    });
    $('ul#dinnerslide').innerfade({
        speed: 1000,
        timeout: 5000,
        type: 'sequence',
        containerheight: '220px'
    });
    $('ul#factsslide').innerfade({
        speed: 1000,
        timeout: 5000,
        type: 'sequence',
        containerheight: '220px'
    });
    $('ul#drinksslide').innerfade({
        speed: 1000,
        timeout: 5000,
        type: 'sequence',
        containerheight: '220px'
    });
    $('ul#newsslide').innerfade({
        speed: 1000,
        timeout: 5000,
        type: 'sequence',
        containerheight: '220px'
    });
	 $('ul#galleryslide').innerfade({
        speed: 1000,
        timeout: 5000,
        type: 'sequence',
        containerheight: '220px'
    });
    
    /*
     function fixPng(png) {
     // get src
     var src = png.src;
     // set width and height
     if (!png.style.width) { png.style.width = $(png).width(); }
     if (!png.style.height) { png.style.height = $(png).height(); }
     // replace by blank image
     png.onload = function() { };
     png.src = blank.src;
     // set filter (display original image)
     png.runtimeStyle.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + src + "',sizingMethod='scale')";
     }
     */
    $(window).load(function(){
    
        if ($.browser.msie && ($.browser.version.indexOf("6.") == 0 || $.browser.version.indexOf("7.") == 0)) {
            $("#backintro").css('top', '-2042px');
            $("#animation").css('display', 'none');
        }
        else {
            
            
            
                $(".frame1").stop().fadeIn(2000).fadeOut(2000, function(){
                    $(".frame2logo").fadeIn(1000, function(){
                        $("#backintro").animate({
                            "top": "-=2042px"
                        }, {
                            queue: true,
                            duration: 20000
                        });
                        $(".txt1").fadeIn(1800, function(){
                            $(".txt1").fadeOut(800);
                            $(".txt2").fadeIn(1800, function(){
                                $(".txt2").fadeOut(800);
                                $(".txt3").fadeIn(1800, function(){
                                    $(".txt3").fadeOut(800);
                                    $(".txt4").fadeIn(1800, function(){
                                        $(".txt4").fadeOut(800);
                                        $(".txt5").fadeIn(1800, function(){
                                            $(".frame2").fadeOut(2000, function(){
                                                $("#animation").css('display', 'none');
                                            });
                                        });
                                    });
                                });
                            });
                        });
                    });
                    
                });
            
            
            $('.skip').click(function(){
                $(".skip").css('display', 'none');
                $(".frame1").stop(true);
                $(".frame2logo").stop(true);
                $("#backintro").stop(true);
                $("#backintro").css('top', '-2042px');
                $("#animation").css('display', 'none');
                //console.log('click');
            });
            
            
        }
        
        $(".panel1").hide();
        $(".container1").css('display', 'block');
        $(".container1").animate({
            left: "0"
        }, 2000);
        $(".panel1").fadeIn(1000).show(0);
        
        $(".panel2").hide();
        $(".panel3").hide();
        $(".panel4").hide();
        $(".panel5").hide();
        $(".panel6").hide();
		$(".panel7").hide();
    });
    
    $('.home').click(function(){
    
        if ($(".container1").css('display') == 'block') 
            return false;
        for (var i = 2; i <= 7; i++) {
            if ($(".container" + i).css('display') == 'block') {
                $(".container" + i).stop();
                $(".container" + i).animate(outObj, 800, function(){
                    $(this).css('display', 'none');
                }).fadeOut(400);
                $(".panel" + i).fadeOut(400);
            }
        };
        /*
         $("#wrapper #content div:visible:first").stop();
         $("#wrapper #content div:visible:first").animate({
         left: "-=400",
         opacity: "0"
         }, 800, function(){
         $(this).css('display', 'none');
         }).fadeOut(400);
         */
        $(".panel1").hide();
        $(".container1").stop();
        $(".container1").css({
            'display': 'block',
            'left': '1300px'
        });
        $(".container1").animate(inObj, 2000);
        $(".panel1").stop();
        $(".panel1").fadeIn(1000)
        return false;
    });
    
    
    $('.about').click(function(){
        if ($(".container2").css('display') == 'block') 
            return false;
        for (var i = 1; i <= 7; i++) {
            if ($(".container" + i).css('display') == 'block' && i != 2) {
                $(".container" + i).stop();
                $(".container" + i).animate(outObj, 800, function(){
                    $(this).css('display', 'none');
                });
                $(".panel" + i).fadeOut(400);
            }
        };
        
        $(".panel2").hide();
        $(".container2").stop();
        $(".container2").css({
            'display': 'block',
            'left': '1300px'
        });
        $(".container2").animate(inObj, 2000);
        $(".panel2").stop();
        $(".panel2").fadeIn(1000)
        return false;
    });
    
    
    $('.facts').click(function(){
        if ($(".container3").css('display') == 'block') 
            return false;
        for (var i = 1; i <= 7; i++) {
            if ($(".container" + i).css('display') == 'block' && i != 3) {
                $(".container" + i).stop();
                $(".container" + i).animate(outObj, 800, function(){
                    $(this).css('display', 'none');
                });
                $(".panel" + i).fadeOut(400);
            }
        };
        
        $(".panel3").hide();
        $(".container3").stop();
        $(".container3").css({
            'display': 'block',
            'left': '1300px'
        });
        $(".container3").animate(inObj, 2000);
        $(".panel3").stop();
        $(".panel3").fadeIn(1000)
        return false;
        
    });
    
    $('.dinner').click(function(){
        if ($(".container4").css('display') == 'block') 
            return false;
        for (var i = 1; i <= 7; i++) {
            if ($(".container" + i).css('display') == 'block' && i != 4) {
                $(".container" + i).stop();
                $(".container" + i).animate(outObj, 800, function(){
                    $(this).css('display', 'none');
                });
                $(".panel" + i).fadeOut(400);
            }
        };
        
        $(".panel4").hide();
        $(".container4").stop();
        $(".container4").css({
            'display': 'block',
            'left': '1300px'
        });
        $(".container4").animate(inObj, 2000);
        $(".panel4").stop();
        $(".panel4").fadeIn(1000)
        return false;
    });
    
    $('.drinks').click(function(){
    
        if ($(".container5").css('display') == 'block') 
            return false;
        for (var i = 1; i <= 7; i++) {
            if ($(".container" + i).css('display') == 'block' && i != 5) {
                $(".container" + i).stop();
                $(".container" + i).animate(outObj, 800, function(){
                    $(this).css('display', 'none');
                });
                $(".panel" + i).fadeOut(400);
            }
        };
        
        $(".panel5").hide();
        $(".container5").stop();
        $(".container5").css({
            'display': 'block',
            'left': '1300px'
        });
        $(".container5").animate(inObj, 2000);
        $(".panel5").stop();
        $(".panel5").fadeIn(1000)
        return false;
    });
    
    $('.newsletter').click(function(){
    
        if ($(".container6").css('display') == 'block') 
            return false;
        for (var i = 1; i <= 7; i++) {
            if ($(".container" + i).css('display') == 'block') {
                $(".container" + i).stop();
                $(".container" + i).animate(outObj, 800, function(){
                    $(this).css('display', 'none');
                });
                $(".panel" + i).fadeOut(400);
            }
        };
        
        $(".panel6").hide();
        $(".container6").stop();
        $(".container6").css({
            'display': 'block',
            'left': '1300px'
        });
        $(".container6").animate(inObj, 2000);
        $(".panel6").stop();
        $(".panel6").fadeIn(1000)
        return false;
    });
    
      $('.gallery').click(function(){
    
        if ($(".container7").css('display') == 'block') 
            return false;
        for (var i = 1; i <= 7; i++) {
            if ($(".container" + i).css('display') == 'block') {
                $(".container" + i).stop();
                $(".container" + i).animate(outObj, 800, function(){
                    $(this).css('display', 'none');
                });
                $(".panel" + i).fadeOut(400);
            }
        };
        
        $(".panel7").hide();
        $(".container7").stop();
        $(".container7").css({
            'display': 'block',
            'left': '1300px'
        });
        $(".container7").animate(inObj, 2000);
        $(".panel7").stop();
        $(".panel7").fadeIn(1000)
        return false;
    });
    
});

