$(document).ready(function()
{
	$(".scrollable").scrollable({
			circular: true
		})
		.autoscroll(3000);


	var wrappedContent = $("#wrapperContent");
	var sidebar = $(".sidebar");

	if( wrappedContent.height() > sidebar.height() )
	{
		sidebar.height(wrappedContent.height() + 64);
	}

	$("ul.tabs").tabs("div.panes > div");

	fixNav();
	$(window).resize(fixNav);

	$('.header .back a').click( function()
	{
		history.go(-1);
		return false;
	});

	$('.getStarted a').click( function()
	{
		var api = $('#welcome').data("overlay");
		api.load();
		return false;
	});

	$('#welcome').overlay( {
		load : false,
		mask : '#000000',
		left : 'center',
		oneInstance : false,
		top : 'center',
		onClose: function()
		{

		}
	});
	

//	$('#landingSurveyDiv').overlay( {
//		load : false,
//		mask : '#000000',
//		left : 'center',
//		oneInstance : false,
//		top : 'center'
//	});


	$("#welcome #welcomeBrowseButton").click(function( e )
	{
		var api = $('#welcome').data("overlay");
		api.close();
		e.preventDefault();
	});
	

	$('body:not(.html) #leftSideBar .filter a').each( function(i, a)
	{
		var a = $(a);
		var href = a.attr('href').replace('/html', '');
		a.attr('href',href);
	});

});

function fixNav()
{
	var width = 0;
	$('#innerNav ul li').each(function( count, li )
	{
		width += $(li).width();
	});

	$('#innerNav ul').width(width);
}

function closeLandingSurveyOverlay()
{
	$('#landingSurveyDiv').data('overlay').close();
}

function resizeLandingSurveyIFrame( height )
{
	$('#landingSurveyIFrame').attr('height', height);
}

