// JavaScript Document
function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}


				
function TrimS(){ 
	return (this.toString() ? this.toString().replace(/\s+$|^\s*/g, "") : "")
}

String.prototype.trim = TrimS

function ValidDate(y, m, d) 
	{
		with (new Date(y, m, d)) return ((getDate()==d) && (getMonth()==m)) 
	}

function ReadISO8601date(Q)
	{ 
		if (Q.search(/^\d+-\d\d-\d\d$/)!=0) { return -2 } 
		var T = Q.split('-')
		for (i=0; i<=2; i++) { T[i] = parseInt(T[i], 10) } 
		if (!ValidDate(T[0], T[1]-1, T[2])) { return -1 } 
		return T 
	}

function Show(S)
	{
		p = S<-1?'Not d+-dd-dd':S==-1?'Bad value':S
		return (p);
	}
			
function controlla_data(campo_data,msg,frm)
{
	var data=eval("document." + frm + "." + campo_data + ".value");
			
	if (campo_data.length != 0)
	{
		sdata=data.split("/");
		day=sdata[0];
		month=sdata[1];
		year=sdata[2];                     
		if (year<1753)
			{
				alert(msg);
				return false;
			}
		Fdate= year + '-' + month + '-' + day;
		result = ReadISO8601date(Fdate.trim())
		if ((result == -1) || (result == -2))
			{
			    alert (msg);
			    return false;
			}
	}
	return true;
}

function setColor(objName,bg) 
{ 
	obj = document.getElementById(objName);
	if (obj.style) { 
		//obj.style.color = fg; 
		obj.style.backgroundColor = bg; 
	} 
}

function setColorCheckboxListini(objName,bg) 
{ 
	obj = document.getElementById(objName);
	obj.cheked = !obj.cheked
	if (obj.style) { 
		if (obj.cheked) {
			obj.style.backgroundColor = bg; 
		}
		else {
			obj.style.backgroundColor = "#ffffff"; 
		}
	} 
}
