// imposta l'opzione che ha il valore specificato a selected
function setSelectedValueOnSelect(obj_select,valore){
	var ops,i;
	if (obj_select==null)
		return "";
	ops=obj_select.options;
	for(i=0;i<ops.length;i++){
		if (ops[i].value==valore)
			ops[i].selected=true;
		else
			ops[i].selected=false;
	}
}
// ritorna una rappresentazione stringa dell'oggetto
function printObj(obj,sep){
	return printObjImp(obj,sep,false)
}
function printObjRecursive(obj,sep){
	return printObjImp(obj,sep,true)
}
function printObjImp(obj,sep,rec){
	var ret,s,c;
	if (sep)
		s=sep;
	else
		s="\n";
	ret="";
	
	for (c in obj){
		if (String(obj[c]).indexOf('function')>-1){
			ret=ret + c + ": FUNC"+s;
		} else {
			if (rec && typeof(obj[c])=="object")
				ret=ret + c + ": {" + printObjImp(obj[c],s,rec) + "}" + s;
			else
				ret=ret + c + ": " + obj[c] + s;
		}
	}
	return ret;
}
// ritorna una stringa che se "eval"utata in php restituisce un array isomorfo all'oggetto
function objToPHP(obj){
	var ret="",strand="";
	ret=ret + "array(";
	for (c in obj) {
		if (dojo.lang.isArray(obj[c]) || dojo.lang.isObject(obj[c])) {
			ret=ret + strand + " \""+c+"\" => " + objToPHP(obj[c]);
		} else {
			ret=ret + strand + " \""+c+"\" => \"" + obj[c] +"\"";
		}
		strand=",";
	}
	ret=ret + ")";
	return ret;
}
// ritorna una stringa che se "eval"utata in php restituisce un array isomorfo all'oggetto
// VERSIONE PER IL FE: senza dojo ASSUMIAMO CHE SIA UN'ARRAY
function arrayToPHP(obj){
	var ret="",strand="";
	ret=ret + "array(";
	for (i=0;i<obj.length;i++) {
		ret=ret + strand + " \""+i+"\" => \"" + obj[i] +"\"";
		strand=",";
	}
	ret=ret + ")";
	return ret;
}
// rimuove tutti i figli di un nodo
function removeAllChilds(n){
	while(n.hasChildNodes() == true) {
    	n.removeChild(n.firstChild);
    }
}

