/*

Global Javascript Functions

Alexander & Baldwin
08.23.08
	
Christopher Kalima (chris@airspaceworkshop.com)


*/

// Initialize Global Slider FX

window.addEvent('domready', function(){
	
	// CSS Class Names For SlideFX
	
	var globalToggleClass = '.slide-toggle'; //elements that toggle
	
	var toggles = $$(globalToggleClass);
	
	var myToggles = {};
	
	// Create Fx.Slide Classes based on toggle targets
	// This requires href attribute to be set to #id
	
	toggles.each(function(el, i){

		var linkid = toggles[i].get('href');
		
		var splithref = {}
		splithref = linkid.split('#');
		
		$(splithref[1]).slide('hide');
		
	});

	// Assign Fx.Slide Events To Toggles
	
	toggles.each(function(el, i){
	
		toggles[i].addEvent('click', function(e){
		
			e = new Event(e);
			
			var linkid = this.get('href');
			
			var splithref = {}
			splithref = linkid.split('#');
			
			$(splithref[1]).slide('toggle');

			this.toggleClass('hide');
			
			if (this.hasClass('hide')) {
					this.getElement('span').set('text', 'Hide');
				} else {
					this.getElement('span').set('text', 'View');
			}

			e.stop();
		
		});
	});

});
