﻿try
{
  document.execCommand("BackgroundImageCache", false, true);
} catch(err) {}



$(document).ready(function()
{
	$(document).pngFix();
	StyleSite();
	MoveWebPartEditPane();
});
$(window).load(function()
{
	SetDivSizes();
});
$(window).wresize(function()
{
	SetDivSizes();
});

function SetDivSizes()
{
	//set these to auto to force a recalculation of the function
	$('#body').height('auto');
	$('#main').height('auto');
	$('#navigation').height('auto');
	if(jQuery.browser.msie && parseInt(jQuery.browser.version) < 7.0)
	{
		$('#content').height(100);
	}

	//values for setting div sizes
	//these values don't change even if the window is resized
	var headerHeight = $('#header').height();
	var footerHeight = $('#footer').height();
	var headerFooterHeight = headerHeight + footerHeight;

	var documentHeight = $(document).height();
	var windowHeight = $(window).height();
	var tallerElement;
	var contentHeight = $('#content').height();
	//alert(contentHeight);
	var navigationHeight = $('#navigation').height() + 100; //100 for the reposition
	//alert('content '+contentHeight);
	//alert('nav '+navigationHeight);
	var combinedHeight = windowHeight - headerFooterHeight;
	
	//find out which is higher: navigation or content div
	/*if(contentHeight <= navigationHeight)
	{
		tallerElement = navigationHeight;
	}
	else if(contentHeight > navigationHeight )
	{
		tallerElement = contentHeight;
	}*/
	tallerElement = (contentHeight <= navigationHeight) ? navigationHeight : contentHeight;
	
	//if the content is too small, 
	//expand it to fill the entire height of the window
	if(headerFooterHeight + tallerElement < windowHeight)
	{
		tallerElement = windowHeight - headerFooterHeight;
	}
	//alert(contentHeight);
	
	//set the body size to accomodate
	$('#content').height(tallerElement);
	$('#navigation').height(tallerElement);

	var mainHeight = $('#main').height();
	$('#shadowLeft').height(mainHeight);
	$('#shadowRight').height(mainHeight);
}
function MoveWebPartEditPane()
{
	var toolPane = $('.ms-ToolPaneOuter').get();
	$(toolPane).css(
	{
		'width': 'auto',
		'height': '400px',
		'overflow': 'auto'
	});
	
	$('#navigationContainer').prepend(toolPane);
}

function StyleSite()
{
	$('#topBarNav TABLE TD:first').hide();
}

