jQuery.fn.delay = function(time,func){
	this.each(function(){
		setTimeout(func,time);
	});
	
	return this;
};

function imgCache() {
	var d=document;
	if(d.images) { 
		if(!d.MM_p) d.MM_p=new Array();
		var i,j=d.MM_p.length,a=imgCache.arguments; for(i=0; i<a.length; i++)
		if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}
	}
}


/* Cursor mod for Firefox */
$(document).ready(function () {
	$('a').mouseenter(function () {
		$(this).css('cursor','pointer');
	});
});

$(document).ready(function () {
	$('.hand_cursor').mouseenter(function () {
		$(this).css('cursor','pointer');
	});
});


/* Wipeout search box on focus */
$(document).ready(function () {
	var already_focused = 0;
	$('#site_search_terms').focus(function () {
		if (already_focused == 0) {
			$(this).attr('value','');
		}
		already_focused = 1;	
	});
});


/* Highlight fields in inline forms */
$(document).ready(function () {
	$('.inf').focus(function () {
		$(this).addClass('inf-on');
	});
	$('.inf').blur(function () {
		$(this).removeClass('inf-on');
	});
});



/****************************/
/* Site-specific functions: */
/****************************/


/* Cache the hover state images */

$(document).ready(function () {
	imgCache(
		'/fb_site/images/mn-01-b.png',
		'/fb_site/images/mn-02-b.png',
		'/fb_site/images/mn-03-b.png',
		'/fb_site/images/mn-04-b.png',
		'/fb_site/images/mn-05-b.png'
	);
});


/* Main navigation hover states */

$(document).ready(function () {

	$('#mn_01').mouseenter(function () {
		$(this).addClass('mn_01_on');
		$(this).children('div').show();
	});
	$('#mn_01').mouseleave(function () {
		$(this).removeClass('mn_01_on');
		$(this).children('div').hide();
	});

	$('#mn_02').mouseenter(function () {
		$(this).addClass('mn_02_on');
		$(this).children('div').show();
	});
	$('#mn_02').mouseleave(function () {
		$(this).removeClass('mn_02_on');
		$(this).children('div').hide();
	});

	$('#mn_03').mouseenter(function () {
		$(this).addClass('mn_03_on');
		$(this).children('div').show();
	});
	$('#mn_03').mouseleave(function () {
		$(this).removeClass('mn_03_on');
		$(this).children('div').hide();
	});

	$('#mn_04').mouseenter(function () {
		$(this).addClass('mn_04_on');
		$(this).children('div').show();
	});
	$('#mn_04').mouseleave(function () {
		$(this).removeClass('mn_04_on');
		$(this).children('div').hide();
	});

	$('#mn_05').mouseenter(function () {
		$(this).addClass('mn_05_on');
		$(this).children('div').show();
	});
	$('#mn_05').mouseleave(function () {
		$(this).removeClass('mn_05_on');
		$(this).children('div').hide();
	});

});


/* Wipeout newsletter opt-in box on focus */

$(document).ready(function () {
	var already_focused_b = 0;
	$('#sb_newsletter_inpt').focus(function () {
		if (already_focused_b == 0) {
			$(this).attr('value','');
		}
		already_focused_b = 1;	
	});
});


