$(document).ready(function(){

	initializeFancybox();
	
	$('textarea.tinymce').tinymce({
		// Location of TinyMCE script
		script_url : '/site/framework/tiny_mce/tiny_mce.js',

		// General options
		theme : "advanced",
		plugins : "pagebreak,style,table,advhr,advimage,advlink,inlinepopups,media,searchreplace,contextmenu,paste,fullscreen,visualchars,advlist,smimage,smexplorer,smeditimage,youtube,yolkpages",

		// Theme options
		theme_advanced_buttons1 : "bold,italic,underline,strikethrough,|,justifyleft,justifycenter,justifyright,justifyfull,formatselect,|,smimage,smeditimage,image,|,smexplorer,|,media,youtube",
		theme_advanced_buttons2 : "cut,copy,paste,pastetext,|,search,replace,|,bullist,numlist,|,outdent,indent,blockquote,|,undo,redo,|,link,unlink,anchor,cleanup,code,|,forecolor,backcolor",
		theme_advanced_buttons3 : "tablecontrols,|,hr,removeformat,|,sub,sup,|,charmap,advhr,|,fullscreen, styleprops,,pagebreak,yolkpages",
		
		theme_advanced_toolbar_location : "top",
		theme_advanced_toolbar_align : "left",
		theme_advanced_statusbar_location : "bottom",
		theme_advanced_resizing : true,

		// Example content CSS (should be your site CSS)
		content_css : "/site/styles/admin/stylesheets/elements.css",
		relative_urls : false,
		verify_html : false,

		// Drop lists for link/image/media/template dialogs
		template_external_list_url : "lists/template_list.js",
		external_link_list_url : "lists/link_list.js",
		external_image_list_url : "lists/image_list.js",
		media_external_list_url : "lists/media_list.js",
		plugin_smimage_directory : "/media/images/",
		plugin_smimage_server : "http://www.yolkfolk.com",
		plugin_smexplorer_directory : "/media/"
	});
		
	
	// Display changes on page load (Must be at the end of the file, else the height may be calculated incorrectly due to disappearing elements)
	$('<div id="background-cloud1"></div>').insertAfter('#background-cloudsTop');
	$('<div id="background-cloud2"></div>').insertAfter('#background-cloud1');   
	// $('<div id="background-cloud3"></div>').insertAfter('#background-cloud2');   
	//  $('<div id="background-heaven"></div>').insertAfter('#background-cloud3');       
	
	//Change height of clouds
	$('#background-cloud1').height(($(document).height() ));
	$('#background-cloud2').height(($(document).height() ));
	//$('#background-cloud3').height(($(document).height() ));
	
	// Animate clouds
	$('#background-cloud1').animate({"left": -50000}, 3600000, 'linear');
	$('#background-cloud2').animate({"left": -25000}, 3600000, 'linear');   
	// $('#background-cloud3').animate({"left": -15000}, 3600000, 'linear');   
	// $('#background-heaven').animate({"left": -20000}, 3600000, 'linear');    
       

});



/* Open links in an new window with the rel="external" tag 
   This is to apply with XHTML 1.0 Stict Standards */
function externalLinks() {  
 if (!document.getElementsByTagName) return;  
 var anchors = document.getElementsByTagName("a");  
 for (var i=0; i<anchors.length; i++) {  
   var anchor = anchors[i];  
   if (anchor.getAttribute("href") &&  
       anchor.getAttribute("rel") == "external")  
     anchor.target = "_blank";  
 }  
}  
window.onload = externalLinks;

function initializeFancybox() {
	
	$("a.fancybox").attr('rel', 'gallery').fancybox({
		'transitionIn'	:	'elastic',
		'transitionOut'	:	'elastic',
		'speedIn'		:	600, 
		'speedOut'		:	200
	});
	
	$("a.imagelink").fancybox({
		'transitionIn'	:	'elastic',
		'transitionOut'	:	'elastic',
		'speedIn'		:	600, 
		'speedOut'		:	200
	});
	
	$('a.youtube').fancybox({ 
		'padding' : 0,
		'type':'iframe' 
	}); 

	
	$('a.lbLink').fancybox({ 
		'margin'  : 0,
		'padding' : 0,
		'type':'iframe' 
	}); 
	
	$("a.PetitionViewLink").fancybox({
		'transitionIn'	:	'elastic',
		'transitionOut'	:	'elastic',
		'speedIn'		:	600, 
		'speedOut'		:	200
	});	
		
};


