/*
	This is the first function called after the DOM is loaded and ready for manipulation.
*/
Spool.setup = function() {
	var aryFeatures = $$("#features li");
	if(aryFeatures.length) {
		var curFeature = 0;
		setInterval(function() {
			Effect.Fade(aryFeatures[curFeature], { duration: 1 });
			curFeature = (curFeature+1) % aryFeatures.length;
			Effect.Appear(aryFeatures[curFeature], { duration: 1 });
		}, 5000);
	}
	
	Spool.initClickTracking();
	
	Spool.require("util/defaultValueActsAsHint.js", function() {
		$$('.hint').each(function(elem) {
			elem.defaultValueActsAsHint();
		});
	});
	
	//> 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-full.js", function() {
		hs.expandCursor = null;
		hs.restoreCursor = null;
		hs.graphicsDir = Spool.javascriptBase + '/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
		});
	});
};

/***********************************************
* Bookmark site script- © Dynamic Drive DHTML code library (www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit Dynamic Drive at http://www.dynamicdrive.com/ for full source code
***********************************************/

function bookmarkSite(title,url){
	if (window.sidebar) { // firefox
		window.sidebar.addPanel(title, url, "");
	}
	else if(window.opera && window.print) { // opera
		var elem = document.createElement('a');
		elem.setAttribute('href',url);
		elem.setAttribute('title',title);
		elem.setAttribute('rel','sidebar');
		elem.click();
	} 
	else if(document.all) {// ie
		window.external.AddFavorite(url, title);
	}
}

function doSubmit() {
	$('frmEmail').request({
		onSuccess: function(t) {
			alert(t.responseText);
			$('frmEmail').reset();
		}
	});
}
