var controlNome = "";
var controlCognome = "";
var controlEmail = "";
var arrayRegion = new Array();

function generaGallery(source){
	var myurl = source;
	
	jQuery.ajax({
	   				type: "POST",
	   				async: false,
	  				url: myurl,
	   				data: "",
	   				success: function(risposta){
						
						document.getElementById('galleryPubblica').innerHTML = risposta;
						try{
							document.getElementById("tableGallery4").style.display = "none";
							document.getElementById("tableGallery3").style.display = "none";
							document.getElementById("tableGallery2").style.display = "none";
							document.getElementById("tableGallery1").style.display = "none";
						}catch(e){
							/*finite le celle da nascondere*/
						}
					},
	    			error: function(){
	    				//alert('errore chiamata ajax');
	   			}
	 			});
}

function exitItem(id){
	if(id=="nome"){
		if(document.getElementById(id).value == ""){
				document.getElementById(id).value = controlNome;
		}
	}
	if(id=="cognome"){
		if(document.getElementById(id).value == ""){
				document.getElementById(id).value = controlCognome;
		}
	}
	if(id=="email"){
		if(document.getElementById(id).value == ""){
				document.getElementById(id).value = controlEmail;
		}
	}
}

function enterItem(id){
	if(id=="nome"){
		if(controlNome==""){
			controlNome = document.getElementById(id).value;
		}
		if(document.getElementById(id).value==controlNome){
			document.getElementById(id).value="";
		}
	}
	if(id=="cognome"){
		if(controlCognome==""){
			controlCognome = document.getElementById(id).value;
		}
		if(document.getElementById(id).value==controlCognome){
			document.getElementById(id).value="";
		}
	}
	if(id=="email"){
		if(controlEmail==""){
			controlEmail = document.getElementById(id).value;
		}
		if(document.getElementById(id).value==controlEmail){
			document.getElementById(id).value="";
		}
	}
}

function registratiNews(){
	if(document.getElementById('tipologia').value == ""){
		var lng = controlLinguaReturnUrl();
		if (lng.toUpperCase() == "IT"){
			alert('Compilare tutti i campi obbligatori');
		}
		if (lng.toUpperCase() == "EN"){
			alert('Required fields');
		}
		if (lng.toUpperCase() == "FR"){
			alert('Les champs obligatoires');
		}
		if (lng.toUpperCase() == "DE"){
			alert('Pflichtfelder');
		}
		if (lng.toUpperCase() == "ES"){
			alert('Campos obligatorios');
		}
		return false;
	}
	if(document.getElementById('nome').value == ""){
		var lng = controlLinguaReturnUrl();
		if (lng.toUpperCase() == "IT"){
			alert('Compilare tutti i campi obbligatori');
		}
		if (lng.toUpperCase() == "EN"){
			alert('Required fields');
		}
		if (lng.toUpperCase() == "FR"){
			alert('Les champs obligatoires');
		}
		if (lng.toUpperCase() == "DE"){
			alert('Pflichtfelder');
		}
		if (lng.toUpperCase() == "ES"){
			alert('Campos obligatorios');
		}
		return false;
	}
	if(document.getElementById('nome').value == controlNome){
		var lng = controlLinguaReturnUrl();
		if (lng.toUpperCase() == "IT"){
			alert('Compilare tutti i campi obbligatori');
		}
		if (lng.toUpperCase() == "EN"){
			alert('Required fields');
		}
		if (lng.toUpperCase() == "FR"){
			alert('Les champs obligatoires');
		}
		if (lng.toUpperCase() == "DE"){
			alert('Pflichtfelder');
		}
		if (lng.toUpperCase() == "ES"){
			alert('Campos obligatorios');
		}
		return false;
	}
	if(document.getElementById('cognome').value == ""){
		var lng = controlLinguaReturnUrl();
		if (lng.toUpperCase() == "IT"){
			alert('Compilare tutti i campi obbligatori');
		}
		if (lng.toUpperCase() == "EN"){
			alert('Required fields');
		}
		if (lng.toUpperCase() == "FR"){
			alert('Les champs obligatoires');
		}
		if (lng.toUpperCase() == "DE"){
			alert('Pflichtfelder');
		}
		if (lng.toUpperCase() == "ES"){
			alert('Campos obligatorios');
		}
		return false;
	}
	if(document.getElementById('cognome').value == controlCognome){
		var lng = controlLinguaReturnUrl();
		if (lng.toUpperCase() == "IT"){
			alert('Compilare tutti i campi obbligatori');
		}
		if (lng.toUpperCase() == "EN"){
			alert('Required fields');
		}
		if (lng.toUpperCase() == "FR"){
			alert('Les champs obligatoires');
		}
		if (lng.toUpperCase() == "DE"){
			alert('Pflichtfelder');
		}
		if (lng.toUpperCase() == "ES"){
			alert('Campos obligatorios');
		}
		return false;
	}
	if(jQuery.trim(Left(document.getElementById('nome').value,2)) == "*"){
			var lng = controlLinguaReturnUrl();
		if (lng.toUpperCase() == "IT"){
			alert('Compilare tutti i campi obbligatori');
		}
		if (lng.toUpperCase() == "EN"){
			alert('Required fields');
		}
		if (lng.toUpperCase() == "FR"){
			alert('Les champs obligatoires');
		}
		if (lng.toUpperCase() == "DE"){
			alert('Pflichtfelder');
		}
		if (lng.toUpperCase() == "ES"){
			alert('Campos obligatorios');
		}
			return false;									
	}
	if(jQuery.trim(Left(document.getElementById('cognome').value,2)) == "*"){
			var lng = controlLinguaReturnUrl();
		if (lng.toUpperCase() == "IT"){
			alert('Compilare tutti i campi obbligatori');
		}
		if (lng.toUpperCase() == "EN"){
			alert('Required fields');
		}
		if (lng.toUpperCase() == "FR"){
			alert('Les champs obligatoires');
		}
		if (lng.toUpperCase() == "DE"){
			alert('Pflichtfelder');
		}
		if (lng.toUpperCase() == "ES"){
			alert('Campos obligatorios');
		}
			return false;									
	}
	if(document.getElementById('email').value == ""){
		var lng = controlLinguaReturnUrl();
		if (lng.toUpperCase() == "IT"){
			alert('Compilare tutti i campi obbligatori');
		}
		if (lng.toUpperCase() == "EN"){
			alert('Required fields');
		}
		if (lng.toUpperCase() == "FR"){
			alert('Les champs obligatoires');
		}
		if (lng.toUpperCase() == "DE"){
			alert('Pflichtfelder');
		}
		if (lng.toUpperCase() == "ES"){
			alert('Campos obligatorios');
		}
		return false;
	}else{
		var tmp = document.getElementById('email').value.search('@');
		if(tmp == -1){
			var lng = controlLinguaReturnUrl();
		if (lng.toUpperCase() == "IT"){
			alert('Compilare tutti i campi obbligatori');
		}
		if (lng.toUpperCase() == "EN"){
			alert('Required fields');
		}
		if (lng.toUpperCase() == "FR"){
			alert('Les champs obligatoires');
		}
		if (lng.toUpperCase() == "DE"){
			alert('Pflichtfelder');
		}
		if (lng.toUpperCase() == "ES"){
			alert('Campos obligatorios');
		}
			return false;
		}
	}
	if(document.getElementById('email').value == controlNome){
		var lng = controlLinguaReturnUrl();
		if (lng.toUpperCase() == "IT"){
			alert('Compilare tutti i campi obbligatori');
		}
		if (lng.toUpperCase() == "EN"){
			alert('Required fields');
		}
		if (lng.toUpperCase() == "FR"){
			alert('Les champs obligatoires');
		}
		if (lng.toUpperCase() == "DE"){
			alert('Pflichtfelder');
		}
		if (lng.toUpperCase() == "ES"){
			alert('Campos obligatorios');
		}
		return false;
	}
	if(document.getElementById('privacy').checked == false){
		var lng = controlLinguaReturnUrl();
		if (lng.toUpperCase() == "IT"){
			alert('è obbligatorio accettare la liberatoria');
		}
		if (lng.toUpperCase() == "EN"){
			alert('Required fields');
		}
		if (lng.toUpperCase() == "FR"){
			alert('Les champs obligatoires');
		}
		if (lng.toUpperCase() == "DE"){
			alert('Pflichtfelder');
		}
		if (lng.toUpperCase() == "ES"){
			alert('Campos obligatorios');
		}
		return false;
	}
	
	var lng = controlLinguaReturnUrl();
	var myurl = '/webapp/webreg.nsf/riceviIscrizione?OpenAgent' + '&nome=' +  document.getElementById('nome').value + '&cognome=' + document.getElementById('cognome').value + '&email=' + document.getElementById('email').value + "&desidero1=" + document.getElementById('eventiCorradi').checked + '&desidero2=' + document.getElementById('contattoCorradi').checked + '&tipologia=' + document.getElementById('tipologia').value + '&lng=' + lng.toUpperCase();
	
				jQuery.ajax({
	   				type: "POST",
	   				async: false,
	  				url: myurl,
	   				data: "",
	   				success: function(risposta){
						var lngStr = controlLinguaReturnUrl();
						if (lngStr.toUpperCase() == "IT"){
							alert('registrazione effettuata');
						}
						if (lngStr.toUpperCase() == "EN"){
							alert('Successfully registered');
						}
						if (lngStr.toUpperCase() == "FR"){
							alert('Enregistré avec succès');
						}
						if (lngStr.toUpperCase() == "DE"){
							alert('Erfolgreich registriert');
						}
						if (lngStr.toUpperCase() == "ES"){
							alert('Registrado con éxito');
						}

						location.href = "http://www.corradi.eu";
						
	   			},
	    			error: function(){
	    				//alert('errore chiamata ajax');
	   			}
	 			});
}

function controlLinguaReturn(){
	var lng = "";
	var myurl = "/webapp/newsman.nsf/getBrowserLang?OpenAgent";
		/*alert(myurl)*/
				jQuery.ajax({
	   				type: "POST",
	   				async: false,
	  				url: myurl,
	   				data: "",
	   				success: function(risposta){
						var language = jQuery.trim(risposta);
						lng = language;
	   			},
	    			error: function(){
	    				//alert('errore chiamata ajax');
	   			}
	 			});	
	return lng;
}

function controlLinguaReturnUrl(){
	var url = location.href;
	var lngApp = "";
	var appUrl = url.split("/");
	var i = 0;
	for(i=0; i<appUrl.length; i++){
		if(appUrl[i].toUpperCase() == "IT"){
				lngApp = appUrl[i];
		}
		if(appUrl[i].toUpperCase() == "EN"){
				lngApp = appUrl[i];
		}
		if(appUrl[i].toUpperCase() == "DE"){
				lngApp = appUrl[i];
		}
		if(appUrl[i].toUpperCase() == "ES"){
				lngApp = appUrl[i];
		}
		if(appUrl[i].toUpperCase() == "FR"){
				lngApp = appUrl[i];
		}
	}
	return lngApp;
}

function controlLingua(){
	var myurl = "/webapp/newsman.nsf/getBrowserLang?OpenAgent";
		/*alert(myurl)*/
				jQuery.ajax({
	   				type: "POST",
	   				async: false,
	  				url: myurl,
	   				data: "",
	   				success: function(risposta){
						var language = jQuery.trim(risposta);
						if (language == "fr" || language == "es" || language == "de" || language == "it"){
								window.location="/index_" + language.toLowerCase() + ".html";
							}
							else if(language == "en"){
								window.location="/index.html";
							}
	   			},
	    			error: function(){
	    				//alert('errore chiamata ajax');
	   			}
	 			});	
}

function controlStateHomePage(){
	var tmp = location.href;
	var temp = tmp.split("/");
	var appoggio = temp[temp.length-1];
	var reindirzzamento = appoggio.split(".");
	if(reindirzzamento[0] == ""){
		controlLingua();
	}
	//alert(reindirzzamento[0]);
	if(appoggio == "index.html"){
		reindirizzaAR();	
		return true;
	}
	if(appoggio == "index_it.html"){
		reindirizzaAR();	
		return true;
	}
	if(appoggio == "index_en.html"){
		reindirizzaAR();	
		return true;
	}
	if(appoggio == "index_fr.html"){
		reindirizzaAR();
		return true;
	}
	if(appoggio == "index_de.html"){
		reindirizzaAR();	
		return true;
	}
	if(appoggio == "index_es.html"){
		reindirizzaAR();	
		return true;
	}
}

function reindirizzaAR(){
		if( document.cookie.match(/DomAuthSessId|LtpaToken/)){
			try{
				var tmpUrl = location.href;
				var appUrl = tmpUrl.split("_")
				var appUrl2 = appUrl[1].split(".")
				if (appUrl2[0].toUpperCase() == "IT"){
					var lngReindirizz = ".html";	
				}else{
					var lngReindirizz = "_" + appUrl2[0].toUpperCase() + ".html";
				}
			}catch(e){
				var lngReindirizz = "_EN.html";
			}
			
			location.href = "indexAR" + lngReindirizz;
		}
}

function generageneraAreaRegistrazione(div, area, lng){
	if(document.getElementById(div)){
		var ncasuale=Math.random();
		var myurl = '/webapp/webreg.nsf/iscrivitiOnline?openAgent&lng=' + lng + '&area=' + area;
		/*alert(myurl)*/
				jQuery.ajax({
	   				type: "POST",
	   				async: false,
	  				url: myurl,
	   				data: "",
	   				success: function(risposta){
						document.getElementById(div).innerHTML=risposta;
	   			},
	    			error: function(){
	    				//alert('errore chiamata ajax');
	   			}
	 			});	
	}
}

function inizializza(img1, img2){
	popolaRivenditoriDiv();	
	var tmp = calcHeightDivBrowser();
	if(document.getElementById('div1Control')){	
		document.getElementById('div1Control').style.height= "auto";	
		document.getElementById('div1Control').style.minHeight= tmp -220 + "px";
	}
	if(document.getElementById('div2Control')){	
		document.getElementById('div2Control').style.height= "auto";	
		document.getElementById('div2Control').style.minHeight= tmp -220 + "px";}
	if(document.getElementById('div3Control')){
		document.getElementById('div3Control').style.height= "auto";	
		document.getElementById('div3Control').style.minHeight= tmp -220 + "px";}    
		var tmp = calcHeightDivBrowser();
		document.getElementById('contenitoreOverflow').style.height= tmp -200 + "px";
		ridimensionamento(img1, img2);
		/*if(tmp < 650){	}*/
}

function ridimensionamento(img1, img2){var tmp = calcHeightDivBrowserImg();
		var val = Math.round(tmp * 100 / 800);
		if(val < 100){	
			val = val+1;
		}
		var percentuale = val;
		var controlVal = 1280 / 100 * val;
		var tmpWidth = calcWidthDivBrowser();
		var controlWidth = Math.round(tmpWidth / 100 * val);
		percentuale = val + 1;
		/*if(controlWidth < tmpWidth){		var appoggio = Math.round(tmpWidth * 100 / 1280);		percentuale = appoggio + 1;}*//*var widthFix = Math.round(1280/100* percentuale) + 1; */
		var heightFix = Math.round(800/100* percentuale) + 1; 
		/*if(heightFix < tmp){	heightFix=tmp;}document.getElementById('background').width = widthFix;*/
		document.getElementById('background').height = heightFix;
		var controlImg43 = tmpWidth/tmp;
		if(controlImg43 > 0.7){
			document.getElementById('background').src=img1;
		}else{
			document.getElementById('background').src = img2;
		}}

function popolaRivenditoriDiv(){
     if(document.getElementById('sezioneRivenditoriCerca')){
		 var ncasuale=Math.random();
		 var lng = controlLinguaReturnUrl();
		var myurl = '/webapp/rivNew.nsf/datiSelezione?open&lng=' + lng;
				jQuery.ajax({
	   				type: "POST",
	   				async: true,
	  				url: myurl,
	   				data: "",
	   				success: function(risposta){
						var tmpRisposta = risposta.split('$$_$$')
						var tmpRisultato = tmpRisposta[1].split('$$');
						for(i=0; i<=tmpRisultato.length; i++){
								/*alert(tmpRisultato[i]);*/
								arrayRegion[i] = tmpRisultato[i];
						}
						document.getElementById('sezioneRivenditoriCerca').innerHTML=tmpRisposta[0] + tmpRisposta[2];
	   			},
	    			error: function(){
	    				alert('errore chiamata ajax');
	   			}
	 			});
	 }
}

function popolaAM(){
     if(document.getElementById('sezioneAM')){
		 var ncasuale=Math.random();
		 var lng = controlLinguaReturnUrl();
		var myurl = '/webapp/rivNew.nsf/datiSelezioneAM?OpenAgent&lng=' + lng;
				jQuery.ajax({
	   				type: "POST",
	   				async: false,
	  				url: myurl,
	   				data: "",
	   				success: function(risposta){
						/*var tmpRisposta = risposta.split('$$_$$')
						var tmpRisultato = tmpRisposta[1].split('$$');
						for(i=0; i<=tmpRisultato.length; i++){
								/*alert(tmpRisultato[i]);
								arrayRegion[i] = tmpRisultato[i];
						}
						document.getElementById('sezioneAM').innerHTML=tmpRisposta[0] + tmpRisposta[2];*/
						document.getElementById('sezioneAM').innerHTML=risposta;
	   			},
	    			error: function(){
	    				//alert('errore chiamata ajax');
	   			}
	 			});
	 }
}

function generaAreaService(id, lng, area){
     if(document.getElementById(id)){
		 var ncasuale=Math.random();
		var myurl = '/webapp/aree.nsf/(rispostaWeb)?OpenAgent&lng=' + lng + '&area=' + area;
				jQuery.ajax({
	   				type: "POST",
	   				async: false,
	  				url: myurl,
	   				data: "",
	   				success: function(risposta){
						document.getElementById(id).innerHTML=risposta;
	   			},
	    			error: function(){
	    				//alert('errore chiamata ajax');
	   			}
	 			});
	 }
}

function sottoMenuProdotti(a){
	if(a == "1"){
		document.getElementById('img_gallery').style.display= "block";
	}else{
		document.getElementById('img_gallery').style.display= "none";		
	}
	if(a == "2"){
		document.getElementById('coloriMateriali').style.display= "block";
	}else{
		document.getElementById('coloriMateriali').style.display= "none";		
	}
	
}

function imgLogo(plus){
	if (/MSIE (\d+\.\d+);/.test(navigator.userAgent)){ //test for MSIE x.x;
 		var ieversion=new Number(RegExp.$1) // capture x.x portion and store as a number
 		if (ieversion<7){
			document.getElementById('logo').src= plus + "img/Logo.gif";
		}else{
			document.getElementById('logo').src= plus + "img/Logo.png";	
		}
	}else{
		document.getElementById('logo').src= plus + "img/Logo.png";	
	}
}

function calcHeight()
{
  //find the height of the internal page
  try{
  	/*var the_height= document.getElementById('iframegallery').contentWindow.document.body.scrollHeight;
		//change the height of the iframe
 		document.getElementById('iframegallery').height= the_height;*/
		document.getElementById('iframegallery').height = '800px';
  }catch(e){
		/*sono in locale*/  
  }
  
  callCalcHeightRepeat();
}

function callCalcHeightRepeat(){
	 x = window.setInterval("calcHeight()", 1000);
}

var prov=new Array(); 
   prov[0]=new Array("Seleziona una provincia...", "Chieti","L'Aquila","Pescara","Teramo"); 
   prov[1]=new Array("Seleziona una provincia...", "Matera","Potenza"); 
   prov[2]=new Array("Seleziona una provincia...", "Catanzaro","Cosenza","Crotone","Reggio Calabria","Vibo Valentia"); 
    prov[3]=new Array("Seleziona una provincia...", "Avellino","Benevento","Caserta","Napoli","Salerno"); 
    prov[4]=new Array("Seleziona una provincia...", "Bologna","Ferrara","Forli-Cesena","Modena","Parma","Piacenza","Ravenna","Reggio Emilia","Rimini"); 
    prov[5]=new Array("Seleziona una provincia...", "Gorizia","Pordenone","Trieste","Udine"); 
    prov[6]=new Array("Seleziona una provincia...", "Frosinone","Latina","Rieti","Roma","Viterbo"); 
    prov[7]=new Array("Seleziona una provincia...", "Genova","Imperia","La Spezia","Savona"); 
    prov[8]=new Array("Seleziona una provincia...", "Bergamo","Brescia","Como","Cremona","Lecco","Lodi","Mantova","Milano", "Monza Brianza", "Pavia","Sondrio","Varese");
    prov[9]=new Array("Seleziona una provincia...", "Ancona","Ascoli Piceno","Macerata","Pesaro e Urbino"); 
    prov[10]=new Array("Seleziona una provincia...", "Campobasso","Isernia"); 
    prov[11]=new Array("Seleziona una provincia...", "Alessandria","Asti","Biella","Cuneo","Novara","Torino","Verbano Cusio Ossola","Vercelli"); 
    prov[12]=new Array("Seleziona una provincia...", "Bari","Brindisi","Foggia","Lecce","Taranto"); 
    prov[13]=new Array("Seleziona una provincia...", "Cagliari", "Carbonia-Iglesias", "Nuoro", "Olbia-Tempio", "Oristano", "Medio Campidano", "Sassari", "Ogliastra"); 
    prov[14]=new Array("Seleziona una provincia...", "Agrigento","Caltanissetta","Catania","Enna","Messina","Palermo","Ragusa","Siracusa","Trapani"); 
    prov[15]=new Array("Seleziona una provincia...", "Arezzo","Firenze","Grosseto","Livorno","Lucca","Massa Carrara","Pisa","Pistoia","Prato","Siena"); 
    prov[16]=new Array("Seleziona una provincia...", "Bolzano","Trento"); 
    prov[17]=new Array("Seleziona una provincia...", "Perugia","Terni"); 
    prov[18]=new Array("Seleziona una provincia...", "Aosta"); 
    prov[19]=new Array("Seleziona una provincia...", "Belluno","Padova","Rovigo","Treviso","Venezia","Verona","Vicenza"); 

var sigle=new Array() 
   sigle[0]=new Array("", "Chieti","L'Aquila","Pescara","Teramo"); 
   sigle[1]=new Array("", "Matera","Potenza"); 
   sigle[2]=new Array("", "Catanzaro","Cosenza","Crotone","Reggio Calabria","Vibo Valentia"); 
    sigle[3]=new Array("", "Avellino","Benevento","Caserta","Napoli","Salerno"); 
    sigle[4]=new Array("", "Bologna","Ferrara","Forli-Cesena","Modena","Parma","Piacenza","Ravenna","Reggio Emilia","Rimini"); 
    sigle[5]=new Array("", "Gorizia","Pordenone","Trieste","Udine"); 
    sigle[6]=new Array("", "Frosinone","Latina","Rieti","Roma","Viterbo"); 
    sigle[7]=new Array("", "Genova","Imperia","La Spezia","Savona"); 
    sigle[8]=new Array("", "Bergamo","Brescia","Como","Cremona","Lecco","Lodi","Mantova","Milano", "Monza Brianza","Pavia","Sondrio","Varese");
    sigle[9]=new Array("", "Ancona","Ascoli Piceno","Macerata","Pesaro e Urbino"); 
    sigle[10]=new Array("", "Campobasso","Isernia"); 
    sigle[11]=new Array("", "Alessandria","Asti","Biella","Cuneo","Novara","Torino","Verbano Cusio Ossola","Vercelli"); 
    sigle[12]=new Array("", "Bari","Brindisi","Foggia","Lecce","Taranto"); 
    sigle[13]=new Array("", "Cagliari", "Carbonia-Iglesias", "Nuoro", "Olbia-Tempio", "Oristano", "Medio Campidano", "Sassari", "Ogliastra"); 
    sigle[14]=new Array("", "Agrigento","Caltanissetta","Catania","Enna","Messina","Palermo","Ragusa","Siracusa","Trapani"); 
    sigle[15]=new Array("", "Arezzo","Firenze","Grosseto","Livorno","Lucca","Massa Carrara","Pisa","Pistoia","Prato","Siena"); 
    sigle[16]=new Array("", "Bolzano","Trento"); 
    sigle[17]=new Array("", "Perugia","Terni"); 
    sigle[18]=new Array("", "Aosta"); 
    sigle[19]=new Array("", "Belluno","Padova","Rovigo","Treviso","Venezia","Verona","Vicenza");
	
function generaMenu2Select(source){
	try{
	with (document.getElementById('provincia')) 
     { 
     while (options.length > 0) 
       options[0]=null; 
     for (i=0;i<prov[source-1].length;i++){
		
		if(i == 0){
			var lng = controlLinguaReturnUrl();
			i=0;
			if(lng.toUpperCase() == "IT"){
				lngStrInit="Seleziona una provincia..."
			}
			if(lng.toUpperCase() == "EN"){
				lngStrInit="Choose an area..."
			}
			if(lng.toUpperCase() == "DE"){
				lngStrInit="Wählen sie einen bereich...";
			}
			if(lng.toUpperCase() == "ES"){
				lngStrInit="Elija una zona..."
			}
			if(lng.toUpperCase() == "FR"){
				lngStrInit="Choisissez une zone..."
			}
			options[i] = new Option(lngStrInit,"");
		}else{
       		options[i]=new Option(prov[source-1][i],sigle[source-1][i]);
		}
		options.selectedIndex=0;
      } 
	  //options.selectedIndex=0; 
	 }
	}catch(e){
		
	}
}

function modificaRivenditore(source, selezione){
	if(document.getElementById('nazione').value.toUpperCase() == "ITALIA"){
		try{
			document.getElementById('regioneEstr').style.display = "none";
		}catch(e){
			
		}
		document.getElementById('regione').style.display = "block";
		if(document.getElementById('regione').value != ""){
			if(source != ""){
				if(selezione != "provincia"){
				generaMenu2Select(source);
				}
			}
			document.getElementById('provincia').style.display = "block";
		}
	}else{
		document.getElementById('regione').value = "";
		document.getElementById('provincia').value = "";
		var appoggioArray = new Array();
		var contApp = 0
		for(i=0; i<arrayRegion.length; i=i+2){
				if(arrayRegion[i] == document.getElementById('nazione').value){
						if(contApp == 0){
							appoggioArray[contApp]="Seleziona una provincia/regione..."
							contApp++;
						}
						appoggioArray[contApp] = arrayRegion[i+1];
						contApp++;
				}
		}
		if(contApp == 0){
							var lng = controlLinguaReturnUrl();
							if(lng.toUpperCase() == "IT"){
								appoggioArray[contApp]="Seleziona una provincia/regione..."
							}
							if(lng.toUpperCase() == "EN"){
								appoggioArray[contApp]="Choose an area/region..."
							}
							if(lng.toUpperCase() == "DE"){
								appoggioArray[contApp] = "Wählen sie einen bereich/region...";
							}
							if(lng.toUpperCase() == "ES"){
								appoggioArray[contApp]="Elija una zona/region..."
							}
							if(lng.toUpperCase() == "FR"){
								appoggioArray[contApp]="Choisissez une zone/region..."
							}
							contApp++;
		}else{
			var lng = controlLinguaReturnUrl();
							if(lng.toUpperCase() == "IT"){
								appoggioArray[0]="Seleziona una provincia/regione..."
							}
							if(lng.toUpperCase() == "EN"){
								appoggioArray[0]="Choose an area/region..."
							}
							if(lng.toUpperCase() == "DE"){
								appoggioArray[0] = "Wählen sie einen bereich/region...";
							}
							if(lng.toUpperCase() == "ES"){
								appoggioArray[0]="Elija una zona/region..."
							}
							if(lng.toUpperCase() == "FR"){
								appoggioArray[0]="Choisissez une zone/region..."
							}				
		}
		document.getElementById('regione').style.display = "none";
		document.getElementById('provincia').style.display = "none";
		if(contApp > 0){
			try{
				var test = document.getElementById('regioneEstr').value;
				try{
				with (document.getElementById('regioneEstr')) 
     				{ 
     				while (options.length > 0) 
       				options[0]=null; 
     				for(i=0; i<appoggioArray.length; i++)
					if(i==0){
						options[i]=new Option(appoggioArray[i], "");
					}else{
       					options[i]=new Option(appoggioArray[i],appoggioArray[i]);
					}
     				options.selectedIndex=0; 
      				} 
					document.getElementById('regioneEstr').style.display = "block";
				}catch(e){
		
			}
			}catch(e){
				
				var comboReturn = '<br><select name="regioneEstr" id="regioneEstr" style="width:250px" onchange="callModRivenditore();">';
				for(i=0; i<appoggioArray.length; i++){
					comboReturn = comboReturn + '<option value ="' + appoggioArray[i] + '">' +  appoggioArray[i] + '</option>';	
				}
				comboReturn = comboReturn + '</select>';
				var resultApp = document.getElementById('sezioneRivenditoriCerca').innerHTML.split('<TD>&nbsp;</TD>');
				var outputResult = resultApp[0] + "<TD>" + comboReturn + "</td>";
				for(i=1; i<resultApp.length; i++){
					outputResult = outputResult + resultApp[i];
				}
				document.getElementById('sezioneRivenditoriCerca').innerHTML = outputResult;
				return false;
			}
		}
		//generaMenuEstero2Select(document.getElementById('nazione').value);
		//document.getElementById('regioneStr').style.display = "block";
	}
	
	var ncasuale=Math.random();
	var lng = controlLinguaReturnUrl();
	/*if(document.getElementById('nazione').value.toUpperCase() == "ITALIA"){*/
		var myurl = '/webapp/rivNew.nsf/selezioneReturn2?OpenAgent' + '&var=' + ncasuale + '&nazione=' +  document.getElementById('nazione').value + '&regione=' + document.getElementById('regione').value + '&provincia=' + document.getElementById('provincia').value+ '&lng=' + lng;
		//alert(myurl);
	/*}else{
		var myurl = '/webapp/rivNew.nsf/selezioneReturn?OpenAgent' + '&var=' + ncasuale + '&nazione=' +  document.getElementById('nazione').value + '&regione=' + document.getElementById('').value;	
	}*/
				jQuery.ajax({
	   				type: "POST",
	   				async: false,
	  				url: myurl,
	   				data: "",
	   				success: function(risposta){
						document.getElementById('risultatoRivenditoriCerca').innerHTML=risposta;
	   			},
	    			error: function(){
	    				//alert('errore chiamata ajax');
	   			}
	 			});
}

function callModRivenditore(){
		var ncasuale=Math.random();
	/*if(document.getElementById('nazione').value.toUpperCase() == "ITALIA"){*/
	var lng = controlLinguaReturnUrl();
		var myurl = '/webapp/rivNew.nsf/selezioneReturn2?OpenAgent' + '&var=' + ncasuale + '&nazione=' +  document.getElementById('nazione').value + '&regione=' + document.getElementById('regioneEstr').value + '&lng=' + lng;
	/*}else{
		var myurl = '/webapp/rivNew.nsf/selezioneReturn?OpenAgent' + '&var=' + ncasuale + '&nazione=' +  document.getElementById('nazione').value + '&regione=' + document.getElementById('').value;	
	}*/
	//alert(myurl);
				jQuery.ajax({
	   				type: "POST",
	   				async: false,
	  				url: myurl,
	   				data: "",
	   				success: function(risposta){
						document.getElementById('risultatoRivenditoriCerca').innerHTML=risposta;
	   			},
	    			error: function(){
	    				//alert('errore chiamata ajax');
	   			}
	 			});
}

function callModRivenditoreAM(){
		var ncasuale=Math.random();
	/*if(document.getElementById('nazione').value.toUpperCase() == "ITALIA"){*/
		var myurl = '/webapp/rivNew.nsf/selezioneReturnAM?OpenAgent' + '&var=' + ncasuale + '&nazione=' +  document.getElementById('nazione').value + '&regione=' + document.getElementById('regioneEstr').value;
	/*}else{
		var myurl = '/webapp/rivNew.nsf/selezioneReturn?OpenAgent' + '&var=' + ncasuale + '&nazione=' +  document.getElementById('nazione').value + '&regione=' + document.getElementById('').value;	
	}*/
				jQuery.ajax({
	   				type: "POST",
	   				async: false,
	  				url: myurl,
	   				data: "",
	   				success: function(risposta){
						document.getElementById('risultatoAM').innerHTML=risposta;
	   			},
	    			error: function(){
	    				//alert('errore chiamata ajax');
	   			}
	 			});
}

function generaMenuEstero2Select(source){
	var cont = 0;
	try{
	with (document.getElementById('provinciaEstr')) 
     { 
     while (options.length > 0) 
       options[0]=null; 
	  for (i=0;i<arrayRegion.length; i=i+2){
		if(source.toLowerCase() == arrayRegion[i]){
			alert(arrayRegion[i]);
			if(i=0){
				var lng = controlLinguaReturnUrl();
							if(lng.toUpperCase() == "IT"){
								strAppRegion ="Seleziona una provincia/regione...";
							}
							if(lng.toUpperCase() == "EN"){
								strAppRegion ="choose an area/region...";
							}
							if(lng.toUpperCase() == "DE"){
								strAppRegion ="Wählen sie einen bereich/region...";
							}
							if(lng.toUpperCase() == "ES"){
								strAppRegion ="Elija una zona/región...";
							}
							if(lng.toUpperCase() == "FR"){
								strAppRegion ="Choisissez une zone/région...";
							}	
						options[cont]=new Option(strAppRegion,strAppRegion);
			}else{
				options[cont]=new Option(arrayRegion[i+1],arrayRegion[i+1]);
			}
			cont = cont + 1;
			options.selectedIndex=0;
		}
	  }
	 }
	 document.getElementById('provinciaEstr').style.display="block";
	}catch(e){
		
	}
}

function modificaAM(source, selezione){
	if(document.getElementById('nazione').value.toUpperCase() == "ITALIA"){
		try{
			document.getElementById('regioneEstr').style.display = "none";
		}catch(e){
			
		}
		document.getElementById('regione').style.display = "block";
		if(document.getElementById('regione').value != ""){
			if(source != ""){
				if(selezione != "provincia"){
				generaMenu2Select(source);
				}
			}
			document.getElementById('provincia').style.display = "block";
		}
	}else{
		var appoggioArray = new Array();
		var contApp = 0
		for(i=0; i<arrayRegion.length; i=i+2){
				if(arrayRegion[i] == document.getElementById('nazione').value){
						if(contApp == 0){
							appoggioArray[contApp]="Seleziona una provincia/regione..."
							contApp++;
						}
						appoggioArray[contApp] = arrayRegion[i+1];
						contApp++;
				}
		}
		if(contApp == 0){
							var lng = controlLinguaReturnUrl();
							if(lng.toUpperCase() == "IT"){
								appoggioArray[contApp]="Seleziona una provincia/regione..."
							}
							if(lng.toUpperCase() == "EN"){
								appoggioArray[contApp]="Choose an area/region..."
							}
							if(lng.toUpperCase() == "DE"){
								appoggioArray[contApp]="Wählen sie einen bereich/region..."
							}
							if(lng.toUpperCase() == "ES"){
								appoggioArray[contApp]="Elija una zona/region..."
							}
							if(lng.toUpperCase() == "FR"){
								appoggioArray[contApp]="Choisissez une zone/region..."
							}
							contApp++;
		}else{
			var lng = controlLinguaReturnUrl();
							if(lng.toUpperCase() == "IT"){
								appoggioArray[0]="Seleziona una provincia/regione..."
							}
							if(lng.toUpperCase() == "EN"){
								appoggioArray[0]="Choose an area/region..."
							}
							if(lng.toUpperCase() == "DE"){
								appoggioArray[0]="Wählen sie einen bereich/region..."
							}
							if(lng.toUpperCase() == "ES"){
								appoggioArray[0]="Elija una zona/region..."
							}
							if(lng.toUpperCase() == "FR"){
								appoggioArray[0]="Choisissez une zone/region..."
							}				
		}
		document.getElementById('regione').style.display = "none";
		document.getElementById('provincia').style.display = "none";
		if(contApp > 0){
			try{
				var test = document.getElementById('regioneEstr').value;
				try{
				with (document.getElementById('regioneEstr')) 
     				{ 
     				while (options.length > 0) 
       				options[0]=null; 
     				for(i=0; i<appoggioArray.length; i++) 
       				options[i]=new Option(appoggioArray[i],appoggioArray[i]);
     				options.selectedIndex=0; 
      				} 
					//document.getElementById('regioneEstr').style.display = "block";
				}catch(e){
		
			}
			}catch(e){
				
				var comboReturn = '<br><select name="regioneEstr" id="regioneEstr" style="width:250px" onchange="callModRivenditoreAM();">';
				for(i=0; i<appoggioArray.length; i++){
					comboReturn = comboReturn + '<option value ="' + appoggioArray[i] + '">' +  appoggioArray[i] + '</option>';	
				}
				comboReturn = comboReturn + '</select>';
				var resultApp = document.getElementById('sezioneRivenditoriCerca').innerHTML.split('<TD>&nbsp;</TD>');
				var outputResult = resultApp[0] + "<TD>" + comboReturn + "</td>";
				for(i=1; i<resultApp.length; i++){
					outputResult = outputResult + resultApp[i];
				}
				document.getElementById('sezioneRivenditoriCerca').innerHTML = outputResult;
				return false;
			}
		}
		//generaMenuEstero2Select(document.getElementById('nazione').value);
		//document.getElementById('regioneStr').style.display = "block";
	}
	
	var ncasuale=Math.random();
	/*if(document.getElementById('nazione').value.toUpperCase() == "ITALIA"){*/
		var myurl = '/webapp/rivNew.nsf/selezioneReturnAM?OpenAgent' + '&var=' + ncasuale + '&nazione=' +  document.getElementById('nazione').value + '&regione=' + document.getElementById('regione').value + '&provincia=' + document.getElementById('provincia').value;
	/*}else{
		var myurl = '/webapp/rivNew.nsf/selezioneReturn?OpenAgent' + '&var=' + ncasuale + '&nazione=' +  document.getElementById('nazione').value + '&regione=' + document.getElementById('').value;	
	}*/
				jQuery.ajax({
	   				type: "POST",
	   				async: false,
	  				url: myurl,
	   				data: "",
	   				success: function(risposta){
						//alert(risposta);
						document.getElementById('risultatoAM').innerHTML=risposta;
	   			},
	    			error: function(){
	    				//alert('errore chiamata ajax');
	   			}
	 			});
}

function calcHeightDivBrowser() {
    var ie = (document.all);
    var ns = (document.layers);
    var ns6 = (document.getElementById && !ie);

    var agent = navigator.userAgent.toLowerCase();
    if (ie) {
        //documentWidth = (centerElement().offsetWidth) + centerElement().scrollLeft;
		var tmp = location.href;
		var control = tmp.search('index');
		if(control>-1){
        	documentHeight = document.documentElement.clientHeight + 15;
		}else{
			control = tmp.search('.html');
			if(control > -1){
				documentHeight = document.documentElement.clientHeight - 20;
			}else{
				documentHeight = document.documentElement.clientHeight + 15;
			}
		}
    }
    else if (ns) {
        documentWidth = window.innerWidth + window.pageXOffset;
        documentHeight = window.innerHeight + window.pageYOffset;
    }
    else if (ns6) {
        documentWidth = self.innerWidth + window.pageXOffset-10;
        documentHeight = self.innerHeight + window.pageYOffset-20;
    }
    /*return documentWidth +"x"+ documentHeight;*/
	return documentHeight
}

function calcHeightDivBrowserImg() {
    var ie = (document.all);
    var ns = (document.layers);
    var ns6 = (document.getElementById && !ie);

    var agent = navigator.userAgent.toLowerCase();
    if (ie) {
        //documentWidth = (centerElement().offsetWidth) + centerElement().scrollLeft;
        documentHeight = document.documentElement.clientHeight;
    }
    else if (ns) {
        documentWidth = window.innerWidth + window.pageXOffset;
        documentHeight = window.innerHeight + window.pageYOffset;
    }
    else if (ns6) {
        documentWidth = self.innerWidth + window.pageXOffset;
        documentHeight = self.innerHeight + window.pageYOffset;
    }
    /*return documentWidth +"x"+ documentHeight;*/
	return documentHeight
}

function calcWidthDivBrowser() {
    var ie = (document.all);
    var ns = (document.layers);
    var ns6 = (document.getElementById && !ie);

    var agent = navigator.userAgent.toLowerCase();
    if (ie) {
        documentWidth = document.documentElement.clientWidth;
        documentHeight = document.documentElement.clientHeight;
    }
    else if (ns) {
        documentWidth = window.innerWidth + window.pageXOffset;
        documentHeight = window.innerHeight + window.pageYOffset;
    }
    else if (ns6) {
        documentWidth = self.innerWidth + window.pageXOffset;
        documentHeight = self.innerHeight + window.pageYOffset;
    }
    /*return documentWidth +"x"+ documentHeight;*/
	return documentWidth
}

function stabilizzaAltezzaDiv(){
	if(document.getElementById('div3Control')){
		var control1 = document.getElementById('div1Control').style.height;
		var control2 = document.getElementById('div2Control').style.height;
		var control3 = document.getElementById('div3Control').style.height;
			if(control1>control2 && control1>control3){
				document.getElementById('div1Control').style.height = control1;
				document.getElementById('div2Control').style.height = control1;
				document.getElementById('div3Control').style.height = control1;
			}
			if(control2>control1 && control2>control3){
				document.getElementById('div1Control').style.height = control2;
				document.getElementById('div2Control').style.height = control2;
				document.getElementById('div3Control').style.height = control2;
			}
			if(control3>control1 && control3>control2){
				document.getElementById('div1Control').style.height = control3;
				document.getElementById('div2Control').style.height = control3;
				document.getElementById('div3Control').style.height = control3;
			}
	}else{
		if(document.getElementById('div3Control')){
			var control1 = document.getElementById('div1Control').style.height;
			var control2 = document.getElementById('div2Control').style.height;
			if(control2>control1){
				document.getElementById('div1Control').style.height = control2;
				document.getElementById('div2Control').style.height = control2;
			}
			if(control1>control2){
				document.getElementById('div1Control').style.height = control1;
				document.getElementById('div2Control').style.height = control1;
			}
		}
	}
}

function visualizzaLinkAR(){
	var lista_a = document.getElementsByTagName("a");
	for(i=0; i < lista_a.length; i++){
		try{
		if(lista_a.item(i).attributes['class'].value == "linkMenuAR"){
			//alert(lista_a.item(i).style.display);
			lista_a.item(i).style.display="inline-block";
		}
		}catch(e){
			
		}
		try{
		if(lista_a.item(i).getAttribute("class") == "linkMenuAR"){
			//alert(lista_a.item(i).style.display);
			lista_a.item(i).style.display="inline-block";
		}
		}catch(e){
			
		}
	}
}



function controlLogin(){
	if (top != self)  top.location.href = location.href;
	controlLine();
	
	if( document.cookie.match(/DomAuthSessId|LtpaToken/)) {
			var ncasuale=Math.random();
			var myurl = '/webapp/webreg.nsf/findUser';
		/*alert(myurl)*/
				jQuery.ajax({
	   				type: "POST",
	   				async: false,
	  				url: myurl,
	   				data: "",
	   				success: function(risposta){
						var utente = risposta.split('|');
						/*alert(utente[0]);
						alert(utente[1]);*/
						lng = utente[1];

						if ( lng=='it' ) welcome= 'Benvenuto ';
						  else if ( lng=='fr' ) welcome= 'Bienvenue ';
						  else if ( lng=='es' ) welcome= 'Bienvenida ';
						  else if ( lng=='de' ) welcome= 'Willkommen ';
						  else welcome= 'Welcome ';
						  var url = location.href;
						  
						tmpCu = jQuery.trim(utente[2]);
						
						if (tmpCu == 'cu')
						{
							
								try{
								stringTmp = document.getElementById('div1Control').innerHTML;
								//alert(stringTmp);
								tmpApp = "";

								var tmpCuArr = stringTmp.split('<br>');
								if(tmpCuArr.length == 1){
									var tmpCuArr = stringTmp.split('<BR>');
								}
								//alert(tmpCuArr.length);
								for(i = 0; i < tmpCuArr.length; i++){
								//	alert(tmpCuArr[i]);
									if (tmpCuArr[i].search("RICHIESTA LICENZA CP") == -1){
										tmpApp = tmpApp + tmpCuArr[i] + "<br>";
									}
								}
								

								document.getElementById('div1Control').innerHTML = tmpApp 
								}catch(e){
									//niente
								}
						}
						
					  
						  try{
							  document.getElementById('areaLogin').innerHTML="LOGOUT";
							  document.getElementById('areaLogin').href="/names.nsf?logout";
							  document.getElementById('loginProgettista').style.display="none";
							}catch(e){
								/*document.write(10/0);*/
							}

							try{
  								document.getElementById('userAR').innerHTML = welcome + utente[0];
							}catch(e){
								/*document.write(10/0);*/
							}
						  
						  alertZonaRiservata();
						  visualizzaLinkAR();
						  
						  var srcUrl = location.href
						  var controlSrc = srcUrl.search("galleryRivenditori")
						  if(controlSrc > -1){
							  var myUrl = '/webapp/gallery.nsf/menudinamicoNew?open';
		/*alert(myurl)*/
				jQuery.ajax({
	   				type: "POST",
	   				async: false,
	  				url: myUrl,
	   				data: "",
	   				success: function(risposta1){
						document.getElementById('div1ControlSpan').innerHTML = '<br><span style=font-family: Verdana, Arial, Helvetica, sans-serif; font-size:10px;"><b>' + risposta1 + '</b></span>';
								},
	    			error: function(){
	    				//alert('errore chiamata ajax');
	   			}
	 			});	}
	   			},
	    			error: function(){
	    				//alert('errore chiamata ajax');
	   			}
	 			});	
		return true;
	}
	//verifico se l'utente è loggato come progettista
	if(getCookie('loginProgettista') != "" && getCookie('loginProgettista') != "-"){
		visualizzaLinkARProg();
		controlStateHomePageProg();
		document.getElementById('areaLogin').innerHTML="LOGOUT";
		document.getElementById('areaLogin').href="javascript:logOutProgettisti();";
		//document.getElementById('areaLogin').innerHTML="LogOut";
		document.getElementById('loginProgettista').style.display="none";
		
		try{
			var tmp = location.href;
			var appTmp = tmp.split('_');
			var lng = "";
			try{
				lng = appTmp[1];
				var tmpTmp = lng.split('.');
				lng = tmpTmp[0];
			}catch(e){
				/*nessun mex di errore*/
			}
			if ( lng=='IT' ) welcome= 'Benvenuto ';
			else if ( lng=='FR' ) welcome= 'Bienvenue ';
			else if ( lng=='ES' ) welcome= 'Bienvenida ';
			else if ( lng=='DE' ) welcome= 'Willkommen ';
			else welcome= 'Welcome ';
			document.getElementById('userAR').innerHTML= welcome + getCookie("loginProgettista");
		}catch(e){
			//niente
		}
	}
}

function logOutProgettisti(){
	setCookie("loginProgettista", "-");
	//alert(getCookie("loginProgettista"));
	location.href="http://www.corradi.eu";
}

function delete_cookie( cookie_name )
{
  var cookie_date = new Date ( );  // current date & time
  cookie_date.setTime ( cookie_date.getTime() - 1 );
  document.cookie = cookie_name += "=; expires=" + cookie_date.toGMTString();
}

function controlStateHomePageProg(){
	var tmp = location.href;
	var temp = tmp.split("/");
	var appoggio = temp[temp.length-1];
	var reindirzzamento = appoggio.split(".");
	if(reindirzzamento[0] == ""){
		controlLingua();
	}
	//alert(reindirzzamento[0]);
	if(appoggio == "index.html"){
		reindirizzaARProg();	
		return true;
	}
	if(appoggio == "index_it.html"){
		reindirizzaARProg();	
		return true;
	}
	if(appoggio == "index_en.html"){
		reindirizzaARProg();	
		return true;
	}
	if(appoggio == "index_fr.html"){
		reindirizzaARProg();
		return true;
	}
	if(appoggio == "index_de.html"){
		reindirizzaARProg();	
		return true;
	}
	if(appoggio == "index_es.html"){
		reindirizzaARProg();	
		return true;
	}
}

function reindirizzaARProg(){
	var tmp = location.href;
	var appTmp = tmp.split('_');
	var lng = "";
	try{
		lng = appTmp[1];
		var tmpTmp = lng.split('.');
		lng = tmpTmp[0];
	}catch(e){
		/*nessun mex di errore*/
	}

	if(lng == undefined){
		location.href = "indexARProg.html";		
	}else{
		if(lng == ""){
			location.href = "indexARProg.html";	
		}else{
			location.href = "indexARProg_" + lng.toUpperCase() + ".html";
			}
	}
}

function visualizzaLinkARProg(){
	var lista_a = document.getElementsByTagName("a");
	for(i=0; i < lista_a.length; i++){
		try{
		if(lista_a.item(i).attributes['class'].value == "linkMenuARProget"){
			//alert(lista_a.item(i).style.display);
			lista_a.item(i).style.display="inline-block";
		}
		}catch(e){
			
		}
		try{
		if(lista_a.item(i).getAttribute("class") == "linkMenuARProget"){
			//alert(lista_a.item(i).style.display);
			lista_a.item(i).style.display="inline-block";
		}
		}catch(e){
			
		}
	}
}

function controlLine(){
	try{
	var div1 = document.getElementById('div1Control').innerHTML;
	var titolo = document.getElementById('titoloPage').innerHTML;
	var appoggio = titolo.split('-');
	var tmp = appoggio[appoggio.length-1];
	tmp = tmp.trim();
	var str = tmp.toUpperCase();
	str = str.trim();
	var str2 = str.split('<');
	if(isNaN(str2[0]) == false){
		return false;	
	}
	str2[0] = str2[0].replace("&nbsp;","");
	str2[0] = str2[0].replace("&NBSP;","");
	var appoggioDiv = div1.replace(jQuery.trim(str2[0]), '<span style="text-decoration:underline">' + str2[0] + '</span>');
	document.getElementById('div1Control').innerHTML=appoggioDiv;
	}catch(e){
		/**/	
	}
}

function gup( name ) 
  			{ 
  				name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]"); 
  				var regexS = "[\\?&]"+name+"=([^&#]*)"; 
				var regex = new RegExp( regexS ); 
  				var results = regex.exec( window.location.href ); 
  				if( results == null ) 
  				return ""; 
  				else 
  				return unescape(results[1]); 
  			} 
			
function correctThumb(){
  var max = maxer();
  var thumbs = document.getElementsByTagName('table');
  for (var i=0; i<thumbs.length; i++){
	  if(thumbs[i].className == "dia"){
	  thumbs[i].width= max + 40;
	  thumbs[i].height= max + 40;
	  }
  }
  return true;
  if (document.all){
    document.styleSheets[0].addRule('table.dia', 'width:' + (max + 20) + 'px;'); 
    document.styleSheets[0].addRule('table.dia', 'height:' + (max + 20) + 'px;'); 
    document.styleSheets[0].addRule('div.smalldesc', 'width:' + (max + 20) + 'px;'); 
  } else {
    document.styleSheets[0].cssRules[6].style.width = (max + 20) + 'px';
    document.styleSheets[0].cssRules[6].style.height = (max + 20) + 'px';
    document.styleSheets[0].cssRules[7].style.width = (max + 20) + 'px';
  }
}

function correctPic(){
  var max = maxer();
  var thumbs = document.getElementsByName('contbundl');
  for (var i=0; i<thumbs.length; i++){
	  thumbs[i].width= max + 40;
	  thumbs[i].height= max + 40;
  }
  return true;
  if (document.all){
    document.styleSheets[0].addRule('table.image', 'width:' + (max + 40) + 'px;'); 
    document.styleSheets[0].addRule('table.image', 'height:' + (max + 40) + 'px;'); 
  } else {
    document.styleSheets[0].cssRules[11].style.width = (max + 40) + 'px';
    document.styleSheets[0].cssRules[11].style.height = (max + 40) + 'px';
  }
}

function maxer(){
  var maxw = 0; var maxh = 0;
  var thumbs = document.getElementsByName('bundl');
  for (var i=0; i<thumbs.length; i++){
    if (thumbs[i].width > maxw){ maxw = thumbs[i].width; }
    if (thumbs[i].height > maxh){ maxh = thumbs[i].height; }
  }
  var max = maxh; if (maxw > maxh){ max = maxw; }

  return max;
}

function Left(StringToLeft, EndOfCount) { 
	return StringToLeft.substr(0, EndOfCount); 
}

function setCookie(sNome, sValore) {
	document.cookie = sNome + "=" + escape(sValore) + ";path=/;domain=corradi.eu"
}
//

//
function getCookie(sNome) {
  // genera un array di coppie "Nome = Valore"
  // NOTA: i cookies sono separati da ';'
  var asCookies = document.cookie.split("; ");
  // ciclo su tutti i cookies
  for (var iCnt = 0; iCnt < asCookies.length; iCnt++)
  {
    // leggo singolo cookie "Nome = Valore"
    var asCookie = asCookies[iCnt].split("=");
    if (sNome == asCookie[0]) { 
      return (unescape(asCookie[1]));
    }
  }

  // SE non esiste il cookie richiesto
  return("");
}

function cambioLingua(lngSelect){
	var urlTmp = location.href;
	var appUrl = urlTmp.split("/");
	
	if (appUrl[3].toLowerCase() != lngSelect.toLowerCase()){	
		appUrl[3] = lngSelect.toLowerCase();
	
		var newUrl = "http:/";
		for(i=2; i<appUrl.length; i++){
				newUrl = newUrl + "/" + appUrl[i];
		}
		//alert(newUrl);
		location.href = newUrl;
	}
}

function scrollDetect(elemId) {
	var elem = document.getElementById(elemId);
	if (elem.scrollHeight > elem.clientHeight) {
		alert("code says scroll bar is present on '" + elemId + "'\n" + elem.scrollHeight + ", " + elem.clientHeight);
	} else {
		alert("No scroll bar detected for '" + elemId + "'\n" + elem.scrollHeight + ", " + elem.clientHeight);
	}
}

function controlDivSrolbar(){
	//alert(document.getElementById('div1Control').innerHTML);	
}