/**
 * General delete confirmation
 */
function confirmDel(msg, url) {
  if (confirm(msg)) {
    document.location=url;
  }
}


function logoutConfirm() {
  if (confirm('Teil on ostukorvis mõned tooted. Kas soovite ilma tellimata väljuda?')) {
    document.location='login.php?logout';
  }
}

/**
 * Manage shooping cart actions
 */
function CartActionHandler(action,msg) {

  action_elem = document.cartForm.action;

  switch (action) {

    case 'empty':
      if (msg.length > 0) {
        if (confirm(msg)) {
          action_elem.value = 'empty';
        }
        else {
          return 0;
          //window.location.href = '/shoppingCart.php';
        }
      }
      else {
        return 0;
        //window.location.href = '/shoppingCart.php';
      }
      //action_elem.value = 'empty';
      break;
    case 'order':
      action_elem.value = 'order';
      break;
    default:
      action_elem.value = 'update';
      break;
  }

  document.cartForm.submit();

}