// JavaScript Document


//<![CDATA[
function inizializza() {
a = document.getElementsByTagName('A');
for(i=0;a[i];i++) if(a[i].className.indexOf('blank') != -1) {
  a[i].title += " [new window]";
  a[i].onclick = function () {window.open(this.href, '_blank');return false;};
  a[i].onkeypress = function (e) {
    k = (e) ? e.keyCode : window.event.keyCode;
    if(k==13) {
      window.open(this.href, '_blank');
      return false;
    }
  }
}
}
window.onload = function() {inizializza();}

function check(campo, tipo, label) {
  switch(tipo) {
    case "txt":
      if(document.getElementById(campo).value == '') {
        alert('Non ' + String.fromCharCode(232)+' stato compilato il campo ' + label);
        document.getElementById(campo).focus();
        return false;
      }
      break;
    case "chk":
      if(document.getElementById(campo).checked == '') {
        alert('Non ' + String.fromCharCode(232)+' stato compilato il campo ' + label);
        document.getElementById(campo).focus();
        return false;
      }
      break;
  }
  return true;
}

function checkEmail(campo) {
  var filter  = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
	if(!filter.test(document.getElementById(campo).value)) {
    alert('Non ' + String.fromCharCode(232)+' stata specificata un\'email valida');
    document.getElementById(campo).focus();
    return false;
  }
  return true;
}

function checkUguali(campo1, campo2) {
  if(document.getElementById(campo1).value != document.getElementById(campo1).value) {
    alert('Le due email sono diverse');
    document.getElementById(campo1).focus();
    return false;
  }
  return true;
}

function ricalcola_mesi(id) {
  var giorno_attuale = document.getElementById('g' + id).options[document.getElementById('g' + id).options.selectedIndex].value;
  while(document.getElementById('g' + id).options.length) document.getElementById('g' + id).options[0]=null;
  mese = document.getElementById('m' + id).options.selectedIndex;
  giorni_mese=31;
  if(mese == 3 || mese == 5 || mese == 8 || mese == 10)
    giorni_mese=30;
  if(mese == 1)
    if(document.getElementById('a' + id).options[document.getElementById('a' + id).options.selectedIndex].value % 4 == 0)
      giorni_mese=29;
    else
      giorni_mese=28;
  for (i=0; i <= giorni_mese - 1; i++)
    document.getElementById('g' + id).options[i]=new Option(i+1, i+1);
  document.getElementById('g' + id).options[giorno_attuale-1].selected=true;
}

function apri(cosa) {
  open(cosa, '', 'width=500,height=500,toolbars=no');
}






var win=null;

		function popup(url,w,h,title,extra)
		{
			//css = 'width: '+w+'px;height: '+h+'px;margin: 0px;';
			css = 'height: '+h+'px;margin: 0px;vertical-align: middle;';
			html = '<HTML>\n<HEAD>\n<TITLE>'+title+'</TITLE>\n</HEAD>\n<BODY BGCOLOR="#000000" LEFTMARGIN=0 MARGINWIDTH=0 TOPMARGIN=0 MARGINHEIGHT=0>\n<div style="width: 100%;height: 100%;text-align: center;"><A HREF="javascript:window.close()"><IMG style="'+css+'" SRC="'+url+'" BORDER=0 NAME=imageTest></A></div>\n</BODY>\n</HTML>';
			
			/*win.document.open("text/html", "replace");
			win.document.write(html);
			win.document.close();

			img=new Image;
			img.src=url;
			w=img.width;
			h=img.height;	*/

			offsetw=20;
			offseth=60;

			var macie=false;var ie=false;
			var agt=navigator.userAgent.toLowerCase();
			var plat=navigator.platform.toLowerCase();
			if (agt.indexOf("msie") != -1 && plat.indexOf("mac") != -1) macie=true;
			if (agt.indexOf("msie")!=-1) ie=true;

			if(ie){
				offsetw=20;
	                        offseth=100;
			}

			str="height="+(h+offseth)+",width="+(w+offsetw)+","+extra;
			str+=",left="+(screen.width -w)/2+",top="+parseInt((screen.height -h)/3);
			str+=",toolbar=no, location=no,status=no,menubar=no,scrollbars=no,resizable=no";

			if(win==null || !win.open || win.closed){
				win=window.open('','name',str);
				win.resizeTo((w+offseth), (h+offseth));
				with (win.document) {
				  win.document.open(); //("text/html", "replace");
				  win.document.write(html);
				  win.document.close();
				}
			}else{
				if (win && win.open && !win.closed) {
					  win.resizeTo((w+offsetw), (h+offseth));
					  win.document.open(); //("text/html", "replace");
					  win.document.write(html);
					  win.document.close();
				}
			}
			win.focus();
			if(macie) win=null;
		}




<!--
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

//-->//-->






//]]>







function apri(url) {
	newin = window.open(url,'titolo','scrollbars=no,resizable=yes, width=680,height=600,status=no,location=no,toolbar=no');
}
