function loadXMLDoc(url,cfunc)
{
if (window.XMLHttpRequest)
  {// code for IE7+, Firefox, Chrome, Opera, Safari
  xmlhttp=new XMLHttpRequest();
  }
else
  {// code for IE6, IE5
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
xmlhttp.onreadystatechange=cfunc;
xmlhttp.open("GET",url,true);
xmlhttp.send();
}

function changeSong(song)
{
// If audio is already there, pause it.
myAudio = document.getElementsByTagName('audio')[0];
if (myAudio) {myAudio.pause();}
// Replace with new audio
document.getElementById("musiccontent").innerHTML="<img src=\"layout/loader.gif\" alt=\"Loading...\" \>";	
surlToLoad = "musicplayer.php?song="+song;
loadXMLDoc(surlToLoad,function()
  {
  if (xmlhttp.readyState==4 && xmlhttp.status==200)
    {
    document.getElementById("musiccontent").innerHTML=xmlhttp.responseText;
	var playeropened = "yes";
	}
  }); 
}

function changePage(page)
{
document.getElementById("loader").innerHTML="<div align=\"center\"><img src=\"layout/loader.gif\" alt=\"Loading...\" \></div>";	
purlToLoad = "content.php?page="+page;
loadXMLDoc(purlToLoad,function()
  {
  if (xmlhttp.readyState==4 && xmlhttp.status==200)
    {
	document.getElementById("content").innerHTML=xmlhttp.responseText;
	document.getElementById("loader").innerHTML="";	
	window.location.hash=page;
    changeMenu(page);
	loadedpage=page;
	pageTracker._trackPageview("/?" + page); //Google Analytics
	}
  });
}

function changeMenu(menu)
{
murlToLoad = "menu.php?page="+menu;
loadXMLDoc(murlToLoad,function()
  {
  if (xmlhttp.readyState==4 && xmlhttp.status==200)
    {
    document.getElementById("menu").innerHTML=xmlhttp.responseText;
    }
  });
}

function shownews()
{
document.getElementById('morenews').style.display='block';
document.getElementById('morenewslink').innerHTML='<a href="?home" onclick="javascript:hidenews(); return false;">Show less news...</a>';
window.location.hash="home/more";
loadedpage="home/more";
}

function hidenews()
{
document.getElementById('morenews').style.display='none';
document.getElementById('morenewslink').innerHTML='<a href="?home/more" onclick="javascript:shownews(); return false;">Show more news...</a>';
window.location.hash="home";
loadedpage="home";
}

function CheckForHash(){
			var hashpage = window.location.hash.slice(1);
			if (hashpage!=loadedpage)  {changePage(hashpage);}
}

var loadedpage = "";
var HashCheckInterval = self.setInterval("CheckForHash()", 500);
window.onload = CheckForHash;
