
var d=document;function get_ext(v)
{return v.substring(v.lastIndexOf(".")+1,v.length).toLowerCase();}
function basename(v)
{if(isset(v))
{var pos=v.lastIndexOf("\/");var r=v.substring(pos+1);return r;}
else
{return false;}}
function dec_hex(v)
{return v.toString(16);}
function hex_dec(v)
{return parseInt(v,16);}
function isset(v)
{return(typeof v!="undefined"&&v!==null)?true:false;}
function is_null(v)
{return(v===null);}
function popup(name,url,width,height,left,top,options)
{if(isset(name)&&isset(url))
{var option_string="width="+width+",height="+height;if(isset(left)&&left!==0){option_string+=",left="+left;}
if(isset(top)&&top!==0){option_string+=",top="+top;}
if(!isset(options)){options="resizable,status,scrollbars";}
if(options.indexOf("location")!=-1){option_string+=",location=yes";}
if(options.indexOf("menubar")!=-1){option_string+=",menubar=yes";}
if(options.indexOf("resizable")!=-1){option_string+=",resizable=yes";}
if(options.indexOf("scrollbars")!=-1){option_string+=",scrollbars=yes";}
if(options.indexOf("status")!=-1){option_string+=",status=yes";}
if(options.indexOf("toolbar")!=-1){option_string+=",toolbar=yes";}
option_string+=",dependent=yes";return window.open(url,name,option_string);}
else
{return false;}}
function rand(min,max)
{var r=Math.round(Math.random()*(max-min))+min;return r;}
function redirect(v)
{if(isset(v))
{window.location.href=v;}}
function strip_scripts(v)
{return v.replace(/<script[^>]*>([\u0001-\uFFFF]*?)<\/script>/g,"");}
function strip_tags(v)
{return v.replace(/<[^>]*>/g,"");}
core={app:{},util:{},tools:{open:function()
{core.tools.Window=new Ext.Window({id:"tools",title:"Tools",width:200,height:"auto",maximizable:false,html:new Ext.Template("<div style=\"padding: 10px;\"><ul><li><a href=\"?a=100&amp;t=0&amp;y=1000\">Reset Application</a><li></ul></div>")});core.tools.Window.show();core.tools.Window.alignTo("admin.tools","l",Array(0,16));}}}
core.control=function(id)
{this.Id=id;try
{this.ext=Ext.get(id);this.dom=Ext.get(id).dom;}
catch(e){}
this.disable=function()
{if(typeof(this.dom.disabled=="boolean"))
{this.ext.removeClass("x-form-invalid");this.setValue("");this.dom.disabled=true;}};this.enable=function()
{if(typeof(this.dom.disabled)=="boolean")
{this.dom.disabled=false;}};this.validate=function(v)
{if(typeof(v)!="undefined"&&v!="")
{var validate=new core.validate();var validations=v.toString().split(";");for(i=0;i<=validations.length;i++)
{var validation=validations[i];if(typeof(validation)=="string")
{var match=validation.match(/^([a-zA-Z]+)(\(([a-zA-Z0-9,]+)\))?$/);if(isset(match[1]))
{var cmd=match[1];if(isset(match[3]))
{args=match[3].toString().split(",");}
else
{var args=[];}
if(isset(validate[cmd]))
{if(!validate[cmd](this.getValue(),args))
{this.ext.addClass("x-form-invalid");return false;}}}}}}
this.ext.removeClass("x-form-invalid");return true;};if(typeof(this._construct)=="function")this._construct();return this;};core.control.common=Ext.extend(core.control,{Type:"common"});core.control.layer=Ext.extend(core.control,{Type:"layer",toggle:function()
{if(this.ext.isVisible())
{this.hide();}
else
{this.show();}
return true;},hide:function()
{this.ext.setVisible(false);this.ext.setDisplayed("none");return true;},show:function()
{this.ext.setVisible(true);this.ext.setDisplayed("block");return true;}});core.control.form=Ext.extend(core.control,{Type:"form",items:Array(),_construct:function()
{delete(this.disable);delete(this.enable);this.validate=this.validateForm;var exclude=Array();for(i=0;i<this.dom.length;i++)
{var item=false;var ele=this.dom.elements[i];switch(ele.tagName)
{case"INPUT":switch(ele.type)
{case"checkbox":var item=new core.control.form.checkbox(ele.id);break;case"radio":if(exclude.indexOf(ele.name)==-1)
{var item=new core.control.form.radio(ele.id);exclude.push(ele.name);}
break;case"hidden":case"password":case"text":var item=new core.control.form.text(ele.id);break;}
break;case"SELECT":var item=new core.control.form.select(ele.id);break;case"TEXTAREA":var item=new core.control.form.text(ele.id);break;}
if(typeof(item)!=="undefined"&&item!==false)
{this.items.push(item);}}},exists:function(key)
{for(i=0;i<this.items.length;i++)
{if(this.items[i].Id==key)
{return i;}}
return undefined;},get:function(key)
{var i=this.exists(key);if(typeof(i)!="undefined")
{return this.items[i];}
return undefined;},toString:function()
{var r="";for(i=0;i<this.items.length;i++)
{var item=this.items[i];if(typeof(item)=="object")
{if(typeof(item.getValue)=="function")
{var v=item.getValue();}
else
{var v=undefined;}
r+="&"+item.Id+"="+((typeof(v)=="undefined")?"":escape(v));}}
return r;},validateForm:function()
{for(i=0;i<this.items.length;i++)
{var item=this.items[i];if(typeof(item)=="object")
{if(!item.validate(item.dom.getAttribute("validate")))
{return false;}}}
return true;}});core.control.form.fieldset=Ext.extend(core.control,{Type:"fieldset",toggle:function()
{try
{var fieldset=this.ext;var layer=Ext.get(this.Id+".content");if(layer.isVisible())
{layer.hide(false);fieldset.setHeight(10,true);}
else
{fieldset.setHeight(layer.getHeight()+50,true);setTimeout(function(){layer.show(false);},500);}
return true;}
catch(e)
{return false;}}});core.control.form.checkbox=Ext.extend(core.control,{Type:"checkbox",checked:function()
{try
{return(this.dom.checked)?true:false;}
catch(e)
{return false;}},getValue:function()
{try
{return(this.checked())?this.dom.value:undefined;}
catch(e)
{return undefined;}},setValue:function(v)
{return false;},value:function(v)
{if(typeof(v)==="undefined")
{return this.getValue();}
else
{return this.setValue(v);}}});core.control.form.image=Ext.extend(core.control,{Type:"image",clear:function()
{try
{this.dom.value="";Ext.get(this.Id+".image").dom.src="image.php?file=img/core/blank.gif&options=";return true;}
catch(e)
{return false;}},getValue:function()
{try
{return this.dom.value;}
catch(e)
{return undefined;}},setValue:function(value)
{try
{this.dom.value=value;Ext.get(this.Id+".image").dom.src=value;return true;}
catch(e)
{return false;}},value:function(v)
{if(typeof(v)==="undefined")
{return this.getValue();}
else
{return this.setValue(v);}}});core.control.form.radio=Ext.extend(core.control,{Type:"radio",items:null,_construct:function()
{this.items=this.dom.form[this.Id];this.disable=function()
{for(i=0;i<this.items.length;i++)
{this.items[i].disabled=true;}};this.enable=function()
{for(i=0;i<this.items.length;i++)
{this.items[i].disabled=false;}};},count:function()
{try
{return this.items.length;}
catch(e)
{return 0;}},getValue:function()
{for(i=0;i<this.items.length;i++)
{if(this.items[i].checked==true)
{return this.items[i].value;}}
return undefined;},select:function(i)
{try
{for(l=0;l<this.items.length;l++)
{this.items[l].checked=false;}
this.items[i].checked=true;return true;}
catch(e)
{return false;}},setValue:function(v)
{return false;},value:function(v)
{if(typeof(v)==="undefined")
{return this.getValue();}
else
{return this.setValue(v);}}});core.control.form.select=Ext.extend(core.control,{Type:"select",items:null,_construct:function()
{this.items=this.dom.options;this.disable=function()
{this.ext.removeClass("x-form-invalid");this.select(0);this.dom.disabled=true;};},clear:function()
{try
{this.dom.options.length=0;return true;}
catch(e)
{return false;}},count:function()
{try
{return this.dom.options.length;}
catch(e)
{return 0;}},getValue:function()
{try
{return this.dom.options[this.dom.selectedIndex].value;}
catch(e)
{return undefined;}},remove:function(i)
{try
{this.dom.options[i]=null;return true;}
catch(e)
{return false;}},select:function(i)
{try
{this.dom.options[i].selected=true;return true;}
catch(e)
{return false;}},setValue:function()
{return false;},value:function(v)
{if(typeof(v)==="undefined")
{return this.getValue();}
else
{return this.setValue(v);}}});core.control.form.text=Ext.extend(core.control,{Type:"text",getValue:function()
{try
{return this.dom.value;}
catch(e)
{return undefined;}},setValue:function(v)
{try
{this.dom.value=v;return true;}
catch(e)
{return false;}},value:function(v)
{if(typeof(v)==="undefined")
{return this.getValue();}
else
{return this.setValue(v);}}});core.control.tab=Ext.extend(core.control,{Type:"tab",_construct:function()
{if(typeof(this.dom)!="undefined"&&typeof(this.dom.attributes["x-tabs"])!="undefined")
{this.tabs=this.dom.attributes["x-tabs"].value.split(",");}},toggle:function()
{if(this.ext.isVisible())
{this.ext.setVisible(false);this.ext.setDisplayed("none");}
else
{this.ext.setVisible(true);this.ext.setDisplayed("block");}},activate:function(id)
{for(var i=0;i<this.tabs.length;i++)
{var layer=Ext.get("layer."+this.tabs[i]);var tab=Ext.get(this.tabs[i]);if(this.tabs[i]==id)
{layer.setVisible(true);layer.setDisplayed("block");tab.removeClass("tab");tab.addClass("tab-selected");}
else
{layer.setVisible(false);layer.setDisplayed("none");tab.removeClass("tab-selected");tab.addClass("tab");}}}});core.validate=function()
{return{"alpha":function(v,args)
{return/^[a-zA-Z_]+$/.test(v);},"alphanum":function(v,args)
{return/^[a-zA-Z0-9_]+$/.test(v);},"email":function(v,args)
{return/^([\w]+)(.[\w]+)*@([\w-]+\.){1,5}([A-Za-z]){2,4}$/.test(v);},"max":function(v,args)
{return(v.length<=args[0])?true:false;},"min":function(v,args)
{return(v.length>=args[0])?true:false;},"url":function(v,args)
{return/(((https?)|(ftp)):\/\/([\-\w]+\.)+\w{2,3}(\/[%\-\w]+(\.\w{2,})?)*(([\w\-\.\?\\\/+@&#;`~=%!]*)(\.\w{2,})?)*\/?)/i.test(v);}};};core.language={strings:{},get:function(key)
{if(this.exists(key))
{return this.strings[key];}
else
{return undefined;}},exists:function(key)
{return(typeof(this.strings[key])!="undefined")?true:false;},set:function(arg1,arg2)
{switch(typeof(arg1))
{case"string":this.strings[arg1]=arg2;break;case"object":if(arg1 instanceof Array)
{for(i=0;i<arg1.length;i++)
{if(arg1[i]instanceof Array&&arg1.length==2)
{core.language.set(arg1[i][0],arg1[i][1]);}}}
else if(arg1 instanceof Object)
{for(item in arg1)
{core.language.set(item,arg1[item]);}}
break;}}};core.util.guid=function()
{var token=function(amount)
{var seed1=rand(0,Math.pow(8,8)*16);var seed=seed1^rand(0,Math.pow(10,seed1.length));seed=dec_hex(seed);return seed.substring(seed.length-(amount+1),seed.length-1);};this.toString=function()
{return this.value;};this.valueOf=function()
{return this.value;};this.value=token(4)+token(4)+"-"+token(4)+"-"+token(4)+"-"+token(4)+"-"+token(4)+token(4)+token(4);}
core.util.mouse={CURSOR_AUTO:"auto",CURSOR_CROSSHAIR:"crosshair",CURSOR_DEFAULT:"default",CURSOR_HELP:"help",CURSOR_MOVE:"move",CURSOR_POINTER:"pointer",CURSOR_TEXT:"text",CURSOR_WAIT:"wait",PosX:0,PosY:0,ScrolledX:0,ScrolledY:0,WindowX:0,WindowY:0,resetCursor:function()
{document.body.style.cursor=this.CURSOR_DEFAULT;},setCursor:function(style)
{document.body.style.cursor=style;},update:function(e)
{if(document.all?true:false)
{this.PosX=event.clientX;this.PosY=event.clientY;}
else
{this.PosX=e.pageX;this.PosY=e.pageY;}
if(self.pageYOffset)
{this.ScrolledX=self.pageXOffset;this.ScrolledY=self.pageYOffset;}
else if(document.documentElement&&document.documentElement.scrollTop)
{this.ScrolledX=document.documentElement.scrollLeft;this.ScrolledY=document.documentElement.scrollTop;}
else if(document.body)
{this.ScrolledX=document.body.scrollLeft;this.ScrolledY=document.body.scrollTop;}
if(typeof(window.innerWidth)=='number')
{this.WindowX=window.innerWidth;this.WindowY=window.innerHeight;}
else if(document.documentElement&&(document.documentElement.clientWidth||document.documentElement.clientHeight))
{this.WindowX=document.documentElement.clientWidth;this.WindowY=document.documentElement.clientHeight;}
else if(document.body&&(document.body.clientWidth||document.body.clientHeight))
{this.WindowX=document.body.clientWidth;this.WindowY=document.body.clientHeight;}}}
document.onmousemove=function(e){core.util.mouse.update(e);};
