$(document).ready(function()
{
	$('#TopNavMenu').CSSDropDownMenu();
	$('#TopNavCatMenu').CSSDropDownMenu();
	setPageHeight();
	$(window).resize(function() {
	  setPageHeight();
	});
	highlightCurrentParentCategory();
	fixImagesWithErrors();
});
function fixImagesWithErrors()
{
	$('img').each(function()
		{
			if($(this).attr('src').indexOf('.jpg') < 0 && $(this).attr('src').indexOf('.png') < 0 && $(this).attr('src').indexOf('.gif') < 0)
			{
				$(this).attr('src','images/controls/bit.gif');
			}
		});
	/*$('img').error(function()
		{
			//alert($(this).attr('src'));
			$(this).attr('src','images/controls/bit.gif');
		});*/
}
function highlightCurrentParentCategory()
{
	var cat = '';
	cat = $.getUrlVar('Category')//.substring(1,4);
	if(cat && cat != '')
	{
		cat = cat.substring(1,3);
		//alert(cat);
		var links = $('#TopNavCatMenu > ul > li > a');
		for(var i = 0; i < links.length; i++)
		{
			if($(links).eq(i).attr('href').indexOf(cat) > -1)
			{
				$(links).eq(i).parent().addClass('Selected');
				break;
			}
		}
	}
}

function setPageHeight()
{
	var viewportHeight = $(window).height();
	var navHeight = $('#navmain1').height();
	var contentHeight = $('#content').height();
	var footerHeight = $('#footer').height();
	var totalSiteHeight = navHeight + contentHeight + footerHeight;
	if(viewportHeight > totalSiteHeight)
	{
		var requiredContentHeight = viewportHeight - footerHeight - navHeight;
		$('#content').css({'height':requiredContentHeight + 'px'})
	}
}

