
function alert_test() { alert('test12342134sdfsadfasdf'); return false; }
function h3trbasket_get() { h3ajax_post('#h3trbasket', {op1:'order3',op2:'trbasket'}); }
function h3menu_get(menu_id) { return h3ajax_post('#maincontent', {op1:'/', op2:'menuget', id: menu_id}); }

//left search form submit button
function searchform_submit1(form, step, searchlist_post1)
{
  var params = {op1:'/',op2:'bookget',step:step};
  $('form#'+form).find('input').each(function(){params[this.name] = $(this).val();});
  $('form#'+form).find('select').each(function(){params[this.name] = $(this).val();});
  h3ajax_post('#maincontent', params, searchlist_post1, null, '#maincontent');
  return false;
}

function h3customer_logon(page)
{
  if (document.location.protocol=='http:')
  {
    $('form#h3customer_logonid').submit();
    return;
  }
  var params = {op1:'logon', op2:'customer'};
  $('form#h3customer_logonid').find('input').each(function(){ params[this.name] = $(this).val(); });
  $('#maincontent').block({ message: $wait_message });
  $.post("index_ajax.php", params,
    function(data){
      if ('OK'==data.substring(0,2))
      {
        h3ajax_post('#usercontent', {op1:'/',op2:'menu_top_logon'}, null, null, null, null);
        h3ajax_post('#maincontent', {op1:'/',op2:page,step:3}, null, null, null, null);
      }
      else
        $('#h3logonerror').text(data);
      $('#maincontent').unblock();
    });
  return false;
}
function h3customer_logout()
{
  var params = {op1:'logon', op2:'customer', useraction:'logout'};
  $('#maincontent').block({ message: $wait_message });
  $.post("index_ajax.php", params,
    function(data){
      h3ajax_post('#usercontent', {op1:'/',op2:'menu_top_logon'}, null, null, null, null);
      h3ajax_post('#maincontent', {op1:'/',op2:'customer'}, null, null, null, null);
      $('#maincontent').unblock();
    });
  return false;
}

function h3agent_logon()
{
  if (document.location.protocol=='http:')
  {
    $('form#h3agent_logonid').submit();
    return;
  }
  var params = {op1:'logon', op2:'agent'};
  $('form#h3agent_logonid').find('input').each(function(){ params[this.name] = $(this).val(); });
  $('#maincontent').block({ message: $wait_message });
  $.post("index_ajax.php", params,
    function(data){
      if ('OK'==data.substring(0,2))
      {
        h3ajax_post('#usercontent', {op1:'/',op2:'menu_top_logon'}, null, null, null, null);
        h3ajax_post('#maincontent', {op1:'/',op2:'agent'}, null, null, null, null);
      }
      else
        $('#h3logonerror').text(data);
      $('#maincontent').unblock();
    });
  return false;
}
function h3agent_logout()
{
  var params = {op1:'logon', op2:'agent', agentaction:'logout'};
  $('#maincontent').block({ message: $wait_message });
  $.post("index_ajax.php", params,
    function(data){
      h3ajax_post('#usercontent', {op1:'/',op2:'menu_top_logon'}, null, null, null, null);
      h3ajax_post('#maincontent', {op1:'/',op2:'agent'}, null, null, null, null);
    });
  return false;
}

function h3form_submit(page, form, ssl)
{
  if (ssl=='ssl')
  {
    if (document.location.protocol=='http:')
    {
      $('form#'+form).submit();
      return;
    }
  }
  var params = {op1:'/',op2:page};
  $('form#'+form).find('input').each(function(){ if(this.type=='checkbox' && this.checked==false) return; params[this.name]=$(this).val();});
  $('form#'+form).find('select').each(function(){params[this.name] = $(this).val();});
  h3ajax_post('#maincontent', params, null, null, '#maincontent');
  return false;
}

function h3ajax_post(container, params, post_function, post_params, wait_container, wait_message)
{
  if (wait_container)
  {
    if (!wait_message)
      wait_message = $wait_message;
    $(wait_container).block({ message: wait_message });
  }
  $.post("index_ajax.php", params,
    function(data){ 
			$(container).html(data);
      if (post_function)
        post_function(post_params);
      if (wait_container)
        $(wait_container).unblock();
    });
  return false;
}

var h3log_dbg=0;
var h3log_str='';
function h3log(str)     { if(h3log_str)h3log_str+="\n"; h3log_str+=str; }
function h3logShow(str) { if(str){if(h3log_str)h3log_str+="\n";h3log_str+=str;} if(h3log_dbg)alert(h3log_str); h3log_str=''; }
function h3logEnable()  { h3log_dbg=true; }
function h3logDisable()  { h3log_dbg=false; }

