// legal popup
jQuery(function() {
	jQuery('a[rel="legal"]').click(function(e) {
		e.preventDefault();
		
		var height	= 500;
		var width	= 650;
		window.open(this.href, 'legal_popup', 'height='+height+', left='+(screen.width-width)/2+', location=no, resizable=no, scrollbars=yes, status=no, toolbar=no, top='+(screen.height-height)/2+', width='+width);

	});
});

// bookmark utility
jQuery(function() {
	jQuery('a.bookmark').click(function(e){
		e.preventDefault();
	
		var burl = this.href;
		var btitle = this.title;
 
		if(window.sidebar) { // For Mozilla Firefox Bookmark
			window.sidebar.addPanel(btitle,burl,"");
		} else if(window.external || document.all) { // For IE Favorite
			window.external.AddFavorite(burl,btitle);
		} else if(window.opera) { // For Opera Browsers
			jQuery('a.bookmark').attr('href',burl);
			jQuery('a.bookmark').attr('title',btitle);
			jQuery('a.bookmark').attr('rel','sidebar');
		} else { // for other browsers which does not support
			 alert('Your browser does not support this bookmark action');
			 return false;
		}
	});
});

// image modifications
jQuery(function() {
	jQuery('#mid img[align=right]').addClass('img-right');
	jQuery('#mid img[align=left]').addClass('img-left');
	jQuery('#mid .recipeImg img[alt="Ghirardelli"]').css('border','none').css('margin-top','-32px');
});

// image archive fixes
jQuery(function() {
	jQuery('#mid .image-archive-list-item:nth-child(3n+1)').css('clear','left');
	jQuery('#mid .image-archive-list-item a[rel="external"]').click(function(){
		window.open(this.href);
		return false;
	});
});

// wine pairing & suggestions flash
jQuery(function() {
	if(jQuery('#winepairingsuggestions').length) {
		jQuery('#winepairingsuggestions #mid h1').after('<div id="food-wine-pairing"></div>');
		
		var so = new SWFObject(path+"/flash/wine-pairing.swf", "player", "630", "369", "8", "#ffffff");
		// so.addVariable("playlist", "playlist.xml"); // optional
		so.addParam("wmode","opaque");
		so.write("food-wine-pairing");
	}
});

// right sidebar
jQuery(function() {
	jQuery('#right .sidebarWidget:first').css('margin-top','12px');
});

// editorials flash video button
jQuery(function() {
	jQuery('#mid a[href="#watch"]').click(function(e){
		jQuery('#video-'+$(this).attr('class')).css('display','block');
	});
});

// cookbook
jQuery(function() {
	jQuery('a[href="#cookbook"]').click(function(e){
		showCookbook();
		
		e.preventDefault();
	});
});

function showCookbook(){
	src_loader='../cookbook/index.htm';
	/*document.getElementById("container").style.overflow="hidden";
	document.getElementById("container").style.height="100%";
	document.getElementById("container").style.position="relative";*/
	GB_myShow2('Mirassou.com Cookbook', '../cookbook/index.htm');
	
	return false;
}
GB_myShow2 = function(caption, url, /* optional */ height, width, callback_fn) {
	var options = {
		caption: caption,
		center_win: false,
		width: width || 900,
		height: height ||500,
		fullscreen: false,
		show_loading: false,
		callback_fn: callback_fn,
		url:url
	}
	var win2 = new GB_Window(options);
	
	return win2.show(url);
}