﻿// Load jQuery gallery 

$(document).ready(function() {


    $(".gallerybg").animate({ opacity: 0 });

    $("div.logo").click(function() {
        window.location = "..";
    });

    /////////////////////////////////////////////////////
    // Gallery Events
    /////////////////////////////////////////////////////

    // Contact & info event
    $(".infoBtn").toggle(
				    function() { infoBoxIn() },
				    function() { infoBoxOut() }
	    );
    // Nav & thumbnail menu event
    $(".menubtn").toggle(
				    function() { navMenuIn() },
				    function() { navMenuOut() }
	    );

    /////////////////////////////////////////////////////
    // Gallery Functions
    /////////////////////////////////////////////////////

    // Show/hide navmenu
    function navMenuIn() {
        if ($('.infotext').is(':visible')) {
            infoBoxOut(); // hide info box
        };
        $(".menubtn img").tipsy("hide");
        $(".navbgcon").fadeIn(1000);
        $(".navmenu").fadeIn(1000);
        $(".menubtn img").css({ opacity: 0.5 });
    }

    function navMenuOut() {
        $(".navbgcon").fadeOut(500);
        $(".navmenu").fadeOut(500);
        $(".menubtn img").css({ opacity: 1 })
    }


    // Show/hide infobox layer 
    function infoBoxIn() {

        if ($('.navmenu').is(':visible')) {
            navMenuOut(); // hide nav menu when opened
            //alert('true');
        };

        $(".infotext").fadeIn(2500);
        $(".infobox").animate({
            width: "400px",
            height: "280px"
        }, 1000);
        $(".infoBtn").animate({
            bottom: "6px",
            left: "6px"
        }, 1000);
    }

    function infoBoxOut() {
        $(".infotext").fadeOut(400);
        $(".infobox").animate({
            width: "36px",
            height: "36px"
        }, 1000);
        $(".infoBtn").animate({
            bottom: "0px",
            left: "0px"
        }, 1000);
    }

    // Set tool tip event
    //		$('.menubtn').live('mouseover mouseout', function(event) {
    //		  if (event.type == 'mouseover') {
    //			  if ($(".navmenu").is(':hidden')){
    //				  $(".menubtn img").tipsy("show"); return false;
    //			  }
    //		  } else {
    //			$(".menubtn img").tipsy("hide"); return false;
    //		  }
    //		});

    // tool tip style
    $('.menubtn img').tipsy({
        trigger: 'manual',
        gravity: 'e',
        fade: true,
        opacity: 0.5,
        delayIn: 500
    }
		    );
    $('.infoBtn').tipsy({
        trigger: 'manual',
        gravity: 'ne',
        fade: true,
        opacity: 0.5,
        delayIn: 500
    }
		    );

    var menuHover = {
        over: function() {
            if ($(".navmenu").is(':hidden')) {
                $(".menubtn img").tipsy("show"); return false;
            }
        },
        interval: 400,
        out: function() { $(".menubtn img").tipsy("hide"); return false; }
    };

    var infoHover = {
        over: function() {
            if ($(".infotext").is(':hidden')) {
                $(".infoBtn").tipsy("show"); return false;
            }
        },
        interval: 400,
        out: function() { $(".infoBtn").tipsy("hide"); return false; }
    };

    $(".menubtn img").hoverIntent(menuHover);

    $(".infoBtn").hoverIntent(infoHover);


});


