// MS: This script returns stock Lead time text-->
function StockLevels(pItem,Lead,Release)
{
var strIDs = 'Stock Message: '
{
if (pItem >= 1)
{
strIDs = '<font color=green><b>' + pItem + ' In Stock</font></b><br>Delivery: Next Day'
}
else
{
	if (Release  != "")
	{
	strIDs = '<font color=red><b>OUT OF STOCK</font></b><br>Expected: ' + Release
	}
	else
	{
	strIDs = '<font color=green><b>Available</font></b><br>Delivery: ' + Lead
	}
}
}
return strIDs
}




// MS: This script returns item weight text. not used in v10-->
function ItemWeight(wItem)
{
wItem = wItem / 1000
wItem = FormatNumber(wItem,1)
if (wItem > 0)
{
return document.write("<LI>Weight: " + wItem + " kg<br>");
}
}


// MS: This script returns key group text-->
function KeyGroup(zItem)
{
//zItem = zItem / 1000
//zItem = FormatNumber(zItem,1)
if (zItem != '')
{
return document.write("<LI>Key Group: " + zItem);
}
}


// MS: These scripts return RRP and saving text
function checkrrp(pItem, qItem)
{
pItem = pItem*100
qItem = qItem*100
percent = 100 - ((qItem/pItem)*100)
percent = FormatPercent(percent,0)
if (pItem > qItem)
{
pItem = FormatNumber(pItem/100,2)
return document.write("RRP: £" + pItem + " (<b>Save " + percent + "%</b>)");
//return document.write(pItem);
}

}

// MS: These scripts return RRP and saving text
function saving(pItem, qItem)
{
pItem = pItem*100
qItem = qItem*100
percent = 100 - ((qItem/pItem)*100)
percent = FormatPercent(percent,0)
if (pItem > qItem)
{
pItem = FormatNumber(pItem/100,2)
return document.write("(Save " + percent + "%)");
//return document.write(pItem);
}

}




function FormatNumber(expr, decplaces)
{
var str = "" + Math.round(eval(expr) * Math.pow(10,decplaces));
while (str.length <= decplaces)
{
str = "0" + str;
}
var decpoint = str.length - decplaces;
return str.substring(0,decpoint) + "." + str.substring(decpoint, str.length);
}



function FormatPercent(expr, decplaces)
{
var str2 = "" + Math.round(eval(expr) * Math.pow(10,decplaces));
while (str2.length <= decplaces)
{
str2 = "0" + str2;
}
var decpoint = str2.length - decplaces;
return str2.substring(0,decpoint)
} 

// MS: This script returns quantity discount text-->
function QtyDiscount(qNum,qPerc)
{
if (qNum > 0)
{
return document.write("<LI>Qty Discount:<b> " + qPerc + "% off " + qNum + " or more</b><br>");
}
}



// MS: Anti Spam Script-->
function EMU()
{
var _u = "sales";
var _d = "saundersonsecurity.co.uk";
var _l = _u + "@" + _d;
var _m = "Email Us";
return document.write("<a href='mailto:"+_l+"'>"+_m+"</a>");
}

