recipe_array = new Array();
recipe_array['Asparagus with Citrus Cilantro Sauce'] = 'asparagus.html';
recipe_array['Penne with Fennel Pumpkin Sauce'] = 'penne.html';
recipe_array['Fennel Pork Loin'] = 'fennel_pork_loin.html';

recipe_array['Mixed Field Greens Salad with Balsamic Vinaigrette'] = 'mixed_field_greens.html';
recipe_array['Spiked Spiced Berries'] = 'spiked_berries.html';

recipe_array['Orange-Rosemary Salmon'] = 'rosemary_salmon.html';
recipe_array['Roasted Garlic Mashed Potatoes'] = 'garlic_mashed_potatoes.html';
recipe_array['Caramelized Anisette Figs with Carnaval Sauce'] = 'carmelized_figs.html';

recipe_array['Strawberry Spinach Salad with Raspberry Balsamic Vinaigrette'] = 'strawberry_salad.html';
recipe_array['Chicken Casserole with Roasted Garlic and Fresh Herbs'] = 'chicken_casserole.html';
recipe_array['Tropical Carrot Cake'] = 'tropical_carrot_cake.html';

recipe_array['Sesame & Pistachio Encrusted Tuna with Wasabi Dream Sauce'] = 'encrusted_tuna.html';
recipe_array['Seared Spinach with Roasted Gar'] = 'seared_spinach.html';
recipe_array['Classic Chocolate Ganache with Strawberries'] = 'chocolate_ganache.html';

recipe_array['Seasoned Tomatoes Appetizer'] = 'seasoned_tomatoes.html';
recipe_array['Bella Brown Rice'] = 'brown_rice.html';
recipe_array['Chicken Fricassee'] = 'chicken_fricassee.html';

var i = 0;
var recipe_list = '<ul>';
for (var key in recipe_array)
{
 recipe_list+= '<li><a href="#'+recipe_array[key]+'" title="load recipe:'+key+'" id="anchor'+i+'">'+key+'</a></li>';
 i++;
}
recipe_list+='</ul>';

var old_html = '';
var old_recipe = '';
var old_this = '';

function openRecipes()
{
	scrollHeight = parseInt(document.getElementById('container').scrollHeight);
	pageSize = getPageSize();
	browserHeight = pageSize[1];
	browserWidth = pageSize[0];
	if(scrollHeight > browserHeight) {var width = browserWidth - 20;var opHeight = scrollHeight}
	else {var width = browserWidth; var opHeight = browserHeight;}
	$("body").append('<div id="opacity"></div><div id="recipes"><div class="top"><h2>Recipes from Romancing Your Palate</h2><div class="close"><a href="javascript:printRecipe()">PRINT</a> | <a href="javascript:closeRecipes()">X CLOSE</a></div><div class="clear"></div></div><div id="recipe_list"></div><div id="recipe_content"></div></div>');
	$("#opacity").height(opHeight+"px").width(width+"px");
	TB_position('recipes',700,300);
	$("#recipe_list").append(recipe_list);
	$("#opacity").fadeIn();
	$("#recipes").fadeIn();
	$("#recipe_list a").click(function(){
		if(old_html!='')
		{
			$(".active_list").parent("li").removeClass('recipe_active');
			$(".active_list").remove();
			$("#recipe_list a").show();	
		}
	
			loadRecipe(this.getAttribute('href'));
			old_html = $(this).parent("li").html();
			var html = '<div class="active_list">'+$(this).html()+'</div>';
			
			$(this).parent("li").append(html).addClass('recipe_active');
			$(this).hide();
		
	});
}

function loadRecipe(recipe)
{
	recipe_split = recipe.split('#');
	recipe = recipe_split[1];
	old_recipe = recipe;
	$("#recipe_content").load("ryp_recipes/"+recipe,function(){
   		$("#recipe_content").show();
	});
}

function printRecipe()
{
	if(old_recipe) 
	{
		var w = window.open('ryp_recipes/'+old_recipe,'print');
		w.focus();
	}
	else(alert("You have not loaded any recipes yet"));
}

function closeRecipes()
{
	$("#opacity").fadeOut();
	$("#recipes").fadeOut();
}

// following 3 functions taken from Thickbox script

/*
 * Thickbox 1.2 - One box to rule them all.
 * By Cody Lindley (http://www.codylindley.com)
 * Under an Attribution, Share Alike License
 * Thickbox is built on top of the very light weight jquery library.
 */

function TB_position(layer,width,height) {
	var pagesize = getPageSize();	
	var arrayPageScroll = getPageScrollTop();
	$("#"+layer).css({left: ((pagesize[0] - width)/2)+"px", top: (arrayPageScroll[1] + ((pagesize[1]-height)/2))+"px" });
}

function getPageScrollTop(){
	var yScrolltop;
	if (self.pageYOffset) {
		yScrolltop = self.pageYOffset;
	} else if (document.documentElement && document.documentElement.scrollTop){	 // Explorer 6 Strict
		yScrolltop = document.documentElement.scrollTop;
	} else if (document.body) {// all other Explorers
		yScrolltop = document.body.scrollTop;
	}
	arrayPageScroll = new Array('',yScrolltop) 
	return arrayPageScroll;
}

function getPageSize(){
	var de = document.documentElement;
	var w = window.innerWidth || self.innerWidth || (de&&de.clientWidth) || document.body.clientWidth;
	var h = window.innerHeight || self.innerHeight || (de&&de.clientHeight) || document.body.clientHeight;
	
	arrayPageSize = new Array(w,h) 
	return arrayPageSize;
}


function viewImage(image,img_height,img_width)
{
	if($("#opacity")) $("#opacity").remove();
	if($("#gallery")) $("#gallery").remove();
	pageSize = getPageSize();
	browserHeight = pageSize[1];
	browserWidth = pageSize[0];
	scrollHeight = parseInt(document.getElementById('container').scrollHeight);
	if(scrollHeight > browserHeight) {var width = browserWidth - 20;var opHeight = scrollHeight}
	else {var width = browserWidth; var opHeight = browserHeight;}
	$("body").append('<div id="opacity"></div><div id="gallery"><div id="close"><a href="javascript:imageClose()">x close</a></div><div id="image_in_gallery"><img src="" alt="Gallery Image" height="'+img_height+'" width="'+img_width+'" id="gallery_image" /></div></div>');
	$("#gallery_image").src("../images/"+image+".jpg");
	$("#opacity").height(opHeight+"px").width(width+"px");
	TB_position('gallery',img_width,img_height);
	$("#opacity").fadeIn();
	$("#gallery").fadeIn();
}

function imageClose()
{
	$("#opacity").fadeOut();
	$("#gallery").fadeOut();
}

function viewVideo(video, vid_height, vid_width)
{
	window.open('videos/'+video+".html",'video','width='+vid_width+',height='+vid_height+',resizeable=no,scrollbars=no');
}


function closeVideo(video)
{
	$("#"+video).hide();
	$("#opacity").fadeOut();
}
 