var indirizzoimmagine;

function popup(url,winName,width,height) {
	width=(screen.width*width)/100;
	height=(screen.height*height)/100;
	xpos = (screen.width-width)/2;
	ypos = (screen.height-height)/2;
	options = "scrollbars=1,toolbar=1,menubar=1,width="+width+",height="+height+",left="+xpos+",top="+ypos+"position:absolute";
	window.open(url,winName,options);
}
function popup2(url,winName,width,height) {
	xpos = (screen.width-width)/2;
	ypos = (screen.height-height)/2;
	options = "scrollbars=1,toolbar=1,menubar=1,width="+width+",height="+height+",left="+xpos+",top="+ypos+"position:absolute";
	window.open(url,winName,options);
}

function finestra() {
  window.self.moveTo(0,0);
	window.self.resizeTo(screen.width,screen.height-50);
}

function sricerca(campo,evento) {
 if (document.layers || document.getElementById) tasto=evento.which;
 if (tasto==13 || event.keyCode==13) {
  document.formdx.action='ricerca.php?av=false';
  document.formdx.submit();
	return false;
 } else return true;
}


function check() {
	 document.carica.action.value="_self";
   file = document.carica.indirizzo.value;
	 var img1 = new Image();
	 img1.src = file;
	 ext2= file.substr(file.length-4,4);
   ext = file.substr(file.length-3,3);
   ext = ext.toLowerCase();
	 controllo=true;
   if((ext != 'jpg')) {
	  if((ext != 'gif')) {
	   if((ext2 != 'jpeg')) {
	    if((ext != 'bmp')) {
	     if((ext != 'png')) {
        alert('Hai selezionato un file '+ext2+
               ' Non è un tipo di file consentito! Prova con un file .gif o .jpg');
	      controllo=false;
			 }
		  }
		 }
	  }
	 }
	alt = document.carica.altinvio.value;
	if(alt=='') {
	 alert('Devi inserire un testo alternativo per ogni immagine!');
	 controllo=false;
	}
	if ((img1.height>768) || (img1.width>1024)) {
     controllo=confirm("Il file supera le dimensioni di 1024x768. Questo potrebbe richiedere tempi di invio e di consumo banda per gli utenti molto lunghi. Continuare con l'upload?");
  }
	if (controllo) {
    document.carica.submit();
	} else return false;
}

function controllonews() {
 p=document.iscrizione.pass.value;
 c=document.iscrizione.cpass.value;
 if (p!=c) {
  alert("La password non è stata confermata in modo valido!");
	controllo=false;
 } else controllo=true;
 if (controllo) {
  filtro= new RegExp("^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-]{2,})+\.)+([a-zA-Z0-9]{2,})+$");
	indirizzo=document.iscrizione.email.value;
  if (filtro.test(indirizzo)) controllo=true;
  else {
   alert("L'indirizzo di e-mail inserito non è valido");
   controllo=false;
  }
 }
 if (controllo) document.iscrizione.submit(); else return false;
}

function insert(a, b) {
 add = "[immagine "+a+" indirizzo="+b+"]";
 document.news.testo.value += add;
}

function insert3(a) {
 var add3 = "[link url="+a+"]Testo del link[/link]";
 document.news.testo.value += add3;
}

function insert4(a) {
 var add3 = "["+a+"][/"+a+"]";
 document.news.testo.value += add3;
}

function insert5(a) {
 var add3 = "["+a+"]";
 document.news.testo.value += add3;
}

function insert6(a) {
 b=a.replace(a.substr(0,1), a.substr(0,1).toUpperCase());
 var add3 = b+", ";
 document.news.alias.value += add3;
}

function insert7(a, b) {
 var add3 = "Fonte: [Link url="+a+"]"+b+"[/Link]";
 document.news.testo.value += add3;
}

function taglio() {
 if (document.news.alias.value.length>0) {
  a=document.news.alias.value.length-2;
  document.news.alias.value=document.news.alias.value.substr(0, a);
 }
}

function diariotutte(a) {
 if (a=="tutte") document.diario.tutte[1].checked=true; else document.diario.tutte[0].checked=true;
 document.diario.submit();
}
