

//Preload Images	
function preload(arrayOfImages) {
    $(arrayOfImages).each(function(){
        $('<img/>')[0].src = this;
        // Alternatively you could use:
        // (new Image()).src = this;
    });
}

// Usage:

preload([
    'images/homeb.png',
    'iimages/aboutb.png',
    'iimages/actingb.png',
	'images/modellingb.png',
    'iimages/aforumb,png',
    'iimages/talentb.png',
	'images/agentsb.png',
    'iimages/castingdirectorsb.png',
    'iimages/registerb.png'
]);


(function($){
	$('ul.descb').hide();
    markSelected($('a.catb[name=chosenb]'));
    
	var timeout;
	$timeout = 1; 

// hover on main menu
	$('a.catb').hover(function(e){
		unselectAll();
		clearTimeout(timeout);
		markSelected($(e.currentTarget));
		$("img", this).attr("src", $("img", this).attr("src").replace(".png", "b.png"));
		$("img", this).addClass("b");
		}, function(e){	
		timeout = setTimeout(function(){ $("ul.descb").hide() }, 500);
		$("img", this).attr("src", $("img", this).attr("src").replace("b.png", ".png"));
	});
	
	
// Hover on sub menu
	$('.descb').hover(function(e){
		clearTimeout(timeout);
		$("img.b").attr("src", $("img.b").attr("src").replace(".png", "b.png"));
		}, function(e){
		timeout = setTimeout(function(){ $("ul.descb").hide() }, 500);
		$("img.b").attr("src", $("img.b").attr("src").replace("b.png", ".png"));
	});

	$timeout;
	
	
		
	function markSelected(link){
		var next = $('.descb'+link.attr("name"));
		next.show();
		link.addClass("selected");
		
	}

	function unselectAll(){
		$('ul.descb').hide();
		$('a.catb').removeClass("selected");
		$('img').removeClass("b");
	}
	

	
})(jQuery);


