function chiudi(){
	self.close();
}


function deuspopup(theURL,winName,features, myWidth, myHeight, isCenter) { //v3.0
  if(window.screen)if(isCenter)if(isCenter=="true"){
    var myLeft = (screen.width-myWidth)/2;
    var myTop = (screen.height-myHeight)/2;
    features+=(features!='')?',':'';
    features+=',left='+myLeft+',top='+myTop;
  }
  //document.write(features+((features!='')?',':'')+'width='+myWidth+',height='+myHeight);
  
  window.open(theURL,winName,features+((features!='')?',':'')+'width='+myWidth+',height='+myHeight);
}

function deuspopupclose(theURL,winName,features, myWidth, myHeight, isCenter) { //v3.0
  if(window.screen)if(isCenter)if(isCenter=="true"){
    var myLeft = (screen.width-myWidth)/2;
    var myTop = (screen.height-myHeight)/2;
    features+=(features!='')?',':'';
    features+=',left='+myLeft+',top='+myTop;
  }
  
window.open(theURL,winName,features+((features!='')?',':'')+'width='+myWidth+',height='+myHeight);
self.close();
}




function textCounter(field, countfield) {
   var maxlimit = 400;
   if (field.value.length > maxlimit) {
        field.value = field.value.substring(0, maxlimit);
        alert("Hai raggiunto la lunghezza massima per il messaggio");   } else {
     countfield.value = maxlimit - field.value.length;   
}
}



	function validate(data)
	{
		error = 0;

		if((data.charAt(2)!="/" && data.charAt(5)!="/") || data.length!=10)
			error = 1;
		else if(isNaN(data.charAt(0))||isNaN(data.charAt(1))||isNaN(data.charAt(3))||isNaN(data.charAt(4))||isNaN(data.charAt(6))||isNaN(data.charAt(7))||isNaN(data.charAt(8))||isNaN(data.charAt(9)))
			error = 1;
		else
		{
			day = eval(data.charAt(0)+data.charAt(1));
			day = parseInt(day);
			mnth = eval(data.charAt(3)+data.charAt(4));
			mnth = parseInt(mnth);
			yr = eval(data.charAt(6)+data.charAt(7)+data.charAt(8)+data.charAt(9));
			yr = parseInt(yr);

			if(mnth>12 || mnth<1)
				error = 2;

                        // mnthArray[0] is january, mnthArray[11] is december
			mnthArray = new Array(31,28,31,30,31,30,31,31,30,31,30,31);

			// netscape/IE number months starting with january = 0
			mnth = mnth-1;
			mydate = new Date(day,mnth,yr);


			if(day > parseInt(mnthArray[parseInt(mnth)]))
				error = 3;
		}

		switch(error)
		{
		case 1: alert("la data deve essere nel formato gg/mm/yyyy");
				document.forms[0].mdata.focus();
				break;
		case 2: alert("il mese inserito non è valido.");
				document.forms[0].mdata.focus();
				break;
		case 3: alert("Il giorno inserito non è valido.");
				document.forms[0].mdata.focus();
				break;
		
		
		}
	}