// JavaScript Document

$(document).ready(function(){
	clearClick();
	setBrowserClass();
	if(!hasFlash){
		$('.no_flash').show();
		$('.has_flash').hide();
	}else{
		$('.no_flash').remove();
		$('#wrapper_shadow').css('background','none');
	}
	if(isIE(6)){
		$(document).pngFix();
	}
	
	adjustFooter();
	setTimeout('resizeFacebookPane();', 1000);
	window.onresize = function(){
		adjustFooter();
		resizeFacebookPane();
		if($('#myGallery').length > 0 && hasFlash){
			resizeGallery();
		}
	}
});

function resetNav(h){
	$("#sidebar").height(h);	
}

function resizeGallery(){
	var size = getScreenSize().split('x');
	var height = size[1];
	var galleryHeight = height - $('#header').outerHeight() - $('#footer').outerHeight();
	$('#flashgallery').height(galleryHeight);
}


var activeTab = '';
var isRelative = false;

function adjustFooter(){
	var size = getScreenSize().split('x');
	var width = size[0];
	var height = size[1];
	var minWidth = 1200; // 960px plus left and right padding
	//var bodyHeight = $('body').outerHeight();
	var bodyHeight = $('#wrapper').outerHeight() + $('#header').outerHeight() + $('#footer').outerHeight();
	
	// Decrease left and right padding at smaller resolutions
	/* if(width < minWidth){
		$('#tabs_nav').css('padding','0 20px');
		$('#tabs').css('padding','0 20px');
	}else{
		$('#tabs_nav').css('padding','0 120px');
		$('#tabs').css('padding','0 120px');
	} */
	
	// Determine whether footer should be fixed or just at the bottom of the content
	//alert('height='+height+' | bodyHeight='+bodyHeight);
	if(height < bodyHeight){
		$('#footer').css('bottom',null);
		$('#footer').css('position','relative');
		isRelative = true;
	}else{
		$('#footer').css('bottom',0);
		$('#footer').css('position','fixed');
		isRelative = false;
	}
}

function toggleFooter(tab){
	if(activeTab != '' && tab == activeTab){
		hideFooterTabs();
		activeTab = '';
	}else{
		$('#tabs .tab').hide();
		$('#div_'+tab).show();
		if($('#footer #tabs').is(':hidden'))
			showFooterTabs();
		activeTab = tab;
	}
	//adjustFooter();
}

function hideFooterTabs(){
	$('#footer #tabs').hide();
	$('#footer #transparent_bg').css('background-color','#FFFFFF');
	$('#footer #tabs_nav a').attr('class','');
	$('#footer').attr('class','');
}

function showFooterTabs(){
	$('#footer').attr('class','nogradient');
	$('#footer #tabs_nav a').attr('class','over');
	$('#footer #transparent_bg').css('background-color','#CCCCCC');
	$('#footer #tabs').show();
	if(isRelative) $.scrollTo($('body').outerHeight(),0);
}

function resizeFacebookPane(){
	var size = getScreenSize().split('x');
	var width = size[0];
	
	// Adjust size of Facebook Like Box
	var iframeWidth = width - 240; // subtract left and right padding
	$('#div_facebook iframe').width(iframeWidth);
}
