function hon(what){ what.style.backgroundColor="#e3e3e3" }
function hoff(what){ what.style.backgroundColor="#ffffff" }


function SwitchVisibility(ObjToSwitch) {
	obj = document.getElementById(ObjToSwitch);
	obj.style.display = (obj.style.display == 'inline') ? 'none' : 'inline';
}

//###################################################################################################

function isValidEmail(str) { return(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,5})+$/.test(str)) }

//###################################################################################################

function createAjaxObject() {
	var AjaxObjectType;
	var browser = navigator.appName;
	if(browser == "Microsoft Internet Explorer"){
		AjaxObjectType = new ActiveXObject("Microsoft.XMLHTTP");
	} else { 
		AjaxObjectType = new XMLHttpRequest();
	}
	return AjaxObjectType;
}
var http = createAjaxObject();

//###################################################################################################
function numeralsOnly(evt) {
    evt = (evt) ? evt : event;
    var charCode = (evt.charCode) ? evt.charCode : ((evt.keyCode) ? evt.keyCode : ((evt.which) ? evt.which : 0));
    
    // && charCode != 44 && charCode != 46)
    if (charCode > 31 && (charCode < 48 || charCode > 57)) {
    	
        alert("Puoi inserire solo numeri!"); 
        return false;
    }
    return true;
}
//###################################################################################################


//http://www.somacon.com/p355.php
String.prototype.trim = function() { return this.replace(/^\s+|\s+$/g,""); }



//###################################################################################################
function allowedChars(myfield, e, allowed) {
  var key;
  var keychar;
  if (window.event) key = window.event.keyCode;
  else if (e) key = e.which;
  else  return true;
  keychar = String.fromCharCode(key);
  if ((key==null) || (key==0) || (key==8) || (key==9) || (key==13) || (key==27) ) return true;
  else if (((allowed).indexOf(keychar) > -1)) return true;
  else return false;
}
//###################################################################################################

