CODE FOR FUNCTION SYD
<script language="JavaScript">
<!--
// Function to calculate Depreciation
function syd(cost, salvage, life, per)
{
cost = parseFloat(cost);
salvage = parseFloat(salvage);
life = parseFloat(life);
per = parseInt(per);
if (( cost == 0 ) || ( life == 0 ) || (per == 0)){
alert("Why do you want to test me with zeros?");
return(0);
}
x = ((cost - salvage)*(life - per + 1))*2;
syd_value = x / (life * (life+1));
syd_value = conv_number(syd_value,2);
return (syd_value);
}
function conv_number(expr, decplaces)
{ // This function is from David Goodman's Javascript Bible.
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));
}
// --></script>