function ahah(url, target) {
	if (window.XMLHttpRequest) {
		req = new XMLHttpRequest();
	} else if (window.ActiveXObject) {
		req = new ActiveXObject("Microsoft.XMLHTTP");
	}
	if (req != undefined) {
		req.onreadystatechange = function() {ahahDone(url, target);};
		req.open("GET", url, true);
		req.send("");
	}
}  

function ahahDone(url, target) {
	if (req.readyState == 4) {
		if (req.status == 200) {
			document.getElementById(target).innerHTML = req.responseText;
		} else {
			document.getElementById(target).innerHTML=" Error:\n"+ req.status + "\n" +req.statusText;
		}
	}
}

function load(name, div) {
	ahah(name,div);
	return false;
}

function inputclear(field) {
	if(field.value=="gg/mm/aaaa" || field.value=="nome" || field.value=="localita'"){
		field.style.color="black";
		field.value="";
	}
}

function bookmarksite(title, url){
	if (document.all){
		window.external.AddFavorite(url, title);
	}else if (window.sidebar){
		window.sidebar.addPanel(title, url, "");
	}
}

function adapt_height(){
	var divpage = document.getElementById('page');
	if(document.documentElement){
	//	if(document.documentElement.clientHeight > (divpage.offsetHeight+86)) divpage.style.height = (document.documentElement.clientHeight-126)+'px';
	}
	var u_menu_lst = document.getElementById('u_menu_lst');
	if(document.documentElement && u_menu_lst){
		if(document.documentElement.clientWidth > 880){
			u_menu_lst.style.left = ((document.documentElement.clientWidth-880)/2 + 720)+'px';
		}else{
			u_menu_lst.style.left = '720px';
		}
	}	
}

function open_player(id){
	var stile = 'top=10, left=10, width=530, height=220, status=no, menubar=no, toolbar=no, scrollbar=no, resizable=no, location=no';
	if(id){
		id = '?id='+id;
	}else{
		id = '';
	}
	var pu = window.open('player/player.html'+id,'getLIVE_player',stile,true);
	if(pu.navigate){
		pu.navigate('player/player.html'+id);
	}else{
		pu.location.href = 'player/player.html'+id;
	}
}

function find_position(id) {
	var oElement = document.getElementById(id);
	if(typeof( oElement.offsetParent )!='undefined') {
		for( var posX = 0, posY = 0; oElement; oElement = oElement.offsetParent ) {
			posX += oElement.offsetLeft;
			posY += oElement.offsetTop;
		}
		return [posX,posY];
	}else{
		return [oElement.x,oElement.y];
	}
}
function showWindow(window_id,caller_id){
	var window_div = document.getElementById(window_id);
	var caller_div = document.getElementById(caller_id);
	if(window_div){
		if(caller_div){
			var position = find_position(caller_id);
			window_div.style.left = (position[0])+'px';
			window_div.style.top = (position[1]+16)+'px';
		}
		window_div.style.display = 'block';
	}
}
function hideWindow(window_id){
	var window_div = document.getElementById(window_id);
	window_div.style.display = 'none';
}
