$(document).ready(function(){
    /***************************************************************
     * 			Function for the top navigation flyouts
     ***************************************************************/
    $("#topnav").children("li").children("a").hoverIntent(function(){
        //Over state
        //Hide all flyboxes that's visible for some reason
        $(".flyBox:visible").slideUp();
        
        $(this).parent().find(".flyBox").slideDown();
    }, function(){
        //Out state
        //Get coords and size of the flyout element and hide if mouse goes out of bounds.
        var fly_el = $(this).parent().find(".flyBox");
        
        var xl = fly_el.offset().left;
        var xr = xl + fly_el.width();
        var yt = fly_el.offset().top - 2;
        var yb = yt + fly_el.height();
        
        $(document).bind("mousemove", function(e){
        
            if (!(((xr > e.pageX) && (e.pageX > xl)) &&
            ((yb > e.pageY) && (e.pageY > yt)))) {
                fly_el.slideUp();
                $(document).unbind("mousemove");
            }
        });
    });
    
	$.fn.preloadImages = function(){
        return this.each(function(){ // "this" is the jQuery object
            $('<img/>')[0].src = this; // "this" is the value in the array
        });
    };
	
    $(window).load(function(){
        $([	'/assets/images/topright_home_green.jpg','/assets/images/topright_contact_green.jpg']).preloadImages();
    });

	
	
	
});

