/*****************************************/
/* Name: 	common.js	   	*/
/* Author:	CJH		   	*/
/* Date:	21/05/2008	   	*/
/* Desc:	NTU common javascript	*/
/*		functions 		*/
/*****************************************/

// On document load
jQuery(function() {
	textResize();
	searchInput();
});


// Resize the screen text
function textResize() {
	jQuery("#userTextOptions span a").click(function() {
		var size = jQuery(this).attr("class");	

		switch (size) {
			case "textSizeLarge" :
				document.body.style.fontSize = "120%";
				break;
			case "textSizeMedium" :
				document.body.style.fontSize = "110%";
				break;
			default :
				document.body.style.fontSize = "100.1%";
				break;
		};
	});
}


// Show/hide the search help text
function searchInput() {
	var $search = jQuery("#siteSearchInput");
	var defaultText = "Search NTU...";

	// On losing focus, reset help text
	$search.blur(function() {
		if($search.val() == "")
			$search.val(defaultText);
	});

	// On gaining focus, hide help text
	$search.focus(function() {
		if($search.val() == defaultText)
			$search.val("");
	});	
}


// Redirect the user based on the option they selected in fast find 
function fastfindRedirect(obj) {
	window.location.href = obj.options[obj.selectedIndex].value;
}


/* Print window */
$(function() {
	$("#printLink").click(function() {
		window.print();
	});
});


/* Centre Pop Up */
function PopupCenter(pageURL, title,w,h) {
	var left = (screen.width/2)-(w/2);
	var top = (screen.height/2)-(h/2);
	var targetWin = window.open (pageURL, title, 'toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=no, resizable=no, copyhistory=no, 	width='+w+', height='+h+', top='+top+', left='+left);
}

