var dp_options = {};
var innerfade_height = 265;
try { document.execCommand('BackgroundImageCache', false, true); } catch(e) {}; //ie 6 bg image fix

$(function(){
	$('#topnav li').hover(function(e){
		$('ul', this).stop().css('height', 'auto').slideDown('fast');
	}, 	function(e){
			$('ul', this).slideUp('fast');
		})
	// create rollover images
	$('.rollover').mouseover(function(){
		var img = $(this).find('img')[0];
		img.src = img.src.replace(/(\.[^.]+)$/, '_ovr$1');
	});
	
	var mouseout = function(){
		var img = $(this).find('img')[0];
		img.src = img.src.replace(/_ovr(\.[^.]+)$/, '$1');
	};

	$('.rollover').mouseout(mouseout);
	$('.rollover').click(mouseout); /* RESET IT FOR SAFARI BACK BUTTON PROBLEM NOT EXECUTING DOMREADY*/
	
	
	// rotating images on secondary pages
	$('#bigpics ul').innerfade({
		animationtype: 'fade',
		speed: 1000,
		timeout: 4000,
		type: 'sequence',
		containerheight: innerfade_height + 'px'
	});
	
	
	// datepicker and forms
	Date.format = 'mm/dd/yyyy';
	Date.firstDayOfWeek = 0;
	
	//$('.fillin').fillin();
	
	// need to set these ones because of what FF likes to do with form fields after you've filled out and soft refreshed the page
	$('.search').fillin('Search Keyword');
	$('.datepicker').fillin('mm/dd/yyyy');
	$('.datepicker_hh').fillin('hh');
	$('.datepicker_mm').fillin('mm');
	$('.datepicker').filter(":not('.dp-applied')").each(function(i){
		if ($(this).val() != Date.format){
			var d = $(this).val();
			var picker = $(this).datePicker(dp_options).dpSetSelected(d);
		} else {
			var picker = $(this).datePicker(dp_options);
		}
		picker.bind(
			'dateSelected', 
			function(e, selectedDates) {
				$(this).removeClass("fillin");
			}
		);
		
	});
	$('#form input:first').select();
	// $('#form .error_highlight input:first').select();
	
});
