/*
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

	DEFAULT - initialize, functions
	
-----------------------------------------------------------------------------------------------------------------------------

	DEPENDENCIES: 
	MooTools - version 1.20              
	copyright 2007 | Valerio Proietti | http://mootools.net/
	MIT-style license | http://www.opensource.org/licenses/mit-license.php
	
	Clientside CNET Libraries for MooTools
	For descriptions and documentation: http://clientside.cnet.com/wiki/cnet-libraries
	
-----------------------------------------------------------------------------------------------------------------------------

	:: squarehead design studio   -  845.331.1953 | www.squarehead.com | sbliss@squarehead.com
	
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
*/


/* 	opens and closes the search field
---------------------------------------------------------------------------------------------------------------------------*/
function openSearch(entry) {
	$('searchField').tween('width', '200');
	entry.value = ""
}
function closeSearch(entry) {
	if (entry.value == "") {
		$('searchField').tween('width', '100');
		entry.value = "SEARCH"
	}
}

/* 	accordions
---------------------------------------------------------------------------------------------------------------------------*/
function initAccordions(){
	if ($$('aToggle')){
		aPanels = new Accordion($$('.aToggle'), $$('.aPanel'), {
			duration: 400,
			opacity: false,
			alwaysHide: true, 
			start: 'all-closed',
			onActive: function(toggler, element){
				toggler.addClass('toggler-open');
			},
			onBackground: function(toggler, element){
				toggler.removeClass('toggler-open');
			}
		});
	}
}

/* 	initialize menu - create effects on tabs
---------------------------------------------------------------------------------------------------------------------------*/
function initMenu(){
	$$('#navbar .active a').addEvents({
		'mouseenter': function(){
			this.morph({
				'background-color':'#0D392C'
			});
		},
		'mouseleave': function(){
			this.morph({
				'background-color':'#595D5E'
			});
		},
		'mousedown': function(){
			this.morph({
				'background-color':'#C7901C'
			});
		}
	});	
}

/* 	initialize link widgets - contain arrow and link
---------------------------------------------------------------------------------------------------------------------------*/
function initLinkWidget(url){
	if ($$('.linkWidget')){
		$$('.linkWidget').addEvents({
			'mouseenter': function(){
				this.getFirst().set('tween', {
					duration: 700,
					transition: Fx.Transitions.Elastic.easeOut
				}).tween('margin-left', '40px');
			},
			'mouseleave': function(){
				this.getFirst().set('tween', { duration: 200 }).tween('margin-left', '20px');
			},
			'click': function(){
				location.href = url;
			}
		});
	}	
}

/* 	tips
---------------------------------------------------------------------------------------------------------------------------*/
function initTips(){
	if ($$('.toolTipElement')){
		var myTips = new Tips($$('.toolTipElement'), {
			hideDelay: 700,
			fixed: false,
			offsets: {'x': -10, 'y': 25}
		});
	}
}


/* 	Carousel - CNET framework - Clentside docs: http://clientside.cnet.com/docs/Layout/SimpleCarousel
---------------------------------------------------------------------------------------------------------------------------*/
function initCarousel(){
	new SimpleCarousel($('simpleCarousel'), $$('#simpleCarousel div.slide'), $$('#simpleCarousel td.button'), {
		slideInterval: 5000,
		rotateAction: 'click'
	});
}

/* 	INITIALIZE STUFF AFTER DOM LOADS
---------------------------------------------------------------------------------------------------------------------------*/
window.addEvent('domready', function(){
	initMenu();
	initAccordions();
	initTips();
});



