function addToCart(nummer, itmId, ehdId, page_refresh) {

    // nummer = machinenummer
    // itmid = id van input veld waar de waarde van het aantal in staat

	jq_cartId  = "#cart_" + nummer;	
	jq_extraId = "#extra_" + nummer;
	jq_prijsId = "#prijs_" + nummer;		
	
    jq_itmId   = "#" + itmId;
    jq_itmAmt  = $(jq_itmId).attr('value');

    jq_ehdId   = "#" + ehdId;
    eenheid = $(jq_ehdId).val();

    if(jq_itmAmt == '') {
        jq_itmAmt = '1'
        }

    $.ajax({
        type: "POST",
        url: "/async/addtocart",
        data: "artnr=" + nummer + "&aantal=" + jq_itmAmt + "&eenheid=" + eenheid,
        datatype: "json",
        success: function(data){
            //add2cart( itmId, 'top_basket');
            var obj = jQuery.parseJSON(data);
            $cart_count = obj.cart_count + " artikelen";
            $cart_totaal = "&euro; " + obj.cart_totaal.toFixed(2);
            $item_prijsEHDP  = "&euro; " + obj.item_prijsEHDP.toFixed(2);
			
            $item_aantal = obj.item_aantal;
            $item_artnr  = obj.item_artnr;
            $item_oms    = obj.item_oms;
		
            //Bijwerken van de prijs van het artikel
            $(jq_prijsId).html($item_prijsEHDP);
            //Bijwerken van het totaal aantal artikelen
            $('#cart_count').html($cart_count); 
            //Bijwerken van het totaal bedrag
            $('#cart_totaal').html($cart_totaal); 		
		
            //Schonen van het aantal veld
            $(jq_itmId).attr('value', $item_aantal);
		
            if (page_refresh == 'Y') {
                location.reload();
            } else {
				$.jGrowl('Artikel ' + $item_artnr + ' (' + $item_oms + ') in winkelwagen bijgewerkt...', {
						life: 3000,
						glue: 'after',
						position: 'bottom-right'
				});	
				$('#cart_image').removeClass('empty');
				$('#cart_image').addClass('full');

				$(jq_cartId).removeClass('empty');
				$(jq_cartId).addClass('full');				

				$(jq_extraId).show();
			}
        }
    });

}

function submitZoekForm($message) {
	if ($message === undefined) { $message = "Gegevens worden opgehaald..."; }
    $("#content_sec").mask( $message);
	return true;
}

function popupWindow(url, height, width, name, parms) {

    if ( height === undefined ) {
        height = 600;
    }
    if ( width  === undefined ) {
        width  = 800;
    }
    if ( name   === undefined ) {
        name   = 'popupWindow';
    }

    var left = Math.floor( (screen.width - width) / 2);
    var top = Math.floor( (screen.height - height) / 2);
    var winParms = "top=" + top + ",left=" + left + ",height=" + height + ",width=" + width + "";

    if (parms) {
        winParms += "," + parms
    } else {
        winParms += ", toolbar=no, location=no, directories=no, status=no, menubar=no, resizable=yes, scrollbars=yes";
    }

    var win = window.open(url, name, winParms);
    if (parseInt(navigator.appVersion) >= 4) {
        win.window.focus();
    }
    return win;
}

function getDescription(artnr, itmId) {

    // itmid = id van input veld waar de waarde van het artikelnummer in staat
    jq_itmId  = "#oms_" + itmId;

    $.ajax({
        type: "POST",
        url: "/async/getdescription",
        data: "artnr=" + artnr,
        datatype: "json",
        success: function(data){
				
            var obj = jQuery.parseJSON(data);
            $omschrijving = obj.omschrijving;
          		
            //Bijwerken van het omschrijving veld
            $(jq_itmId).html($omschrijving); 
        }
    });

}



