// JavaScript Document

  
  
  
  function ch_lang(lang){
    
    if(lang!=""){
      
      $.php('/modules/statistics/ch_lang.php', {'lang':lang, 'sessionId':sessionId});
      
    }
  
  }
  
  
  function ch_template(template){
    
    if(template!=""){
      
      $.php('/modules/statistics/ch_template.php', {'template':template, 'sessionId':sessionId});
      
    }
  
  }
  
  
  function logout_client(cnf){
    if(cnf){
      jConfirm('Вы действительно хотите\rзавершить работу?', 'Завершение работы', 
              function(r){if(r){$.php('/modules/logout/index.php', {'sessionId':sessionId});}});
    }else{$.php('/modules/logout/index.php', {'sessionId':sessionId});}   
  }
  
  
  function cr_popup(url, w, h, scr, resize){
    window.open(url, get_uniqid(), 'scrollbars='+get_logic(scr)+',width='+w+',height='+h+',resizable='+get_logic(resize)+',location=no,menubar=no');
  }
  
  
  function get_logic(par){
    
    if(par){return "yes";}
    else{return "no";}
  
  }
  
  
  function get_uniqid(){
    
    return 'w'+(Math.floor(Math.random() * 100) + 1);
    
  }
  
 function trigger(id){

  var el = document.getElementById(id);
  if(el.style.display=="none"){
    el.style.display = "";
  }else{el.style.display = "none";}

}


  function put_message(cont, title){jAlert(cont, title);}
  
  
function php_exec(obj){
  
  obj["sessionId"] = sessionId;
  put_load_window();
  $.php('/ajax.php', obj);
  
}

  function put_load_window(){$.jGrowl("Выполняется загрузка!", {header:"Системное сообщение"});}
  
  client_send_form = function (divid) {
    var url = '/ajax.php';
    var arr = $(divid).formToArray(true);
    arr.push({name:'sessionId', value:sessionId});
    
    put_load_window();
    $.php(url, arr);
    return false;
    
    // do an ajax post request
    $.ajax({
       // AJAX-specified URL
       url: url,
       // JSON
       type: "POST",
       data: arr,
       dataType : "json",
       
       /* Handlers */       
       // Handle the beforeSend event
       beforeSend: function(){
           return put_load_window();
       },
       // Handle the success event
       success: function(data, textStatus){   
           return php.success(data, textStatus);
       },
       // Handle the error event
       error: function (xmlEr, typeEr, except) {
           return php.error(xmlEr, typeEr, except);                  
       },
       // Handle the complete event
       complete: function (XMLHttpRequest, textStatus) {              
           return php.complete(XMLHttpRequest, textStatus);
       }
    });
    return false;
    
}
  
  function redirect(par){location.href=par;}
  
  function getClientDimensions() {
  
    var myWidth = 0, myHeight = 0;
    if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
      myWidth = window.innerWidth;
      myHeight = window.innerHeight;
    } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
      myWidth = document.documentElement.clientWidth;
     myHeight = document.documentElement.clientHeight;
    } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
      myWidth = document.body.clientWidth;
      myHeight = document.body.clientHeight;
    }
    return [myWidth, myHeight];
  }
  
  
