var Site = {
	start: function(){
		MooTools.lang.setLanguage("en-US");
		// Launch-in-new-window links automagically created
		var extLinks = $$('a.external');
		if ( extLinks.length ) {
			extLinks.each(function(elem, idx) { 
				elem.setProperty('target', '_blank');
			});
		}
		// Form validation automagic
		var valForms = $$('form.validate-form');
		if ( valForms.length ) {
			valForms.each(function(elem, idx) { 
				new FormValidator.Inline(elem, {
					onFormValidate: Site.formHandler
				});
			});
		}
		if ($('member-login-content')) Site._memberLoginSetup();
		if ($('accordion')) Site._accordionSetup();
		if ($('text-decrease-top')) {
			$('text-decrease-top').addEvent('click', Site.scaleDown);
			$('text-increase-top').addEvent('click', Site.scaleUp);
            $('print-page').addEvent('click', Site.printPage);
		}
        
	},
    
    printPage: function(url)
    {
        window.open("&rtemplate=2441", 'PrintPage', 'width=680,height=740,location=no,toolbars=no,status=no, scrollbars=yes');
    },
    
    
	formHandler: function(pass, form, submitEvent) {
		// Do anything necessary here
	},
	_memberLoginSetup: function() {
		
		var slidey = new Fx.Slide('member-login-content').hide();
				
		$('member-login-btn').addEvent('click', function(e){
			e.stop();
			slidey.toggle();
		});

	},
	_accordionSetup: function() {

		var myAccordion = new Accordion($('accordion'), 'h3.toggler', 'div.stretcher', {
			opacity: false,
			onActive: function(toggler, element){
				toggler.setStyle('background-position', 'left bottom');
			},
			onBackground: function(toggler, element){
				toggler.setStyle('background-position', 'left top');
			}
		});

	},
	currentFontSize: 100,
	scaleDown: function() {
		Site.currentFontSize -= 10;
		Site.updateFontSize();
	},
	scaleUp: function() {
		Site.currentFontSize += 10;
		Site.updateFontSize();
	},
	updateFontSize: function() {
		$('content-main-inner').style.fontSize = Site.currentFontSize+"%";
		$('content-main-inner').style.lineHeight = (Site.currentFontSize * 1.5)+"%"; // * 1.5 'cause lineheight should already be 150%
		Cufon.replace('#member-login h3, #content-main-inner h1, #content-main h2, #content-main h3, #footer h5, #top-logged-in h1', { fontFamily: 'Myriad Pro' });
	}
    
};
window.addEvent('domready', Site.start);
