
Object.prototype.Clone=function()
{var retval=this.constructor();for(prop in this)
{retval[prop]=this[prop];}
return retval;}
Object.prototype.ConvertToString=function(include_funcs,index)
{if(typeof(index)!='number')
index=1;else if(index>4)
return'end of recursion';switch(typeof(this))
{case'boolean':return(this?'true':'false');case'number':return this+'';case'string':return this;case'array':case'object':if(typeof(include_funcs)!='boolean')
include_funcs=false;var str='';for(prop in this)
{if(prop!='ConvertToString')
{if(include_funcs||typeof(this[prop])!='function')
{str+=prop+'=>'+this[prop].ConvertToString(include_funcs,(index+1))+';';}}}
return str;default:return'undefined';}};Object.extend=function(childClass,parentClass)
{function inheritance(){}
inheritance.prototype=parentClass.prototype;childClass.prototype=new inheritance();childClass.prototype.constructor=childClass;childClass.parentCtor=parentClass;childClass.parent=parentClass.prototype;}
String.prototype.trim=function()
{return this.replace(/^\s+|\s+$/g,"");}
String.prototype.ltrim=function()
{return this.replace(/^\s+/,"");}
String.prototype.rtrim=function()
{return this.replace(/\s+$/,"");}
String.prototype.startsWith=function(txt)
{return(this.substr(0,txt.length)==txt);}
Array.prototype.in_array=function(search_term)
{var i=this.length;if(i>0)
{do
{if(this[i]===search_term)
return true;}while(i--);}
return false;}
function g_sort_numeric(arg1,arg2)
{arg1=arg1*1;arg2=arg2*1;if(arg1<arg2)return-1;else if(arg1>arg2)return 1;else return 0;}
Array.prototype.sort_numeric=function()
{return this.sort(g_sort_numeric);}
Array.prototype.merge=function(arr2)
{for(var i=0;i<arr2.length;i++)
this.push(arr2[i]);}
var is_ie=document['all']?true:false;if(is_ie)
{document.get=function(id)
{var tag=document.getElementById(id);if(tag.id==id)
return tag;var tags=document.getElementsByName(id);for(var i=0;i<tags.length;i++)
{if(tags[i].id==id)
return tags[i];}
return null;}}
else
{document.get=document.getElementById;}
function getCommonEvent(evt)
{if(!evt){evt=window.event;}
evt.name='Derek\'s Common Event';if(typeof(evt['keyCode'])=='undefined')evt.keyCode=evt.which;if(typeof(evt['target'])=='undefined')evt.target=evt.srcElement;if(typeof(evt['pageX'])=='undefined')
{evt.pageX=evt.clientX+document.body.scrollLeft;evt.pageY=evt.clientY+document.body.scrollTop;}
if(typeof(evt['stopPropagation'])=='undefined')
evt.stopPropagation=function(){this.cancelBubble=true;};return evt;}
function register_event_handler(control_id,event_name,code,autocomplete)
{var control=document.getElementById(control_id);var full_code="var evt=getCommonEvent(e);"+code;var listener=new Function('e',full_code);var old_listener=control[event_name];if(old_listener)
control[event_name]=function(e){old_listener(e);listener(e);}
else
control[event_name]=listener;if(typeof(autocomplete)=='boolean'&&autocomplete==false)
control.setAttribute('autocomplete','off');}