$(function() {

		// NEW ABOUT US PAGE 

		$(".scrollable").scrollable();
		
		$(".items img").click(function() {
		
			// see if same thumb is being clicked
			if ($(this).hasClass("active")) { return; }
		
			// calclulate large image's URL based on the thumbnail URL (flickr specific)
			var url = $(this).attr("src").replace("_t", "");
		
			// get handle to element that wraps the image and make it semi-transparent
			var wrap = $("#imageWrap").fadeTo("medium", 1);
		
			// the large image from www.flickr.com
			var img = new Image();
			
			
			// Employee Name
			var employeeName = $(this).attr("title");
			$("div#image_caption").html(employeeName);
			
			// Employee Name
			var employeeNick = $(this).attr("class");
			$("div#nickName").html(employeeNick);
			
			// Employee Description
			var employeeDescr = $(this).attr("alt");
			$("div#Description").html(employeeDescr);
			
			//Pet Slideshow Link
			var petBtn = $(this).attr("id");
			var petBtnwithPar = "/about_us/" + petBtn;

			
						
			
			$("div#InfoBox a").attr("href", petBtnwithPar);
		
		
			// call this function after it's loaded
			img.onload = function() {
		
				// make wrapper fully visible
				wrap.fadeTo("fast", 1);
		
				// change the image
				wrap.find("img").attr("src", url);
		
			};
		
			// begin loading the image from www.flickr.com
			img.src = url;
		
			// activate item
			$(".items img").removeClass("active");
			$(this).addClass("active");
		
		// when page loads simulate a "click" on the first image
		}).filter(":first").click();

	
	
	$("a.iframe").fancybox({
		'transitionIn'	:	'elastic',
		'width'			:	760,
		'height'		:	600,
		'autoDimensions':	'true',
		'padding'		:	0,
		'margin'		:	0,
		'scrolling'		:	'no'
	});
	
	$('.overlay_triggerSend').fancybox();
	
	$('.overlay_trigger').fancybox({
		'autoDimensions'	: true,
		'scrolling'		: 'no'

	});
	
	$('.overlay_triggerMap').fancybox({
		'autoDimensions'	: false,
		'scrolling'		: 'no',
		'width'			: 500,
		'height'		: 500
	});
	

	
	// TABS FOR PRODUCTS PAGE
	$("#tabs").tabs("#panes .pane", {
		tabs	: "li"
	});

	// SLIDER FOR HOMEPAGE
	
	var homepageScroller = $(".homepage #scroller");
	
	if(homepageScroller.length > 0){
		
		var resizeHappended = 0;
		
		homepageScroller.find(".item").css("width", $(document).width());
		
		homepageScroller.scrollable({
			circular	: true,
			speed		: 1500,
			keyboard	: false
		}).autoscroll({
			interval	: 6500
		}).navigator();
		
		api = homepageScroller.data("scrollable");
		
		$(window).resize(function() {
			if(homepageScroller.find(".items:animated").length === 0) {
				FixContainerWidth();
			}
			
			resizeHappended = 1;
		});
		
		api.onSeek(
			function(){
				if(resizeHappended === 1){
					FixContainerWidth();
					resizeHappended = 0;
				}
			}
		);
		
		function FixContainerWidth(){
			$(".homepage #scroller .item").css("width", $(document).width());
			offset = $(document).width() * (api.getIndex() + 1);
			$(".homepage #scroller .items").css("left", "-" + offset + "px");
		}
	}
	

	
	// OVERLAY
	

	

	
	// SEARCH FOR PRODUCTS PAGE
	
	var page_products = $(".page-products");
	
	if(page_products.length > 0){
		$("#dog_food_container").hoke({
			search		: "#dog_food_search",
			container	: "#dog_food_container",
			node		: ".search_node",
			fields		: { tags : "p" },
			onEmpty		: function() { 
				
			},
			onUpdate	: function() {
				
			},
			onActivate	: function() { 
				$("#dog_food_search").show();
			}
		});
		
		$("#cat_food_container").hoke({
			search		: "#cat_food_search",
			container	: "#cat_food_container",
			node		: ".search_node",
			fields		: { tags : "p" },
			onEmpty		: function() { 
				
			},
			onUpdate	: function() {
				
			},
			onActivate	: function() { 
				$("#cat_food_search").show();
			}
		});
		
		$("#dog_accessories_container").hoke({
			search		: "#dog_accessories_search",
			container	: "#dog_accessories_container",
			node		: ".search_node",
			fields		: { tags : "p" },
			onEmpty		: function() { 
				
			},
			onUpdate	: function() {
				
			},
			onActivate	: function() { 
				$("#dog_accessories_search").show();
			}
		});
		
		$("#cat_accessories_container").hoke({
			search		: "#cat_accessories_search",
			container	: "#cat_accessories_container",
			node		: ".search_node",
			fields		: { tags : "p" },
			onEmpty		: function() { 
				
			},
			onUpdate	: function() {
				
			},
			onActivate	: function() { 
				$("#cat_accessories_search").show();
			}
		});
		
		$("#fish_container").hoke({
			search		: "#fish_search",
			container	: "#fish_container",
			node		: ".search_node",
			fields		: { tags : "p" },
			onEmpty		: function() { 
				
			},
			onUpdate	: function() {
				
			},
			onActivate	: function() { 
				$("#fish_search").show();
			}
		});
		
		$("#birds_container").hoke({
			search		: "#birds_search",
			container	: "#birds_container",
			node		: ".search_node",
			fields		: { tags : "p" },
			onEmpty		: function() { 
				
			},
			onUpdate	: function() {
				
			},
			onActivate	: function() { 
				$("#birds_search").show();
			}
		});
		
		$("#small_animals_container").hoke({
			search		: "#small_animals_search",
			container	: "#small_animals_container",
			node		: ".search_node",
			fields		: { tags : "p" },
			onEmpty		: function() { 
				
			},
			onUpdate	: function() {
				
			},
			onActivate	: function() { 
				$("#small_animals_search").show();
			}
		});
		
		$(".search_node").each(
			function(){
				var img_cache = $(this).find("img");
				var img_height = parseInt(img_cache.css("height"));
				var offset = (110 - img_height) / 2;
				img_cache.css("margin-top" , offset);
			}
		);
	}
	
	
	// GALLERY PAGE
	
	var pageGalleryScroller = $(".page-gallery");
	
	if(pageGalleryScroller.length > 0){
		pageGalleryScroller.find("#area #scroller").scrollable({
			next		: "#area .next",
			prev		: "#area .prev"
		});
		
		
		//pageGalleryScroller.find("#vertical_area #scroller").scrollable({
		//	vertical	: true,
		//	next		: "#vertical_area .next",
		//	prev		: "#vertical_area .prev"
		//});
	}

	// GALLERY
	$(document).ready(function() {
	    $('#mycarousel').jcarousel({
	        vertical: true,
	        scroll: 1
	    });
	});

	
});



























