$(document).ready(function(e) {
	// anchor rollover/out
	$('a.rollover').mouseover(function(a) {
		var img = $(this).children()[0];
		$(img).attr('src', $(img).attr('src').replace('/Buttons/', '/Buttons/Over/'));
	});
	$('a.rollover').mouseout(function(a) {
		var img = $(this).children()[0];
		$(img).attr('src', $(img).attr('src').replace('/Buttons/Over/', '/Buttons/'));
	});
	
	// input rollover/out
	$('input.rollover').mouseover(function(a) {
		var btn = $(this);
		$(btn).attr('src', $(btn).attr('src').replace('/Buttons/', '/Buttons/Over/'));
	});
	$('input.rollover').mouseout(function(a) {
		var btn = $(this);
		$(btn).attr('src', $(btn).attr('src').replace('/Buttons/Over/', '/Buttons/'));
	});
	
	var previous;
	// top menu
	$('#top td').mouseover(function(a) {
		var a = $(this).children()[0];
		var img = $(a).children()[0];
		previous = $(img).attr('src');
		if ($(img).attr('src').indexOf('/TopMenu/Over/') == -1)
		{
			$(img).attr('src', $(img).attr('src').replace('/TopMenu/', '/TopMenu/Over/'));
		}
		if ($(img).attr('src').indexOf('/Menu/Over/') == -1)
		{
			$(img).attr('src', $(img).attr('src').replace('/Menu/', '/Menu/Over/'));
		}		
	});
	$('#top td').mouseout(function(a) {
		var a = $(this).children()[0];
		var img = $(a).children()[0];
		$(img).attr('src', previous);
	});
	
	// side menu
	$('#side > li > a').click(function(a) {
		if ($(this).parent().children('ul').length > 0)
		{
			a.preventDefault();
			if (!$(this).next('ul').is(':visible'));
				$(this).next('ul').slideDown(200);
		}
	});
	
	// search box
	$('#txtSearch').focus(function(a) {
		$(this).removeClass('watermark');
	});
	$('#txtSearch').blur(function(a) {
		if ($(this).val().length == 0)
			$(this).addClass('watermark');
	});
	
	// watermark
	$('.watermark').focus(function(a) {		
		if ($(this).attr('accesskey') == $(this).val())
		{
			$(this).val('');
			$(this).removeClass('watermark');
		}
	});
	$('.watermark').blur(function(a) {
		if ($(this).val().length == 0 || $(this).attr('accesskey') == $(this).val())
		{
			if ($(this).attr('accesskey') != 'txtSearch')
				$(this).val($(this).attr('accesskey'));
			$(this).addClass('watermark');
		}
	});
});
