function setSpanColor(input,span_id,color1,color2,error_text) {
	//alert("value:"+input.value);
	var span=document.getElementById(span_id);
	if ((input.value!='')&&(input.value!=error_text)) {
		span.style.color=color1;
	} else {
		span.style.color=color2;
	}
}

function setSpanColorFromSelect(select,span_id,color1,color2,error_text) {
	//alert("value:"+select.options[select.selectedIndex].value);
	var span=document.getElementById(span_id);
	if (select.options[select.selectedIndex].value!='null') {
		span.style.color=color1;
	} else {
		span.style.color=color2;
	}
}
function openClosePar(div_name,a_name) {
	$(div_name).toggle();
	if ($(div_name).visible()) {
		$(a_name).firstChild.nodeValue='chiudi';
	} else {
		$(a_name).firstChild.nodeValue='continua...';
	}

}
function open_close_div(div_name,a_name,control,control_value) {
	//alert("working on "+div_name);
	var div=document.getElementById(div_name);
	var a=document.getElementById(a_name);
	//alert("working on "+div.style.display);
	if (div.style.display=="none") {
		//alert("so open");
		div.style.display="inline";
		if (a_name!=null) {
			a.firstChild.nodeValue='chiudi';
			a.setAttribute('title','Collapse');

			if (control!=null) {
				var input=document.getElementById(control);
				//alert(input);
				input.value=parseFloat(input.value)+control_value;
			}

		}
	} else {
		//alert("so close");
		div.style.display="none";
		if (a_name!=null) {
			a.firstChild.nodeValue='apri';
			a.setAttribute('title','Expand');
		}

		if (control!=null) {
			var input=document.getElementById(control);
			//alert(input);
			input.value=parseFloat(input.value)-control_value;
		}

	}
}
function enableDisableObject(check,button_id) {
	//alert("working on "+button_id);
	var button=document.getElementById(button_id);

	if (check.checked) {
		button.disabled=false;
		if ($('cond1'))
			$('cond1').hide();
	} else {
		button.disabled=true;
		if ($('cond1'))
			$('cond1').show();
	}



}
function enableDisableObjectFromSelect(select,index,obj_id,sentence) {
	//alert("selectedIndex:"+select.selectedIndex+"\nindex:"+index+"\n workin on "+obj_id);
	var obj=document.getElementById(obj_id);

	if (select.selectedIndex==index) {
		//alert("enable!")
		obj.disabled=false;
	} else {
		//alert("disable!")
		if (obj.value=='')
			obj.value=sentence;
		obj.disabled=true;

	}

}