function getCategoryItems(siteNumber,categoryId, customerId, currencyId, containerId, priceContainerId, basePriceContainerId){
    //var src = '/app/site/hosting/scriptlet.nl?script=customscript_byn_getcategoryitems&deploy=customdeploy_byn_getcategoryitems&categoryid=' + categoryId + '&customerid=' + customerId + '&currencyid=' + currencyId + '&containerid=' + conayinerId + '&pricecontainerid=' + priceConayinerId;
    // Sandbox var src = 'https://forms.sandbox.netsuite.com/app/site/hosting/scriptlet.nl?script=146&deploy=1&compid=638609&h=38c5452bbf978d3edded&categoryid=' + categoryId + '&customerid=' + customerId + '&currencyid=' + currencyId + '&containerid=' + containerId + '&pricecontainerid=' + priceContainerId;
	var src = 'https://forms.netsuite.com/app/site/hosting/scriptlet.nl?script=140&deploy=1&compid=638609&h=410554b64c5fe696b726&sitenumber=' + siteNumber +'&categoryid=' + categoryId + '&customerid=' + customerId + '&currencyid=' + currencyId + '&containerid=' + containerId + '&pricecontainerid=' + priceContainerId +'&basepricecontainerid=' + basePriceContainerId;	
    var scriptFile = document.createElement('script');
    scriptFile.setAttribute('type', 'text/javascript');
    scriptFile.setAttribute('src', src);
    document.getElementsByTagName('head')[0].appendChild(scriptFile);
    
}

function bynSetItem(categoryId){

    objSelectItem = document.getElementById("byn_selectitems" + categoryId);
    if (objSelectItem != null) {
        if (objSelectItem.value != 'Select License') {
            document.forms["form" + categoryId].buyid.value = objSelectItem.value;
            document.forms["form" + categoryId].itemid.value = objSelectItem.value;
			var strSymbol = eval('strCurrencySymbol' + categoryId);
			var strPriceFormat = eval('arrCategoryItemsPrice' + categoryId + '["' + objSelectItem.value + '"]');
    	    document.getElementById("byn_itemprice" + categoryId).innerHTML =  formatNumber(strPriceFormat,strSymbol);
        }
        else {
            document.forms["form" + categoryId].buyid.value = '';
            document.forms["form" + categoryId].itemid.value = '';			
			document.getElementById("byn_itemprice" + categoryId).innerHTML = ''
        }
		document.forms["form" + categoryId].qty.value = '1';		        
    }    
}

function bynSetPrice(categoryId){    
    objSelectItem = document.getElementById("byn_selectitems" + categoryId);
    if (objSelectItem != null) {
        if (objSelectItem.value != 'Select License') {
            var strPrice = eval('arrCategoryItemsPrice' + categoryId + '["' + objSelectItem.value + '"]');
            var intQty = parseInt(document.forms["form" + categoryId].qty.value);
            var fltPrice = parseFloat(strPrice);
            if (fltPrice > 0 && intQty > 0) {
                fltPrice = fltPrice * intQty;
				var strSymbol = eval('strCurrencySymbol' + categoryId);
				var strPriceFormat = fltPrice.toFixed(2).toString();
                document.getElementById("byn_itemprice" + categoryId).innerHTML = formatNumber(strPriceFormat,strSymbol);
            }
            else {
                document.getElementById("byn_itemprice" + categoryId).innerHTML = '';
            }
        }
        else {
            document.getElementById("byn_itemprice" + categoryId).innerHTML = '';
        }
    }
    return false;
    
}

function bynAddToCart(categoryId){
    if (document.forms["form" + categoryId].buyid.value != '') {
        var intQty = parseInt(document.forms["form" + categoryId].qty.value);
        if (intQty != 'NaN' && intQty > 0) {
            document.forms["form" + categoryId].submit();
        }
        else {
            document.forms["form" + categoryId].qty.value = '';
            alert('Invalid number (must be greater than 0).');
        }
    }
    else {
        alert('Select a License.');
    }
}

function formatNumber(strNum, strPrefix){
    strPrefix = strPrefix || '';
    strNum += '';
    var strSplit = strNum.split('.');
    var strSplitLeft = strSplit[0];
    var strSplitRight = strSplit.length > 1 ? '.' + strSplit[1] : '';
    var regx = /(\d+)(\d{3})/;
    while (regx.test(strSplitLeft)) {
        strSplitLeft = strSplitLeft.replace(regx, '$1' + ',' + '$2');
    }
    return strPrefix + ' ' + strSplitLeft + strSplitRight;
	//return strPrefix + ' ' + strSplitLeft;
}

