$(document).ready(function(){
	
	$("a[rel='external']").click(function(event){
		event.preventDefault();
		window.open(this);
	});	
	
	$('span.addr').each(function() {
		$(this).attr("id", "addr0");
		var spt = "#" + $(this).attr("id");
		var to = ' [at] ';
		var period = ' [.] ';
		var addr = $(spt).text()
			.replace(to, "@")
			.replace(period, ".")
			.replace(period, ".");
		$(spt).after('<a href="mailto:' + addr + '">' + addr +'</a>');
		$(spt).remove();
	});
	
	$('#cd_menu a').each(
		function() {
			$(this).click(
				function(e) {
					e.preventDefault();
					toggleMenus( this.id );
				}
			);
		}
	);
	
//	$('#order_link').click( function(e) {
//		e.preventDefault();
//		toggleMenus( this.id );
//	});
//	
//	$('#lyrics_link').click( function(e) {
//		e.preventDefault();
//		toggleMenus( this.id );
//	});
//	
//	$('#samples_link').click( function(e) {
//		e.preventDefault();
//		toggleMenus( this.id );
//	});
//	
//	$('#credits_link').click( function(e) {
//		e.preventDefault();
//		toggleMenus( this.id );
//	});
	
});

function toggleMenus( elm ) {
	
	var elm_temp = elm.split('_');
	var len = $('#cd_menu a').length;
	var i = 0;
	
	$('#cd_menu a').each(
			
		function() {
			
			i++;
			var temp = this.id.split('_');
			
			if ( i == 4 ) {
				$('#' + temp[0]).fadeOut(
					function() {
						$('#' + elm_temp[0]).fadeIn();
					}
				);
			} else {
				$('#' + temp[0]).hide();
			}
			
		}
		
	);
	
	
		//$('#' + elm_temp[0]).fadeIn();
	
}
