google.setOnLoadCallback(function() {
	$(document).ready(function() {	
		newWindowLinks();
		defaultText();
		clickable();
		$("#gallery a").lightbox({ fitToScreen: true });
		$(".datepicker").datepicker({ dateFormat: 'dd-mm-yy', changeMonth:true, changeYear:true, yearRange:"1950:2009" });		
	});	
});


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