// JavaScript Document
//Richidi informazioni
function sendRichInfo(id_villaggi)
{
   //loading immagine
   $('#results').html('<center><img src="images/loader.gif"></center>'); 

   $.ajax({
   type: "POST",
   url: "sendRichInfo.php?id_villaggi="+id_villaggi,
   cache: false,
   data: $("#form_mail").serialize(),
   
   success: function(html){
    $('#results').empty(); 
    if(html=="1")
    {
      $('#results').html('<font style="color:green;">La tua richiesta è stata inoltrata corretamente.</font>');
      clearForm('#form_mail');
    }
    
    else
    {
      $('#results').html('<font style="color:red;">Compila i campi obbligatori.</font>');
    }
    
   }

 });  
}
function sendRegala1()
{
   //loading immagine
   $('#results').html('<center><img src="images/loader.gif"></center>'); 

   $.ajax({
   type: "POST",
   url: "sendRegala1.php",
   cache: false,
   data: $("#form_regala1").serialize(),
   
   success: function(html){
    $('#results').empty();
    
        if(html=='&nbsp;')
          {
            $('#form_regala1').hide();
            $('#testo').hide();
          }
        $('#results').html(html);
      
    
   }

 });  
}

function sendRegalaInfo()
{
   //loading immagine
   $('#results').html('<center><img src="images/loader.gif"></center>'); 

   $.ajax({
   type: "POST",
   url: "sendRegalaInfo.php",
   cache: false,
   data: $("#form_regala1").serialize(),
   
   success: function(html){
    $('#results').empty();
    
        
        $('#results').html(html);
      
    
   }

 });  
}

function sendRegala2()
{
   //loading immagine
   $('#results').html('<center><img src="images/loader.gif"></center>'); 

   $.ajax({
   type: "POST",
   url: "sendRegala2.php",
   cache: false,
   data: $("#form_regala2").serialize(),
   
   success: function(html){
    $('#results').empty();
    if(html=='1')
    {
    //cliente memorizzato
    $('#results').html('<font style="color:green;">I tuoi dati sono stati salvati correttamente.Attendere...</font>');
    clearForm('#form_arearis2');
    setTimeout('parent.$.prettyPhoto.close();',2000);
    //setTimeout('parent.location.replace("promozioni-sconti-class-company-club.html");',2000); 
    }
    else
    {
    $('#results').html(html);
    } 
    
    
   }

 });  
}

function sendAreaRis1()
{
   //loading immagine
   $('#results').html('<center><img src="images/loader.gif"></center>'); 

   $.ajax({
   type: "POST",
   url: "sendAreaRis1.php",
   cache: false,
   data: $("#form_arearis1").serialize(),
   
   success: function(html){
    $('#results').empty();
    if(html=='1')
    {
    //codice già inserito
    $('#results').html('<font style="color:green;">I tuoi dati sono gi&agrave; presenti.Attendere...</font>');
    clearForm('#form_arearis1');
    setTimeout('parent.$.prettyPhoto.close();',2000);
    setTimeout('parent.location.replace("promozioni-sconti-class-company-club.html");',2000);  
    } 
    else
      {
        if(html=='&nbsp;')
          {
            $('#form_arearis1').hide();
            $('#testo').hide();
          }
        $('#results').html(html);
      }
    
   }

 });  
}
function sendAreaRis2()
{
   //loading immagine
   $('#results').html('<center><img src="images/loader.gif"></center>'); 

   $.ajax({
   type: "POST",
   url: "sendAreaRis2.php",
   cache: false,
   data: $("#form_arearis2").serialize(),
   
   success: function(html){
    $('#results').empty();
    if(html=='1')
    {
    //cliente memorizzato
    $('#results').html('<font style="color:green;">I tuoi dati sono stati salvati correttamente.Attendere...</font>');
    clearForm('#form_arearis2');
    setTimeout('parent.$.prettyPhoto.close();',2000);
    setTimeout('parent.location.replace("promozioni-sconti-class-company-club.html");',2000); 
    }
    else
    {
    $('#results').html(html);
    } 
    
    
   }

 });  
}

//VARIE FUNZIONI
function sendFormRicercaL(formulaire,id_local,id_regione)
{
  if(id_local=='1')
    nome_ricercal='buoni-vacanza-mare';
  if(id_local=='2')
    nome_ricercal='buoni-vacanza-montagna';
  if(id_local=='3')
    nome_ricercal='buoni-vacanza-lago';
  if(id_local=='4')
    nome_ricercal='buoni-vacanza-estero';
  if(id_local=='5')
    nome_ricercal='buoni-vacanza-per-le-famiglie';
  if(id_local=='6')
    nome_ricercal='buoni-vacanza-aperto-tutto-anno';
  if(id_local=='')
    nome_ricercal='buoni-vacanza';
  formulaire.action=nome_ricercal+'-rl-'+id_local+'.html';
  formulaire.submit();
}
function clearForm(ele) {

    $(ele).find(':input').each(function() {
        switch(this.type) {
            case 'password':
            case 'select-multiple':
            case 'select-one':
            case 'text':
            case 'textarea':
                $(this).val('');
                break;
            case 'checkbox':
            case 'radio':
                this.checked = false;
        }
    });

}