/**
* hoverIntent r5 // 2007.03.27 // jQuery 1.1.2+
* <http://cherne.net/brian/resources/jquery.hoverIntent.html>
* 
* @param  f  onMouseOver function || An object with configuration options
* @param  g  onMouseOut function  || Nothing (use configuration options object)
* @author    Brian Cherne <brian@cherne.net>
*/
(function($) { $.fn.hoverIntent = function(f, g) { var cfg = { sensitivity: 7, interval: 100, timeout: 0 }; cfg = $.extend(cfg, g ? { over: f, out: g} : f); var cX, cY, pX, pY; var track = function(ev) { cX = ev.pageX; cY = ev.pageY; }; var compare = function(ev, ob) { ob.hoverIntent_t = clearTimeout(ob.hoverIntent_t); if ((Math.abs(pX - cX) + Math.abs(pY - cY)) < cfg.sensitivity) { $(ob).unbind("mousemove", track); ob.hoverIntent_s = 1; return cfg.over.apply(ob, [ev]); } else { pX = cX; pY = cY; ob.hoverIntent_t = setTimeout(function() { compare(ev, ob); }, cfg.interval); } }; var delay = function(ev, ob) { ob.hoverIntent_t = clearTimeout(ob.hoverIntent_t); ob.hoverIntent_s = 0; return cfg.out.apply(ob, [ev]); }; var handleHover = function(e) { var p = (e.type == "mouseover" ? e.fromElement : e.toElement) || e.relatedTarget; while (p && p != this) { try { p = p.parentNode; } catch (e) { p = this; } } if (p == this) { return false; } var ev = jQuery.extend({}, e); var ob = this; if (ob.hoverIntent_t) { ob.hoverIntent_t = clearTimeout(ob.hoverIntent_t); } if (e.type == "mouseover") { pX = ev.pageX; pY = ev.pageY; $(ob).bind("mousemove", track); if (ob.hoverIntent_s != 1) { ob.hoverIntent_t = setTimeout(function() { compare(ev, ob); }, cfg.interval); } } else { $(ob).unbind("mousemove", track); if (ob.hoverIntent_s == 1) { ob.hoverIntent_t = setTimeout(function() { delay(ev, ob); }, cfg.timeout); } } }; return this.mouseover(handleHover).mouseout(handleHover); }; })(jQuery); (function($) {
    if (typeof (Tiga) == "undefined") Tiga = {};

    // Reference for Protected Function
    var page_controller_init;

    Tiga.PageController = function() {
        var current_page = -1,
		    pages = {},
			  $d = null,
			  $navigation = null,
			base = this;

        // Public Functions:
        this.add_page_transition = function(page, transition_in, transition_out, color) {
            var transition = {
                page: page,
                _in: transition_in ? transition_in : function(callback) { callback() },
                _out: transition_out ? transition_out : function(callback) { callback() },
                color: color
            };
            pages[page] = transition;
        };

        var $nav_a;

        // Protected Functions
        var init = function() {
            $d = $(document.body);
            $navigation = $("#navigation");

            $nav_a = $navigation.find("a");



            $nav_a.click(function(e) {
                /*
                var pages = location.href.split('#');
                if (pages.length > 1) {

                    pages = pages[1].split('/'); 
                if (pages.length > 2 && ('#/' + pages[1] == $(this).attr('href'))) {
                return false;
                }
                }*/

                $.History.setHash($(this).attr('href'));
                return false;
            });

            $navigation.find('li').click(function() {
                $(this).find('a').click();
            })
        };
        page_controller_init = init;

        // Private Functions

        this.changePage = function(page, callback) {
            if (page == current_page) return;

            $nav_a.removeClass('selected');
            $nav_a.eq(page - 1).addClass('selected');

            if (typeof (callback) != "function") callback = function() { };
            if (pages[page]) {
                hidePage(page, function() {
                    pages[page]._in(callback);
                });
                changeColor(pages[page].color, 1000);
            } else {
                hidePage(page, callback);
            }
        };

        var hidePage = function(new_page, callback) {
            if (pages[current_page]) {
                pages[current_page]._out(callback);
            } else {
                callback();
            }
            current_page = new_page;
        };

        var changeColor = function(color, speed) {
            $d.animate({ backgroundColor: color }, speed);
        };
    };

    Tiga.PageController = new Tiga.PageController();

    // Some of the init requires the DOM to be ready;
    $(function() { page_controller_init(); });

})(jQuery);



$.fn.prepStart = function(options) {
    var defaults = {
        visibility: 'visible',
        opacity: 0.0,
        zIndex: 1000,
        'filter': 'alpha(opacity=0)'
    };
    return this.stop(true).css($.extend(defaults, options));
};

$.fn.prepEnd = function(options) {
    var defaults = {
        opacity: 1.0,
        zIndex: 100,
        'filter': 'alpha(opacity=100)'
    };
    return this.stop(true).css($.extend(defaults, options));
};


Tiga.PageController.add_page_transition(1, function(callback) {
    $page1.prepStart().animate({ opacity: 1.0, top: 0 }, 500, "easeInOutQuint", function() {
        $(this).css({ 'filter': 'none' });
        callback();
    });

}, function(callback) {
    $page1.prepEnd().animate({ opacity: 0.0 }, 500, "easeInOutQuint", function() {
        $(this).css({ visibility: 'hidden' });
        callback();
    });
}, "#18597f");


Tiga.PageController.add_page_transition(2, function(callback) {
    $page2.prepStart().animate({ opacity: 1.0, top: 20 }, 500, "easeInOutQuint", function() {
        $(this).css({ 'filter': 'none' });
        callback();
    });
}, function(callback) {
    $page2.prepEnd().animate({ opacity: 0.0, top: -10 }, 500, "easeInOutQuint", function() {
        $(this).css({ visibility: 'hidden' });
        callback();
    });
}, "#A40029");




Tiga.PageController.add_page_transition(3, function(callback) {
    initHSWhoWeAre();
    $page3.prepStart().animate({ opacity: 1.0, top: 0 }, 500, "easeOutBounce", function() {
        $(this).css({ 'filter': 'none' });
        callback();
    });
}, function(callback) {

    $page3.prepEnd().animate({ opacity: 0.0, top: -200 }, 500, "easeInOutQuint", function() {
        $(this).css({ visibility: 'hidden' });
        callback();
    });
}, "#dc9d10");



Tiga.PageController.add_page_transition(4, function(callback) {
    initHSPortfolio();
    $page4.prepStart().animate({ opacity: 1.0 }, 500, "easeInQuint", function() {

        $(this).css({ 'filter': 'none', 'display': 'block' });
        callback();

    });
}, function(callback) {
    distroyPortfolioGalerry();
    $page4.prepEnd().animate({ opacity: 0.0 }, 500, "easeInOutQuint", function() {

        $(this).css({ visibility: 'hidden', 'display': 'none' });
        callback();
        $('#menu').animate({ top: 0 }, { queue: false, duration: 2500 });

    });
}, "#ACBA07");

Tiga.PageController.add_page_transition(5, function(callback) {
    $page5.prepStart().animate({ opacity: 1.0 }, 500, "easeInQuint", function() {
    $(this).css({ 'filter': 'none', top: 0 });
        callback();

    });
}, function(callback) {
    $page5.prepEnd().animate({ opacity: 0.0 }, 500, "easeOutQuint", function() {

    $(this).css({ 'visibility': 'hidden', top: -1400 });
        callback();

    });
}, "#851AE6");

Tiga.PageController.add_page_transition(6, function(callback) {
    $page6.prepStart().animate({ opacity: 1.0, top: 0 }, 800, "easeOutBounce", function() {
        $(this).css({ 'filter': 'none' });
        callback();
    });
}, function(callback) {
    $page6.prepEnd().animate({ opacity: 0.0, top: -1400 }, 500, "easeInOutQuint", function() {
        $(this).css({ visibility: 'hidden' });
        callback();
    });
}, "#C69E6F");

