$(document).ready(function(){

	//form-script
	$("#on-load").fancybox({
				'padding'			: 0,
				'width'         	: 440,
				'height'        	: 555,
				'transitionIn'		: 'fade',
				'transitionOut'		: 'fade',
				'overlayColor'		: '#333',
				'overlayOpacity'	: 0.6,
				'type'				: 'iframe'
			});
	//form-script
	
	$('#pd-01').mouseover(function(){
		$('#pd-item1').addClass('link-active');
	});
	$('#pd-01').mouseout(function(){
		$('#pd-item1').removeClass('link-active');
	});
	$('#pd-02').mouseover(function(){
		$('#pd-item2').addClass('link-active');
	});
	$('#pd-02').mouseout(function(){
		$('#pd-item2').removeClass('link-active');
	});
	$('#pd-03').mouseover(function(){
		$('#pd-item3').addClass('link-active');
	});
	$('#pd-03').mouseout(function(){
		$('#pd-item3').removeClass('link-active');
	});
	$('#pd-04').mouseover(function(){
		$('#pd-item4').addClass('link-active');
	});
	$('#pd-04').mouseout(function(){
		$('#pd-item4').removeClass('link-active');
	});
	
	$("#clip a").click(function() {
	$.fancybox({
			'padding'			: 5,
			'autoScale'			: false,
			'transitionIn'		: 'elastic',
			'transitionOut'		: 'elastic',
			'easingIn'      	: 'easeOutBack',
			'overlayColor'		: '#FFF',
			'overlayOpacity'	: 0.6,
			'title'				: this.title,
			'href'				: this.href.replace(new RegExp("watch\\?v=", "i"), 'v/') + '&autoplay=1',
			'type'				: 'swf',
			'swf'				: {
			   	 'wmode'		: 'transparent',
				'allowfullscreen'	: 'true'
			}
		});

	return false;
	});
	
	$('#recipe-in aside #clip').remove();
	
	$('.gallery li').hover(
	function(){
		$(this).find('.play').stop().animate({opacity:1}, 200);
		$(this).find('a').addClass('active');
	},
	function(){
		$('.play').stop().animate({opacity:.6}, 200);
		$('a').removeClass('active');
	});
	
	//var aHi = $('#related a').height() + 10;
	//$('#related a').css({'top': 50% - aHi});
	
	$('#print a').click(function(e){
		e.preventDefault();
		artPrint();
	});
	
	$('#save a').click(function(){
  		alert("Please use \"Save Page As\" button on the menu bar");
  	});
	//$('#saveie a').click(function(e){
	//	e.preventDefault();
	//	artSave();
  	//});
	
	function artPrint() {  
	    
	    var title = $('title').text();
	    
	    var display_setting="toolbar=yes,location=no,directories=yes,menubar=yes,";  
	    display_setting+="scrollbars=yes,width=450, height=600, left=100, top=25";  
	      
	    var content_innerhtml = $('article').html();  
	    var document_print=window.open("","",display_setting);  
	    document_print.document.open();  
	    document_print.document.write('<html><head><title>'+title+'</title>');
	    document_print.document.write('<style>#ingredients{list-style:none;} ol {width:400px;}');
	    document_print.document.write('h2 {display:none;} h5 {display:block;font-size:20px;} </style></head>');
	    document_print.document.write('<body style="font-family:Times New Roman; font-size:12px;" onLoad="self.print();self.close();" >');  
	    document_print.document.write('<img src="images/logo.png" />');
	    document_print.document.write(content_innerhtml);
	    document_print.document.write('</body></html>');
	    document_print.print();  
	    document_print.document.close();
	    return false;
	}
	function artSave() {  
	    
	    var title = $('title').text();
	    
	    var display_setting="toolbar=yes,location=no,directories=yes,menubar=yes,";  
	    display_setting+="scrollbars=yes,width=450, height=600, left=100, top=25";  
	      
	    var content_innerhtml = $('article').html();  
	    var document_print=window.open("","",display_setting);  
	    document_print.document.open();  
	    document_print.document.write('<html><head><title>'+title+'</title>');
	    document_print.document.write('<style>#ingredients{list-style:none;} ol {width:400px;}');
	    document_print.document.write('h2 {display:none;} h5 {display:block;font-size:20px;} </style></head>');
	    document_print.document.write('<body style="font-family:Times New Roman; font-size:12px;" onload="self.tclik();self.close();" >');  
	    document_print.document.write('<img src="images/logo.png" />');
	    document_print.document.write('<a id="sss" href="javascript:void(0);" onclick="document.execCommand(\'SaveAs\',true,\'<% = fileN %>.html\');"></a>');
	    document_print.document.write(content_innerhtml);
	    document_print.document.write('</body></html>');
	    document_print.execCommand('SaveAs',true,'<% = fileN %>.html');
	    document_print.document.close();
	    return false;
	}
	
	function tclik() {
		$('#sss').trigger('click');
	}
	
	//ads
	$("a[rel=ads-im]").fancybox({
				'transitionIn'		: 'elastic',
				'transitionOut'		: 'elastic',
				'overlayColor'		: '#FFF',
				'overlayOpacity'	: 0.5,
				'titlePosition' 	: 'over',
				'padding'			: 1,
				'titleFormat'		: function(title, currentArray, currentIndex, currentOpts) {
					return '<span id="fancybox-title-float">' + (title.length ? ' &nbsp; ' + title : '') + ' &nbsp; ' + (currentIndex + 1) + ' / ' + currentArray.length + '</span>';
				}
			});
	
	
});
