$(document).ready(function(){
	
	extendJQuery();
	
	try{
	
		$("#how_to_find").fancybox({ 
			'overlayShow': true,
			'overlayOpacity': 0.7,
			'frameWidth': 335
		}); 
		$("#how_to_find").click(function(e){
			$('#fancy_content #distributors').accordion({
				autoHeight: false
			});
		});
		
	}catch(e){}
	
	var loc_arr = window.location.href.split("/");
	var locations = {
		'products':'products',
		'the_process':'process',
		'the_legend':'legend',
		'mellow_moments':'mellow',
		'news_and_events':'news_and_events',
		'the_master_distiller':'master',
		'faq':'faq',
		'distillery_tour':'tour',
		'recipes':'recipes',
		'about_us':'about_us',
		'contact':'contact',
		'10_recipes':'ten_recipes'
	}


	if(loc_arr.length == 4)
	{
		try{
			var item = locations[loc_arr[3]];
			$("div.header ."+item).addClass(item+"_active");
		}
		catch(e){}
	}

	preloadImages();
	
	setupTenRecipes();


}); //end ready


function extendJQuery()
{
	//add outerHTML() to jquery
	jQuery.fn.outerHTML = function() {
		return $('<div>').append( this.eq(0).clone() ).html();
	};
	
}//end extendJQuery



function preloadImages()
{
      var preload_image_object = new Image();
      // set image url
      var image_url = new Array();

	  image_url[0]  = "http://web1.fourroses.us/images/mnav_products_over.gif";
	  image_url[1]  = "http://web1.fourroses.us/images/mnav_process_over.gif";
	  image_url[2]  = "http://web1.fourroses.us/images/mnav_legend_over.gif";
	  image_url[3]  = "http://web1.fourroses.us/images/mnav_mellow_over.gif";
	  image_url[4]  = "http://web1.fourroses.us/images/mnav_news_events_over.gif";
	  image_url[5]  = "http://web1.fourroses.us/images/snav_master_over.gif";
	  image_url[6]  = "http://web1.fourroses.us/images/snav_faq_over.gif";
	  image_url[7]  = "http://web1.fourroses.us/images/snav_tour_over.gif";
	  image_url[8]  = "http://web1.fourroses.us/images/snav_recipes_over.gif";
	  image_url[9]  = "http://web1.fourroses.us/images/snav_about_over.gif";
	  image_url[10] = "http://web1.fourroses.us/images/snav_contact_over.gif";
	  image_url[11] = "http://web1.fourroses.us/images/btn_mariage_over.png";
	  image_url[12] = "http://web1.fourroses.us/images/btn_limited_over.png";
	  image_url[13] = "http://web1.fourroses.us/images/btn_single_over.png";
	  image_url[14] = "http://web1.fourroses.us/images/btn_small_over.png";
	  image_url[15] = "http://web1.fourroses.us/images/btn_yellow_over.png";
	  image_url[16] = "http://web1.fourroses.us/images/btn_super_over.png";
	  image_url[17] = "http://web1.fourroses.us/images/btn_black_over.png";
	  image_url[18] = "http://web1.fourroses.us/images/sub_yellow_usa_over.png";
	  image_url[19] = "http://web1.fourroses.us/images/sub_yellow_eur_over.png";
	  image_url[20] = "http://web1.fourroses.us/images/sub_yellow_jpn_over.png";
	  image_url[21] = "http://web1.fourroses.us/images/sub_single_100_over.png";
	  image_url[22] = "http://web1.fourroses.us/images/sub_single_86_over.png";
	  image_url[23] = "http://web1.fourroses.us/images/sub_limited_120_over.png";
	  image_url[24] = "http://web1.fourroses.us/images/sub_limited_40_over.png";
	  image_url[25] = "http://web1.fourroses.us/images/sub_limited_2009_over.png";

      for(var i=0; i < image_url.length; i++)
	  {
	  	 preload_image_object.src = image_url[i];
	  }
      	
}//end funtion preloadImages


var initial_10_recipes_data = "";
function setupTenRecipes()
{
	//hide all the recipes
	$("#recipe_data_holder").hide();
	
	$("#barrels a").each(function(){
		
		$(this).mouseover(function(){
			
			//save the initial data should we need it later
			if(initial_10_recipes_data == "")
			{
				initial_10_recipes_data = $("#default_data").outerHTML();
				
			}//end if
			
			$rel = $(this).attr("rel");
			$("#barrels").css("background-position", "0px " + $rel + "px");
			$data = $($(this).attr("href")).outerHTML();
			
			//set the new data
			$("#recipe_info_block").html($data);
			
		});//end mouseover
		
	});//end each
	
}//end setupTenRecipes