
function menu() {
		$("#menu a").hover(
	      function () {
	        $(this).siblings().css('visibility', 'visible');
			}, 
	      function () {
	        $(this).siblings().css('visibility', 'hidden');
	      }
	);
}

function swap_letter() {
	$('.release_desc p:first, .news_item p:first').each(function(index) {
		var paragraph = this;
		var node = paragraph;
		while (node.childNodes.length) {
			node = node.firstChild;
		}
		var text = node.nodeValue;
		var first_letter = text.substr(0,1);
		var match = /[a-zA-Z]/.test(first_letter);
		if ( match ) {
			node.nodeValue = text.slice(1);
			$('<img />')
			.attr('src','/xmedia/theme/marienbad/img/lettrines/' + first_letter.toUpperCase() + '.gif')
			.attr('alt',first_letter)
			.addClass('fancy_letter')
			.prependTo( paragraph );
			first_letter = "";
		}
	});
}

function scrolling() {
	// Smoother scrolling on #local links
	jQuery(function( $ ){
	   $.localScroll({
			axis:'xy',
			//queue:true,
			duration: 1600,
			//easing:'easeInOutExpo'
			hash:true		
		});
	});
}

function news() {
	var options = {
		newsList: "#intro_ticker",
		tickerRate: 70,
		startDelay: 10,
		loopDelay: 3500,
		placeHolder1: " _"
	}
	$().newsTicker(options);
}

function showLogRes() { 
	// Display the log_res div, for alerts and results
	$('#log_res').addClass("ajax_loading").animate({ 
		opacity: 1
		}, 1000 )
		.css("display", "block");
}

function showResponse(responseText, statusText)  { 
	$('#log_res').removeClass("ajax_loading"); 
}


$(document).ready(function() { 
	
	// Go to #home at loading //
	document.location.hash = '#home';
	
	//menu
	menu();
	
	// Record history for using with browser's back/forward arrows //
	$.ajaxHistory.initialize();
		
	// Add smooth movement on anchors links //
	scrolling();
	
	// News ticker in #home //
	news();
	
	// Add little flash player on #releases tracklists //
	$(".mp3").jmp3({
	   showfilename: "false",
	   backcolor: "FFFFFF",
	   forecolor: "000000",
		width: 20,
	   showdownload: "false"
	 });
	
	// Add tooltips on #releases_grid rollover //
	$(function() {
		$('#releases_grid *').tooltip();
	});

	// Validate and send the #contact form //
	var options = { 
		target:        '#log_res',  
		beforeSubmit:  showLogRes,  
		success:       showResponse
	}; 
	$('#emailForm').ajaxForm(options);

	// Add initial letters on paragraphs, #releases #news_items //
	swap_letter();
	
});




