$(function() {
	
	//LAVA LAMP
	/*$(document).ready(function () {

			//transitions
			//for more transition, goto http://gsgd.co.uk/sandbox/jquery/easing/
			var style = 'easeOutElastic';

			//Retrieve the selected item position and width
			var default_left = Math.round($('#navigators li.selected').offset().left - $('#navigators').offset().left);
			var default_width = $('#navigators li.selected').width();

			//Set the floating bar position and width
			$('#box').css({left: default_left});
			$('#box .head').css({width: default_width});

			//if mouseover the menu item
			$('#navigators li').hover(function () {

				//Get the position and width of the menu item
				left = Math.round($(this).offset().left - $('#navigators').offset().left);
				width = $(this).width(); 

				//Set the floating bar position, width and transition
				$('#box').stop(false, true).animate({left: left},{duration:1000, easing: style});	
				$('#box .head').stop(false, true).animate({width: width},{duration:1000, easing: style});	

			//if user click on the menu
			}).click(function () {

				//reset the selected item
				$('#navigators li').removeClass('selected');	

				//select the current item
				$(this).parent().addClass('selected');

			});

			//If the mouse leave the menu, reset the floating bar to the selected item
			$('#navigators').mouseleave(function () {

				//Retrieve the selected item position and width
				default_left = Math.round($('#navigators li.selected').offset().left - $('#navigators').offset().left);
				default_width = $('#navigators li.selected').width();

				//Set the floating bar position, width and transition
				$('#box').stop(false, true).animate({left: default_left},{duration:1500, easing: style});	
				$('#box .head').stop(false, true).animate({width:default_width},{duration:1500, easing: style});		

			});

		});*/
	
	
	//PAGE SCROLL
	$(document).ready(function() {

		//get all link with class panel
		$('a.panel').click(function () {

	                //reset and highlight the clicked link
			$('a.panel').removeClass('selected');
			$(this).addClass('selected');

			//grab the current item, to be used in resize function
			current = $(this);

	                //scroll it to the destination
			$('#contents').scrollTo($(this).attr('href'), 1200);		

	                //cancel the link default behavior
			return false;
		});


		//resize all the items according to the new browser size
		$(window).resize(function () {

			//call the resizePanel function
			resizePanel();
		});

	});
	

	function resizePanel() {

		//get the browser width and height
		width = $(window).width();
		height = $(window).height();

		//get the mask width: width * total of items
		mask_width = width * $('.item').length;

		//set the dimension	
		$('#contents, .item').css({width: 930, height: 630});
		$('#mask').css({width: 4480, height: 630}); 

		//if the item is displayed incorrectly, set it to the corrent pos
		$('#contents').scrollTo($('a.selected').attr('href'), 0);

	}
	
	//PRETTY PHOTOS
		$(document).ready(function(){
			$("a[rel^='prettyPhoto']").prettyPhoto();
		});

});
