﻿

//document entry point
$(document).ready(function () {

    //hook-up home page nav effects
    $("#loop-stage div.section").hover(
        function () {
            $(this).addClass("hover");
            SetLoopSplitterState($(this), true);
        },

        function () {
            $(this).removeClass("hover");
            SetLoopSplitterState($(this), false);

        }
   );

    $("#loop-stage div.section").click(function () {
        document.location=$(this).find("a").attr("href");
    });
});


var SetLoopSplitterState = function (sectionEl, isHovered) {

    var elInfo = sectionEl.attr("rel").split(',');

    if (elInfo.length > 0) {

        var hoverLeftEl = null;

        try {
            hoverLeftEl = $("#" + elInfo[0]);
        }
        catch (e) { }


        var hoverRightEl = null;

        try {
            hoverRightEl = $("#" + elInfo[1]);
        }
        catch (e) { }

        if (isHovered) {
            if (hoverLeftEl != null) {
                hoverLeftEl.addClass("hover-left");
            }

            if (hoverRightEl != null) {
                hoverRightEl.addClass("hover-right");
            }
        }
        else {
            if (hoverLeftEl != null) {
                hoverLeftEl.removeClass("hover-left");
            }

            if (hoverRightEl != null) {
                hoverRightEl.removeClass("hover-right");
            }
        }
    }
}



/*

Copyright (c) 2009 Dimas Begunoff, http://www.farinspace.com

Licensed under the MIT license
http://en.wikipedia.org/wiki/MIT_License

*/

function imgpreload(a, b) { if (b instanceof Function) { b = { all: b} } if (typeof a == "string") { a = [a] } var c = []; var t = a.length; var i = 0; for (i; i < t; i++) { var d = new Image(); d.onload = function () { c.push(this); if (b.each instanceof Function) { b.each.call(this) } if (c.length >= t && b.all instanceof Function) { b.all.call(c) } }; d.src = a[i] } } if (typeof jQuery != "undefined") { (function ($) { $.imgpreload = imgpreload; $.fn.imgpreload = function (b) { b = $.extend({}, $.fn.imgpreload.defaults, (b instanceof Function) ? { all: b} : b); this.each(function () { var a = this; imgpreload($(this).attr('src'), function () { if (b.each instanceof Function) { b.each.call(a) } }) }); var c = []; this.each(function () { c.push($(this).attr('src')) }); var d = this; imgpreload(c, function () { if (b.all instanceof Function) { b.all.call(d) } }); return this }; $.fn.imgpreload.defaults = { each: null, all: null} })(jQuery) }

//preload loop hover images
$.imgpreload(['Content/images/loop-hover-rect-b.png', 'Content/images/loop-hover-rounded-br-b.png', 'Content/images/loop-hover-rounded-tr-b.png'],
{
    each: function () {
        // this = new image object
        // callback executes on every image load
    },
    all: function () {
        // this = array of new image objects
        // callback executes when all images are loaded
    }
}

);
