function addMethod(){this.prototype.inherits = inherits;}Function.prototype.addMethod = addMethod;Function.addMethod();function inherits(clase){this.prototype = new clase();}function Reflection(myObj){var debug = "";for(var i in myObj){debug += i + " -> " + myObj[i] + "\n";}alert(debug);}function Timing(time){this.time= time;this.toSeconds = toSeconds;this.toMinutes = toMinutes;this.toHours = toHours;this.toDays= toDays;this.getSeconds= getSeconds;this.getMinutes= getMinutes;this.getHours= getHours;this.getDays = getDays;function toString(format){return "%d %h %m %s";}function toSeconds(){seconds = this.time / 1000;seconds *= seconds < 0 ? -1 : 1;return seconds;}function toMinutes(){seconds = this.toSeconds(this.time); return Math.floor(seconds / 60);}function toHours(){minutes = this.toMinutes(this.time); return Math.floor(minutes / 60);}function toDays(){hours = this.toHours(this.time); return Math.floor(hours / 24);}function getSeconds(){seconds = this.toSeconds(this.time);return Math.floor(seconds % 60);}function getMinutes(){minutes = this.toMinutes(this.time);return Math.floor(minutes % 60);}function getHours(){hours = this.toHours(this.time);return Math.floor(hours % 24);}function getDays(){return this.toDays(this.time);}}function PositionFinder(){	this.getPosition= getPosition;	this.getCursorPosition= getCursorPosition;	this.getMousePosition = getMousePosition;function getPosition(obj){	var curX = 0;	var curY = 0;while(obj.offsetParent){curX += obj.offsetLeft;curY += obj.offsetTop;obj = obj.offsetParent;	}return new Position(curX,curY);}function getMousePosition(e){	var posx = 1;	var posy = 1;	if (!e) var e = window.event;	if (e.pageX || e.pageY){posx = e.pageX;posy = e.pageY;	}	else if (e.clientX || e.clientY){posx = e.clientX + document.body.scrollLeft	+ document.documentElement.scrollLeft;posy = e.clientY + document.body.scrollTop	+ document.documentElement.scrollTop;	}return new Position(posx,posy);}function getCursorPosition(evnt){return new Position(evnt.screenX, evnt.screenY);}function Position(x,y){	this.x = x;	this.y = y;this.getX = getX;	this.getY = getY;	function getX(){ return this.x;	}	function getY(){ return this.y;	}}}function HashMap(){this.data = new Array();this.get= get;this.put= put;this.remove = remove;this.size = size;this.containsKey= containsKey;this.getIndex = getIndex; function get(key){var i = this.getIndex(key);if(i == -1){return null;}return this.data[i][1];}function put(key, value){var i = this.getIndex(key);if(i == -1){this.data.push(new Array(key,value));}else{var obj = this.get(key);this.data[i] = new Array(key,value);return obj;}return null;}function remove(key){var i = this.getIndex(key);if(i == -1){return null;}var obj = this.get(key);this.data.splice(i,1);return obj;}function size(){return this.data.length;} function containsKey(key){var i = this.getIndex(key);if(i > -1){return true;}return false;}function getIndex(key){for(var i = 0; i < this.data.length; i++){if(this.data[i][0] == key){return i;}}return -1;}}function FormObjectsManager(){this.setStringDisplay = setStringDisplay;this.setIntegerDisplay= setIntegerDisplay;this.setFloatDisplay= setFloatDisplay;this.setCurrencyDisplay = setCurrencyDisplay;this.setObjectVisibility= setObjectVisibility;this.setImageSrc= setImageSrc;this.setFieldValue= setFieldValue;this.getObject= getObject;this.getObjectVisibility= getObjectVisibility;this.getFieldValue= getFieldValue;function setStringDisplay(display_id, val){this.getObject(display_id).innerHTML = val;}function setIntegerDisplay(display_id, val){this.setStringDisplay(display_id, val);}function setFloatDisplay(display_id, val, precision){num = new Number(val);if(!isNaN(num)){val = num.toFixed(precision);}this.setStringDisplay(display_id, val);}function setCurrencyDisplay(display_id, val, precision){num = new Number(val);if(!isNaN(num)){val = "$" + num.toFixed(precision).replace(".",",");}this.setStringDisplay(display_id, val);}function setObjectVisibility(object_id, visible){obj = this.getObject(object_id);if(visible){obj.style.display = "";}else{obj.style.display = "none";}}function setImageSrc(image_id, src_value){obj = this.getObject(image_id);if(obj.nodeName == "IMG"){obj.src = src_value;}}function setFieldValue(field_id, val){this.getObject(field_id).value = val;}function getObject(field_id){return document.getElementById(field_id);}function getObjectVisibility(object_id){obj = this.getObject(object_id);if(obj.style.display != "none"){return true;}return false;}function getFieldValue(field_id){return this.getObject(field_id).value;}}function WindowsManager(){this.windows = Array();this.pfinder = new PositionFinder();this.openWindow= openWindow;this.openModalWindow = openModalWindow;this.openModelessWindow= openModelessWindow;this.closeWindow = closeWindow;this.registerWindow= registerWindow;this.unregisterWindow= unregisterWindow;this.getRegisteredWindow = getRegisteredWindow;this.createFeatures= createFeatures;this.createModalFeatures = createModalFeatures;this.closeAllWindows = closeAllWindows;this.isClosed= isClosed;function openWindow(url,n,featObj){var openedWindow = this.getRegisteredWindow(n);if(openedWindow != null){uri = openedWindow.document.location.href;if(uri.indexOf(url) > -1){openedWindow.focus();}else{openedWindow.document.location.href = url;}}else{ var sFeat = this.createFeatures(featObj);var openedWindow = window.open(url,n,sFeat);this.registerWindow(openedWindow);}openedWindow.focus();}function openModalWindow(url,n,featObj){var sFeat = this.createModalFeatures(featObj);if(window.showModalDialog){window.showModalDialog(url,self,sFeat);}else{newWindow = window.open(url,n,sFeat);newWindow.dialogArguments = self;}}function openModelessWindow(url,n,feat){}function createModalFeatures(featObj){var sFeat;if(window.showModalDialog){sFeat = "dialogLeft:" + featObj.posX + ";dialogTop:" + featObj.posY + ";dialogHeight:" + featObj.height + "px;dialogWidth:" + featObj.width + "px;center:" + featObj.center + ";edge:" + featObj.edge + ";scroll:" + featObj.scrollbars +";status:" + featObj.status + ";help:" + featObj.help + ";resizable:" + featObj.resizable;}else{sFeat = this.createFeatures(featObj);sFeat += ",modal=1";}return sFeat;}function createFeatures(featObj){return "left=" + featObj.posX + ",top=" + featObj.posY +",height=" + featObj.height + "px,width=" + featObj.width +"px,menubar=" + featObj.menubar + ",scrollbars=" + featObj.scrollbars +",status=" + featObj.status + ",resizable=" + featObj.resizable +",titlebar=" + featObj.titlebar;}function closeWindow(n){}function registerWindow(win){return this.windows.push(win);}function unregisterWindow(win){}function getRegisteredWindow(n){for(i=0; i < this.windows.length; i++){if(this.windows[i].closed){this.windows.splice(i,1);}else{if(this.windows[i].name == n){return this.windows[i];}}}return null;}function closeAllWindows(){for(i=0; i < this.windows.length; i++){if(!this.isClosed(this.windows[i])){this.windows[i].close();}}}function isClosed(win){if(win.screenTop > 9000){return true;}return false;}}function WindowFeatures(str){this.posX = finder("posX", str) ? finder("posX", str) : 0; this.posY = finder("posY", str) ? finder("posY", str) : 0; this.center = finder("center", str) ? finder("center", str) : 0; this.width= finder("width", str) ? finder("width", str) : 0; this.height = finder("height", str) ? finder("height", str) : 100; this.resizable= finder("resizable", str) ? finder("resizable", str) : 0; this.scrollbars = finder("scrollbars", str) ? finder("scrollbars", str) : 0; this.status = finder("status", str) ? finder("status", str) : 0; this.titlebar = finder("titlebar", str) ? finder("titlebar", str) : 0; this.menubar= finder("menubar", str) ? finder("menubar", str) : 0; this.edge = finder("edge", str) ? finder("edge", str) : "raised";this.help = finder("help", str) ? finder("help", str) : 0; function finder(p, str){var re = new RegExp("(\\,|^)" + p + "=(\\w+)(\\,|$)");if(str.search(re) > -1){var result = str.match(re);return result[2];}else{return false;}}}function DOMEventTarget(){this.listeners = new Array();this.addEventListener= addEventListener;this.removeEventListener = removeEventListener;this.dispatchEvent = dispatchEvent;function addEventListener(type, listener, useCapture){if(listener.handleEvent){this.listeners.push(listener);}else{alert("EventTarget.addEventListener(): El objeto que intenta registrar no es un EventListener o no implementa el método handleEvent(). El objeto es: " + listener);}}function removeEventListener(type, listener, useCapture){}function dispatchEvent(evt){for(i=0; i < this.listeners.length; i++){this.listeners[i].handleEvent(evt);}}}function ClickeableTarget(elementId){var thisInstance = this; this.fom = new FormObjectsManager();this.listeners = new Array();this.init= init;function init(){this.obj = this.fom.getObject(elementId);this.obj.onclick = onClick;} this.init(); function onClick(evt){evt = (evt || window.event);if(!evt.target){evt.target = thisInstance.obj;}thisInstance.dispatchEvent(evt);}} ClickeableTarget.inherits(DOMEventTarget);function ActiveObject(objType){var thisInstance = this; this.listeners = new Array();this.obj = null; this.display = null; this.init= init;this.appendChild = appendChild;this.toggleDisplay = toggleDisplay;this.setId = setId;this.setSrc= setSrc;this.setClass= setClass;this.setDisplay= setDisplay;this.setText = setText;this.getDisplay= getDisplay;this.getObject = getObject;function init(){this.obj = document.createElement(objType);this.obj.onclick = onClick;} this.init();function setId(newId){this.obj.setAttribute("id",newId);}function setSrc(newSrc){if(this.obj.nodeName == "IMG"){this.obj.src = newSrc;}}function setClass(newClass){this.obj.setAttribute("className",newClass);this.obj.setAttribute("class",newClass);}function setDisplay(newValue){this.obj.style.display = newValue;}function toggleDisplay(original){if(this.getDisplay() != "none"){this.setDisplay("none");}else{this.setDisplay(original);}}function setText(newText){this.obj.innerHTML = newText;}function appendChild(obj){this.obj.appendChild(obj.getObject());}function getDisplay(){return this.obj.style.display;}function getObject(){return this.obj;}function onClick(evt){evt = (evt || window.event);if(!evt.target){evt.target = thisInstance.obj;}thisInstance.dispatchEvent(evt);}}ActiveObject.inherits(DOMEventTarget);
