// 
// functions and initialization 
//
var monthNames=new Array(
 "Jan","Feb","Mar","Apr","May","Jun",
 "Jul","Aug","Sep","Oct","Nov","Dec");
// returns a quote based on todays date
function todaysQuote(){ 
	var d=new Date();
	var dInDays = Math.floor(d.getTime()/(1000*60*60*24));
	return ( quotes[ dInDays%(quotes.length)]);
}
// returns a random quote
function todaysRandomQuote(){ 
	var r= Math.floor(Math.random()*1000);
	var n=quotes.length;
	return (r%n );	
}
// returns todays date in text format (client-side)
function todaysDate(){ 
	var d=new Date();
	return ( monthNames[d.getMonth()] + " " + d.getDate() + ", " + d.getFullYear());
}

// set behaviours once the DOM is ready
$(document).ready(function(){
						   
// update rinpoche quote --------------------------------------------------------------
		var qn = todaysRandomQuote();
		$("#qod").html("As we live our lives, we should learn that "+quotes[qn]); 
		$("#quoteNumber").html('#'+qn);	
		
// install an iframe at the end of the right hand column ------------------------------
// NOTE: THE LOADED CODE WILL NOT BE BOUND TO BEHAVIOURS 
		$("#sidebar:not(:has('div#recentnews'))").append('<div id="recentnews"></div>');
		$("#sidebar #recentnews").load('recentnewsmaster.html div#recentnews');	
		
// create behaviour to popup window for .popup links-----------------------------------
		$('a.popup, a.popup800x700').click(function(){ 
				window.open(this.href, 
				'_blank',
				'scrollbars=yes,resizable=yes,width=800,height=700');
				return false;
		});
		
// create behaviour to popup window for .popupmovie links ----------------------------------
		$('a.popupmovie').click(function(){ 
				window.open(this.href, 
				'_blank',
				'scrollbars=yes,resizable=yes,width=400,height=350');
				return false;
		});
		
// clear initial values for text field if they are chosen and darken text color--------
		$('input[@type=text]').focus(function(){ 
				$(this).attr("value","").css("color","#000000");
		});
		
// change opacity of any image links when they are hovered over------------------------
		$('a img').hover(
				function(){ $(this).css('opacity', 0.5);}, 
				function(){$(this).css('opacity', 1.0);}
				);
// add sfHover class to hovered navbar items in first ul ... NEEDED FOR IE6 BEHAVIOR
		$('ul#nav>li').hover(
				function(){ $(this).addClass('sfHover');}, 
				function(){$(this).removeClass('sfHover');}
				);
		
});// end of document ready