/* Horizonal Scroll */

$(document).ready(function() {	

	//Get the height of the first item
	$('#main').scrollTo($('#panel-1'), 1200);
	$.scrollTo( 0 );
	$('#main').css({'height':$('#panel-1').height()});

	//Calculate the total width - sum of all sub-panels width
	//Width is generated according to the width of #main * total of sub-panels
	$('#panel').width(parseInt($('#main').width() * $('#panel div').length));

	//Set the sub-panel width according to the #main width (width of #main and sub-panel must be same)
	$('#panel div.panelInner').width($('#main').width());

	//Get all the links with rel as panel
	$('a[rel=panel]').click(function () {

		//Get the height of the sub-panel
		var panelheight = $($(this).attr('href')).height();

		//Set class for the selected item
		$('a[rel=panel]').removeClass('current');
		$(this).addClass('current');

		//Resize the height
		$('#main').animate({'height':panelheight},{queue:false, duration:1200});

		//Scroll to the correct panel, the panel id is grabbed from the href attribute of the anchor
		$('#main').scrollTo($(this).attr('href'), 1200);

		//Discard the link default behavior
		return false;
	});
	$('a[rel=home]').click(function () {

		//Get the height of the sub-panel
		var panelheight = $($(this).attr('href')).height();

		//Set class for the selected item
		$('a[rel=panel]').removeClass('current');
		$('#gn-info a').addClass('current');

		//Resize the height
		$('#main').animate({'height':panelheight},{queue:false, duration:1200});

		//Scroll to the correct panel, the panel id is grabbed from the href attribute of the anchor
		$('#main').scrollTo($(this).attr('href'), 1200);

		//Discard the link default behavior
		return false;
	});

	$('a[rel=external]').click(function(){
		this.target = "_blank";
	});
});
