/* Strings */
String.prototype.trim = function(){return (this.replace(/^[\s\xA0]+/, "").replace(/[\s\xA0]+$/, ""))}
String.prototype.startsWith = function(str) {return (this.match("^"+str)==str)}
String.prototype.endsWith = function(str) {return (this.match(str+"$")==str)}
String.prototype.replaceAll = function(from, to) { return this.split(from).join(to); }
String.prototype.width = function() { var textwidthtest = g('_fw_def_textwidthtest'); if(!textwidthtest) { var textwidthtest = document.createElement('div'); textwidthtest.setAttribute('id', '_fw_def_textwidthtest'); textwidthtest.style.position = 'absolute'; textwidthtest.style.display = 'none'; document.body.appendChild(textwidthtest); } textwidthtest.innerHTML = this; textwidthtest.style.display = ''; var width = textwidthtest.clientWidth; textwidthtest.style.display = 'none'; return width; }

/* Html elements */
function addEvent(obj, eventType, functionToCall) { if (obj.addEventListener){ obj.addEventListener(eventType, functionToCall, false); return true; } else if (obj.attachEvent){ var r = obj.attachEvent("on"+eventType, functionToCall); return r; } else { return false; } } 
function getElement(sender) { var t0_obj = sender; if(!t0_obj.id) { t0_obj = event.srcElement; } return t0_obj; }

/* Abbriviations */
function g(id) { return document.getElementById(id); }
function t(tag, elem) { if(elem == null) { elem = document; } return elem.getElementsByTagName(tag); }
function ta(id, text) { ta(id, text, false); }
function ta(id, text, append) { var elem = g(id); var t = text; if(append) { t = elem.innerHTML + text;} elem.innerHTML = t; }
function pos(obj) { var curtop = curleft = 0; if(obj.offsetParent) { while(1) { curtop += obj.offsetTop; curleft += obj.offsetLeft; if(!obj.offsetParent) { break; } obj = obj.offsetParent; } } else if(obj.y) { curtop += obj.y; curleft += obj.x; } return [curleft,curtop]; }
