// JavaScript Document


function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);


function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}


function WindowOpen(theURL,winName,features) {
  window.open(theURL,winName,features);
}

/*
function Edit(file){
  window.opener.document.forms['form1'].ico.value = file;
  //alert(file);
}
*/
function Manda(file) {
	document.forms['form2'].img.value = file;
}

function Edit(file){

  window.opener.document.getElementById('form1').ico.value = file;
}

function Mandadoc(file) {
	document.getElementById('form2').doccanc.value = file;
}



	
	
	
  function test() {

var f = document.contatta; 
if ((f.txtName.value == "" ) || (f.txtName.value.charAt(0) == " ")){
alert("Manca il tuo nome");
f.nome.focus();
return false;
}
if ((f.txtEmail.value == "" ) || (f.txtEmail.value.charAt(0) == " ")){
alert("Manca la tua email");
f.email.focus();
return false;
}
var re = new RegExp("^[!#$&'*+/-9=?A-Z^-~-]+(\\.[!#$&'*+/-9=?A-Z^-~-]+)*@[!#$&'*+/-9=?A-Z^-~-]+(\\.[!#$&'*+/-9=?A-Z^-~-]+)+$","");
if (!f.txtEmail.value.match(re)){
alert("Indirizzo email non corretto!")
f.txtEmail.select();
return false;
}
if ((f.txtMessagge.value == "") || (f.txtMessagge.value.charAt(0) == " ")){
alert("Dovresti scrivere qualcosa nel messaggio");
f.messaggio.focus();
return false;
}
document.contatta.submit();
}

//----------------------------

function testmail() { 
e = document.contatta.txtEmail.value; 
a = e.indexOf("@"); // posizione della chiocciola 
p = e.lastIndexOf("."); // posizione del punto 
if (a<3 || p<(a+4) || p>(e.length-3)) { 
alert("\n Devi inserire una e-mail valida"); 
return false; 
document.contatta.txtEmail.focus();
} 
} 

function chiudi_e_aggiorna()
{
window.opener.location.reload();
this.close();
}


function templateChange(){
	//controllo browser
	if(!document.styleSheets){
		var ss = getAllSheets() //Opera
	}else{
		var ss = document.styleSheets; //Dom
	}
	// disabilita tutti i fogli di stile con un titolo 
	// tranne quello passato per argomento alla funzione
	for( var x = 0; x < ss.length; x++ ) {
		if( ss[x].title ) {
			ss[x].disabled=true;
		}
		for( var y = 0; y < arguments.length; y++ ) {
			//controlla ogni titolo ...
			if(ss[x].title == arguments[y]){
				//e riabilita il foglio di stile se ha il titolo scelto
				ss[x].disabled=false;
			}
		}
	}
	if( !ss.length ) { 
		alert( 'Il tuo browser non è abilitato a cambiare i fogli di stile CSS' );
	}
}
// Funzione per Opera
function getAllSheets(){
	if( document.getElementsByTagName ) {
		var Lt = document.getElementsByTagName('LINK');
		var St = document.getElementsByTagName('STYLE');
	} else {
		// browser minori - restituisce array vuoto
		return []; 
	}
	//per tutti i tag link ...
	for( var x = 0, os = []; Lt[x]; x++ ) {
		//controlla l'attributo rel per vedere se contiene 'style'
		if( Lt[x].rel ) {
			var rel = Lt[x].rel;
		} else if( Lt[x].getAttribute ) {
			var rel = Lt[x].getAttribute('rel');
		} else {
			var rel = '';
		}
		if(typeof(rel)=='string'&&rel.toLowerCase().indexOf('style')+1){
			//riempe la variabile os con i stylesheets linkati
			os[os.length] = Lt[x];
		}
	}
	//include anche tutti i tags style e restituisce l'array
	for( var x = 0; St[x]; x++ ) {
		os[os.length] = St[x];
	}
	return os;
}
//-->

