// Checks that a string contains only numbers
function isNumber(str) {
  for(var position=0; position<str.length; position++){
    var chr = str.charAt(position)
        if  ( (chr < "0") || (chr > "9") ) 
              return false;
  };      
  return true;
};

function add2cart (str_handler)
{
    str_handler = 'ADD-' + str_handler;
    
    if (document.forms.ADD.num.value)
    {
        if  (isNumber(document.forms.ADD.num.value) && (document.forms.ADD.num.value!='0') )
        {
            str_handler = str_handler + '-' + document.forms.ADD.num.value;
            /* alert(str_handler); */
            handle_cart (str_handler);
        } else
        {
            alert ('FEHLER! Bitte geben Sie eine gültige Anzahl ein.');
        }
    } else
    {
        str_handler = str_handler + '-1';
        /* alert(str_handler); */
        handle_cart (str_handler);
    }
    
}

function addvariant2cart (number, str_handler)
{
    //alert (number + ' x ' + str_handler);
    str_handler = 'ADD-' + str_handler;
    
    if (number)
    {
        if  (isNumber(number) && (number!='0') )
        {
            str_handler = str_handler + '-' + number;
            /* alert(str_handler); */
            handle_cart (str_handler);
        } else
        {
            alert ('FEHLER! Bitte geben Sie eine gültige Anzahl ein.');
        }
    } else
    {
        str_handler = str_handler + '-1';
        /* alert(str_handler); */
        handle_cart (str_handler);
    }
    
}

function updatecart (number, str_handler)
{
    //alert (number + ' x ' + str_handler);
    str_handler = 'UPDATE-' + str_handler;
    
    if (number)
    {
        if  (isNumber(number) && (number!='0') )
        {
            str_handler = str_handler + '-' + number;
            /* alert(str_handler); */
            handle_cart (str_handler);
        } else
        {
            alert ('FEHLER! Bitte geben Sie eine gültige Anzahl ein.');
        }
    } else
    {
        str_handler = str_handler + '-1';
        /* alert(str_handler); */
        handle_cart (str_handler);
    }
    
}


function handle_cart (str_handler)
{
    // ACTION-ID-VARIANTE-QTY
    // alert("str_handler="+str_handler);
    document.location.href = '/warenkorb,DE-726.html?cart_action='+str_handler;
}

function topsearch() {}
