﻿/***

Blueroom V4 academy js
2008 www.aislondon.com
Alasdair McLeay
Toby Brancher
Marvin Barretto

***/

$(function() {
$("ul.global-sub-nav li.first").hover(function() {
	 $(".sub-nav").css({'display':"block"});
	 $(".sub-nav ul").css({'display':"block"});	 
	 }, function() {
	 $(".sub-nav").css({'display':"none"});
	 $(".sub-nav ul").css({'display':"none"});
	 }); 
});
(function($) {


    $.blueroom = $.blueroom || {};
    
    var g_ready = false;
    var g_self = this;

    $.fn.preferences = function() {
        return this.each(function() {
            //alert("API method called on " + this);
        });
    };

    $.blueroom.academy = function(options) {
        var c_self = this;
        var c_ready = false;
        c_self.options = $.extend({}, $.blueroom.academy.defaults, options);

        c_self.functions = {
            interval: function() {
                c_self.functions.debuglog("interval event");
                setTimeout(c_self.functions.interval, c_self.options.intervalFrequency);
            },
            initialise: function(context) {
                context.each(function(index) {

                    var currentContext = $(this);
                    
                    c_self.functions.setupScrollWindow()
                });

            },
            setupScrollWindow: function(){
				var totalLIHeight = 0;
				$('#priority-tickets ol li').each(function(){
					totalLIHeight += $(this).height();
				})
				
				if(totalLIHeight >= 434) {
					$('#priority-tickets ol').css('height', '434px');
				}
            },
            preload: function() {
                c_self.functions.debuglog("preload");
                c_self.functions.preloadImages(/*insert array of images here*/);
            },
            preloadImages: function() {
                for (var i = 0; i < arguments.length; i++) {
                    $("<img>").attr("src", arguments[i]);
                }
            },
            debuglog: function(logtext) {
                try {
                    if (console && console.log) {
                        console.log(logtext);
                    }
                }
                catch (err) {
                    //alert(err);
                }
            }
        };

        c_self.functions.initialise($("body"));
        c_ready = true;
    };

    // defaults
    $.blueroom.academy.defaults = {
        //TODO:
        easing: "quad",
        animationSpeed: "1000",
        intervalFrequency: "10000"
    };
  
   

    // optional - initialise one or more instances of the class
    $(document).ready(function() {
        new $.blueroom.academy();
    });
})(jQuery);