function ShowStat(){
    if($('statField').visible() == false){      
       Effect.BlindDown('statField');  
    } else {
       Effect.BlindUp('statField');  
    }
}

function sendGB(){
    vars = $('gbookForm').serialize();
    new Ajax.Request('saveGB.php?GBact=1', {
      method: 'post',
      encoding: 'UTF-8',
      parameters: vars,
      onSuccess: function(transport) {
          resp = transport.responseJSON;
          if(resp.error === true){
             $('gb_error').update(resp.errorText);
             $('gbf_n').value='';
             $('gbf_n').style.backgroundColor = 'white';
             $('gbf_t').value='';
             $('gbf_t').style.backgroundColor = 'white';
             $('gbf_m').value='';
             $('gbf_m').style.backgroundColor = 'white';
             $('gbf_o').value=''; 
             $('gbf_o').style.backgroundColor = 'white';
             
             readGB();
          } else {
             $('gb_error').update(resp.errorText); 
                console.debug(resp.error+'--'+$('gbf_n').value);
             if(resp.error == 1){                     
                if($('gbf_n').value==''){
                   $('gbf_n').style.backgroundColor = 'red'; 
                } 
                if($('gbf_t').value==''){
                   $('gbf_t').style.backgroundColor = 'red'; 
                } 
                if($('gbf_m').value==''){
                   $('gbf_m').style.backgroundColor = 'red'; 
                } 
                if($('gbf_o').value==''){
                   $('gbf_o').style.backgroundColor = 'red'; 
                } 
             }
             else if(resp.error == 2){   
                   $('gbf_m').style.backgroundColor = 'red'; 
                   $('gbf_n').style.backgroundColor = 'white';
                   $('gbf_t').style.backgroundColor = 'white';
                   $('gbf_o').style.backgroundColor = 'white';
             }             
          }
      }
    });

}

function readGB(page){      
$('GBEntries').update('<h1 style="text-decoration:blink;">Wird geladen....</h1>'); 
    if(typeof(page) === 'undefined'){
        page = 1;
    }
    
    new Ajax.Request('saveGB.php?GBact=2', {
      method: 'post',
      encoding: 'UTF-8', 
      parameters: 'gbp='+page,
      onSuccess: function(transport) {  
          $('GBEntries').hide(); 
          resp = transport.responseJSON;   
          $('GBEntries').update(resp.GBContent);
          $('GBEntries').appear();
      }   
    });    
}

function openLoc(Newurl){
    document.location = '?'+Newurl;
}
