// JavaScript Document

$(document).ready(function() {
	
	checkURL();	
	
	$('a.panel').click(function () {
		$('.nav li').removeClass('current');
		hash = $(this).attr('href');
		currentNav = hash.replace('#', '.') + "btn";
		
		$(currentNav).addClass('current');
		$('#wrapper').scrollTo(hash, 500, {onAfter: function(hash){window.location.hash = hash;} });	
		
			
		return false;
	});
	
	$('#toplink').click(function () {
		$('#wrapper').scrollTo($('li.current a').attr('href'), 0);		
		return false;
	});

	$(window).resize(function () {
		resizePanel();
	});
	
	
	$("a[rel='cbox']").colorbox();
	
	$("a[rel='cbox']").click(function(){
		$('#colorbox').fadeIn("normal");
	});
});

function resizePanel() {

	width = $(window).width();
	height = $(window).height();

	mask_width = width * $('.item').length;
		
	$('#debug').html(width  + ' ' + height + ' ' + mask_width);
		
	$('#wrapper, .item').css({width: width, height: height});
	$('#mask').css({width: mask_width, height: height});
	$('#wrapper').scrollTo($('li.current a').attr('href'), 0);
		
}

function checkURL(hash)
{
	if(!hash) hash=window.location.hash;	
	if(window.location.hash.length < 1) hash = '#home';
	
	$('#wrapper').scrollTo($(hash), 0);
	$('.nav li').removeClass('current');
	
	hash=hash.replace('#','.');
	$(hash+'btn').addClass('current');
}


