(function($){
	
	$.randomImage = {
		defaults: {
			
			//you can change these defaults to your own preferences.
			path: 'images/', //change this to the path of your images
			myImages: ['header-images-1.png', 'header-images-2.png', 'header-images-3.png', 'header-images-4.png', 'header-images-5.png', 'header-images-6.png', 'header-images-7.png' ] //put image names in this bracket. ex: 'harold.jpg', 'maude.jpg', 'etc'
			
		}			
	}
	
	$.fn.extend({
			randomImage:function(config) {
				
				var config = $.extend({}, $.randomImage.defaults, config); 
				
				 return this.each(function() {
						
						var imageNames = config.myImages;
						
						//get size of array, randomize a number from this
						// use this number as the array index

						var imageNamesSize = imageNames.length;

						var lotteryNumber = Math.floor(Math.random()*imageNamesSize);

						var winnerImage = imageNames[lotteryNumber];

						var fullPath = config.path + winnerImage;
						
						
						//put this image into DOM at class of randomImage
						// alt tag will be image filename.
						$(this).attr( {
										src: fullPath,
										alt: winnerImage
									});
				
						
				});	
			}
			
	});
	
	
	
})(jQuery);

$(document).ready(function(){	
	$(" #nav li ul ").css({display: "none"}); // Opera Fix				
	$(" #nav li.sectionheader span").click(function(){
		$(this).parent().find('ul:first').slideToggle("fast");
		$(this).toggleClass("active"); return false;
	});
					
	$("#nav li ul li.currentpage").parent().css("display", "block");
	$(this).toggleClass("active"); return false;
});

$(document).ready(function(){
	$("#showcc").click(function(){
		$("#cc").slideToggle("slow");
		$(this).toggleClass("active"); return false;
	});
	
	$("#printmc").click(function(){
		$("#print").printElement({ overrideElementCSS: true });
	});
	
	$("#nav li.menuactive ul").css("display", "block");
	$(this).toggleClass("active"); return false;
});

$(document).ready(function(){	

	$("a#comment-link").fancybox();
	  
	$(".page_Home #pagetitle").html('<img src="images/longdown-h1-home.png" title="Welcome to Longdown Activity Farm" />');
	
	$(".page_specialevents #pagetitle").html('<img src="images/longdown-h1-special-events.png" title="The Latest Events from Longdown" />');
	
	$(".page_longdownfarmnews #pagetitle").html('<img src="images/longdown-h1-farm-news.png" title="Longdown Farm News" />');
	
	$(".page_findusmap #pagetitle").html('<img src="images/longdown-h1-find-us.png" title="How to Find us" />');
	
	$(".page_seasontickets #pagetitle").html('<img src="images/longdown-h1-season-tickets.png" title="Season Tickets" />');
	
	$(".page_admissionprices #pagetitle").html('<img src="images/longdown-h1-admission-prices.png" title="Admission Prices" />');
	
	$(".page_contactus #pagetitle").html('<img src="images/contact-us.png" title="Contact Us" />');
	
	$(".page_yourcomments #pagetitle").html('<img src="images/your-comments.png" title="Your Comments" />');
	
	$(".page_vacancies #pagetitle").html('<img src="images/vacancies.png" title="Vacancies" />');
	
	$(".page_horsesandcattle #pagetitle").html('<img src="images/horses-and-cattle--for-sale.png" title="Horses and Cattle for sale" />');
	
	$(".page_hutchesrabbitequipment #pagetitle").html('<img src="images/hutches-and-equipment-for-sale.png" title="Hutches and Equipment for sale" />');
	
	$(".page_chickens #pagetitle").html('<img src="images/chickens-for-sale.png" title="Chickens for sale" />');
	
	$(".page_calves #pagetitle").html('<img src="images/calves-for-sale.png" title="Calves for Sale" />');
	
	$(".page_guineapigs #pagetitle").html('<img src="images/guinea-pigs-for-sale.png" title="Guinea Pigs for sale" />');
	
	$(".page_rabbits #pagetitle").html('<img src="images/rabbits-for-sale.png" title="Rabbits for sale" />');
	
	$(".page_ducks #pagetitle").html('<img src="images/ducks-for-sale.png" title="Ducks for sale" />');
	
	$(".page_goats #pagetitle").html('<img src="images/goats-for-sale.png" title="Goats for sale" />');
	
	$(".page_pigs #pagetitle").html('<img src="images/pigs-for-sale.png" title="Pigs for sale" />');
	
	$(".page_farmanimalsforsale #pagetitle").html('<img src="images/farm-animals-for-sale.png" title="Farm animals for sale" />');
	
	$(".page_longdownfarmshop #pagetitle").html('<img src="images/longdown-farm-shop.png" title="Longdown farm shop" />');
	
	$(".page_giftshoptearoom #pagetitle").html('<img src="images/poppies-gift-shop.png" title="Poppies Gift Shop" />');
	
	$(".page_playtime #pagetitle").html('<img src="images/play-time.png" title="Play time" />');
	
	$(".page_healthsafety #pagetitle").html('<img src="images/health-and-safety.png" title="Health and Safety" />');
	
	$(".page_teachers #pagetitle").html('<img src="images/information-for-teachers.png" title="Information for Teachers" />');
	
	$(".page_groups #pagetitle").html('<img src="images/group-visit-information.png" title="Group visit information - 2010" />');
	
	$(".page_caringforanimals #pagetitle").html('<img src="images/caring-for-animals.png" title="Caring for animals" />');
	
	$(".page_ouranimals2 #pagetitle").html('<img src="images/our-animals.png" title="Our animals" />');
	
	$(".page_colouringcompetition #pagetitle").html('<img src="images/childrens-colouring-competition.png" title="Childrens Colouring Competition" />');
	
	$(".page_santasgrotto #pagetitle").html('<img src="images/santas-grotto.png" title="Santas Grotto" />');
	
	$(".page_farmersday #pagetitle").html('<img src="images/farmers-day.png" title="Farmers Day" />');
	
	$(".page_farmersday2 #pagetitle").html('<img src="images/farmers-day.png" title="Farmers Day" />');
	
	$(".page_birthdayparties #pagetitle").html('<img src="images/birthday-parties.png" title="Birthday Parties" />');
	
	$(".page_birthdayparties2 #pagetitle").html('<img src="images/birthday-parties.png" title="Birthday Parties" />');
	
	$(".page_everyday #pagetitle").html('<img src="images/whats-on-each-day.png" title="Whats on each day" />');
	
	$(".page_supportinglocalproducers #pagetitle").html('<img src="images/supporting-local-producers.png" title="Supporting Local Producers" />');
	
	$(".page_farmshopnews2 #pagetitle").html('<img src="images/farmshop-news-and-offers.png" title="Farmshop News &amp; Offers" />');
	
	$(".page_seasonalnewsrecipes #pagetitle").html('<img src="images/seasonal-produce-and-recipe.png" title="Seasonal Produce &amp; Recipe" />');
	
	$(".page_productslist #pagetitle").html('<img src="images/products-list.png" title="Products List" />');
	
	$(".page_newsletter #pagetitle").html('<img src="images/longdown-h1-newsletter.png" title="Email Newsletter" />');
	
	$(".page_newsletterfarmshop #pagetitle").html('<img src="images/longdown-h1-newsletter.png" title="Email Newsletter" />');
	
	$(".page_contactdetails #pagetitle").html('<img src="images/contact-details.png" title="Contact Details" />');
	
	$(".page_surveyform #pagetitle").html('<img src="images/longdown-h1-survey-form.png" title="Survey Form" />');
	
	
	$("#header-images img").randomImage();
	
	var options = {
    newsList: "#news",
    startDelay: 40,
    tickerRate: 50,
	loopDelay: 6000,
    placeHolder1: " _"
	  }
	  $().newsTicker(options);
	  
	  $("a#video").fancybox({
		'hideOnContentClick': true
	});
	
	
	
	

	
});


