function capsuleClick() {
	var $this = $(this);
	
	if ($this.hasClass("stop")) {
		toggleCapsule();
		
		$(".stop span").text("play capsule mix");
		$(".stop").removeClass("stop");
	} else {
		toggleCapsule(this.href);
		
		$(".stop span").text("play capsule mix");
		$(".stop").removeClass("stop");
		
		$this.addClass("stop");
		$(".stop span").text("stop capsule mix");
	}
	
	return false;
}

function deobfuscate() {
	var s = $(this).attr("title").split("|");
	var a = s[2] + "@" + s[1] + "." + s[0];
	$(this).attr({href: "mailto:" + a, title: ""}).text(a);
}

function rateClick() {
    $(this).toggleClass("rated");
	$.post(this.href);
    
	return false;
}

$(document).ready(function() {
	$("#search input[type=text]").prompt();
	
	$("form#registerForm input#password").change(function(){$("input#passwordConfirm").val('');});
	
	$("a.obfuscated").each(deobfuscate);
	
	$(".rate").click(rateClick).tooltip();
	
	if(window.initPlayer != null) { initPlayer(); }
	if(window.initPage != null) { initPage(); }
});
