function init(){
	resizePanels();
	window.onresize = resizePanels;
	
	loadMap();
}

function resizePanels(){
	var windowHeight = getHeight();
	var windowWidth = getWidth();
	
	var pageTopElement = document.getElementById("page-top");
	var pageMenuElement = document.getElementById("page-menu");
	var pageBottomElement = document.getElementById("page-bottom");
	var mapElement = document.getElementById("map");
	
	// logo height 50
	// map height
	// menu height 28
	// bottom height 200
	
	var mapHeight = windowHeight - (50 + (28/2) + 200);
	
	if(mapHeight < 100){
		mapHeight = 100;
	}
	
	// adjustable heights
	pageTopElement.style.height = mapHeight;
	pageTopElement.style.width = windowWidth;
	mapElement.style.height = mapHeight;
	mapElement.style.width = windowWidth;
	
	
	// positions
	pageMenuElement.style.top = 50 + mapHeight;
	pageBottomElement.style.top = 50 + mapHeight + (28/2);
	

	if(map != null){
		map.resize(windowWidth,mapHeight);
	}
}

function getWidth(){
	var myWidth = 0;
  	if(typeof( window.innerWidth ) == 'number') {
    	//Non-IE
    	myWidth = window.innerWidth;
    } 
    else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    	//IE 6+ in 'standards compliant mode'
    	myWidth = document.documentElement.clientWidth;
  	} 
  	else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
   		//IE 4 compatible
    	myWidth = document.body.clientWidth;
  	}
	
	return myWidth;
}

function getHeight(){
	var myHeight = 0;
  	if( typeof( window.innerWidth ) == 'number' ) {
    	//Non-IE
   		myHeight = window.innerHeight;
  	} 
  	else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    	//IE 6+ in 'standards compliant mode'
    	myHeight = document.documentElement.clientHeight;
  	} 
  	else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
   		//IE 4 compatible
    	myHeight = document.body.clientHeight;
	}
	
	return myHeight;
}

function menuOptionImage(imgElement, src){
	imgElement.src=src;
}

function menuWorld(){
	var infoPanelText = document.getElementById("page-bottom-content-text");
	var updateUrl = "service.php?type=getworldhtml";
	htmlUpdate(updateUrl, infoPanelText);
}

function menuAbout(){
	var infoPanelText = document.getElementById("page-bottom-content-text");
	var updateUrl = "service.php?type=getabouthtml";
	htmlUpdate(updateUrl, infoPanelText);
}

function menuJoin(){
	var infoPanelText = document.getElementById("page-bottom-content-text");
	var updateUrl = "service.php?type=getjoinhtml";
	htmlUpdate(updateUrl, infoPanelText);
}

function menuFeed(){
	window.open("service.php","_blank");
}

function addUser(){
	var infoPanelText = document.getElementById("page-bottom-content-text");
	var lastfmidElement = document.getElementById("lastfmid");
	var ibmidElement = document.getElementById("ibmid");
	
	var updateUrl="service.php?type=updateuser&ibmid="+escape(ibmidElement.value)+"&lastfmid="+escape(lastfmidElement.value);
	
	htmlUpdate(updateUrl, infoPanelText);
	

}