function toggleMenucategory(catid, toggleit)
{
	var linkplus = document.getElementById('imenucardplus'+catid);
	var linkminus = document.getElementById('imenucardminus'+catid);
	var catproducts = document.getElementById('imenucardproducts'+catid);
	var classnmstr;
	if (linkplus && linkminus && catproducts)
	{
		if (toggleit)
		{
			linkplus.className = 'categorymenucard_nodisplay';
			linkminus.className = 'categorymenucard';

			classnmstr = catproducts.className;

			if (classnmstr.substr(classnmstr.length-10)=='_nodisplay')
			{
				catproducts.className = classnmstr.substr(0,classnmstr.length-10);
			}

			xmlRequest('setMenuCategoryExpand.php','action=collapse&menucat=' + catid,'idummy');
		}
		else
		{
			linkplus.className = 'categorymenucard';
			linkminus.className = 'categorymenucard_nodisplay';

			classnmstr = catproducts.className;

			if (classnmstr.substr(classnmstr.length-10)!='_nodisplay')
			{
				catproducts.className = classnmstr + '_nodisplay';
			}

			xmlRequest('setMenuCategoryExpand.php','action=expand&menucat=' + catid,'idummy');
		}
	}
	return false;
}

function expandAllMenuCategories()
{
	var i;
	var classnmstr = '';
	var linkplus;
	var productsnodisplay;
	var catid = 0;
	var linkminusses = document.getElementsByTagName('a');
	if (linkminusses.length>0)
	{
		for (i=0;i<linkminusses.length;i++)
		{
			if (linkminusses[i].className=='categorymenucard_nodisplay')
			{
				var idstr = new String(linkminusses[i].id);
				if (idstr.substr(0,14)=='imenucardminus')
				{
					//display the plus
					linkminusses[i].className = 'categorymenucard';
					//retrieve minus
					catid = idstr.substr(14);
					linkplus = document.getElementById('imenucardplus'+catid);
					if (linkplus)
					{
						//hide minus
						linkplus.className = 'categorymenucard_nodisplay';
					}
					productsnodisplay = document.getElementById('imenucardproducts'+catid);
					var classnmstr = new String(productsnodisplay.className);
					productsnodisplay.className = classnmstr.substr(0,classnmstr.length-10);
				}
			}
		}
	}
	xmlRequest('setMenuCategoryExpand.php','action=expandall','idummy');
}

function changeTotalSidedishPriceCheckbox(nr,nrofdecimals,decimalsepp,thousandsepp,symb,sidedishselector)
{
	var currentpriceelt = document.getElementById('isidedishprice');
	var currenpriceelttext = document.getElementById('isidedishpricetext');
	if (currentpriceelt && currenpriceelttext)
	{
		var currentprice = parseFloat(currentpriceelt.value);
		if (!isNaN(currentprice))
		{
			if (sidedishselector.checked)
			{
				//add pr
				currentpriceelt.value = nr + currentprice;
			}
			else
			{
				//substract pr
				currentpriceelt.value = currentprice - nr;
			}
			//show new pr
			var strtext = format_price(currentpriceelt.value,nrofdecimals,decimalsepp,thousandsepp,symb);
			currenpriceelttext.innerHTML = strtext;
		}
	}
}

function changeTotalSidedishPricePulldown(nrofdecimals,decimalsepp,thousandsepp,symb,pulldownselector)
{
	var currentpriceelt = document.getElementById('isidedishprice');
	var currenpriceelttext = document.getElementById('isidedishpricetext');
	var idstr = new String(pulldownselector.id);
	idstr = idstr.substr("isidedishpulldown_".length);
	var oldselectvalue = document.getElementById('isidedishselectvalue_'+idstr);
	var nr = 0.0;
	var strnr = new String(pulldownselector.options[pulldownselector.selectedIndex].value);
	var strarr = strnr.split(';');
	if (currentpriceelt && currenpriceelttext && strarr.length>=2)
	{
		var currentprice = parseFloat(currentpriceelt.value);
		var oldvalue = parseFloat(oldselectvalue.value);
		var newvalue = parseFloat(strarr[1]);
		if (!isNaN(currentprice) && !isNaN(oldvalue) && !isNaN(newvalue))
		{
			//add pr
			currentpriceelt.value = currentprice - oldvalue + newvalue;
			//set oldvalue
			oldselectvalue.value = newvalue;
			//show new pr
			var strtext = format_price(currentpriceelt.value,nrofdecimals,decimalsepp,thousandsepp,symb);
			currenpriceelttext.innerHTML = strtext;
		}
	}
}

function changeTotalColumnsPricePulldown(nrofdecimals,decimalsepp,thousandsepp,symb,pulldownselector,baseprice,destinationeltid)
{
	var destinationelt = document.getElementById(destinationeltid);
	var strnr = new String(pulldownselector.options[pulldownselector.selectedIndex].value);
	var strarr = strnr.split(';');
	if (destinationelt && strarr.length>=2)
	{
		var basepricef = parseFloat(baseprice);
		var columnpricef = parseFloat(strarr[1]);
		if (!isNaN(basepricef) && !isNaN(columnpricef))
		{
			var strtext = format_price((basepricef+columnpricef),nrofdecimals,decimalsepp,thousandsepp,symb);
			destinationelt.innerHTML = strtext;
		}
	}
}

function checkNumberOfSidedishProducts(numberinput)
{
	//must be numeric between 1 and 99, else default to 1
	var str = new String(numberinput.value);
	str=trim(str);
	if (str!="")
	{
		var num = parseInt(str);
		if (isNaN(num) || (new String(num).length!=str.length))
		{
			numberinput.value = 1;
		}
		else
		{
			//must be max 99 and min 1
			if (num > 99) numberinput.value = 99;
			else if (num < 1) numberinput.value = 1;
		}
	}
}

function checkOnlyNumeric(numberinput, orgvalue)
{
	//must be numeric between 1 and 99, else default to 1
	var str = new String(numberinput.value);
	str=trim(str);
	if (str!="")
	{
		var num = parseInt(str);
		if (isNaN(num) || (new String(num).length!=str.length))
		{
			numberinput.value = orgvalue;
		}
		else
		{
			//must be max 99 and min 1
			if (num > 99) numberinput.value = 99;
			else if (num < 1) numberinput.value = 1;
		}
	}
}
