/*#############################################
########## Functions utility ##################
#############################################*/
/*function writeIt(content,where){
	
	//alert(content+" "+where);
	if(document.all) {
		w = document.all[where];
	}else if (document.getElementById){
		w = document.getElementById(where);
	}
	w.innerHTML = content;
	
	
}*/
function writeIt(text,id){
	if (document.getElementById){
		x = document.getElementById(id);
		x.innerHTML = '';
		x.innerHTML = text;
	}else if (document.all){
		x = document.all[id];
		x.innerHTML = text;
	}else if (document.layers){
		x = document.layers[id];
		x.document.open();
		x.document.write(text);
		x.document.close();
	}
}


/*#############################################
########## Functions once #####################
#############################################*/
/*pathGet = "/";
function upd(who, what){
	whatdiv = what+"-div";
	if (document.getElementById){
		ajaxGet(pathGet+"get_"+what+".php?"+who,writeIt, whatdiv);
	}else if(document.all) {
		ajaxGet(pathGet+"get_"+what+".php?"+encodeURIComponent(who),writeIt, whatdiv);
	} 
}*/
/*#############################################
########## Functions once #####################
#############################################*/
pathGet = "/";
function upd(who, what, act){
	whatdiv = what+"-div";
	if (document.getElementById){
		var temp = document.getElementById(who).value;
		//if(temp != ""){
			ajaxGet(pathGet+"get_"+what+".php?id="+encodeURIComponent(temp)+"&a="+act,writeIt, whatdiv);
			//alert(who+" "+what+" "+temp);
		//}
	}else if(document.all) {
		var temp = document.all[who].value;
		//if(temp != ""){
			ajaxGet(pathGet+"get_"+what+".php?id="+encodeURIComponent(temp)+"&a="+act,writeIt, whatdiv);
		//}
	} 
}
function lgin(){
	if( (document.getElementById('usr').value == null || document.getElementById('usr').value == undefined || document.getElementById('usr').value == "") || (document.getElementById('psw').value == null || document.getElementById('psw').value == undefined || document.getElementById('psw').value == "") ){
		alert("Attenzione, inserisci il i tuoi dati!");
		return;	
	}
	var user = document.getElementById('usr').value;
	var pass = document.getElementById('psw').value;
	ajaxGet(pathGet+"get_login.php?usr="+encodeURIComponent(user)+"&psw="+encodeURIComponent(pass), writeIt, "boxlogin"); 
}
function checkEnter(e){ 
	 if(e && e.which){ 
		 e = e;
		 characterCode = e.which;
	 }else{							
		 e = event;				
		 characterCode = e.keyCode
	 }
	 if(characterCode == 13){ 
		 lgin();
		 return false;
	 }else{
		 return true;
	 }
}
/*
funzioni per modulo amministrazione
*/
function error(what){
	alert("Check "+what+" field before send!");
}
