/* Cufon */
//Cufon.replace('.cufon',{hover: true});


/**
 * DOM Load
 */
$(document).ready(function() {
	pageEnhance();
	if($.browser.msie && $.browser.version<=6) {
		DD_belatedPNG.fix('img');
	}
});

/**
 * General "init" function for progressively enhancing the page on DOM load
 */
function pageEnhance() {
	newWindowLinks();
	clickable();
	defaultText();
	publicationRoll();
}


/* 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);
     	}
	 });
}


/* Clickable blocks */
function clickable() {
	$(".clickable:has(a):not(.disabled)").live("click",function() {
		var link = $("a",this).eq(0).attr("href");
		window.location = link;
	}).hover(function(){
		if(!$(this).hasClass("disabled")) {
			$(this).addClass("hover").css({"cursor":"pointer"});
		}
	},function(){
		$(this).removeClass("hover").css({"cursor":"default"});
	})
}


/**
 * animate page to a #elementid
 */
function inPageLinksScrollTo() {
	$(".scrollTo").click(function(){
		var href 	= $(this).attr("href");
		var	target	= $(href);
		if(target.size()>0) {
			var offset 	= target.offset()
			$('html,body').animate({scrollTop:offset.top},1000)
			return false;
		} else {
			return true;
		}
	})
}


/**	
 * Target new windows
 */
function newWindowLinks(){
	$('a[rel=external]').live("click",function(){
		window.open($(this).attr('href'));
		return false;
	});
}


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

/*  */
function publicationRoll() {
	$(".publicationLarge,.publicationArchive").hover(function(){
		$(".hover",this).remove()
		$(this).css({zIndex:"10000"})
		var html = $('<div class="hover">' + $(this).html() + '</div>');	
		$(this).prepend(html);
		html.show();
	},function(){
		$(".hover",this).remove()
		$(this).css({zIndex:"1"})
	}) 
}
