$(document).ready( function ()
{
	// Display PAGE FUNCTIONS
	$("#mailPrintFontTools").css("visibility","visible");
		
	// LHS NAVIGATION - add functionality to make the whole nav item block clickable
	$("#left_frame dt").hover(
		function(){
			if ( $("a",this).size()  ) {
				$(this).addClass("hover");		
				$("a",this).addClass("hover");		
			}
		},
		function(){
			if ( $("a",this).size()  ) {
				$(this).removeClass("hover");		
				$("a",this).removeClass("hover");		
			}									
		}
	); 
	
	$("#left_frame dt").click(
		function(){

		 	if ( $("a",this).size()  && $("a",this).attr("href").search("http://") == -1) {
				document.location.href = $("a",this).attr("href");		
			}
		}
	);
	
	// Enable PRINT/EMAIL features
	$("#menuTop #emailThisPage").click(function(){ //Email
												
		var SubjectLine=top.document.title;
		var BodyText='The sender of this link has forwarded the URL because of your interest in Asia Education website:\n\n'+top.document.location.href;
		
		location.href = "mailto:?SUBJECT="+escape(SubjectLine)+"&BODY="+escape(BodyText);								
	});
	$("#menuTop #printThisPage").click(function(){ //Print
		window.print();							
	});
	
	
	// VIDEOS - flashing arrow
	// NOTE: This works for audio and video in middle or RHS frame.
	// TODO: 0029 - STOP queueing of flashing PLAY buttons
	$(".videoAbstractImage a").hover(
	    function(){
	        $(this).stop().fadeTo('normal', 0.40).fadeTo('normal', 0.67).fadeTo('normal', 0.40).fadeTo('normal', 0.67);
	    },
	    function(){
	        $(this).stop().fadeTo('normal', 0.67);
	    }
	);
	
	// SEARCH box - display default text, remove when input field has the focus
	// TOP LHS SEARCH BOX
	var cSEARCH_DEFAULT_TEXT = "";
	
	$("#searchFieldLeft").focus
	(
		function()
		{
		 	if ($(this).attr("value") == cSEARCH_DEFAULT_TEXT)
		 	{
				$(this).attr("value","");
			}
		}
	);
	
	$("#searchFieldLeft").blur
	(
		function()
		{
		 	if (!$(this).attr("value"))
		 	{
				$(this).attr("value",cSEARCH_DEFAULT_TEXT);
			}
		}
	);
	// RHS CONTENT SEARCH BOX
	$("#searchFieldRight").focus
	(
		function()
		{
		 	if ($(this).attr("value") == cSEARCH_DEFAULT_TEXT)
		 	{
				$(this).attr("value","");
			}
		}
	);
	
	$("#searchFieldRight").blur
	(
		function()
		{
		 	if (!$(this).attr("value"))
		 	{
				$(this).attr("value",cSEARCH_DEFAULT_TEXT);
			}
		}
	);
	
	// SEARCH paging buttons - add hover effect
	$(".SearchSummaryBottom .SearchSummaryBottomItem").hover(
		function(){
			if ( $("a",this).size()  ) {
				$(this).addClass("hover");		
				$("a",this).addClass("hover");		
			}
		},
		function(){
			if ( $("a",this).size()  ) {
				$(this).removeClass("hover");		
				$("a",this).removeClass("hover");		
			}									
		}
	); 
	
	// Make whole button clickable
	$(".SearchSummaryBottom .SearchSummaryBottomItem").click(
		function(){
		 	if ( $("a",this).size()  && $("a",this).attr("href").search("http://") == -1) {
				document.location.href = $("a",this).attr("href");		
			}
		}
	);
	
	// Remove UNDERLINE and ADD CURSOR = HAND on paging links if JQuery is active
	$(".SearchSummaryBottom .SearchSummaryBottomItem").css("cursor","pointer").css("text-decoration","none");
	// Remove CURSOR = HAND on currently selected page link
	$(".SearchSummaryBottom .selected").css("cursor","default");
});
