
function openPopUp(page, w, h) { 
	var height = h;
	var width = w;
	
	var str = "height=" + height + ",innerHeight=" + height;
	str += ",width=" + width + ",innerWidth=" + width;
	if (window.screen) {
	    	var ah = screen.availHeight - 30;
	    	var aw = screen.availWidth - 10;
	
	    	var xc = (aw - width) / 2;
	    	var yc = (ah - height) / 2;
	
	    	str += ",left=" + xc + ",screenX=" + xc;
	    	str += ",top=" + yc + ",screenY=" + yc;
	}
  	return window.open(page, "", str+",scrollbars=yes,resizable=yes");
}

function compareDates(d1, d2) {
	if(d1.length != 16) return -2;
	if(d2.length != 16) return -3;
	
	var strd1 = d1.substring(6,10) + d1.substring(3,5) + d1.substring(0,2) + d1.substring(11,13) + d1.substring(14,16);
	var strd2 = d2.substring(6,10) + d2.substring(3,5) + d2.substring(0,2) + d2.substring(11,13) + d2.substring(14,16);

	if(strd1 < strd2) return -1;
	else if(strd1 > strd2) return 1;
	else return 0;
}


function checkInputEuro(inputeuro) {
	var len = inputeuro.value.length;
	var newstr = "";
	var foundpoint = false;
	for(var i=0; i<len; i++) {
		var last = inputeuro.value.charAt(i);
		if(last >= "0" && last <= "9")
			newstr += last;
		else if(last == "," || last == ".") {
			if(!foundpoint)	{
				newstr += ".";
				foundpoint = true;
			}
		}
	}
	inputeuro.value = newstr;
}


function initSearchForm(formid) {
	var formel = document.getElementById(formid);
	if(formel == null) return;

	if(formel.search.value.length == 0) {
		formel.onsubmit = function() {
			if(formel.search.value.length == 0 || formel.search.value == "Cerca") {
				formel.search.focus();
				return false;
			}
		}
		
		formel.search.value = "Cerca";
		formel.search.onfocus = function() {
			if(formel.search.value == "Cerca") formel.search.value = "";
		}
		formel.search.onblur = function() {
			if(formel.search.value == "") formel.search.value = "Cerca";
		}
	}
	else {
		formel.search.onfocus = function() {
			this.select();
		}
	}
}
