/*GLOBAL VARIABLES*/
//utilizzata per chiudere la finestra della progress bar che appare quando carichi un video
var sonPage;
//isErrorOn viene utilizzata dalle pagine ErrorPage.jsp e AdminErrorPage.jsp
//e serve a visualizzare la pagina di errore in modo che occupi tutta la pagina del browser 
var isErrorOn = false;

function changeImage(fieldId, ref)
  {
  //alert("document.getElementById(fieldId).src: "+document.getElementById(fieldId).src);
  //alert("ref: "+ref);
  document.getElementById(fieldId).src = ref;
  }
  
function changeClassName(fieldId, ref)
  {
  //alert("document.getElementById(fieldId).className: "+document.getElementById(fieldId).className);
  //alert("ref: "+ref);
  document.getElementById(fieldId).className = ref;
  }
  
function changeJCaptcha(action) 
  {
  document.formSignup.signup_action.value = action;
  document.formSignup.submit();
  } 
   
function closeSon()
  {
  sonPage.close();
  }
  
function confirmAction(form)
  {
  return confirm("Vuoi aggiungere l'utente "+form.userName.value+" ai tuoi contatti?");
  }
  
function copy(fieldId) {
var inElement = document.getElementById(fieldId);
  if (inElement.createTextRange) {
    var range = inElement.createTextRange();
    if (range)
      range.execCommand('Copy');
  } else {
    var flashcopier = 'flashcopier';
    if(!document.getElementById(flashcopier)) {
      var divholder = document.createElement('div');
      divholder.id = flashcopier;
      document.body.appendChild(divholder);
    }
    document.getElementById(flashcopier).innerHTML = '';
    var divinfo = '<embed src="_clipboard.swf" FlashVars="clipboard='+encodeURIComponent(inElement.value)+'" width="0" height="0" type="application/x-shockwave-flash"></embed>';
    document.getElementById(flashcopier).innerHTML = divinfo;
  }
}
  
function copyAddressBook(addressBook, fieldId)
  {
  document.getElementById(fieldId).value += addressBook;
  }

function checkAdminUpdateFormFields()
  {
  var isCheckSuccesfull = false;
  
  var channel = document.getElementById("category").selectedIndex;
  
  
  if (document.getElementById("mediaName").value == "") 
    {
    alert("Il campo titolo è obbligatorio");
    }
  else if (document.getElementById("mediaDescription").value == "") 
    {
    alert("Il campo descrizione è obbligatorio");
    }
  else 
    {
    isCheckSuccesfull = true;
    }
    //alert ("isCheckSuccesfull: "+isCheckSuccesfull + " canale:" +channel);
  return isCheckSuccesfull;
  }


function checkOrderFormFields( language )
{
	var isCheckSuccesfull = false;
	
	// Variabili associate ai campi del modulo
	
	var firstName = document.getElementById("firstNameId");
	var lastName = document.getElementById("lastNameId");
	var email = document.getElementById("emailId");
	var fiscalCode = document.getElementById("fiscalCodeId");
	var addressName = document.getElementById("addressNameId");
	var addressNumber = document.getElementById("addressNumberId");
	var addressComune = document.getElementById("addressComuneId");
	var addressCountry = document.getElementById("addressCountryId");
	var addressProvincia = document.getElementById("addressProvinciaId");
	var postalCode = document.getElementById("postalCodeId");
	
	
	// Espressione regolare dell'email
	var email_reg_exp = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-]{2,})+\.)+([a-zA-Z0-9]{2,})+$/;
	
	if (firstName.value == "") 
	  {
		if( language == "it")
			alert("Il campo nome è obbligatorio.");
		else
			alert("Name field is required");
	  firstName.focus();
	  }
	else if ((lastName.value == "")) 
	  {
		if( language == "it")
			alert("Il campo cognome è obbligatorio.");
		else
			alert("Surname field is required");
	  lastName.focus();    
	  }
	else if (!email_reg_exp.test(email.value) || (email.value == "")) 
	  {
		if( language == "it")
			alert("Inserire un indirizzo email corretto.");
		else
			alert("Please insert a valid email");
	  email.select();    
	  }
	else if ((fiscalCode.value == "")) 
	{
		if( language == "it")
			alert("Il campo codice fiscale è obbligatorio.");
		else
			alert("Tax field is required");
	fiscalCode.focus();    
	}
	else if ((addressName.value == "")) 
	{
		if( language == "it")
			alert("Il campo indirizzo è obbligatorio.");
		else
			alert("Address name field is required");
	addressName.focus();    
	}
	else if ((addressNumber.value == "")) 
	{
		if( language == "it")
			alert("Il campo numero civico è obbligatorio.");
		else
			alert("Address number field is required");
	addressNumber.focus();    
	}
	else if ((addressComune.value == "")) 
	{
		if( language == "it")
			alert("Il campo comune è obbligatorio.");
		else
			alert("City name field is required");
	addressComune.focus();    
	}
	else if ((postalCode.value == "")) 
	{
		if( language == "it")
			alert("Il campo codice postale è obbligatorio.");
		else
			alert("Postal code field is required");
	postalCode.focus();    
	}
	else if ((addressProvincia.value == "") && language == "it" && addressCountry.value == "IT") 
	{
			alert("Il campo provincia è obbligatorio.");
			addressProvincia.focus();    
	}	
	//form valido
	else 
	  {
	  isCheckSuccesfull = true;
	  }
	
	return isCheckSuccesfull;
}

function checkOrderAziendaFormFields( language )
{
	var isCheckSuccesfull = false;
	
	// Variabili associate ai campi del modulo
	
	//azienda
	var nomeCompagnia =  document.getElementById("nomeCompagniaId");
    var ragioneSociale =  document.getElementById("ragioneSocialeId");
    var partitaIva =  document.getElementById("partitaIvaId");
	
	var email = document.getElementById("emailId");
	var fiscalCode = document.getElementById("fiscalCodeId");
	var addressName = document.getElementById("addressNameId");
	var addressNumber = document.getElementById("addressNumberId");
	var addressComune = document.getElementById("addressComuneId");
	var addressCountry = document.getElementById("addressCountryId");
	var addressProvincia = document.getElementById("addressProvinciaId");
	var postalCode = document.getElementById("postalCodeId");
	
	
	// Espressione regolare dell'email
	var email_reg_exp = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-]{2,})+\.)+([a-zA-Z0-9]{2,})+$/;
	if ((nomeCompagnia.value == "")) 
	{
		if( language == "it")
			alert("Il campo nome azienda è obbligatorio.");
		else
			alert("Company name field is required");
		nomeCompagnia.focus();    
	}
	if ((ragioneSociale.value == "")) 
	{
		if( language == "it")
			alert("Il campo ragione sociale è obbligatorio.");
		else
			alert("Full company name field is required");
		ragioneSociale.focus();    
	}
	if ((partitaIva.value == "")) 
	{
		if( language == "it")
			alert("Il campo partita Iva è obbligatorio.");
		else
			alert("Vat field is required");
		partitaIva.focus();    
	}
	else if (!email_reg_exp.test(email.value) || (email.value == "")) 
	  {
		if( language == "it")
			alert("Inserire un indirizzo email corretto.");
		else
			alert("Please insert a valid email address");
	  email.select();    
	  }
	else if ((fiscalCode.value == "")) 
	{
		if( language == "it")
			alert("Il campo codice fiscale è obbligatorio.");
		else
			alert("Tax field is required");
	fiscalCode.focus();    
	}
	else if ((addressName.value == "")) 
	{
		if( language == "it")
			alert("Il campo indirizzo è obbligatorio.");
		else
			alert("Address field is required");
	addressName.focus();    
	}
	else if ((addressNumber.value == "")) 
	{
		if( language == "it")
			alert("Il campo numero civico è obbligatorio.");
		else
			alert("Address number field is required");
	addressNumber.focus();    
	}
	else if ((addressComune.value == "")) 
	{
		if( language == "it")
			alert("Il campo comune è obbligatorio.");
		else
			alert("City field is required");
	addressComune.focus();    
	}
	else if ((postalCode.value == "")) 
	{
		if( language == "it")
			alert("Il campo codice postale è obbligatorio.");
		else
			alert("Postal code field is required");
	postalCode.focus();    
	}
	else if ((addressProvincia.value == "") && language == "it" && addressCountry.value == "IT") 
	{
		
			alert("Il campo provincia è obbligatorio.");
			addressProvincia.focus();    
	}
	
	//form valido
	else 
	  {
	  isCheckSuccesfull = true;
	  }
	
	return isCheckSuccesfull;
}


function checkDeliveryFormFields( language )
{
	var isCheckSuccesfull = false;
	
	// Variabili associate ai campi del modulo
	
	var addressProvincia = document.getElementById("deliveryAddressProvinciaId");
	var addressCountry = document.getElementById("deliveryAddressCountryId");
	
	if ((addressProvincia.value == "") && language == "it" && addressCountry.value == "IT") 
	{
			alert("Il campo provincia è obbligatorio.");
			addressProvincia.focus();    
	}	
	//form valido
	else 
	  {
	  isCheckSuccesfull = true;
	  }
	
	return isCheckSuccesfull;
}

function checkOrderDeliveryDetails( language )
{
	var isCheckSuccesfull = false;
	
	// Variabili associate ai campi del modulo
 	                       	
 	 
	var deliveryFirstName = document.getElementById("deliveryFirstNameId");
	var deliveryLastName = document.getElementById("deliveryLastNameId");
	var deliveryAddressName = document.getElementById("deliveryAddressNameId");
	var deliveryAddressNumber = document.getElementById("deliveryAddressNumberId");
	var deliveryAddressComune = document.getElementById("deliveryAddressComuneId");
	var deliveryAddressProvincia = document.getElementById("deliveryAddressProvinciaId");
	var deliveryPostalCode = document.getElementById("deliveryPostalCodeId");
	
	
	if (deliveryFirstName.value == "") 
	  {
		if( language == "it")
			alert("Il campo nome è obbligatorio.");
		else
			alert("Name field is required");
	  deliveryFirstName.focus();
	  }
	else if ((deliveryLastName.value == "")) 
	  {
		if( language == "it")
			alert("Il campo cognome è obbligatorio.");
		else
			alert("Surname number field is required");
	  deliveryLastName.focus();    
	  }
	else if ((deliveryAddressName.value == "")) 
	{
		if( language == "it")
			alert("Il campo indirizzo è obbligatorio.");
		else
			alert("Address field is required");
	deliveryAddressName.focus();    
	}
	else if ((deliveryAddressNumber.value == "")) 
	{
		if( language == "it")
				alert("Il campo numero civico è obbligatorio.");
		else
			alert("Address number field is required");
	deliveryAddressNumber.focus();    
	}
	else if ((deliveryAddressComune.value == "")) 
	{
		if( language == "it")
			alert("Il campo comune è obbligatorio.");
		else
			alert("City field is required");
	deliveryAddressComune.focus();    
	}
	else if ((deliveryAddressProvincia.value == "") && language == "it") 
	{
		alert("Il campo provincia è obbligatorio.");
		deliveryAddressComune.focus();    
	}
	else if ((deliveryPostalCode.value == "")) 
	{
		if( language == "it")
			alert("Il campo codice postale è obbligatorio.");
		else
			alert("Postal code field is required");
	deliveryPostalCode.focus();    
	}
	
	//form valido
	else 
	  {
	  isCheckSuccesfull = true;
	  }
	
	return isCheckSuccesfull;
}

function checkSendMailFormFields() {
	var isCheckSuccesfull = false;

	var emailMittente = document.getElementById("emailMittente").value;
	var testo = document.getElementById("testo").value;

	if (emailMittente == "") {
		alert("Il campo Email è obbligatorio");
	} else if (testo == "") {
		alert("Il campo Testo è obbligatorio");
	} else {
		isCheckSuccesfull = true;
	}
	// alert ("isCheckSuccesfull: "+isCheckSuccesfull);
	return isCheckSuccesfull;
}

function checkSignupFormFields( language )
  {
  var isCheckSuccesfull = false;
  
  // Variabili associate ai campi del modulo

  var username = document.getElementById("usernameId");
  var password = document.getElementById("passwordId");
  var confirmPassword = document.getElementById("confirmPasswordId");
//  var birthdate = document.getElementById("birthdateId");
  var email = document.getElementById("emailId");
  var j_captcha_response = document.getElementById("j_captcha_response");
  var acceptance = document.getElementById("acceptance");

  // Espressione regolare dell'email
  var email_reg_exp = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-]{2,})+\.)+([a-zA-Z0-9]{2,})+$/;

  //Effettua il controllo sul campo username
  if (username.value == "") 
    {
	  if( language == "it")
		  alert("Il campo username è obbligatorio.");
	  else
			alert("Username field is required");
    username.focus();
    }
  else if (username.value.length > 20) 
    {
	  if( language == "it")
		  alert("Il campo username non può essere superiore a 20 caratteri.");
	  else
		alert("Username field has a maximum of 20 characters");
    username.focus();
    }
  //Effettua il controllo sul campo password
  else if ((password.value == "")) 
    {
	  if( language == "it")
		  alert("Il campo password è obbligatorio.");
	  else
		alert("Password field is required");
    password.focus();    
    }
  //Effettua il controllo sul campo confirmPassword
  else if ((confirmPassword.value == "")) 
    {
	  if( language == "it")
		  alert("Il campo conferma password è obbligatorio.");
	  else
			alert("Confirm password field is required");
    confirmPassword.focus();
    }
  //Effettua il controllo sul campo confirmPassword
  else if ((password.value != confirmPassword.value)) 
    {
	  if( language == "it")
		  alert("Le due password inserite non coincidono.");
	  else
		alert("Password are different");
    confirmPassword.focus();
    }
  else if (!email_reg_exp.test(email.value) || (email.value == "")) 
    {
	  if( language == "it")
		  alert("Inserire un indirizzo email corretto.");
	  else
		alert("Insert a valid email address");
    email.select();    
    }
  //Effettua il controllo sul campo birthdate
  //else if ((birthdate.value == "") || (birthdate.value.length != 10)) 
  //  {
  //  alert("Il campo data di nascita deve essere nel formato gg/mm/aaaa.");
  //  birthdate.focus();    
  //  }
  //Effettua il controllo sul campo DATA DI NASCITA
  //verifica che la data sia inserita in formato gg/mm/aaaa 
  //che sia una data esistente (ad esempio non 36/18/2000) 
  //e non sia inferiore al 1900
  //else if (birthdate.value.substring(2,3) != "/" ||
  //  birthdate.value.substring(5,6) != "/" ||
  // isNaN(birthdate.value.substring(0,2)) ||
  //  isNaN(birthdate.value.substring(3,5)) ||
  //  isNaN(birthdate.value.substring(6,10))) 
  //  {
  //  alert("Inserire data di nascita in formato gg/mm/aaaa");
    //document.modulo.nascita.value = "";
  //  birthdate.focus();
  //  }
  //else if (birthdate.value.substring(0,2) > 31) 
  // {
  //  alert("Impossibile utilizzare un valore superiore a 31 per i giorni della data di nascita");
  //  birthdate.focus();
  //  }
  //else if (birthdate.value.substring(3,5) > 12) 
  //  {
  //  alert("Impossibile utilizzare un valore superiore a 12 per i mesi della data di nascita");
  //  birthdate.focus();    
  //  }
  //else if (birthdate.value.substring(6,10) < 1900) 
  //  {
  //  alert("Impossibile utilizzare un valore inferiore a 1900 per l'anno della data di nascita");    
  //  birthdate.focus();    
  //  } 
  else if (j_captcha_response.value == "") 
    {
	  if( language == "it")
		  alert("Il codice sicurezza non è corretto");    
	  else
			alert("Securut code is wrong");
    j_captcha_response.focus();    
    }
  else if (!acceptance.checked) 
    {
	  if( language == "it")
		  alert("E' necessario esprimere l'adesione ai termini di utilizzo e privacy");    
	  else
		alert("Please accept conditions and privacy policy");
    acceptance.focus();    
    } 
  //form valido
  else 
    {
    isCheckSuccesfull = true;
    }
  
  return isCheckSuccesfull;
  }

function checkAdminUserUpdateFormFields()
  {
  return true;
  }
   
function deleteOrder( orderId, firstResult )
{
if(confirm("Sei sicuro di voler eliminare l'ordine n. "+orderId+"?"))
  self.location.href="AdminDeleteOrderServlet?orderId="+orderId+"&firstResult="+firstResult;
}

function deleteDiscount( discountId )
{
if(confirm("Sei sicuro di voler eliminare il buono sconto?"))
  self.location.href="AdminDeleteDiscountServlet?discountId="+discountId;
}

function deleteMedia(mediaName, mediaId, topicId)
  {
  if(confirm("Sei sicuro di voler eliminare il video '"+mediaName+"'?"))
    self.location.href="DeleteMediaServlet?mediaId="+mediaId+"&topicId="+topicId;
  }

function deleteUser(userName, userId)
  {
  if(confirm("Sei sicuro di voler eliminare l'utente '"+userName+"' in maniera definitva dal database?"))
    self.location.href="AdminDeleteUserServlet?userId="+userId;
  }
   
function deleteUserFromGroup(username, userId, groupId)
  {
  if(confirm("Sei sicuro di voler eliminare il contatto '"+username+"'?"))
    self.location.href="RemoveUserFromGroupServlet?contactId="+userId+"&groupId="+groupId;
  }
  
function deleteGroup(groupName, groupId)
  {
  if(confirm("Sei sicuro di voler eliminare il gruppo '"+groupName+"'?"))
    self.location.href="RemoveGroupServlet?groupId="+groupId;
  }

function deleteVideoRoom(videoRoomName, topicId)
  {
  if(confirm("Sei sicuro di voler eliminare la Video Room '"+videoRoomName+"'?"))
    self.location.href="DeleteTopicServlet?topicId="+topicId;
  }

/*Gestisce la problematica sul layout nel caso venga generato un errore all'interno di una pagina jsp*/
function isErrorFound()
  {
  if(isErrorOn)
    location.href="ErrorPage.jsp";
  }

function openInformazioniProfilo(userId)
  {
  var urlContratto='ShowProfileServlet?userId='+userId;
  open(urlContratto , 'Contratto', 'scrollbars=yes,menubar=no,resizable=no,height=520,width=330');
  }

function openPopupPdf(path, nomeDocumento) 
	{
	window.open(path+"/"+nomeDocumento+".pdf",nomeDocumento,"scrollbars=yes,toolbar=no,menubar=no,location=no,width=700,height=700,top=100,left=200");  
	}

function openPopupJsp(path, nomeDocumento) 
   {
   window.open(path+"/"+nomeDocumento+".jsp",nomeDocumento,"scrollbars=yes,toolbar=no,menubar=no,location=no,width=700,height=700,top=100,left=200");  
   }
   
function openPopupJsp(path, nomeDocumento, tracklistKey) 
   {
   window.open(path+"/"+nomeDocumento+".jsp?tracklistKey="+tracklistKey,nomeDocumento,"scrollbars=yes,toolbar=no,menubar=no,location=no,width=700,height=700,top=100,left=200");  
   }
   
function openPopupMediaAdvertisementJsp(nomeDocumento, mediaId) 
   {
   window.open(nomeDocumento+".jsp?mediaId="+mediaId,nomeDocumento,"scrollbars=yes,toolbar=no,menubar=no,location=no,width=800,height=500,top=100,left=200");  
   }
//////////////////////VIDEOPOPUP
function openPopupVideoJsp(nomeDocumento, mediaId) 
   {
   window.open(nomeDocumento+".jsp?mediaId="+mediaId,nomeDocumento,"scrollbars=no,toolbar=no,menubar=no,location=no,width=500,height=400,top=100,left=200");  
   }


function openRelativePopup( relativePath) 
   {
   window.open(relativePath+".html",nomeDocumento,"scrollbars=yes,toolbar=no,menubar=no,location=no,width=700,height=700,top=100,left=200");  
   }
   
function openPopup(path, nomeDocumento) 
   {
   window.open(path+"/"+nomeDocumento+".html",nomeDocumento,"scrollbars=yes,toolbar=no,menubar=no,location=no,width=700,height=700,top=100,left=200");  
   }
   
function openPopupSmall(path, nomeDocumento) 
   {
   window.open(path+"/"+nomeDocumento+".html",nomeDocumento,"scrollbars=no,toolbar=no,menubar=no,location=no,width=700,height=480,top=100,left=200");  
   }
   
function openPopupSmallJsp(path, nomeDocumento) 
   {
   sonPage = window.open(path+"/"+nomeDocumento+".jsp",nomeDocumento,"scrollbars=no,toolbar=no,menubar=no,location=no,width=700,height=450,top=100,left=200");  
   }
   
function openURL(URL) 
   {
    window.open( URL, "orogioielli");
   }
  

function hideDiv(divId)
  {
  document.getElementById(divId).style.display='none';  
  }

/**Mostra un div se è nascosto, lo nasconde se è visibile*/
function hideShowSingleDiv(divId)
  {
  //alert(divId);
  //alert(document.getElementById(divId).style.display);
  if (document.getElementById(divId).style.display=='block')
	  document.getElementById(divId).style.display='none';  
  else
	  document.getElementById(divId).style.display='block';  
  }
  
function hideShowDiv(divId, diveIdTohide1, diveIdTohide2 )
{
//alert(divId);
//alert(document.getElementById(divId).style.display);
	document.getElementById(diveIdTohide1).style.display='none';  
	document.getElementById(diveIdTohide2).style.display='none';  
if (document.getElementById(divId).style.display=='block')
	  document.getElementById(divId).style.display='none';  
else
	  document.getElementById(divId).style.display='block';  
}

function showDiv(divId)
  {
  document.getElementById(divId).style.display='block';  
  }
  
function imposeMaxLength(field, maxLength)
  {	  

  if (field.value.length>maxLength)
    {
    alert("Non si possono inserire più di "+maxLength+" caratteri.");
    field.value=field.value.substring(0, maxLength);
    }
  }

function imposeEuro()
{	  
	  var field = document.getElementById("mediaComment").value;
	  var temp = "";
	  while (field.length > 0)
	  {
		  var ch = field.substring(0, 1);
		  field = field.substring(1,field.length);
		  if (ch != '€')
			  temp = temp + ch;
	  	else
	  	{
	  		temp = temp + "&euro;";
	  	}
	  }
		  field = temp;
		  document.getElementById("mediaComment").value = field;
	}


function resetChannel()
  {
  //alert(document.getElementById("channelCheckbox").checked)
  if (document.getElementById("channelMenuCheckbox").checked==true) 
    {
	document.getElementById("categoryMenu").disabled = false;
    }
  else 
    {
	document.getElementById("categoryMenu").disabled = true;
    document.getElementById("categoryMenu").selectedIndex = 0;
    }
  }

function resetUsername()
  {
  //alert(document.getElementById("usernameCheckbox").checked)
  if (document.getElementById("usernameMenuCheckbox").checked==true) 
    {
	document.getElementById("usernameMenu").disabled = false;
    }
  else 
    {
	document.getElementById("usernameMenu").disabled = true;
    document.getElementById("usernameMenu").value = 'Tutti gli utenti';
    }
  }

//scommentare quando dovrà essere attivato
//tipoTvId nella Signup.jsp
function showLayer(layerId)
  {
  //if (BrowserDetect.browser == "Firefox")
    //document.getElementById(layerId).style.display='table-row';   
  //else
    //document.getElementById(layerId).style.display='inline';  
  }

function submitAdminMediaPlayDelete() 
  {  
  if(confirm("Sei sicuro di voler eliminare il Prodotto?"))
    {
    document.formAdminMediaPlay.action = "AdminDeleteMediaServlet";
    document.formAdminMediaPlay.submit();
    }
  } 

function submitAdminMediaPlayUpdate() 
  {  
  if (checkAdminUpdateFormFields()) 
    {
    document.formAdminMediaPlay.action = "AdminUpdateMediaServlet";
    document.formAdminMediaPlay.submit();
    }
  }

function submitAdminUserUpdateForm() 
  {  
  if (checkAdminUserUpdateFormFields()) 
    {
    document.formAdminUserUpdate.action = "AdminUpdateUserServlet";
    document.formAdminUserUpdate.submit();
    }
  }  

function submitAdminUserListUpdateForm() 
  {
  //document.formAdminUserListUpdate.action = "AdminUpdateUserListServlet";
  document.formAdminUserListUpdate.submit();
  }
function printpage()
{
  if (window.print)
  {
    window.print();
  }
  else
  {
    alert('Funzione non supportata dal browser.');
  }
}

function disableProvincia()
{
//alert(document.getElementById("usernameCheckbox").checked)
if (    document.getElementById("addressCountryId").value != 'IT' ) 
  {
	document.getElementById("addressProvinciaId").disabled = true;
	document.getElementById("addressProvinciaId").value = '';
  }
else 
  {
	
	document.getElementById("addressProvinciaId").disabled = false;
  }
}

function disableAddressProvincia()
{
//alert(document.getElementById("usernameCheckbox").checked)
if (    document.getElementById("deliveryAddressCountryId").value != 'IT' ) 
  {
	document.getElementById("deliveryAddressProvinciaId").disabled = true;
	document.getElementById("deliveryAddressProvinciaId").value = '';
  }
else 
  {
	
	document.getElementById("deliveryAddressProvinciaId").disabled = false;
  }
}

function openPopupInCenter(windowHeight, windowWidth, windowName, windowUri)
{
    var centerWidth = (window.screen.width - windowWidth) / 2;
    var centerHeight = (window.screen.height - windowHeight) / 2;

    newWindow = window.open(windowUri, windowName, 'resizable=0,width=' + windowWidth + 
        ',height=' + windowHeight + 
        ',left=' + centerWidth + 
        ',top=' + centerHeight);

    newWindow.focus();
    return newWindow.name;
}

