function prinav () {	
	$('#nav > li').hover(
		function(){$(this).addClass('hovered'); $('#nav > #' + $(this).attr('id') + ' > ul').css('left','0');}, 
		function(){$(this).removeClass('hovered'); $('#nav > #' + $(this).attr('id') + ' > ul').css('left','-999em');}
	);
	
    $('#nav > li > ul > li.popout').hover(
		function() {$(this).addClass('hover');},
	 	function() {$(this).removeClass('hover');
    });	// This removes the need for HTC fix csshover.htc
	
	$('#nav > li > a').focus(
		function(){$(this).parent().addClass('hovered');}
	);
	$('#nav > li > a').blur(
		function(){$(this).parent().removeClass('hovered');}
	);
		
	$('#nav > li > ul > li > a').focus(
		function(){$(this).parent().parent().parent().addClass('hovered');}
	);
	$('#nav > li > ul > li > a').blur(
		function(){$(this).parent().parent().parent().removeClass('hovered'); $('#nav > #' + $(this).attr('id') + ' > ul').css('left','-999em');}
	);
	$('#nav > li > ul > li.popout > a').blur(
		function (){
			$(this).parent().removeClass('popoutfocus'); // removes the grey line in the li		
			}
			
	);
	$('#nav > li > ul > li.popout > a').focus(
		function(){
			$(this).parent().parent().find('li ul.popoutfocus').removeClass('popoutfocus'); //This is what removes the ul (it bloody works)
			$(this).next().addClass('popoutfocus'); //This adds what is removed above to the current ul
			$(this).parent().css('position','relative'); //This puts the UL next to the parent li
			$(this).parent().addClass('popoutfocus'); // adds the grey line in the li
			}
	);

}
function toggleForm(targetId, linkId){
	var link = document.getElementById(linkId);
	var target = document.getElementById(targetId);
	target.className = "show";
	link.onclick = function() {
		toggler(target, link);
		return false;
	}

}
function toggler(target, link) {
	target.className = (target.className == "hide") ? "show" : "hide";
	link.className = (link.className == "tertiary openState") ? "tertiary" : "tertiary openState";
	
}
function openSearch(){
	if ( $("#openSchedule").length > 0 ) {
			toggleForm("ddBreakdown", "openSchedule");
		}
	
}

$(document).ready(function() {
	openSearch();
	prinav();
	$(".lightbox").lightbox();
	$("#promoRotatorContainer").jqGalScroll();
	$('#tabs #tabsUL').tabs({ fxFade: true, fxSpeed: 'slow' });
	$('#mytabs').tabs({ fxSlide: true, fxFade: true, fxSpeed: 'fast' });
	$('a.lightbox').lightBox(); // Select all links with lightbox class

	$('#datepicker').datepicker({ dateFormat: 'ddMy' });
	$('#datepicker2').datepicker({ dateFormat: 'ddMy' });
	$('#datepicker3').datepicker({ dateFormat: 'ddMy' });
	$('#datepicker4').datepicker({ dateFormat: 'ddMy' });
	$('#datepicker5').datepicker({ dateFormat: 'ddMy' });
	$('#datepicker2').change(function() { 
               loc = $('#datepicker2').val(); 
               $('#datepicker3').val(loc); 
    });
	$('#datepicker4').change(function() { 
               loc = $('#datepicker4').val(); 
               $('#datepicker5').val(loc); 
    });

	$("#slider").easySlider({
				restartDuration: 6000,
				loop: true,
  				autoplayDuration: 10000,
				prevId: 'prevBtn',
				nextId: 'nextBtn'			
	});
	$("#tabs>div>table>tbody>tr:even").addClass("even");			

});

 
