var Site = {
	start:function(){
		//Site.menu_accordion();
		Site.menu_collapse();
		Site.externalLinks();
		Site.bounceLogo();
	},
	
	externalLinks: function(){
        $$(document.links).each(function(link){
            if (link.getProperty('rel') == 'nofollow') link.setProperties({'target': '_blank', 'title': 'opens in new window'});
        });
    },

    bounceLogo: function(){
        // Adapted from http://moofx.mad4milk.net/
        var ball = $('ieee_logo');
		var ballfx = new Fx.Styles(ball, {duration: 1000, 'transition': Fx.Transitions.Elastic.easeOut});
		new Drag.Base(ball, {
			onComplete: function(){
				ballfx.start({'top': 15, 'left': 882});
			}
		});

    },
	
	menu_accordion:function(){
		var accordion = new Accordion('a.stretch_toggler', 'div.stretcher', {
			opacity: false,
			onActive: function(toggler, element){
				toggler.setStyle('color', '#ff3300');
			},
		 
			onBackground: function(toggler, element){
				toggler.setStyle('color', '#222');
			}
		}, $('unique-menu'));
	},
	
	menu_collapse: function(){
		var colls = $$('div.stretcher');
		var headers = $$('a.strecth_toggler');
		
		headers.each( function(header, i) {
			var collapsible = new Fx.Slide(colls[i], { 
				duration: 500, 
				transition: Fx.Transitions.linear
			});
			
			header.onclick= function(){	
				collapsible.toggle();
				return false;
			};
			
			collapsible.hide();
			if(header.getParent().hasClass('active')){
				collapsible.show();
			}
		});
	}
}
