google.setOnLoadCallback(function() {
	$(document).ready(function() {
		newWindowLinks();
		defaultText();
		clickable();		
		hero();	
	});	
});

/**	
 * Hero
 */
function hero() {
	var heroImage = $("#hero img")
	var loader = new Image();
	loader.onload = function() {			
		heroImage.hide().css({top:"0"}).fadeIn(1000);
	}
	loader.src = heroImage.attr("src");	
}


/**	
 * Target new windows
 */
function newWindowLinks(){
	$('a.pop').unbind('click').click(function(){
		window.open($(this).attr('href'));
		return false;
	});
}

/* Remove default value and replace */
function defaultText() {
	$(".defaultText").unbind("focus,blur").focus(function () {		
		if ($(this).val() == $(this)[0].defaultValue) {
        	$(this).val("");
        }
	 }).blur(function() {
        if ($(this).val() == "") {
        	$(this).val($(this)[0].defaultValue);
     	}
	 });
}

/* Make a whole box clickable */
function clickable() {
	$(".clickable:has(a)").css({"cursor":"pointer"}).unbind("click").click(function() {
		var link = $("a",this).eq(0).attr("href");
		window.location = link;
	}).hover(function(){
		$(this).addClass("hover");
	},function(){
		$(this).removeClass("hover");
	})
}

/* Un-obfuscate email */
function fnE(inarr) {
	inarr = inarr.split(",");
	var out = "";
	for(i=inarr.length-1;i>=0;i--) {
		out += inarr[i];
	}
	document.write('<a href="mailto:'+out+'">'+out+'</a>');	
}

