 $(function() {
	if (document.location.href.indexOf('photo-gallery.html') !== -1) {
		$('a.photo-gallery').lightBox();    
		$("#slider").easySlider({
			auto: true,
			continuous: true
		});
		$("p#return").remove();
	}
	$('#MapsLink').attr('href', 'map.html');
	mainMenu();
	faq();
	tableStyle();
	randomTip();
  });
  
  function faq() {
	if (document.location.href.indexOf('faq.html') !== -1) {
		$('dd').hide();
		$('dt').each(function() {
			$(this).wrapInner('<a href="#"></a>').click(function() {
				if ($(this).next('dd').css('display') == 'none') {
					$(this).next('dd').slideDown('slow');
				} else {
					$(this).next('dd').slideUp('slow');
				}
				return false;
			});
		});
		$('dl').before('<p>Please use the links below to view answers to our most frequently answered questions.</p>');
	}
  }
  
  function tableStyle() {
	  $('tr:gt(0)').hover(function(){
		 $(this).css('background-color', '#F4A110').css('color', '#fff');
	 }, 
	 function() {
		 if ($(this).hasClass('even')) {
			$(this).css('background-color', '#FBECB5');
		 } else {
			 $(this).css('background-color', 'transparent');
		 }
		 $(this).css('color', '#58595B');
	 });
  }

 function randomTip(){
	$('#tips li').hide();
	var pause = 5000; // define the pause for each tip (in milliseconds) 
	var length = $("#tips li").length; 
	var temp = -1;        

	this.getRan = function(){
		// get the random number
		var ran = Math.floor(Math.random()*length) + 1;
		return ran;
	};
	this.show = function(){
		var ran = getRan();
		// to avoid repeating
		while (ran == temp){
			ran = getRan();
		}; 
		temp = ran;
		$("#tips li").hide();    
		$("#tips li:nth-child(" + ran + ")").show();        
	};
	show();
	setInterval(show,pause);
}
 function mainMenu(){
	$("#nav ul ").css({display: "none"}); // Opera Fix
	$("#nav li").hover(function(){
				$(this).find('ul:first').css({visibility: "visible",display: "none"}).show('normal');
			},function(){
				$(this).find('ul:first').css({visibility: "hidden"});
	});
}
