/*
	This is the first function called after the DOM is loaded and ready for manipulation.
*/
Spool.setup = function() {
	Spool.initClickTracking();
	
	//> set up tinymce
	Spool.require("vendor/tiny_mce/tiny_mce.js", function() {
		tinyMCE.init({
			extended_valid_elements: 'style,a[name|href|target|title|onclick],img[class|src|border=0|alt|title|hspace|vspace|width|height|align|onmouseover|onmouseout|name]',
			relative_urls : false,
			remove_script_host : false,
			document_base_url : Spool.baseUrl,
			mode : "specific_textareas",
			editor_selector : "mce-editor",
			theme : "advanced",
			plugins : "safari,pagebreak,style,layer,iespell,media,paste",
			theme_advanced_buttons1 : "copy,paste,pastetext,pasteword,|,bold,italic,underline,|,charmap,|,justifyleft,justifycenter,justifyright, justifyfull,|,bullist,numlist,|,link,unlink",
			theme_advanced_buttons2 : "",
			theme_advanced_buttons3 : "",
			theme_advanced_toolbar_location : "top",
			theme_advanced_toolbar_align : "left",
			theme_advanced_statusbar_location : "bottom",
			paste_retain_style_properties: 'none'
		});
	});
	
	//> set up highslide
	Spool.requireCSS("vendor/highslide/highslide.css");
	Spool.require("vendor/highslide/highslide.min.js", function() {
		hs.expandCursor = null;
		hs.restoreCursor = null;
		hs.graphicsDir = Spool.baseUrl + '/system/views/_js/vendor/highslide/graphics/';
		hs.align = 'center';
		hs.transitions = ['expand', 'crossfade'];
		hs.fadeInOut = true;
		hs.dimmingOpacity = 0.8;
		hs.wrapperClassName = '-borderless floating-caption';
		hs.captionEval = 'this.thumb.alt';
		hs.marginLeft = 100; // make room for the thumbstrip
		hs.marginBottom = 80 // make room for the controls and the floating caption
		hs.numberPosition = 'caption';
		hs.lang.number = '%1 of %2';
		hs.showCredits = false;

		// // Add the slideshow providing the controlbar and the thumbstrip
		// hs.addSlideshow({
		// 	//slideshowGroup: 'group1',
		// 	interval: 5000,
		// 	repeat: false,
		// 	useControls: true,
		// 	overlayOptions: {
		// 		className: 'text-controls',
		// 		position: 'bottom center',
		// 		relativeTo: 'viewport',
		// 		offsetX: 50,
		// 		offsetY: -75
		// 	},
		// 	thumbstrip: {
		// 		position: 'bottom top',
		// 		mode: 'horizontal',
		// 		relativeTo: 'viewport'
		// 	}
		// });

		// Add the simple close button
		hs.registerOverlay({
			html: '<div class="closebutton" onclick="return hs.close(this)" title="Close"></div>',
			position: 'top right',
			fade: 2 // fading the semi-transparent overlay looks bad in IE
		});
	});
};
