File: //old_home_backup/gurkhajustice.org.uk/public_html/script/general.js
/* Event observing for cursor positioning and key pressing */
var gMouseX = 0;
var gMouseY = 0;
var gCurKey = 0;
function gGetCords(e){
gMouseX = Event.pointerX(e);
gMouseY = Event.pointerY(e);
}
function gGetKey(e){
gCurKey = e.keyCode;
}
function gEventLoader(){
Event.observe(document, "mousemove", gGetCords);
Event.observe(document, "keypress", gGetKey);
}
Event.observe(document, "dom:loaded", gEventLoader, false);
/* Function used to show and hide help */
function gShowHelp(objname){
var obj = $(objname);
if(obj){
obj.toggleClassName('hidden');
}
obj.setStyle({ left: (gMouseX - 232) + 'px', top: (gMouseY + 10) + 'px' });
}
function CurrencyFormatted(amount){
var i = parseFloat(amount);
if(isNaN(i)) {
i = 0.00;
}
var minus = '';
if(i < 0) {
minus = '-';
}
i = Math.abs(i);
i = parseInt((i + .005) * 100);
i = i / 100;
s = new String(i);
if(s.indexOf('.') < 0) {
s += '.00';
}
if(s.indexOf('.') == (s.length - 2)) {
s += '0';
}
s = minus + s;
return s;
}