//
//  jQuery IE Fade Fix
//
//  Adapted from code found at http://jquery.malsup.com/fadetest.html.
//
//
(function($) {
    $.fn.fadeIn = function(speed, callback) {
        return this.animate({opacity: 'show'}, speed, function() {
                if ( $.browser.msie )
                {
                        this.style.removeAttribute('filter');
                }
                if ( $.isFunction(callback) )
                {
                        callback.call(this);
                }
        });
    };

    $.fn.fadeOut = function(speed, callback) {
        return this.animate({opacity: 'hide'}, speed, function() {
                if ( $.browser.msie )
                {
                        this.style.removeAttribute('filter');
                }
                if ( $.isFunction(callback) )
                {
                        callback.call(this);
                }
        });
    };

    $.fn.fadeTo = function(speed, to, callback) {
        return this.animate({opacity: to}, speed, function() {
                if ( to == 1 && $.browser.msie )
                {
                        this.style.removeAttribute('filter');
                }
                if ( $.isFunction(callback) )
                {
                        callback.call(this);
                }
        });
    };
})(jQuery);

if (navigator.userAgent.toLowerCase().indexOf('chrome') > -1)
{
     var chromeCss = document.createElement("link");

     chromeCss.rel = "stylesheet";
     chromeCss.href = "css/chromeStyles.css";

     document.getElementsByTagName("head")[0].appendChild(chromeCss);
}

// document ready
// this function runs at initial page load completion and sets all persistent elements
$(window).bind("load",function(){

	// main navigation
	$("#nav a.ajax-nav").ajaxNav();

	// home page animation
	$("#image-gallery div").gallerize();
	
	// home page messaging
	$("#message-gallery img").delay(messageStartDelay).messaging();

	// pagination bindings
	$("#pagination a").paginationControls();

	// get content from label/subLabel
	loadContent();
	
});
