function help_ie()
{
	if($.browser.msie)
	{
		$('#mainnav li').hover(function(){
			$(this).addClass('over');
		},
		function(){
			$(this).removeClass('over');
		});
		
		$('input.button').hover(function(){
			$(this).addClass('over');
		},
		function(){
			$(this).removeClass('over');
		});
	}
}
				
function table_helper()
{
	$('table:not(.nohover) tbody tr').hover(function(){
		$(this).addClass('over');
	},
	function(){
		$(this).removeClass('over');
	});
	
	$('table:not(.nohover) tbody tr td:first-child').addClass('l');
	
	$('table:not(.nohover .noLinks) tbody tr td a').each(function(){
		var rowhref=$(this).attr('href');
		$(this).parent().parent().click(function(){
			window.location.href=rowhref;
		})
	});
}
	
function download_checkbox_helper()
{
	if( $( "input[type='checkbox'].downloadCheckbox:checked" ).length )
	{		
		$( "input[type='checkbox'].downloadCheckbox" ).each( function(){
			if ($(this).attr('checked'))
			{
				$( "#" + $(this).attr('ref') ).show();
			}
		});
	}
	
	$( "input[type='checkbox'].downloadCheckbox" ).click( function(){
		
		if ($(this).attr('checked'))
		{
			$( "#" + $(this).attr('ref') ).show();
		} else
		{
			$( "#" + $(this).attr('ref') ).hide();		
		}
	});
}

function search_focus()
{
	$('#search input:first').focus(function(){
		$(this).val('');
	});
}

function init_lightbox()
{
	$('a[@name*=zoom]').lightBox({
		overlayBgColor:'#FFF',
		overlayOpacity:0.8,
		imageBlank:'/global/img/lightbox/blank.gif',
		imageLoading:'/global/img/lightbox/loading.gif',
		imageBtnClose:'/global/img/lightbox/close.gif',
		imageBtnPrev:'/global/img/lightbox/prev.gif',
		imageBtnNext:'/global/img/lightbox/next.gif',
		containerBorderSize:10,
		containerResizeSpeed:350,
		txtImage:'',
		txtOf:''
	});
}

$(document).ready( function(){
		table_helper();
		help_ie();
		init_lightbox();
		search_focus();
		$("#catdownloads").tablesorter({sortList: [[0,0], [1,0]]});
		download_checkbox_helper();
});
