function currency(anynum) {
   anynum=eval(anynum);
   workNum=Math.abs((Math.round(anynum*100)/100));workStr=""+workNum;
   if (workStr.indexOf(".")==-1){workStr+=".00";}
   dStr=workStr.substr(0,workStr.indexOf("."));dNum=dStr-0;
   pStr=workStr.substr(workStr.indexOf("."));
   while (pStr.length<3){pStr+="0";}
   if (dNum>=1000) {
      dLen=dStr.length;
      dStr=parseInt(""+(dNum/1000))+","+dStr.substring(dLen-3,dLen);
   }
   if (dNum>=1000000) {
      dLen=dStr.length;
      dStr=parseInt(""+(dNum/1000000))+","+dStr.substring(dLen-7,dLen);
   }
   retval = dStr + pStr;
   if (anynum<0) {retval="("+retval+")";}
   return retval;
}

function calculateAICPrice () {

x = document.calculator.users.value;

if(x > 999) {
	alert("Please contact our sales department for bulk purchasing.\nsales@adelix.com");
	return false;
}

if(x < 251) {
	y = x * 9.84;
}

if(x > 250 && x < 501) {
	y = x * 9.18;
}

if(x > 500 && x < 1000) {
	y = x * 7.21;
}

document.calculator.licensecost_ex.value = currency (y);
document.calculator.licensecost_vat.value = currency (y * 0.175);
document.calculator.licensecost_inc.value = currency (y * 1.175);

return false;

}
