$(document).ready(function() {

	//Print current page
	$("#print").click(function() { window.print(); return false;} );	
	
	// Bookmark page
	$("#bookmark").click(function() {
		
		var url = location.href;
		var title = document.title;
		
		if (window.sidebar) {
			window.sidebar.addPanel(title, url,"");
		} else if( document.all ) {
			window.external.AddFavorite(url, title);
		} else if( window.opera && window.print ) {
			return true;
		}
		return false;						  
	});

	//Make all of the doc downloads/related links clickable
	$("#relatedLinks li").click( function() { 
		var link;
		link = $(this).find("a")
		if (link.attr("target")=="_blank") {
			window.open(link.attr("href"));
		}
		else {
			location.href=link.attr("href");
	    }
	    return false;
	} );	 

	
	$("#docDls li").click( function() { location.href=$(this).find("a").attr("href");} );	 

	$('a[rel*=facebox]').facebox();

});

//Cufon text replacement
Cufon.replace('h1', { fontFamily: 'Agenda' });
Cufon.replace('#mainNav a', { fontFamily: 'Agenda' });	
Cufon.replace('h2', { fontFamily: 'Lucida Grande' });	
Cufon.replace('h3', { fontFamily: 'Lucida Grande' });	
Cufon.replace('caption', { fontFamily: 'Lucida Grande' });	
Cufon.replace('a.button', { fontFamily: 'Lucida Grande' });	

$(window).load(function(){
//Equalize column heights again after window has loaded - compensating for increased height due to images
	var leftHeight = 0;
	var rightHeight = 0;
	
	leftHeight = $("#content").height();
	rightHeight = $("#rightNav").height();
	
	if (rightHeight > leftHeight) {
		$("#content").height(rightHeight);
	}
	
	if (leftHeight > rightHeight) {
		$("#rightNav").height(leftHeight);
	}
});


function replaceAll( str, from, to ) {
    var idx = str.indexOf( from );
    while ( idx > -1 ) {
        str = str.replace( from, to ); 
        idx = str.indexOf( from );
    }
    return str;
}

fetch_unix_timestamp = function()
{
	return parseInt(new Date().getTime().toString().substring(0, 10))
}