// 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 sendFormRicercaLFrame(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;
        }
    });

}


//ANIMAZIONE TOP
function moveBg()
{
  $('#bg_ajax').animate({
      marginTop: '0px'
  },1000);
  //setTimeout("$('#backFadeDiv').fadeIn()",1000);
}
function activeMenu()
{
  overmenu();
  setTimeout("$('#menu1').fadeIn()",1000);
  setTimeout("$('#menu2').fadeIn()",1300);
  setTimeout("$('#menu3').fadeIn()",1600);
  setTimeout("$('#menu4').fadeIn()",1900);
  setTimeout("$('#menu5').fadeIn()",2200);
  setTimeout("$('#menu8s').fadeIn()",2500);
  setTimeout("$('#menu6s').fadeIn()",2500);
  setTimeout("$('#menu7s').fadeIn()",2800);
}

//OVER MENU
function overmenu()
{
  var marginAct1=$('#menu1').css('margin-left');
  $('#menu1').hover(

    function ()
      {
        var marginNew=parseInt(marginAct1)-20;
        $(this).stop().animate({
          marginLeft: marginNew+'px'
        },100);
      },
    function ()
      {
          
          $(this).stop().animate({
            marginLeft: marginAct1
          },100);
      });
  var marginAct2=$('#menu2').css('margin-left');
  $('#menu2').hover(

    function ()
      {
        var marginNew=parseInt(marginAct2)-20;
        $(this).stop().animate({
          marginLeft: marginNew+'px'
        },100);
      },
    function ()
      {
          
          $(this).stop().animate({
            marginLeft: marginAct2
          },100);
      });


  var marginAct3=$('#menu3').css('margin-left');
  $('#menu3').hover(

    function ()
      {
        var marginNew=parseInt(marginAct3)-20;
        $(this).stop().animate({
          marginLeft: marginNew+'px'
        },100);
      },
    function ()
      {

          $(this).stop().animate({
            marginLeft: marginAct3
          },100);
      });
      
  var marginAct4=$('#menu4').css('margin-left');
  $('#menu4').hover(

    function ()
      {
        var marginNew=parseInt(marginAct4)-20;
        $(this).stop().animate({
          marginLeft: marginNew+'px'
        },100);
      },
    function ()
      {

          $(this).stop().animate({
            marginLeft: marginAct4
          },100);
      });
      
      
  var marginAct5=$('#menu5').css('margin-left');
  $('#menu5').hover(

    function ()
      {
        var marginNew=parseInt(marginAct5)-20;
        $(this).stop().animate({
          marginLeft: marginNew+'px'
        },100);
      },
    function ()
      {

          $(this).stop().animate({
            marginLeft: marginAct5
          },100);
      });

  var marginAct8=$('#menu8s').css('margin-left');
  $('#menu8s').hover(

    function ()
      {
        var marginNew=parseInt(marginAct8)-20;
        $(this).stop().animate({
          marginLeft: marginNew+'px'
        },100);
      },
    function ()
      {

          $(this).stop().animate({
            marginLeft: marginAct8
          },100);
      });
      
  var marginAct6=$('#menu6s').css('margin-left');
  $('#menu6s').hover(

    function ()
      {
        var marginNew=parseInt(marginAct6)+20;
        $(this).stop().animate({
          marginLeft: marginNew+'px'
        },100);
      },
    function ()
      {

          $(this).stop().animate({
            marginLeft: marginAct6
          },100);
      });

  var marginAct7=$('#menu7s').css('margin-left');
  $('#menu7s').hover(

    function ()
      {
        var marginNew=parseInt(marginAct7)+20;
        $(this).stop().animate({
          marginLeft: marginNew+'px'
        },100);
      },
    function ()
      {

          $(this).stop().animate({
            marginLeft: marginAct7
          },100);
      });

}


//slide toggle condizioni
function expand1()
{
  $("#condiz1").slideToggle("slow");
};


function moveLogo()
{
  $('#logoAj').stop().animate({
    marginLeft: '0px'
  },800)
}

function validate(evt) {
  var theEvent = evt || window.event;
  var key = theEvent.keyCode || theEvent.which;
  key = String.fromCharCode( key );
  var regex = /[0-9]|\./;
  if( !regex.test(key) ) {
    theEvent.returnValue = false;
    if(theEvent.preventDefault) theEvent.preventDefault();
  }
}
function checkFormCC()
{
   //loading immagine
   $('#resultsCC').html('<center><img src="images/loader.gif"></center>');
   $.ajax({
   type: "POST",
   url: "sendCreditCard.php",
   cache: false,
   data: $("#formPay").serialize(),

   success: function(html){
    $('#resultsCC').empty();
    $('#resultsCC').html(html);


   }

 });
}

function checkFormBV()
{
   //loading immagine
   $('#resultsBV').html('<center><img src="images/loader.gif"></center>');
   $.ajax({
   type: "POST",
   url: "sendBv.php",
   cache: false,
   data: $("#formPay").serialize(),

   success: function(html){
    $('#resultsBV').empty();
    $('#resultsBV').html(html);


   }

 });
}
