function login_callback(data) {

  if (data != 1) {
    alert('Incorrect login or password!');
  } else {
    cms_page_refresh();
  }  

}

function do_login() {

  cms_do_ajax_login($('#login_login').val(), $('#login_password').val(), 0, 'login_callback');

}

function do_login2(e) {

  e = e || window.event || {};

  if (e.keyCode == 13) {
    do_login();
  }  

}

function do_search(submit) {

  var searchText = document.getElementById('search_text');
  var searchForm = document.getElementById('search_form');

  if (searchText.value == "" || searchText.value == "SEARCH HERE") {
    searchText.focus();
    alert('Please enter search text');
  } else {
    var searchValue = searchText.value.replace(/[^A-Za-z0-9  +-]/g,  "");
    searchValue =  searchText.value.replace(/[ ]/g, "_");
    searchForm.action += searchValue.toLowerCase() + ".htm";
    searchForm.submit();
  }

}

function add_to_cart(caller, amount, productId) {
  
  $(caller).fadeOut();
  $('#cart_items_sign').fadeOut();
  $('#total_items_sign').fadeOut();
  
  var a = $.get( "?__ajaxMethod=add_to_cart"
               , { amount:    amount
                 , productId: productId
                 }
               ,  function(data, textStatus) {
                   sum = data.substr(0, data.indexOf('#'));
                   amount = data.substr(data.indexOf('#')+1);
                   $(caller).fadeIn();
                   $('#cart_items_sign').html(sum);
                   $('#cart_items_sign').fadeIn();
                   $('#total_items_sign').html(amount);
                   $('#total_items_sign').fadeIn();
                 }
               );

}

function remove_from_cart(caller, productId) {
  
  var a = $.get( "?__ajaxMethod=remove_from_cart"
               , { productId: productId
                 }
               );

}

