$(document).ready(function(){
						   
	/*
	---------------------------------------	
	First, let's add layout elements.
	These elements are not present on the actual code as they are
	redundant and their only purpose is to help with presentation
	---------------------------------------
	*/

	var theContent = $("p#slogan").html();							
	$("p#slogan").replaceWith('<h3 id="slogan">'+theContent+'</h3>');
	// main column corner divs
		if(!$.browser.msie){
			$("div#main-col").before('<div id="main-col-top"></div>').after('<div id="main-col-bottom"></div>');
		}
	// right column corner divs
	$("div#right-col").prepend('<div id="grader"></div>');
	$("div.cornerme").before('<div class="right-col-top"></div>').after('<div class="right-col-bottom"></div>');
	
	/*
	---------------------------------------	
	Second, Calculate the positions of the elements  that are
	dependent on window width: the green background and the
	right column boxes.
	---------------------------------------	
	*/
	
	$(this).calculatePositions();
	

	/*
	---------------------------------------
	Third, sIFR replacements
	---------------------------------------	
	*/
	
	$.sifr({path:'flash'});
	$('h1,h2').sifr({
		font:'neosans'
	});
	$('h3').sifr({
		font:'neosanslight'
	});
	$('h3#slogan').sifr({
		font:'neosansmediumitalic',
		textAlign: 'right'
	});



	/*
	---------------------------------------
	Fourth, scrolling functions. These control the menu's smooth scrolling
	and the picture gallery
	---------------------------------------
	*/
	
	//menu, shows how to scroll the whole window
	$('#menu a').click(function(){//$.scrollTo works EXACTLY the same way, but scrolls the whole screen
		$.scrollTo( this.hash, 1500, {duration:3000});
		$(this.hash).find('span.message').text( this.title );
		return false;
	});
	
	$('#slideshow').serialScroll({
		items:'li',
		prev:'#gallery a.prev',
		next:'#gallery a.next',
		offset:-15, //when scrolling to photo, stop 230 before reaching it (from the left)
		start:0, //as we are centering it, start at the 2nd
		duration:1200,
		force:true,
		stop:true,
		lock:false,
		cycle:false, //don't pull back once you reach the end
		easing:'easeOutQuart', //use this easing equation for a funny effect
		jump: true //click on the images to scroll to them
	});



	/*
	---------------------------------------
	Fifth, Fancybox for the videos.
	---------------------------------------
	*/	
		
	$('#videos a').fancybox({
		'frameWidth':  430,	
		'frameHeight': 349,
		'zoomSpeedIn': 50,
		'zoomSpeedOut':	50
	 });
	
	
	/*
	---------------------------------------
	Sixth, add selected classes to the menu
	---------------------------------------
	*/
	
	$("div#menu ul li#m_home a").addClass("selected"); // on load, the home is selected
	
	$("div#menu ul li a").click(function () { 
		$("div#menu ul li a").removeClass("selected"); // first, remove all other selected items
		$(this).addClass("selected"); // *now* we can add the class
	});

		
		
});



/*
---------------------------------------
Recalculate the position of the elements  that are
dependent on window width, so if the user resizes, they'll
be correctly located
---------------------------------------
*/

$(window).resize(function(){
	$(this).calculatePositions();
});
