/***********************************************
***  BUTTON ROLLOVER & PRELOAD  ****************
************************************************/

$(function(){
	// button rollover
	if ($('.imgBtn') != null) {
		$('.imgBtn').hover(function(){
				if(!$(this).is('.disabled'))
					$(this).attr("src", $(this).attr("src").replace(/^(.*?)(?:-hover)?(\..*?)$/i,'$1-hover$2'));
			},
			function(){
					if(!$(this).is('.disabled'))
						$(this).attr("src", $(this).attr("src").replace(/^(.*)-hover(\..*?)$/i, '$1$2'));
				});
	}
	// preload image rollovers
	if ($("img.imgBtn, img[src^='images/buttons/btn'], input[src^='images/buttons/btn']") != null) {
	    $("img.imgBtn, img[src^='images/buttons/btn'], input[src^='images/buttons/btn']").each(function(){
			    $("<img>").attr("src", $(this).attr("src").replace(/(btn-.*)(\..*?)/i, '$1-hover$2'));
		    });
	}
});

/***********************************************
***  EXTERNAL LINKS  ***************************
************************************************/

$(document).ready(function() {
	$("a[rel=external]").each(function() {
		$(this).addClass('external');
		$(this).attr({
			title: "Open this page in a new window",
			target: "_blank"
		});
	})
});


/***********************************************
***  COMPACT FORM (LABEL OVER INPUT)  **********
************************************************/

$(function(){
	$('.compactForm input, .compactForm select, .compactForm textarea').focus(function(){
			$('label[for=' + $(this).attr('id') + ']').hide();
		});
	$('.compactForm input, .compactForm select, .compactForm textarea').each(function(ele){
			if($(this).val().length > 0)
				$('label[for=' + $(this).attr('id') + ']').css({ display: "none" });
		});
	$('.compactForm input, .compactForm select, .compactForm textarea').blur(function(){
			if($(this).val().length == 0)
				$('label[for=' + $(this).attr('id') + ']').show();
		});
	$('.compactForm').removeClass('compactForm');
});




/***********************************************
***  CUFON  ***************************
************************************************/

$(function() {
	Cufon.replace('#header h1');
	Cufon.replace('#left h1');
	Cufon.replace('#left h2');
	Cufon.replace('#right h1');
   	Cufon.now();
});
