function LoadCountry()
{
  var loadStato = document.getElementById("stato").value;
  if (loadStato != "722")
  {
    document.getElementById("townTr").style.display = "none";
    document.getElementById("townEngTr").style.display = "";
  }
}

function ChangeCountry()
{
  var changeStato = document.getElementById("stato").value;
  if (changeStato != "722")
  {
    document.getElementById("townTr").style.display = "none";
    document.getElementById("townEngTr").style.display = "";
  }
  else if (changeStato == "722")
  {
    document.getElementById("townTr").style.display = "";
    document.getElementById("townEngTr").style.display = "none";
  }
}

function CtrlForm()
{  
	var annonascita = self.document.all.annodinascita.value
	var re = /\D/;	
	if ((annonascita.search(re) != -1 ) || (annonascita.length == 0) || (annonascita < 1900))
	{
		alert("Verificare la data inserita");
		document.all.annodinascita.focus(); //...viene ridato il focus per il reinserimento
		return false;
	} 
	
	//controllo email
	var email = self.document.all.email.value; 
	var nonvalido = "(@.*@)|(\\.\\.)|(@\\.)|(\\.@)|(^\\.)";
	var regnv = new RegExp(nonvalido);				
	var testEt = email.search("\@"); 	  			
	var testP = email.search("[.]"); 
	if (( testEt == -1 ) | ( testP == -1 )) 
	{
	  alert("La preghiamo d'inserire una mail valida"); 
	  self.document.all.email.focus();
	  return false;
	}
	else if (regnv.test(email) == true) 
	{  	
	  alert("La preghiamo d'inserire una mail valida"); 	
	  self.document.all.email.focus();
	  return false;
	}		

	
	//controllino privacy obbligatoria
	if ((GetValueRadio("mand_privacy") == "") || (GetValueRadio("mand_privacy") == "1")) //1 = non accetto
  {
    alert("Per effettuare la transazione è necessario leggere ed accettare le condizioni ed i termini contenuti nelle Condizioni di Vendita in tutti i suoi punti e sotto punti.");
    return false;
  }
	//controllino privacy facoltativa
  var npriv = document.getElementsByName("privacy").length;
  var noChecked = 0;
  
  for (n=0; n<npriv; n++)
  {
    if (document.getElementsByName("privacy")[n].checked == true)
		{
		  noChecked = noChecked + 1;
		}
  }
  if (noChecked == 0)
  {
    alert("E' necessario scegliere una risposta per il Consenso al trattamento dei dati personali facoltativo");
    return false;
  }  
	
}
function GetValueRadio(IdRadio)
{
	var lenRadio = document.getElementsByName(IdRadio).length;
	var value = "";
	
	for (var i=0; i<lenRadio; i++)
	{
    if (document.getElementsByName(IdRadio)[i].checked == true)
    {
			value = document.getElementsByName(IdRadio)[i].value;
			return value;
		}
	}
  
  if (value == "")
		return "";
}

function CtrlProd()
{
  var NRadio = document.getElementsByName("lstPrices").length;
  var noChecked = 0;
  
  for (n=0; n<NRadio; n++)
  {
    if (document.getElementsByName("lstPrices")[n].checked == true)
		{
		  noChecked = noChecked + 1;
      //alert(n + " " + noChecked);
		}
  }
  if (noChecked == 0)
  {
    alert("Occorre selezionare una tipologia di posto.");
    return false;
  }  
}

function LoadTblShip()
{
  if (document.getElementById("tblTd").style.display == "none")
  {
    document.getElementById("tblTd").style.display = "";
  }
  else
  {
    document.getElementById("tblTd").style.display = "none";
  }
}

function LoadCountryShip()
{
  var loadStato = document.getElementById("bill_to_stato").value;
  if (loadStato != "722")
  {
    document.getElementById("townTr").style.display = "none";
    document.getElementById("townEngTr").style.display = "";
  }
}

function ChangeCountryShip()
{
  var changeStato = document.getElementById("bill_to_stato").value;
  if (changeStato != "722")
  {
    document.getElementById("townTr").style.display = "none";
    document.getElementById("townEngTr").style.display = "";
  }
  else if (changeStato == "722")
  {
    document.getElementById("townTr").style.display = "";
    document.getElementById("townEngTr").style.display = "none";
  }
}

function CtrlIntestatario()
{
  if (!document.getElementsByName("intestatario")[0].checked)
  {
    document.getElementById("IntestTD").style.display = "";
  }
  if (!document.getElementsByName("intestatario")[1].checked)
  {
    document.getElementById("IntestTD").style.display = "none";
  }
}

function CtrlDatiInt()
{
  var nomeInt = document.getElementById("nome_int").value;
  var cognomeInt = document.getElementById("cogn_int").value;
  var ragSInt = document.getElementById("rag_int").value;
  
  if ((nomeInt.length == 0) || (cognomeInt.length == 0))
  {
    if (ragSInt.length == 0)
    {
      alert("Compila i campi ''Nome'' e ''Cognome'' o, in alternativa, il campo ''Ragione Sociale'' dell'intestatario della carta di credito.");
      return false;
    }
    else
    {
      return true;
    }
  }
}


function openDialog(pagename, dimension)
{
  demoWindow = window.open(pagename, "demoWindow", dimension);
}



function MouseCursor(e)
{
  if (navigator.appName == "Netscape")
  {
    //alert(document.getElementById(this.id).id.value);
    e.target.style.cursor="pointer";
  }
  else
  {
    e.srcElement.style.cursor = "hand";
  }
}

function display()
{
  if (document.getElementById("textarea2").style.display == "")
  {
    document.getElementById("textarea2").style.display = "none";
  }
  else
  {
    document.getElementById("textarea2").style.display = "";
  }
}

function get_cookie(Name)
{
  var search = Name + "=";
  var returnvalue = "";
  
  if (document.cookie.length > 0)
  {
    offset = document.cookie.indexOf(search)
    if (offset != -1)
    {
      //If cookie exists
      offset += search.length;
      //Set index of beginning of value
      end = document.cookie.indexOf(";", offset);
      //Set index of end of cookie value
      if (end == -1)
        end = document.cookie.length;
      
      returnvalue = unescape(document.cookie.substring(offset, end));
     }
  }
  return returnvalue;
}

function doBlink()
{
  var blink = document.all.tags("BLINK");
  for (var i=0; i < blink.length; i++)
    blink[i].style.visibility = blink[i].style.visibility == "" ? "hidden" :"";
}

function startBlink()
{
  if (document.all)
    setInterval("doBlink()", 800);
}
window.onload = startBlink;

function disabledDept(click)
{
  var clickDept = click;
  alert(clickDept);
  if (clickDept == true)
  {
    document.getElementById(this.id).style.fontSize = '14px';
  }
}
