function autocenter(div) {
	var a = document.body.clientWidth;
	var b = document.getElementById(div);
	var c = b.offsetWidth-a;
	var d = window.pageYOffset; //current vertical scroll position
	/*b.style.marginLeft = (c/2)+"px";
	alert(hscroll);
	if (navigator.appName == "Microsoft Internet Explorer"){
		alert(c+"px");
		alert(b.offsetWidth);
		alert(a);
		var hscroll = 300;
	} else {*/
	var hscroll = c/2;
	/*}*/
	//alert(window.pageYOffset);
	window.scroll(hscroll, d);
}

function scrolltoTop() {
	//alert('should be scrolling');
	window.scroll(window.pageXOffset, 0);
}

function showTitle() {
	var title = document.getElementById('jp-title');
	title.style.display = "block";
}

function pageToggle(page){
	if ((page.substring(0,2)) == "#/"){
		//alert('should be loaded onLoad!');
		var page = page.replace("#/", "");
		var page = page.split("/");
		var subitem = page[2];
		var item = page[1];
		var p = page[0];
	} else {
		var p = page;
	}
	
	if (window.XMLHttpRequest) {
	  xmlhttp=new XMLHttpRequest();
	}
	
	xmlhttp.onreadystatechange=function(){
	  //alert(xmlhttp.readyState);
	  if (xmlhttp.readyState==4 && xmlhttp.status==200){
			//alert('page.php?q='+page);
			document.getElementById('container').innerHTML=xmlhttp.responseText;
	    }
	}
	
	if (typeof(item)!="undefined"){
		if (typeof(subitem) != "undefined"){
			xmlhttp.open("GET","page.php?q="+p+"&item="+item+"&subitem="+subitem,true);
		} else {
			xmlhttp.open("GET","page.php?q="+p+"&item="+item,true);	
		}
	} else {
		xmlhttp.open("GET","page.php?q="+p,true);
	}
	
	xmlhttp.send();
	
	switch(p) {
	
	default:
		document.getElementById('menu_news').style.display = "inline";
		document.getElementById('menu_news_selected').style.display = "none";
		document.getElementById('menu_bio').style.display = "inline";
		document.getElementById('menu_bio_selected').style.display = "none";
		document.getElementById('menu_disc').style.display = "inline";
		document.getElementById('menu_disc_selected').style.display = "none";
		document.getElementById('menu_radio').style.display = "inline";
		document.getElementById('menu_radio_selected').style.display = "none";			
		document.getElementById('menu_media').style.display = "inline";
		document.getElementById('menu_media_selected').style.display = "none";	
		document.getElementById('menu_contact').style.display = "inline";
		document.getElementById('menu_contact_selected').style.display = "none";	
	break;
	
	case "news":
		document.getElementById('menu_news').style.display = "none";
		document.getElementById('menu_news_selected').style.display = "inline";
		document.getElementById('menu_bio').style.display = "inline";
		document.getElementById('menu_bio_selected').style.display = "none";
		document.getElementById('menu_disc').style.display = "inline";
		document.getElementById('menu_disc_selected').style.display = "none";
		document.getElementById('menu_radio').style.display = "inline";
		document.getElementById('menu_radio_selected').style.display = "none";			
		document.getElementById('menu_media').style.display = "inline";
		document.getElementById('menu_media_selected').style.display = "none";	
		document.getElementById('menu_contact').style.display = "inline";
		document.getElementById('menu_contact_selected').style.display = "none";	
	break;
	
	case "biography":
		document.getElementById('menu_news').style.display = "inline";
		document.getElementById('menu_news_selected').style.display = "none";
		document.getElementById('menu_bio').style.display = "none";
		document.getElementById('menu_bio_selected').style.display = "inline";
		document.getElementById('menu_disc').style.display = "inline";
		document.getElementById('menu_disc_selected').style.display = "none";
		document.getElementById('menu_radio').style.display = "inline";
		document.getElementById('menu_radio_selected').style.display = "none";			
		document.getElementById('menu_media').style.display = "inline";
		document.getElementById('menu_media_selected').style.display = "none";	
		document.getElementById('menu_contact').style.display = "inline";
		document.getElementById('menu_contact_selected').style.display = "none";
	break;
	
	case "discography":
		document.getElementById('menu_news').style.display = "inline";
		document.getElementById('menu_news_selected').style.display = "none";
		document.getElementById('menu_bio').style.display = "inline";
		document.getElementById('menu_bio_selected').style.display = "none";
		document.getElementById('menu_disc').style.display = "none";
		document.getElementById('menu_disc_selected').style.display = "inline";
		document.getElementById('menu_radio').style.display = "inline";
		document.getElementById('menu_radio_selected').style.display = "none";			
		document.getElementById('menu_media').style.display = "inline";
		document.getElementById('menu_media_selected').style.display = "none";	
		document.getElementById('menu_contact').style.display = "inline";
		document.getElementById('menu_contact_selected').style.display = "none";	
	break;
	
	case "radio":
		document.getElementById('menu_news').style.display = "inline";
		document.getElementById('menu_news_selected').style.display = "none";
		document.getElementById('menu_bio').style.display = "inline";
		document.getElementById('menu_bio_selected').style.display = "none";
		document.getElementById('menu_disc').style.display = "inline";
		document.getElementById('menu_disc_selected').style.display = "none";
		document.getElementById('menu_radio').style.display = "none";
		document.getElementById('menu_radio_selected').style.display = "inline";			
		document.getElementById('menu_media').style.display = "inline";
		document.getElementById('menu_media_selected').style.display = "none";	
		document.getElementById('menu_contact').style.display = "inline";
		document.getElementById('menu_contact_selected').style.display = "none";	
	break;
	
	case "mediagallery":
		document.getElementById('menu_news').style.display = "inline";
		document.getElementById('menu_news_selected').style.display = "none";
		document.getElementById('menu_bio').style.display = "inline";
		document.getElementById('menu_bio_selected').style.display = "none";
		document.getElementById('menu_disc').style.display = "inline";
		document.getElementById('menu_disc_selected').style.display = "none";
		document.getElementById('menu_radio').style.display = "inline";
		document.getElementById('menu_radio_selected').style.display = "none";			
		document.getElementById('menu_media').style.display = "none";
		document.getElementById('menu_media_selected').style.display = "inline";	
		document.getElementById('menu_contact').style.display = "inline";
		document.getElementById('menu_contact_selected').style.display = "none";	
	break;
	
	case "contact":
		document.getElementById('menu_news').style.display = "inline";
		document.getElementById('menu_news_selected').style.display = "none";
		document.getElementById('menu_bio').style.display = "inline";
		document.getElementById('menu_bio_selected').style.display = "none";
		document.getElementById('menu_disc').style.display = "inline";
		document.getElementById('menu_disc_selected').style.display = "none";
		document.getElementById('menu_radio').style.display = "inline";
		document.getElementById('menu_radio_selected').style.display = "none";			
		document.getElementById('menu_media').style.display = "inline";
		document.getElementById('menu_media_selected').style.display = "none";	
		document.getElementById('menu_contact').style.display = "none";
		document.getElementById('menu_contact_selected').style.display = "inline";	
	break;
	}
	
	
}

function shout(){
	alert('SHOUT!');
}

function pageHeight(){
	//alert('click');
}


function jCycle(){
	$('.banner_top').cycle({
		fx: 'scrollRight', // choose your transition type, ex: fade, scrollUp, shuffle, etc... :)
		speed:  500, // time untill next slide in ms
		timeout: 10000 // time of transition
	});
}

function discography(){
	if(jQuery("#originals-gallery").length){
	//alert(jQuery("#originals-gallery").length);
	
	// Variables aren't use properly due to Webkit
	var totalImages = jQuery("#originals-gallery > li").length, 
		imageWidth = jQuery("#originals-gallery > li:first").outerWidth(true),
		totalWidth = imageWidth * totalImages,
		visibleImages = Math.round(jQuery("#originals-gallery-wrap").width() / imageWidth),
		visibleWidth = visibleImages * imageWidth,
		stopPosition = (visibleWidth - totalWidth);
		//alert(jQuery("#originals-gallery > li").length);
		
	jQuery("#originals-gallery").width(totalWidth);
	
	jQuery("#originals-gallery-prev").click(function(){
		if(jQuery("#originals-gallery").position().left < 0 && !jQuery("#originals-gallery").is(":animated")){
			jQuery("#originals-gallery").animate({left : "+=" + imageWidth*4 + "px"});
		}
		return false;
	});
	
	jQuery("#originals-gallery-next").click(function(){
		if(jQuery("#originals-gallery").position().left > stopPosition && !jQuery("#originals-gallery").is(":animated")){
			jQuery("#originals-gallery").animate({left : "-=" + imageWidth*4 + "px"});
		}
		return false;
	});
	}
	if(jQuery("#remix-gallery").length){
	//alert(jQuery("#remix-gallery").length);
	
	// Variables aren't used properly due to Webkit
	var totalImages = jQuery("#remix-gallery > li").length, 
		imageWidth = jQuery("#remix-gallery > li:first").outerWidth(true),
		totalWidth = imageWidth * totalImages,
		visibleImages = Math.round(jQuery("#remix-gallery-wrap").width() / imageWidth),
		visibleWidth = visibleImages * imageWidth,
		stopPosition = (visibleWidth - totalWidth);
		//alert(jQuery("#remix-gallery > li").length);
		
	jQuery("#remix-gallery").width(totalWidth);
	
	jQuery("#remix-gallery-prev").click(function(){
		if(jQuery("#remix-gallery").position().left < 0 && !jQuery("#remix-gallery").is(":animated")){
			jQuery("#remix-gallery").animate({left : "+=" + imageWidth*4 + "px"});
		}
		return false;
	});
	
	jQuery("#remix-gallery-next").click(function(){
		if(jQuery("#remix-gallery").position().left > stopPosition && !jQuery("#remix-gallery").is(":animated")){
			jQuery("#remix-gallery").animate({left : "-=" + imageWidth*4 + "px"});
		}
		return false;
	});
	}
}

function mediagallery(){
	if(jQuery("#picturesgigs-gallery").length){
	//alert(jQuery("#remix-gallery").length);
		
		// Variables aren't use properly due to Webkit
		var totalImages = jQuery("#picturesgigs-gallery > li").length, 
			imageWidth = jQuery("#picturesgigs-gallery > li:first").outerWidth(true),
			totalWidth = imageWidth * totalImages,
			visibleImages = Math.round(jQuery("#picturesgigs-gallery-wrap").width() / imageWidth),
			visibleWidth = visibleImages * imageWidth,
			stopPosition = (visibleWidth - totalWidth);
			//alert(jQuery("#remix-gallery > li").length);
			
		jQuery("#picturesgigs-gallery").width(totalWidth);
		
		jQuery("#picturesgigs-gallery-prev").click(function(){
			if(jQuery("#picturesgigs-gallery").position().left < 0 && !jQuery("#picturesgigs-gallery").is(":animated")){
				jQuery("#picturesgigs-gallery").animate({left : "+=" + imageWidth*4 + "px"});
			}
			return false;
		});
		
		jQuery("#picturesgigs-gallery-next").click(function(){
			if(jQuery("#picturesgigs-gallery").position().left > stopPosition && !jQuery("#picturesgigs-gallery").is(":animated")){
				jQuery("#picturesgigs-gallery").animate({left : "-=" + imageWidth*4 + "px"});
			}
			return false;
		});
	}
	
	$(".mediagallery").fancybox({
				'overlayColor'		: '#000',
				'overlayOpacity'	: 0.4
	});	
}

function playlistRelease(){
	var playlist = document.getElementById("others");
	var list = '{title:"Visionary (Original Mix)",mp3: "media/mp3/Mark Sixma - Visionary (Original Mix).mp3",oga:"media/ogg/Mark Sixma - Visionary (Original Mix).ogg"},';
	playlist.innerHTML = "dit is een test";
	//playlist.innerHTML = 'function release(){ new jPlayerPlaylist({ jPlayer: "#jquery_jplayer_2", cssSelectorAncestor: "#jp_container_2"	}, ['+list+'], { swfPath: "js", supplied: "oga, mp3", wmode: "window" }); var title2 = document.getElementById(\'jp-title2\'); title2.style.display = "block";'
	//alert(playlist.innerHTML);
}

/*
function release(){
		new jPlayerPlaylist({
		jPlayer: "#jquery_jplayer_2",
		cssSelectorAncestor: "#jp_container_2"
	}, [
		{
		title:"Visionary (Original Mix)",
		mp3: "media/mp3/Mark Sixma - Visionary (Original Mix).mp3",
		oga:"media/ogg/Mark Sixma - Visionary (Original Mix).ogg"
	 	},
		
		{
		title:"Forsaken",
		mp3:"media/mp3/Mark Sixma - Forsaken.mp3",
		oga:"media/ogg/Mark Sixma - Forsaken.ogg"
		},
	], {
		swfPath: "js",
		supplied: "oga, mp3",
		wmode: "window"
	});

	var title2 = document.getElementById('jp-title2');
	title2.style.display = "block";
}
*/

function twitterFadeIn(){
	//alert('fading twitter!!');
	$('.tweets').fadeIn('fast', function() {
        // Animation complete
      });
	$('.twitter').fadeIn('slow', function() {
        // Animation complete
      });
}

function twitterHide(){
	//alert('fading twitter!!');
	$('.tweets').hide();
	$('.twitter').hide();
}

