/*
	Devee
	Default Site Scripts
	====================
	
	by DAVIES MEYER, 2011
*/

var urlHash = false;

function checkHash(){
	if( window.location.hash != urlHash ) {
		urlHash = window.location.hash;
		if( urlHash == "#!/" ) {
			$("#content").hide();
			$("#content").load("start.content.html");
			//$("#content").fadeIn(500);
			$("#content").show();
			$('html, body').animate({scrollTop:0}, 'fast');
		} else {
			if( urlHash ) {
				$("#content").hide();
				$("#content").load(urlHash.substr(2)+".content.html");
				//$("#content").fadeIn(500);
				$("#content").show();
				$('html, body').animate({scrollTop:0}, 'fast');
			}
		}
	}
	setTimeout("checkHash()", 200);
};

$(document).ready(function(){
	
	$(function(){
		checkHash();
	});
	
	/*$("ul#menu li a.menu-title").click(function(event){
		event.preventDefault();
	});*/
	
	
	// Audio player
	$("#footer-audio-player").jPlayer({
		preload: "auto",
	    ready: function () {
	      $(this).jPlayer("setMedia", {	
	        mp3: "http://www.devee.de/music/devee-music.mp3",
	        m4a: "http://www.devee.de/music/devee-music.m4a",
		    oga: "http://www.devee.de/music/devee-music.oga"
	      });
		  $(this).jPlayer("play");
	    },
		ended: function() {
		  $(this).jPlayer("play");
		},
	    swfPath: "../js/jplayer",
	    supplied: "mp3, m4a, oga",
		solution : "flash, html"    // Debugging, default: "html, flash"
	  });
	
	$("a#footer-audio-play").hide();
	$("a#footer-audio-pause").click(function(e){
		e.preventDefault();
		$("#footer-audio-player").jPlayer("pause");
		$("a#footer-audio-play").show();
		$("a#footer-audio-pause").hide();
	});
	$("a#footer-audio-play").click(function(e){
		e.preventDefault();
		$("#footer-audio-player").jPlayer("play");
		$("a#footer-audio-pause").show();
		$("a#footer-audio-play").hide();
	});
	
	// Main menu
	$("ul#menu li a").click(function(event){
		if( $(this).hasClass("menu-title") ) {
			event.preventDefault();
		}
		else {
			$("ul#menu li a").each(function(element){ $(this).removeClass("active"); });
			$(this).addClass("active");
		}
	});
	
});

