// JavaScript Document
function getNews(start){	
	$.get('modules/news.php', {'start':start}, function(data){					
			$('#info .innerdiv').html(data);
	});				
}
				
function setMusicButtons(objectname){
	$('.button').hover(
		function(){src=$("img", this).attr('src');src=src.replace('_N', '_MO');$("img", this).attr('src', src);},
		function(){src=$("img", this).attr('src');src=src.replace('_MO', '_N');$("img", this).attr('src', src);}
	);
	
	
		
		
		
	obj=$(objectname);
	obj.unbind('mouseenter mouseleave');
	$('.track').css('background', 'none');
	$('.track_title').css('color', '#093');
	$('.track img').attr('src', 'img/kleinepijl_N.png');	
	$('.track_title', obj).css('color', '#f00');
	obj.css('background-image', 'url(img/pixel333.png)');
	$('img', obj).attr('src', 'img/kleinepijl_MO.png');	
	
}
function playTrack(objectname, filename){		
	setMusicButtons(objectname);
	var mplayer = $.flash.create({
		swf: 'play.swf',
		height: 200,
		width: 280,
		wmode: 'transparent',
		flashvars: {
			'filename': filename		
		}
	});	
	$('#player').html(mplayer);

}
var next=1;
var current=0;
function blink_seq(current, next){
	l=$('.seq').length;
	
	$('.seq img').eq(current).fadeOut('fast')
	$('.seq img').eq(next).fadeIn('fast')
	
	current=next;
	
	next++;
	if(next>l){next=0;}
	
	setTimeout(blink_seq,5000*Math.random(),  current, next);
}

function sequenzer(){

blink_seq(0,1);
	
}


function showAgendaItem(id){
	alert(id);
}
function navigate(page){
	if(page=='news'){
		$.get('modules/news.php', {'start':'0'}, function(data){					
			$('#info .innerdiv').html(data);
		});
	}else if(page=='contact'){		
		if($('#info .innerdiv').html()==''){$.get('modules/info.php', {'page':'bio'}, function(data){$('#info .innerdiv').html(data);});}
				$.dimScreen(500, 0.7);
				t=($(window).height()/2)-250;
					l=($(window).width()/2)-250;
				$('<div id="contact_popup" style="background-image:url(img/contact.png);width:500px;height:500px;z-index:99999;display:none;position:absolute;"><div style="margin:0px;position:relative;top:0px;left:0px;"><img src="img/close_N.png" onclick="closePopUp()" style="cursor:pointer;position:absolute;right:0px;"/></div><a href="mailto:info@backtomars.net"><img src="img/mail_N.png" alt="" style="cursor:pointer;position:absolute;top:238px;left:177px;border:none;" /></a></div>').appendTo(document.body).fadeIn(500);;
						
					$('#contact_popup').css({'top':t+'px', 'left':l+'px'});
						
							$('#contact_popup img').hover(
						function(){src=$(this).attr('src');src=src.replace('_N', '_MO');$(this).attr('src', src);},
						function(){src=$(this).attr('src');src=src.replace('_MO', '_N');$(this).attr('src', src);}
					);
	}else{
		$.get('modules/info.php', {'page':page}, function(data){					
			$('#info .innerdiv').html(data);
		});	
	}
}

function closePopUp(){
		$.dimScreenStop() 
	$('#contact_popup').fadeOut(500, function(){
	$(this).remove();
	})
}
function anchorNavigate(){
	 $('a[href*="#"]').click(function() {		
			href=($(this).attr('href'));
			 page=href.substr(1, href.length);
			navigate(page);				
	 });
}

$(document).ready(function(){
		$('.seq').hover(
						
		function(){$('img', this).fadeIn('fast');},
		function(){$('img', this).fadeOut('fast');}
	);
		
		//sequenzer();
	anchorNavigate();	
	h=window.location.hash;
	if(h==''){currentpage='bio'}else{currentpage=h.substr(1, h.length);}
	navigate(currentpage)	
	$('.btn_menu').hover(
		function(){$('.overlay', this).fadeIn();},
		function(){$('.btn_menu .overlay').stop(true, true).fadeOut();}
	);
	
});


