jQuery(document).ready(function($) {

// HOME PAGE ---- Get Images for Homepage Rotation

	function get_homepage_image() {
		var imgpath = 'boutiquehotel/wp-content/themes/webers/images/home/';	
		var imgs    = new Array(
			'Elavator1C.jpg',
			'Lobby-3C.jpg',
			'Lobby-6C.jpg',
			'3-PlantersC.jpg',
			'morning-coffee.jpg',
			'room-210.jpg',
			'Front-Flatbluesky.jpg',
			'Restraurant-Final.jpg',
		//	'hotel_room_homepage.jpg',
			'pool_homepage.jpg'
		);

		var imgurl  = imgpath+imgs[Math.floor(Math.random() * imgs.length)];
		
		// fade everything in
		$("body.home #container").hide().css({ "background-image" : "url("+imgurl+")", "border" : "1px solid #000" }).fadeIn('slow', show_feature());
		//find("#btn-hide").add("body.home #blog-title").hide().css({"visibility" : "visible"}).fadeIn("slow");

		// 	animate background clouds on homepage
		$("body.home #wrapper").css( { "background-position": "20% 0"} ).animate( {'background-position-x': "50%"}, {duration:4800} );
	}

	get_homepage_image();

// HOME PAGE ---- Animate feature-post-home after a delay	

	function show_feature() {
		$("#post-home").hide().delay(2000).removeClass("hidden").show('slide',{ direction: 'down' },'slow');
	// Hover to hide special
		$("#btn-hide").hide().delay(2400).removeClass("hidden").fadeIn("slow").hover( 

			function() { 
				$("#post-home").toggle('slide', { direction: 'down' }, '800');
			 } 

			);
	// Click to hide special
	/*
		$("#btn-hide").click( 

			function() { 
				$("#post-home").toggle('slide', { direction: 'right' }, '800');
			 } 

			);	
	*/	
	}
//	show_feature() called by get_homepage_image() function above.


// ALL PAGES ---- EXTERNAL LINKS ---- add a class to all external links called .externalLink

	var thelinks = "a:not(:has(img))"; 

	function linky() {
		$(thelinks).filter(function() {
	    	return this.hostname && (this.hostname !== location.hostname && this.hostname != "www.opentable.com");
	     }).addClass('external-link');
	}
	
linky();


// ALL PAGES ---- PDF LINKS ---- Append PDF logo to any href ending in .pdf and add target="_blank"

	function pdfy() {
		$("a[href$='.pdf']").addClass("pdf-link").attr("target","_blank");
	}
	
pdfy();
	

// SIDEBARS

	function sidebarify(theID) {
		$(theID).addClass("main-aside");
	}
	
sidebarify('#restaurant-aside');

// REMOVE TABINDEX from SEARCH form to play nice with GRAVITYFORMS

$("#searchform #s, #searchform #searchsubmit").removeAttr('tabindex');


// Replace OpenTable Button with Better One function is inline in footer.php

});

