$(document).ready(function () {
	preloadMenu();
	preloadTabs();
})

function preloadMenu() 
{
	$('.menuitem').bind({
		mouseover: function() {
			$('.submenuitem').hide();
			$('.menuitem').removeClass('menuitem_s_hover');
			$('.menuitem').removeClass('menuitem_hover');
			if ($(this).attr('id').length == 0)
			{
				$(this).addClass('menuitem_s_hover');	
			}	
			else
			{
				$(this).addClass('menuitem_hover');	
			}			
			var sh = '#s' + $(this).attr('id');
			$(sh).show();		
		},
		mouseout: function() {
			if ($(this).attr('id').length == 0)
			{
				$(this).removeClass('menuitem_s_hover');	
			}			
		}
	});
}

function preloadTabs()
{
	$('.pbox_header').first().addClass('pbox_header_clicked');
	$('.pbox_content').hide().first().show();
	$('.pbox_header').bind( {
		mouseover: function() {
			if (!($(this).hasClass('pbox_header_clicked')))
				$(this).addClass('pbox_header_hover');
		},
		mouseout: function() {
			$(this).removeClass('pbox_header_hover');
		}
	}).click(function() {
		$('.pbox_content').hide(); 
		$('.pbox_header').removeClass('pbox_header_clicked');
		$(this).addClass('pbox_header_clicked');
		$('#' + $(this).attr('id') + '_content').show();
	});
}

function highlightErrors(jsErrors)
{
	for (i in jsErrors)
	{
		var jser = '#'+jsErrors[i];
		$(jser).addClass('errorHighlight');
		$(jser).bind('blur keypress', function(event) {
			$(this).removeClass('errorHighlight');
		});
	}
}
