function addslashes(str) {
str=str.replace(/\\/g,'\\\\');
str=str.replace(/\'/g,'\\\'');
str=str.replace(/\"/g,'\\"');
str=str.replace(/\0/g,'\\0');
str=str.replace('&','e');
str=str.replace('=','');
return str;
}
function stripslashes(str) {
str=str.replace(/\\'/g,'\'');
str=str.replace(/\\"/g,'"');
str=str.replace(/\\0/g,'\0');
str=str.replace(/\\\\/g,'\\');
return str;
}

function check_all(doc)
{
  var c = new Array();
  c = doc.getElementsByTagName('input');
  for (var i = 0; i < c.length; i++)
  {
    if (c[i].type == 'checkbox')
    {
      c[i].checked = true;
      $j("input#cancella").show();
      $j("input#setletto").show();
    }
  }
}

function uncheck_all(doc)
{
  var c = new Array();
  c = doc.getElementsByTagName('input');
  for (var i = 0; i < c.length; i++)
  {
    if (c[i].type == 'checkbox')
    {
      c[i].checked = false;
      $j("input#cancella").hide();
      $j("input#setletto").hide();
      $j("input#setnoletto").hide();
    }
  }
}

var conta=0;
function controllo_spunte(quale,letto) {
if (quale.checked)
      {
          conta++;
          if (conta > 0)
      {
      $j("input#cancella").show();
          if(letto=="0"){
              $j("input#setletto").show();
              $j("input#setnoletto").hide();    
          }else{
              $j("input#setletto").hide();
              $j("input#setnoletto").show();          
          }
      }
      }
      else
          {
          conta--;
          if (conta == 0)
          {          
        $j("input#cancella").hide()
        $j("input#setnoletto").hide();
        $j("input#setletto").hide();        
          }
          }
}

function controllo_spunte_i(quale) {
if (quale.checked)
      {
          conta++;
          if (conta > 0)
      {
      $j("input#cancella").show();
      }
      }
      else
          {
          conta--;
          if (conta == 0)
          {          
        $j("input#cancella").hide()
          }
          }
}

			function clear_show_bt(id){
      id.value="";
      $j('#bt_commenta').show();
      }
			
		
jQuery(document).ready(function($j) {
  $j('a[rel*=facebox]').facebox()
})


    function closefacebox() {
      $j(document).trigger('close.facebox')
      return false;
    }

    
      function diven_cliente(id_cliente, id_attivita,stato,prov){
                  $j.ajax({ // APRI FUNZIONE JQUERY
                             type: 'post',
                             url: 'sezione/file_comuni/diventa_cliente_ok.php',
                             data: '&idut='+id_cliente+'&idat='+id_attivita+'&stato='+stato,
                             dataType: 'json',
                             success: function(data, status){
                                if(prov=="ricerca"){
                                        $j.get('basepagina.php?sezione=conoscereatt&idmio='+id_cliente, function(data) {
                                        $j('#cont_conoscere').html(data);
                                        });
                                        $j('#cli'+id_attivita).hide();
                                        $j('#cliok'+id_attivita).show();
                                        $j(document).trigger('close.facebox');                                
                                }else if(prov=="home"){
                                      $j.get('basepagina.php?sezione=conoscereatt', function(data) {
                                          $j('#cont_conoscere_att').html(data);
                                          $j(document).trigger('close.facebox');
                                      });
                                      }else{
                                        $j.get('basepagina.php?sezione=conoscereatt&idmio='+id_cliente, function(data) {
                                        $j('#cont_conoscere').html(data);
                                        });
                                        $j('#bt_cliente_div').hide();
                                        $j('#attivita'+id_attivita).hide();
                                        $j(document).trigger('close.facebox');
                                      }     
			                       }
		              }); // funzione jquery close 
      }      

function aggiungi_alle_foto(link,variabili,redirect,dest){

if(dest=="0"){
var variabili_ok=variabili;
}
if(dest=="1"){
var ceck_r = $("input[name='sele_reportage']:checked").val();
var variabili_ok=variabili+ceck_r;
}

                                  $j.ajax({ // APRI FUNZIONE JQUERY
                                      type: 'post',
                                      url: link,
                                      data: variabili_ok,
                                      dataType: 'json',
                                      success: function(data, status){
                                             location.href = redirect;  
			                                }
		                              }); // funzione jquery close                                  

}

function sele_rep(){
      $j("table#seleziona").hide();
      $j("span#titoletto").hide();
      $j("span#titoletto2").show();
      $j("div#seleziona_rep").show();
}

function sele_rep_ok(id){
      $j('div.riga').animate( {backgroundColor: "#ffffff"} );
      $j('div#'+id).animate( {backgroundColor: "#efefef"} );
      $j("div#ok_button").show();
}

function redirect(link){
      location.href = link; 
}

function richiesta_amifan(id_ut,id_mio,tipo){
alert(id_ut+"&"+id_mio+"&"+tipo);
                  $j.ajax({ // APRI FUNZIONE JQUERY
                             type: 'post',
                             url: 'sezione/profilo/stringi_amicizia_ok.php',
                             data: '&idut='+id_ut+'&idmio='+id_mio+'&tipo='+tipo,
                             dataType: 'json',
                             success: function(data, status){
                                        $j('#btami'+id_ut).hide();
                                        $j('#effet'+id_ut).show();
			                                }
		              }); // funzione jquery close 
}

function staff_ospite(id_ut,id_ev,valore,redirect){
                  $j.ajax({ // APRI FUNZIONE JQUERY
                             type: 'post',
                             url: 'sezione/file_comuni/staff_attiva_ospite.php',
                             data: '&idut='+id_ut+'&idev='+id_ev+'&val='+valore,
                             dataType: 'json',
                             success: function(data, status){
                                          location.href = redirect;
			                                }
		              }); // funzione jquery close 
}

function canc_staff(frase,titolo,btok,btannulla,id_staff,id_evento){
      $j.alerts.okButton=btok;
      $j.alerts.cancelButton=btannulla;
      jConfirm(frase, titolo,function(r) 
                  {if(r==true)
                              {
		                              $j.ajax({ // APRI FUNZIONE JQUERY
                                      type: 'post',
                                      url: 'sezione/amici/canc_staff_attiva_ospite.php',
                                      data: 'idut='+id_staff+'&idev='+id_evento,
                                      dataType: 'json',
                                      success: function(data, status){
                                          $j("#riga"+id_staff).hide();                                                                                           
			                                }
		                              }); // funzione jquery close                                  
                              }
                  }
              );
}

function canc_rigax(frase,titolo,btok,btannulla,id_oggetto,file,redirect){
      $j.alerts.okButton=btok;
      $j.alerts.cancelButton=btannulla;
      jConfirm(frase, titolo,function(r) 
                  {if(r==true)
                              {
		                              $j.ajax({ // APRI FUNZIONE JQUERY
                                      type: 'post',
                                      url: file,
                                      data: 'id='+id_oggetto,
                                      dataType: 'json',
                                      success: function(data, status){
                                          location.href = redirect;                                                                                          
			                                }
		                              }); // funzione jquery close                                  
                              }
                  }
              );
}

function mipiaci(id_utente,oggetto,id_oggetto,valore,align){
                  $j.ajax({ // APRI FUNZIONE JQUERY
                             type: 'post',
                             url: 'sezione/file_comuni/mipiaci.php',
                             data: '&idu='+id_utente+'&og='+oggetto+'&id='+id_oggetto+'&v='+valore+'&a='+align,
                             cache: false,
                             success: function(html){
                                        $j('#contatore').html('');
                                        $j('#contatore').append(html);                                
                                      }    
		              }); // funzione jquery close 

}

        function fbs_click(u,t) {
             $j('#salta').hide();
             $j('#procedi').show(); 
             window.open('http://www.facebook.com/sharer.php?u='+encodeURIComponent(u)+'&t='+encodeURIComponent(t),'sharer','toolbar=0,status=0,width=626,height=436');
             return false;
         }            
         
function canc_evento(frase,titolo,btok,btannulla,id_riga){
      var part = id_riga.split(",");
      var dataString= "id="+part[0]+"&t="+part[1];
      jConfirm(frase, titolo,function(r) 
                  {if(r==true)
                              {
                              $j.ajax({
                                        type: "POST",
                                        url: "sezione/file_comuni/eventi_cancella.php",
                                        data: dataString,
                                        cache: false,
                                        success: function(html){
                                          $j(".bar"+id_riga).slideUp('slow', function() {$j(this).remove();});
                                        }
                                  });                                
                              }
                  }
              )
} 

function canc_evento_redir(frase,titolo,btok,btannulla,id_riga,redirect){
      var part = id_riga.split(",");
      var dataString= "id="+part[0]+"&t="+part[1];
      jConfirm(frase, titolo,function(r) 
                  {if(r==true)
                              {
                              $j.ajax({
                                        type: "POST",
                                        url: "sezione/file_comuni/eventi_cancella.php",
                                        data: dataString,
                                        cache: false,
                                        success: function(html){
                                           location.href = redirect;
                                        }
                                  });                                
                              }
                  }
              )
} 

function cancella_attivita(frase,titolo,btok,btannulla,id_attivita,link,tipo){
      $j.alerts.okButton=btok;
      $j.alerts.cancelButton=btannulla;
      jConfirm(frase, titolo,function(r) 
                  {if(r==true)
                              {
		                              $j.ajax({ // APRI FUNZIONE JQUERY
                                      type: 'post',
                                      url: link,
                                      data: 'id='+id_attivita,
                                      dataType: 'json',
                                      success: function(data, status){
                                              location.href = "index.php?sezione="+tipo;                                                     
			                                }
		                              }); // funzione jquery close                                  
                              }
                  }
              );
}

function cancella_utente(frase,titolo,btok,btannulla,id_utente,link){
      $j.alerts.okButton=btok;
      $j.alerts.cancelButton=btannulla;
      jConfirm(frase, titolo,function(r) 
                  {if(r==true)
                              {
                                  $j.ajax({ // APRI FUNZIONE JQUERY
                                      type: 'post',
                                      url: link,
                                      data: 'id='+id_utente,
                                      dataType: 'json',
                                      success: function(data, status){
                                              location.href = "index.php?sezione=home";                                                     
			                                }
		                              }); // funzione jquery close                                  
                              }
                  }
              );

}

function filter_foto(url,variabili,redirect){
                  $j.ajax({ // APRI FUNZIONE JQUERY
                             type: 'post',
                             url: url,
                             data: variabili,
                             cache: false,
                             success: function(data, status){
                                              location.href = redirect;
                                              window.location.reload(true);                                
                                      }    
		              }); // funzione jquery close 

} 

function visualizza_tutticom(prov,msg_id,vars,db){
                  $j.ajax({ // APRI FUNZIONE JQUERY
                             type: 'post',
                             url: 'sezione/file_comuni/lista_tutti_commenti.php',
                             data: '&prov='+prov+'&id='+msg_id+'&vars='+vars+'&db='+db,
                             cache: false,
                             success: function(html){
                                        $j('#button_tutti').hide();
                                        $j('#lista_commenti_tot'+msg_id).append(html);
                                      }    
		              }); // funzione jquery close       
}  

function mipiaci_com(prov,tipo,mioid,msg_id,stato,scrittore,vars){
                  $j.ajax({ // APRI FUNZIONE JQUERY
                             type: 'post',
                             url: 'sezione/file_comuni/mipiaci_commenti.php',
                             data: '&prov='+prov+'&tipo='+tipo+'&id='+msg_id+'&mioid='+mioid+'&stato='+stato+'&scrittore='+scrittore+'&vars='+vars,
                             cache: false,
                             success: function(html){
                                        $j('#'+tipo+'lista_mipiaci'+msg_id).html('');
                                        $j('#'+tipo+'lista_mipiaci'+msg_id).append(html);
                                        
                  $j.ajax({ // APRI FUNZIONE JQUERY
                             type: 'post',
                             url: 'sezione/file_comuni/mipiaci_verifica.php',
                             data: '&prov='+prov+'&tipo='+tipo+'&id='+msg_id+'&mioid='+mioid+'&stato='+stato+'&scrittore='+scrittore+'&vars='+vars,
                             cache: false,
                             success: function(html){
                                        $j('#'+tipo+'mipiaci_riga'+msg_id).html('');
                                        $j('#'+tipo+'mipiaci_riga'+msg_id).append(html);
                                      }    
		              }); // funzione jquery close                                        
                                        
                                      }    
		              }); // funzione jquery close
       
}
       
