/*
 * Project: SLKV
 * Commons Utils functions
 * Date:  
 */
var _w=window,
_d=document,
_l=_w.location,
__mouseX=0,__mouseY=0,
__winWidth=0,__winHeight=0,
__vertScroll=0,__horiScroll=0;
_d.gtn_=_d.getElementsByTagName;
_d.gid_=_d.getElementById;
_d.ce_=_d.createElement;
var _CLS_="className";
var _UDF_="undefined";
var _IMGEXT_="gif";
var _IMGPATH_="_images/";
function BrowserChecking(){
var b=navigator.appName;
if(b.indexOf('Netscape')!=-1)this.b="ns";
else if(b=="Opera"||(navigator.userAgent.indexOf("Opera")>0))this.b="opera";
else if(b=="Microsoft Internet Explorer")this.b="ie";
if(!b)alert('Unidentified browser.\nThis browser is not supported!');
this.version=navigator.appVersion;
this.fv=parseFloat(this.version);
this.v=parseInt(this.version);
this.ns=(this.b=="ns"&&this.v>=4);
this.ns4=(this.b=="ns"&&this.v==4);
this.ns6=(this.b=="ns"&&this.v==5);
this.ns7=(navigator.userAgent.indexOf('Netscape/7')>0);
this.ie=(this.b=="ie"&&this.v>=4);
this.ie4=(this.version.indexOf('MSIE 4')>0);
this.ie5=(this.version.indexOf('MSIE 5')>0);
this.ie55=(this.version.indexOf('MSIE 5.5')>0);
this.ie6=(this.version.indexOf('MSIE 6.0')>0);
this.ie7=(this.version.indexOf('MSIE 7.0')>0);
if(this.ie){
this.iev=parseInt(this.version.substring(this.version.indexOf('MSIE ')+5));
this.ieFixed=(navigator.appMinorVersion.split(';').length>3)||(navigator.userAgent.indexOf('NT 5.1')>0);
}
this.opera=(this.b=="opera");
this.dom=(_d.ce_&&_d.appendChild&&_d.gtn_)?true:false;
this.def=(this.ie||this.dom); // most used browsers, for faster if loops
this.dyn=(this.dom||this.ie||this.ns4);
var ua=navigator.userAgent.toLowerCase();
if(ua.indexOf("win")>-1)this.platform="win32";
else if(ua.indexOf("mac")>-1)this.platform="mac";
else this.platform="other";
}
var is=new BrowserChecking();
function isObject(v){
return (typeof v=="object");
}
function isString(v){
return (typeof v=="string");
}
function __getParent(){
return _d._dEs[this.getAttribute("pID__")];
}
function __firstObject(obj){
if(obj)for(var i in obj)if(typeof obj[i]=='object'&&obj[i])return obj[i];
return null;
}
var _tag=new Object();
_tag.tbl=function(w,h,b,cp,cs,cls,bg,s,id){
w=w!=0?' width="'+(w?w:'100%')+'"':'';
h=h?' height="'+h+'"':'';
b=' border="'+(b?b:'0')+'"';
cp=' cellpadding="'+(cp?cp:'0')+'"';
cs=' cellspacing="'+(cs?cs:'0')+'"';
cls=cls?' class="'+cls+'"':'';
bg=bg?' background="'+bg+'"':'';
s=s?' style="'+s+'"':'';
id=id?' id="'+id+'"':'';
return '<table'+w+h+b+cp+cs+cls+bg+s+id+'>';
}
_tag.tbl_=function(){
return '</table>';
}
_tag.td=function(w,bg,cls,nw){
w=w?' width="'+w+'"':'';
bg=bg?' background="'+bg+'"':'';
cls=cls?' class="'+cls+'"':'';
return '<td'+w+bg+cls+(nw?' nowrap':'')+'>';
}
_tag._td=function(){
return '</td>';
}
_tag.img=function(s,w,h){
if(!is.ie||(s.toLowerCase()).indexOf('.png')<0)return '<img src="'+s+'"'+(w?' width="'+w+'px"':'')+(h?' height="'+h+'px"':'')+' />';
else return '<div style="width:'+(w?w:1)+';height:'+(h?h:1)+';filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src=\''+s+'\',sizingMethod=\''+(w&&h?'scale':'image')+'\');"></div>';
}
function getImage(src){
return _IMGPATH_ + src + "." + _IMGEXT_;
}
function getSpacer(){
return "spacer." + _IMGEXT_;
}
function attachEvent(e,evt,hdl){
if(e){
if(e.addEventListener)e.addEventListener(evt,hdl,false);
else if(e.attachEvent)e.attachEvent("on"+evt,hdl);
else e["on"+evt]=hdl;
}
}
function detachEvent(e,evt,hdl){
if(e){
if(e.removeEventListener)e.removeEventListener(evt,hdl,false);
else if(e.detachEvent)e.detachEvent("on"+evt,hdl);
else e["on"+evt]=null;
}
}
function getWinWidth(d,w){
var ww=0;
if(!d)d=_d;
if(!w)w=_w;
if(d.body&&d.body.clientWidth)ww=d.body.clientWidth;
else if(d.documentElement&&d.documentElement.clientWidth)ww=d.documentElement.clientWidth;
else if(d.body&&d.body.offsetWidth)ww=d.body.offsetWidth;
else if(w.innerWidth)ww=w.innerWidth;
return ww;
}
function getWinHeight(d,w){
var wh=0;
if(!d)d=_d;
if(!w)w=_w;
if(w.innerHeight) {
wh=w.innerHeight;
}else if(d.documentElement&&d.documentElement.clientHeight){
wh=d.documentElement.clientHeight;
}else if(d.body&&d.body.clientHeight){
wh=d.body.clientHeight;
}
return wh;
}
function __unSelectable(e){
var i,t;
if(is.ie){
e=_w.event;
if(!e){
for(i=0;i<_w.frames.length;i++)
if(_w.frames[i]&&_w.frames[i].event){
e=_w.frames[i].event;
break;
}
}
}
if(!e)return false;
t=is.ie?e.srcElement:e.target;
if(t&&typeof t.form!=_UDF_&&t.tagName.toLowerCase()!='label')return true;
else return false;
}
function __emptyFunc(evt){
return false;
}
function __removeEvents(el){
var i;
for(i in el)if(el[i]&&typeof el[i]=="function")el[i]=null;
if(el.childNodes)for(i in el.childNodes)__removeEvents(el.childNodes[i]);
}
function getClientPos(e){
if(!e)return null;
if(isString(e))e=_d.gid_(e);
else if(e.el&&e.type=="DynInteface")e=e.el;
if(!e)return null;
var l=e.offsetLeft,t=e.offsetTop,p=e.parentNode,_wd=e.offsetWidth?e.offsetWidth:e.clientWidth;
while(p&&p.offsetLeft!=null&&p.offsetTop!=null&&p.tagName.toLowerCase()!="body"){
if(p.tagName.toLowerCase()!='tr'){
if  (p.offsetLeft==24 && is.ns){l+=21;_wd+=3}
else{
    l+=p.offsetLeft;
}
t+=p.offsetTop;
}
if(is.ie&&p.style){
if(p.style.borderLeftStyle&&p.style.borderLeftStyle!='none'&&p.style.borderLeftWidth)l+=parseInt(p.style.borderLeftWidth);
else if(p.style.borderStyle&&p.style.borderStyle!='none'&&p.style.borderWidth)l+=parseInt(p.style.borderWidth);
if(p.style.borderTopStyle&&p.style.borderTopStyle!='none'&&p.style.borderTopWidth)t+=parseInt(p.style.borderTopWidth);
else if(p.style.borderStyle&&p.style.borderStyle!='none'&&p.style.borderWidth)t+=parseInt(p.style.borderWidth);
}
p=p.offsetParent;
}
return {left:l,top:t,width:_wd,height:e.offsetHeight?e.offsetHeight:e.clientHeight};
}
function trim(s){
if(!s||!s.length)return '';
var c=s.charCodeAt(0);
while(s.length>0&&(c==32||c==9||c==13)){s=s.substring(1);if(s.length>0)c=s.charCodeAt(0);}
if(s.length>0){
c=s.charCodeAt(s.length-1);
while(s.length>0&&(c==32||c==9||c==13)){s=s.substring(0,s.length-1);if(s.length>0)c=s.charCodeAt(s.length-1,1);}
}
return s;
}
function isEmptyString(s){
return (trim(s).length==0);
}
function _TO(){};
var p=_TO.prototype;
p._g=function(e,t){return e.getElementsByTagName(t);}
p._n=function(e){return e.nextSibling;}
p._p=function(e){return e.previousSibling;}
p._f=function(e){return e.firstChild;}
p._l=function(e){return e.lastChild;}
p._pn=function(e){return e.parentNode;}
p._a=function(p,c){p.appendChild(c);};
var _to=new _TO();
zOrder=1000;//To manage the zIndex of the layers
__dCount=0;//Count of dynamic elements
/**
 * @author Administrator
 */
function DynInteface(){
var a=DynInteface.arguments,r,c,t;
if(!a||!a.length)return;
this.type="DynInteface";
if(a.length==1&&isObject(a[0])&&a[0]){
r=a[0];
a[0]=r.parent;
a[1]=r.tagName;
if(r.ref){
a[2]=r.ref;
a[2].id=r.id;
}else a[2]=new Object({id:r.id});
}
if(isString(a[0]))a[0]=(this._od?this._od:_d).gid_(a[0]);
if(!a[0])a[0]=(this._od?this._od.body:_d.body);
if(a[0].type&&a[0].type=="DynInteface"&&a[0].el)a[0]=a[0].el;
if(!_d._dEs)_d._dEs=new Object();
__dCount++;
if(a.length==1&&!r){
this.parent=a[0].parentNode;
if(!this._od&&this.parent&&this.parent.ownerDocument)this._od=this.parent.ownerDocument;
this.tag=a[0].tagName;
this.id=a[0].getAttribute("id");
this.el=a[0];
this.css=this.el.style;
}else if(a.length==3||r){
this.parent=a[0];
if(!this._od&&this.parent&&this.parent.ownerDocument)this._od=this.parent.ownerDocument;
if(!a[2].id){if(a[2].ID)a[2].id=a[2].id;else a[2].id="__dynElement"+__dCount;}
t=a[2].style;
if(t){
if(t.position!="absolute"){
c=this.parent.innerHTML;
if(a[2].clear||c==" "||c=="&nbsp;"||c.length<=1)this.parent.innerHTML="";
}else{
if(t.left==null&&t.top==null&&!a[2].holder){this.__center=true;}
if(t.width!=null&&isString(t.width)&&t.width.indexOf("%")>=0){this.__aWidth=true;this.__w=parseInt(t.width)/100;}
if(t.height!=null&&isString(t.height)&&t.height.indexOf("%")>=0){this.__aHeight=true;this.__h=parseInt(t.height)/100;}
if(this.parent.tagName=="TD"){
if(t.left!=null)t.left=parseInt(t.left)+this.parent.offsetLeft;
if(t.top!=null)t.top=parseInt(t.top)+this.parent.offsetTop;
if(is.ns){
if(t.width&&isString(t.width)&&t.width.indexOf("%")>=0)t.width=parseInt(parseInt(t.width)*this.parent.offsetWidth/100)+"px";
if(t.height&&isString(t.height)&&t.height.indexOf("%")>=0)t.height=parseInt(parseInt(t.height)*this.parent.offsetHeight/100)+"px";
}
}
}
}
if(a[2].isDialogLayer)this.isDialogLayer=true;
this.tag=a[1];
this.id=a[2].id;
if(_d._dEs[this.id]){
this.el=_d._dEs[this.id].el;
this.ifLayer=_d._dEs[this.id].ifLayer;
this.css=_d._dEs[this.id].css;
this.parent=_d._dEs[this.id].parent;
}else this.__createNode(a[2]);
};
_d._dEs[this.id]=this;
if(this.tag)this.tag=this.tag.toLowerCase();
try{
if(this.el&&this.css){
if(this.getAbsolute()&&!this.css.zIndex)this.css.zIndex=zOrder++;
if((this.__aWidth||this.__aHeight||this.__center)&&!this.isDialogLayer){
this.__resizeMe=new Function('return;');
attachEvent(_w,"resize",this.__resizeMe);
if(this.__center)attachEvent(_w,"scroll",this.__resizeMe);
}
this.el.setAttribute("pID__",this.id);
this.el.getParent=__getParent;
if(this.__center)this.moveCenter();
}
}catch(e){
alert(e.message + " : " + e.lineNumber);
};
};
var p=DynInteface.prototype;
////////////////////////////////////////////////////////////////////////////////////////////////////////
// destroy method: 
//To remove this object from memory, before set this object to null,
//use this method to remove all html element in this
////////////////////////////////////////////////////////////////////////////////////////////////////////
p.destroy=function(removeEvents){this._destroy(removeEvents);}
p._destroy=function(removeEvents){
if(this.unloaded)return;
// Un register the element from application element manager
if(_d._dEs[this.id]){_d._dEs[this.id]=null;delete _d._dEs[this.id];}
// Clear the timer
if(this.__shw_tmr)clearTimeout(this.__shw_tmr);
// Dettach event if raised
if(this.__resizeMe)detachEvent(_w,"resize",this.__resizeMe);
// Remove element
if(this.el){
if(this.css){this.css=null;delete this.css;}
if(this.parent){this.parent=null;delete this.parent;}
if(is.ie){
if(removeEvents)__removeEvents(this.el);
this.el.removeNode(true);
}else this.el.parentNode.removeChild(this.el);
this.el=null;delete this.el;
}
// remove/destroy all children
for(var i in this){
if(this[i]&&this[i].destroy)this[i].destroy();
this[i]=null;
}
this.unloaded=true;
}
////////////////////////////////////////////////////////////////////////////////////////////////////////
// isCompleted method: Check ready status (all resources have to preload from the server!)
////////////////////////////////////////////////////////////////////////////////////////////////////////
p.isCompleted=function(){
if(this.__ready)return true;
var i,a=this.el.getElementsByTagName("img");
if(a&&a.length)for(i=0;i<a.length;i++)if(!a[i].complete)return false;
this.__ready=true;
return true;
}
////////////////////////////////////////////////////////////////////////////////////////////////////////
// __createNode method
////////////////////////////////////////////////////////////////////////////////////////////////////////
p.__createNode=function(ref){
var i,j,el;
this.el=(this.id?(this._od?this._od:_d).gid_(this.id):null);
if(!this.el){
this.el=(this._od?this._od:_d).createElement(this.tag);
}
if(!this.el){
(this._od?this._od:_d).write('<'+tag+' id="'+this.id+'">&nbsp;</'+tag+'>');
this.el=(this._od?this._od:_d).gid_(this.id);
if(this.el)this.el.innerHTML='';
}
if(!this.el)return;
if(ref.style&&ref.style.position=="absolute"){
if(!ref.style.visibility)ref.style.visibility="hidden";
}else if(ref.style&&!ref.style.display)ref.style.display="none";
for(i in ref){
if(ref[i]!=null){
switch(i){
case "style":
for(j in ref.style)if(ref.style[j]!=null) {
try{
this.el.style[j]=ref.style[j];
}catch(e){
alert(e.message);
}
}
break;
case "events":
for(j in ref.events)this.el["on"+j]=new Function(ref.events[j]);
case "alpha":
if(isString(ref[i])&&!ref[i].length)ref[i]=100;
if(is.ie)this.el.style.filter='alpha(opacity='+ref[i]+')shadow()';
else this.el.style.MozOpacity=parseInt(ref[i])/100;
break;
case "className":
this.el[_CLS_]=ref[i];
break;
case "innerHTML":
this.el.innerHTML=ref[i];
break;
default:
this.el.setAttribute(i,ref[i]);
}
}
}
this.parent.appendChild(this.el);
this.css=this.el.style;
}
////////////////////////////////////////////////////////////////////////////////////////////////////////
// swap method: swap this element with other element
////////////////////////////////////////////////////////////////////////////////////////////////////////
p.swapNode=function(node){
if(node){
if(isString(node))node=(this._od?this._od:_d).gid_(node);
if(!node)return;
if(node.tagName)node=new DynInteface(node);
if(!node||!node.el)return;
swapHTMLNode(this.el,node.el);
}
}
p.moveTo=function(left,top,force){
//alert("call me: " + left + " : " + top);
this._moveTo(left,top,force);
}
////////////////////////////////////////////////////////////////////////////////////////////////////////
// moveTo method: Move the element to new position (for absolute position style)
////////////////////////////////////////////////////////////////////////////////////////////////////////
p._moveTo=function(left,top,force){
//alert(top);
if(left!=null&&((this.el.offsetLeft!=left&&left>=0)||force))this.el.style.left=left+"px";
if(top!=null&&((this.el.offsetTop!=top&&top>=0)||force))this.el.style.top=top+"px";
if(this.ifLayer)this.ifLayer._moveTo(left,top);
if(this._lys)this._lys._moveTo(left!=null?left+this._sw:null,top!=null?top+this._sw:null);
}
////////////////////////////////////////////////////////////////////////////////////////////////////////
// moveBy method: Move the element to new position (for absolute position style)
//(dLeft,dTop,force)
////////////////////////////////////////////////////////////////////////////////////////////////////////
p.moveBy=function(dl,dt,f){
var cl=parseInt(this.el.style.left),ct=parseInt(this.el.style.top);
if(cl<=0)cl=this.el.offsetLeft;
if(ct<0)ct=this.el.offsetTop;
this._moveTo(cl+dl,ct+dt,f);
}
////////////////////////////////////////////////////////////////////////////////////////////////////////
// moveCenter method : Move the element center the parent object
////////////////////////////////////////////////////////////////////////////////////////////////////////
p.moveCenter=function(){
alert("call move center");
return true;
}
////////////////////////////////////////////////////////////////////////////////////////////////////////
// setSize method: Set the element size
////////////////////////////////////////////////////////////////////////////////////////////////////////
p.setSize=function(width,height){this._setSize(width,height);}
////////////////////////////////////////////////////////////////////////////////////////////////////////
// setSize method: Set the element size
////////////////////////////////////////////////////////////////////////////////////////////////////////
p._setSize=function(width,height){
if(width!=null&&parseInt(width)>0)this.css.width=width+"px";
if(height!=null&&parseInt(height)>0)this.css.height=height+"px";
if(this.ifLayer)this.ifLayer._setSize(width,height);
if(this._lys)if(this._lys)this._lys._setSize(width,height);
if(this.onresize)this.onresize();
}
////////////////////////////////////////////////////////////////////////////////////////////////////////
// getWidth method: Get the width of the element
////////////////////////////////////////////////////////////////////////////////////////////////////////
p.getWidth=function(){
var f,w=(this.el.clientWidth?this.el.clientWidth:this.el.offsetWidth);
if(is.ns){
f=this.el.firstChild;
if(f&&f.tagName.toLowerCase()=='table'&&f.offsetWidth>w)w=f.offsetWidth;
}
return w;
}
////////////////////////////////////////////////////////////////////////////////////////////////////////
// getHeight method: Get the height of the element
////////////////////////////////////////////////////////////////////////////////////////////////////////
p.getHeight=function(){
var f,h=(this.el.clientHeight?this.el.clientHeight:this.el.offsetHeight);
if(is.ns){
f=this.el.firstChild;
if(f&&f.tagName.toLowerCase()=='table'&&f.offsetHeight>h)h=f.offsetHeight;
}
return h;
}
////////////////////////////////////////////////////////////////////////////////////////////////////////
// getClientLeft method: Get the client left of the element
////////////////////////////////////////////////////////////////////////////////////////////////////////
p.getClientLeft=function(){
var l=this.el.offsetLeft,p=this.parent;
while(p&&(p.offsetLeft!=null)){
if(p.tagName.toLowerCase()!="tr")l+=p.offsetLeft;
p=p.parentNode;
}
return l;
}
////////////////////////////////////////////////////////////////////////////////////////////////////////
// getClientTop method: Get the client top of the element
////////////////////////////////////////////////////////////////////////////////////////////////////////
p.getClientTop=function(){
var t=this.el.offsetTop,p=this.parent;
while(p&&(p.offsetTop!=null)){
if(p.tagName.toLowerCase()!="tr")t+=p.offsetTop;
p=p.parentNode;
}
return t;
}
////////////////////////////////////////////////////////////////////////////////////////////////////////
// show method, display the element
////////////////////////////////////////////////////////////////////////////////////////////////////////
p.show=function(){
if(this.unloaded)return;
/*if(!_DII_&&!this.isCompleted()){
if(this.__shw_tmr){clearTimeout(this.__shw_tmr);this.__shw_tmr=null;}
this.__shw_tmr=setTimeout('if(_d._dEs["'+this.id+'"])_d._dEs["'+this.id+'"].show()',100);
return;
}*/
if(this.__shw_tmr){clearTimeout(this.__shw_tmr);this.__shw_tmr=null;}
this._show();
}
////////////////////////////////////////////////////////////////////////////////////////////////////////
// show method, display the element
////////////////////////////////////////////////////////////////////////////////////////////////////////
p._show=function(){ 
//alert("_show");
if(!this.el)return;
if(this.__center)this.moveCenter();
if(this.ifLayer){
//alert("move here");
this.ifLayer.moveTo(this.el.offsetLeft,this.el.offsetTop);
this.ifLayer.show();
}
if(this._lys){
//alert("move here again");
this._lys.moveTo(this.el.offsetLeft+this._sw,this.el.offsetTop+this._sw);
this._lys.show();
}
if(this.css){
if(this.getAbsolute()){
if(this.css.visibility!="visible")this.css.visibility="visible";
}else{
if(is.ns){
switch(this.tag){
case 'table':
this.css.display='table';
break;
case 'td':
this.css.display='table-cell';
break;
case 'tr':
this.css.display='table-row';
break;
default:
if(this.css.display!="block")this.css.display="block";
}
}else if(this.css.display!="block")this.css.display="block";
}
}
if(this.onshow)this.onshow();
}
////////////////////////////////////////////////////////////////////////////////////////////////////////
// hide method, hide the element
////////////////////////////////////////////////////////////////////////////////////////////////////////
p.hide=function(){this._hide();}
////////////////////////////////////////////////////////////////////////////////////////////////////////
// hide method, hide the element
////////////////////////////////////////////////////////////////////////////////////////////////////////
p._hide=function(){
if(this.unloaded)return;
if(this.__shw_tmr)clearTimeout(this.__shw_tmr);
try{
if(this.getAbsolute())this.css.visibility="hidden";
else this.css.display="none";
}catch(e){
//alert(e.message);
};
if(this.ifLayer)this.ifLayer.hide();
if(this._lys)this._lys.hide();
if(this.onhide)this.onhide();
}
////////////////////////////////////////////////////////////////////////////////////////////////////////
// hide method, hide the element
////////////////////////////////////////////////////////////////////////////////////////////////////////
p.getVisible=function(){
return (this.css.display!='none'&&this.css.visibility!='hidden');
}
////////////////////////////////////////////////////////////////////////////////////////////////////////
// check absolute
// CHANGED: 08.14.2006: This function causes error: Permission denied in IE
////////////////////////////////////////////////////////////////////////////////////////////////////////
p.getAbsolute=function(){
try{
return (this.css.position&&this.css.position.toLowerCase()=="absolute");
}catch(e){
//alert(e.message);
};
return false;
}
////////////////////////////////////////////////////////////////////////////////////////////////////////
// setAlpha method: Set alpha for layer (used only for IE,NS compatible browser)
//(value, applyTo)
////////////////////////////////////////////////////////////////////////////////////////////////////////
p.setAlpha=function(v,a){
var e=a?(isString(a)?(this._od?this._od:_d).gid_(a):a):this.el;
if(isString(v)&&!v.length)v=100;
if(is.ie)e.style.filter="alpha(opacity="+v+")";
else if(is.ns)e.style.MozOpacity=parseInt(v)/100;
}
////////////////////////////////////////////////////////////////////////////////////////////////////////
// setHTML method: Set the content of the element
////////////////////////////////////////////////////////////////////////////////////////////////////////
p.setHTML=function(h){this._setHTML(h);}
////////////////////////////////////////////////////////////////////////////////////////////////////////
// _setHTML method: Set the content of the element
////////////////////////////////////////////////////////////////////////////////////////////////////////
p._setHTML=function(h){
try{
this.el.innerHTML=h;
}catch(e){}
}
////////////////////////////////////////////////////////////////////////////////////////////////////////
// setClass method: Change the class of the element
////////////////////////////////////////////////////////////////////////////////////////////////////////
p.setClass=function(cls){
this.el[_CLS_]=cls;
}
////////////////////////////////////////////////////////////////////////////////////////////////////////
// getClipValues method : Get the clip value
////////////////////////////////////////////////////////////////////////////////////////////////////////
p.getClipValues=function(){
  if(this.css.clip!=null&&this.css.clip.length>0){
    var i,v=this.css.clip.slice(5,-1).split(' ');
for(i=0;i<4;i++)v[i]=parseInt(v[i]);
    return v;
  }else return false;
}
////////////////////////////////////////////////////////////////////////////////////////////////////////
// clipBy method : Set the clip range
////////////////////////////////////////////////////////////////////////////////////////////////////////
p.clipBy=function(t,r,b,l){
var v=this.getClipValues();
if(!v)return;
    this.css.clip="rect("+Number(v[0]+t)+"px, "+Number(v[1]+r)+"px, "+Number(v[2]+b)+"px, "+Number(v[3]+l)+"px)";
if(this.ifLayer)this.ifLayer.clipBy(t,r,b,l);
}
////////////////////////////////////////////////////////////////////////////////////////////////////////
// clipTo method : Set the clip range
////////////////////////////////////////////////////////////////////////////////////////////////////////
p.clipTo=function(t,r,b,l){
this.css.clip="rect("+t+"px, "+r+"px, "+b+"px, "+l+"px)";
if(this.ifLayer)this.ifLayer.clipTo(t,r,b,l);
}
////////////////////////////////////////////////////////////////////////////////////////////////////////
// createIFrame method : create the iframe layer (for IE from 5.5)over all form fields and special object
////////////////////////////////////////////////////////////////////////////////////////////////////////
p.createIfLayer=function(){
if(this.getAbsolute()&&this.tag!="iframe"&&is.ie&&is.iev>5&&!this.ifLayer){
var mi=false;//mustIframe
try{
mi=_w.frames.length||(this._od?this._od:_d).getElementsByTagName("iframe").length;
if(!mi)mi=(this._od?this._od:_d).getElementsByTagName("textarea").length;
if(!mi)mi=(this._od?this._od:_d).getElementsByTagName("select").length;
if(!mi)mi=(this._od?this._od:_d).getElementsByTagName("object").length;
if(!mi)mi=(this._od?this._od:_d).getElementsByTagName("applet").length;
}catch(e){
//alert(e.message + " : " + e.lineNumber);
}
if(mi){
this.ifLayer=new DynInteface(this.parent,"iframe",
{id:this.id+"_ily",
frameBorder:'0',
scrolling:'no',
alpha:1,
style:{position:'absolute',
left:this.el.offsetLeft,
top:this.el.offsetTop,
width:this.getWidth(),
height:this.getHeight(),
visibility:this.css.visibility,
zIndex:this.css.zIndex?this.css.zIndex-1:0}});
}
}
}
////////////////////////////////////////////////////////////////////////////////////////////////////////
// setZIndex method : Set the order level
////////////////////////////////////////////////////////////////////////////////////////////////////////
p.setZIndex=function(z){
if(this.getAbsolute()){
var o=false;
if(!z){z=zOrder+1;o=true;}
if(this.ifLayer)this.ifLayer.css.zIndex=z++;
if(this._lys)this._lys.css.zIndex=z++;
this.css.zIndex=z++;
if(o)zOrder=z;
return z;
}
}
////////////////////////////////////////////////////////////////////////////////////////////////////////
// bringToTop method : move the layer to top most
//(notIframe)
////////////////////////////////////////////////////////////////////////////////////////////////////////
p.bringToTop=function(ni){
if(this.getAbsolute()&&!ni)this.createIfLayer();
this.setZIndex();
}
////////////////////////////////////////////////////////////////////////////////////////////////////////
// setSelectable method : Disable/Enable selectable/dragable by user
//(selectable,applyTo)
////////////////////////////////////////////////////////////////////////////////////////////////////////
p.setSelectable=function(s,a){
try{
var el=a?a:this.el;
if(s){
el.style.cursor='';
if(is.ie)el.onselectstart=el.ondragstart=null;
else el.onmousedown=null;
}else{
el.style.cursor="default";
if(is.ie)el.onselectstart=el.ondragstart=__unSelectable;
else el.onmousedown=__unSelectable;
}
}catch(e){};
}
////////////////////////////////////////////////////////////////////////////////////////////////////////
// attachEvent method: To attach an event handle to this element
//INPUT:
//eventName: The event name
//eventHandle: The event handle function
////////////////////////////////////////////////////////////////////////////////////////////////////////
p.attachEvent=function(evt,hdl){
attachEvent(this.el,evt,hdl);
};
////////////////////////////////////////////////////////////////////////////////////////////////////////
// detachEvent method: To detach an event handle to this element
//INPUT:
//eventName: The event name
//eventHandle: The event handle function
////////////////////////////////////////////////////////////////////////////////////////////////////////
p.detachEvent=function(evt,hdl){
detachEvent(this.el,evt,hdl);
};
/**
 * Project: SKLV
 * By: pKt
 */
var AUTO_HIDE=false;
function PopupCom(uiID,id,parent,ref,ow){
var r=null;
if((PopupCom.arguments.length!=1)||(typeof PopupCom.arguments[0]!="object"))r={uiID:uiID,id:id,parent:parent,ref:ref,ow:ow};
else r=PopupCom.arguments[0];
this.ref=r.ref;
if(this.ref&&!this.ref.length)this.ref=[this.ref];
if(r.ow)this._ow=r.ow;
else this._ow=_w;
this._od=this._ow.document;
this.DynInteface=DynInteface;
this.DynInteface(r.parent,"div",{id:r.id,style:{position:"absolute",left:"0px",top:"0px"}});
    this.el.className='pktPopupMenu';
this.type="PopupCom";
this.__create();
this.setSelectable(false);
try{
this.el.oncontextmenu=__emptyFunc;
}catch(e){};
attachEvent(this._ow,'unload',new Function('try{_d._dEs["'+this.id+'"].destroy();}catch(e){}'));
};
var p=PopupCom.prototype=new DynInteface;
/////////////////////////////////////////////////////////////////////////////////////////////
//  Layer event handle
/////////////////////////////////////////////////////////////////////////////////////////////
p.__layerHandlEvent=function(e){
var p=this.getParent();
if(p){
if(is.ie)e=p._ow.event;
if(p.tmr){clearInterval(p.tmr);p.tmr=null;delete p.tmr;}
//if(e.type=='mouseout')p.tmr=setInterval('if(!_d._dEs["'+p.id+'"].isChildVisible())_d._dEs["'+p.id+'"].hide();',500);
    if(e.type=='mouseout')p.tmr=setInterval('try{if(_d._dEs["'+p.id+'"]&&!_d._dEs["'+p.id+'"].isChildVisible())_d._dEs["'+p.id+'"].hide();}catch(e){}',HIDE_DELAY);
}
return false;
}
/////////////////////////////////////////////////////////////////////////////////////////////
//  Layer event handle
/////////////////////////////////////////////////////////////////////////////////////////////
p.__itemHandlEvent=function(e){
var p=_d._dEs[this.parentID],i,img,smn,cmd,td;
if(!p)return;
if(is.ie)e=p._ow.event;
if(p.ref[this.index].caption=='-'||p.ref[this.index].status=='disabled')return;
switch(e.type){
case 'mouseover':
p.setHover(this);
try{
    if(this.getAttribute("subMenuID")&&!_d._dEs['__sub__'+this.getAttribute("subMenuID")].getVisible()){
    if(p.tmCheck){clearTimeout(p.tmCheck);p.tmCheck=null;}
        p.tmCheck=setTimeout('try{_d._dEs["__sub__'+this.getAttribute("subMenuID")+'"].moveTo('+(p.getClientLeft()+this.offsetWidth-4)+','+(p.getClientTop()+ this.offsetTop+4)+');_d._dEs["__sub__'+this.getAttribute("subMenuID")+'"].show(true);}catch(e){};',200);
    }
}catch(e){}
break;
case 'click':
//hideTip();
// Raise onclick event
if(p.onclick&&!p.onclick(p.ref[this.index]))break;
if(this.getAttribute("subMenuID")){
//Call sub menu
smn=_d._dEs['__sub__'+this.getAttribute("subMenuID")];
if(p.tmCheck){clearTimeout(p.tmCheck);p.tmCheck=null;}
if(!smn||smn.getVisible()||smn.__shw_tmr)return false;
smn.moveTo(p.getClientLeft()+p.offsetWidth-4,p.getClientTop()+this.offsetTop+4);
smn.show(true);
}else{
// Checking radio or check group
if(p.ref[this.index].group){
// Option/Radio group
// Clear current
for(i=0;i<p.ref.length;i++){
if(p.ref[i].group==p.ref[this.index].group&&p.ref[i].checked){
p.ref[i].checked=false;
    break;
}
}

// Set new current
p.ref[this.index].checked=true;
}else if(p.ref[this.index].checked!=null){
// Check item
p.ref[this.index].checked=!p.ref[this.index].checked;
}
//Active this item
cmd=p.ref[this.index].link;
if(!p.unloaded){
p.hide();
while(p.parentMenuID){
try{
    _d._dEs[p.parentMenuID].hide();
    p=_d._dEs[p.parentMenuID];
}catch(e){};
}
}
//Run the current value
if(cmd){
    _w.location.href=cmd; 
}
}
}
return false;
}
/////////////////////////////////////////////////////////////////////////////////////////////
// 
/////////////////////////////////////////////////////////////////////////////////////////////
p.__create=function(){
var i,j,h='',d,cls,c,elm,smn;
h='<div><ul>';
// Checking for blank icon
for(i=0;i<this.ref.length;i++){
if(!this.ref[i])continue;
if((this.ref[i].group&&this.ref[i].group.length)||typeof this.ref[i].checked!=_UDF_){
for(j=0;j<this.ref.length;j++)if(!this.ref[j].icon||!this.ref[j].icon.length)this.ref[j].icon=getImage('mnu_ico_unchk');
break;
}
}
// Create items
for(i=0;i<this.ref.length;i++){
if(!this.ref[i])continue;
d=this.ref[i].status=='hidden'?'none':'block';
cls='';
if(i==this.ref.length-1){
    cls='class="last"';
}
/*cls="none";
if(this.ref[i].sub&&this.ref[i].sub.length>0){
    cls="haschild";
}*/
h+='<li class="'+cls+'"><a id="'+this.ref[i].id+'" index="'+i+'" parentID="'+this.id+'" href="#" '+cls+'>'+(this.ref[i].caption?this.ref[i].caption:'')+'</a><div class="';
if(!this.ref[i].sub)this.ref[i].sub=__firstObject(this.ref[i]);
cls="none";
if(this.ref[i].sub&&this.ref[i].sub.length>0){
    cls="none";
}
h+=cls+'"></div></li>';
}
h+='</ul></div>';
this.setHTML(h);
// Create events handle for layer
//try{
this.el.onmouseover=this.el.onmouseout=this.__layerHandlEvent;
// Create events handle for each items
for(i=0;i<this.ref.length;i++){
if(this.ref[i]&&this.ref[i].id){
elm=this._od.gid_(this.ref[i].id);
if(!elm)continue;
elm.parentID=this.id;
elm.index=i;
// Assign handle event
elm.onmouseover=elm.onclick=this.__itemHandlEvent;
// Create sub menu for this item
if(this.ref[i].sub&&this.ref[i].sub.length){
this.ref[i].subMenuID='__sub__'+this.ref[i].id;
elm.setAttribute("subMenuID",this.ref[i].subMenuID);
smn=new PopupCom(null,'__sub__'+this.ref[i].subMenuID,null,this.ref[i].sub,this._ow);
smn.parentMenuID=this.id;
}
}
}
/*}catch(e){
alert(e.message);
};*/
}
/////////////////////////////////////////////////////////////////////////////////////////////
// 
/////////////////////////////////////////////////////////////////////////////////////////////
p.destroy=function(){
var i,smn;
if(this.unloaded)return;
if(this.__autoHide){
detachEvent(this._od,"click",this.__autoHide);
detachEvent(this._od,"keydown",this.__autoHide);
}
for(i=0;i<this.ref.length;i++){
if(this.ref[i]&&this.ref[i].subMenuID){
try{
    smn=_d._dEs['__sub__'+this.ref[i].subMenuID];
    if(smn&&smn.destroy)smn.destroy();
}catch(e){};
}
}
while(parent.parentMenuID){
try{
    _d._dEs[parent.parentMenuID].hide();
    parent=_d._dEs[parent.parentMenuID];
}catch(e){};
}
this._destroy();
}
/////////////////////////////////////////////////////////////////////////////////////////////
// 
/////////////////////////////////////////////////////////////////////////////////////////////
p.show=function(fromParent){
var i,b,ww,wh,nw,nh,ow=0;
if(this.unloaded)return;
/*if(!_DII_&&!this.isCompleted()){
alert("_DII_");
if(this.__shw_tmr){clearTimeout(this.__shw_tmr);this.__shw_tmr=null;}
this.__shw_tmr=setTimeout('if(_d._dEs["'+this.id+'"])_d._dEs["'+this.id+'"].show()',1);
return;
}*/
if(this.__shw_tmr){clearTimeout(this.__shw_tmr);this.__shw_tmr=null;}
if(this.tmr){clearInterval(this.tmr);this.tmr=null;}
if(this.tmCheck){clearTimeout(this.tmCheck);this.tmCheck=null;}
// Hide all popup menu
//if(!AUTO_HIDE)
hideAllPopupMenu(this);
//if(uii.popMenu.SHADOW)this.setShadow(true,uii.popMenu.SHADOW_ALPHA,uii.popMenu.SHADOW_WIDTH);
// Checking active condition
/*
for(i=0;i<this.ref.length;i++){
if(this.ref[i]&&this.ref[i].id&&this.ref[i].activeWhen){
b=eval(this.ref[i].activeWhen);
this.setItemStatus(this.ref[i].id,b?'default':'disabled');
}
}*/
//
this.bringToTop();
this._fromParent=fromParent;
nw=this.el.firstChild.offsetWidth;
nh=this.el.firstChild.offsetHeight;
ww=this._od.body.scrollLeft+getWinWidth(this._od,this._ow);
wh=this._od.body.scrollTop+getWinHeight(this._od,this._ow);
if((this.el.offsetLeft+nw)>ww-ow)this.moveTo(ww-nw-ow);
if((this.el.offsetTop+nh)>wh-ow)this.moveTo(null,wh-nh-ow);
this.setSize(nw,nh);
this._show();
}
/////////////////////////////////////////////////////////////////////////////////////////////
// 
/////////////////////////////////////////////////////////////////////////////////////////////
p.moveTo=function(left,top,force){
var nw=this.el.firstChild.offsetWidth,
nh=this.el.firstChild.offsetHeight,
ww=this._od.body.scrollLeft+getWinWidth(this._od,this._ow),
wh=this._od.body.scrollTop+getWinHeight(this._od,this._ow),
ow=0;
//alert(this._od.body.scrollTop + " : " + getWinHeight(this._od,this._ow));
//ow=uii.popMenu.SHADOW?uii.popMenu.SHADOW_WIDTH:0;
//alert("left: " + left + " " + ((left+nw)>ww-ow ? ww-nw-ow : "0") + ", top: " + top + ", nw: " + nw + ", nh: " + nh + ", ww: " + ww + ", wh:" + wh);
//alert(top);
if((left+nw)>ww-ow)left=ww-nw-ow;
if((top+nh)>wh-ow)top=wh-nh-ow;
//alert("top later: " + top);
this._moveTo(left,top,force);
}
/////////////////////////////////////////////////////////////////////////////////////////////
// 
/////////////////////////////////////////////////////////////////////////////////////////////
p.onshow=function(){
return this._onshow();
}
/////////////////////////////////////////////////////////////////////////////////////////////
// 
/////////////////////////////////////////////////////////////////////////////////////////////
p._onshow=function(){
/*
if(this.ref&&this.ref.length){
for(var i=0;i<this.ref.length;i++){
if(!this.ref[i])continue;
if(this.ref[i].status!='disabled'&&this.ref[i].status!='hidden'){
this.setHover(this.ref[i].id);
break;
}
}
}*/
//if(!this._fromParent&&AUTO_HIDE)this.tmr=setInterval('try{_d._dEs["'+this.id+'"].hide();}catch(e){}',HIDE_DELAY);
//else 
//if(!this._fromParent)
setTimeout('try{_d._dEs["'+this.id+'"].createHideHandle();}catch(e){}',10);
return true;
}
/////////////////////////////////////////////////////////////////////////////////////////////
// 
/////////////////////////////////////////////////////////////////////////////////////////////
p.__checkChildren=function(c){
if(c&&c.tagName){
var i,e=_to._g(this.el,c.tagName);
for(i in e)if(e[i]==c)return true;
return false;
}else return false;
}
/////////////////////////////////////////////////////////////////////////////////////////////
// 
/////////////////////////////////////////////////////////////////////////////////////////////
p.createHideHandle=function(){
if(!this.__autoHide){
this.__autoHide=new Function('e','try{var el=is.ie?_d._dEs["'+this.id+'"]._ow.event.srcElement:e.target,mnu=_d._dEs["'+this.id+'"];if(!mnu.__checkChildren(el))mnu.hide();return true;}catch(e){alert(e.message);}');
attachEvent(this._od,"click",this.__autoHide);
attachEvent(this._od,"keydown",this.__autoHide);
}
}
/////////////////////////////////////////////////////////////////////////////////////////////
// 
/////////////////////////////////////////////////////////////////////////////////////////////
p.popup=function(l,t){
//alert("popme: " + l + " : " + t);
this.moveTo(l,t);
if(!this.getVisible())this.show();
}
/////////////////////////////////////////////////////////////////////////////////////////////
// 
/////////////////////////////////////////////////////////////////////////////////////////////
p.hide=function(){
if(this.unloaded)return;
if(this.__shw_tmr){clearTimeout(this.__shw_tmr);this.__shw_tmr=null;}
if(this.tmr){clearInterval(this.tmr);this.tmr=null;}
if(this.tmCheck){clearTimeout(this.tmCheck);this.tmCheck=null;}
if(this.__autoHide){
detachEvent(this._od,"click",this.__autoHide);
detachEvent(this._od,"keydown",this.__autoHide);
this.__autoHide=null;
}
this._hide();
if(this.hoverItemID)this.__clearHover();
for(var i=0; i < this.ref.length;i++){
    if(this.ref[i]&&this.ref[i].subMenuID) {
        try{
            _d._dEs['__sub__'+this.ref[i].subMenuID].hide();
        }catch(e){};
    }
}
// Checking for menu bar
if(this.__mnParent){
try{
    _d._dEs[this.__mnParent].clearHover();
    _d._dEs[this.__mnParent].__showSub=false;
}catch(e){};
}
}
/////////////////////////////////////////////////////////////////////////////////////////////
// 
/////////////////////////////////////////////////////////////////////////////////////////////
p.isChildVisible=function(){
var i,e,l;
for(i=0;i<this.ref.length;i++){
if(!this.ref[i])continue;
e=this.ref[i].subMenuID;
if(e){
l=_d._dEs['__sub__'+e];
if(e&&l&&l.getVisible())return true;
}
}
return false;
}
/////////////////////////////////////////////////////////////////////////////////////////////
// 
/////////////////////////////////////////////////////////////////////////////////////////////
p.__clearHover=function(){
if(!this.hoverItemID)return;
var e,t;
e=this._od.gid_(this.hoverItemID);
if(!e)return;
if(this.ref[e.index]&&this.ref[e.index].subMenuID){
    try{
        _d._dEs['__sub__'+this.ref[e.index].subMenuID].hide();
    }catch(e){};
}
this.hoverItemID=null;
if(this.tmCheck){clearTimeout(this.tmCheck);this.tmCheck=null;}
}
/////////////////////////////////////////////////////////////////////////////////////////////
// 
/////////////////////////////////////////////////////////////////////////////////////////////
p.setHover=function(id){
var e,i,f;
if(!id)return;
if(this.hoverItemID){
if(this.hoverItemID==(id.id?id.id:id))return;
else this.__clearHover();
}
e=!id.id?this._od.gid_(id):id;
if(!e)return;
/*
f=(this.ref[e.index].sub&&this.ref[e.index].sub.length)?'d':'o';
e[_CLS_]=_to._g(e,'td')[1][_CLS_]='pmi pmi_'+f;
i=_to._g(e,'img');
if(i&&i.length==2)i[1].setAttribute('src',getImage('mnu_arw_'+f));
*/
this.hoverItemID=e.id;
}
/////////////////////////////////////////////////////////////////////////////////////////////
// 
/////////////////////////////////////////////////////////////////////////////////////////////
p.setItemStatus=function(id,st){
var c,s,e=(typeof id=='string'?this._od.gid_(id):id);
if(!e)return;
if(this.ref[e.index].status==st)return;
c=(st=='disabled'?'default':'pointer');
s=(st=='disabled'?'x':'n');
e[_CLS_]=_to._g(e,'td')[1][_CLS_]='pmi pmi_'+s;
e.style.cursor=c;
e.style.display=(st=='hidden'?'none':'block');
this.ref[e.index].status=st;
}
/////////////////////////////////////////////////////////////////////////////////////////////
// 
/////////////////////////////////////////////////////////////////////////////////////////////
p.setItemCaption=function(id,caption,desc){
var e=(typeof id=='string'?this._od.gid_(id):id);
if(!e)return;
if(this.ref[e.index].caption==caption)return;
this.ref[e.index].caption=caption;
_to._g(e,'td')[1].innerHTML='&nbsp;'+caption;
if(desc)_to._g(e,'td')[1].setAttribute("tipText",desc);
}
////////////////////////////////////////////////////////////////////////////////////////////////////////
// Close all popup menu
////////////////////////////////////////////////////////////////////////////////////////////////////////
function hideAllPopupMenu(e){
    try{
    var i,m;
    for(i in _d._dEs){
    m=_d._dEs[i];
    if(m&&m.type=='PopupCom'&&(!e||!e.parentMenuID))m.hide();
    }
}catch(e){};
try{
    _w.aP.hide();
    _w.aP=null;delete _w.aP;
}catch(e){};
};
// JScript File
/**
 * AJAX Prototype Class
 * Created: 11.11.2006
 * Project: KT4Rum, Lin's version
 * By: Pham Ky Thanh
 */
var userAgent = navigator.userAgent.toLowerCase();
var is_opera  = ((userAgent.indexOf('opera') != -1) || (typeof(window.opera) != 'undefined'));
var is_saf    = ((userAgent.indexOf('applewebkit') != -1) || (navigator.vendor == 'Apple Computer, Inc.'));
var is_webtv  = (userAgent.indexOf('webtv') != -1);
var is_ie     = ((userAgent.indexOf('msie') != -1) && (!is_opera) && (!is_saf) && (!is_webtv));
var is_ie4    = ((is_ie) && (userAgent.indexOf('msie 4.') != -1));
var is_moz    = ((navigator.product == 'Gecko') && (!is_saf));
var is_kon    = (userAgent.indexOf('konqueror') != -1);
var is_ns     = ((userAgent.indexOf('compatible') == -1) && (userAgent.indexOf('mozilla') != -1) && (!is_opera) && (!is_webtv) && (!is_saf));
var is_ns4    = ((is_ns) && (parseInt(navigator.appVersion) == 4));
var is_mac    = (userAgent.indexOf('mac') != -1);

function KT4RUM_AJAX(async){
this.async = async ? true : false;
};
KT4RUM_AJAX.prototype.init = function(){
try{
this.handler = new XMLHttpRequest();
return (this.handler.setRequestHeader ? true : false);
}
catch(e){
try{
this.handler = eval("new A" + "ctiv" + "eX" + "Ob" + "ject('Micr" + "osoft.XM" + "LHTTP');");
return true;
}
catch(e){
return false;
}
}
};

/**
* Detects if the browser is fully compatible
*
* @returnboolean
*/
KT4RUM_AJAX.prototype.is_compatible = function(){
if (is_ie && !is_ie4) { return true; }
else if (typeof XMLHttpRequest != 'undefined'){
try{ 
    return XMLHttpRequest.prototype.setRequestHeader ? true : false; 
}catch(e){
try { 
    var tester = new XMLHttpRequest(); return tester.setRequestHeader ? true : false; 
    }catch(e) { 
        return false; 
    }
}
}else{ 
    return false; 
}
};

/**
* Checks if the system is ready
*
* @returnbooleanFalse if ready
*/
KT4RUM_AJAX.prototype.not_ready = function(){
return (this.handler.readyState && (this.handler.readyState < 4));
};

/**
* OnReadyStateChange event handler
*
* @paramfunction
*/
KT4RUM_AJAX.prototype.onreadystatechange = function(event){
if (!this.handler){
if(!this.init()){
return false;
}
}
if (typeof event == 'function'){
this.handler.onreadystatechange = event;
}else{
alert('XML Sender OnReadyState event is not a function');
}
};

/**
* Sends data
*
* @paramstringDestination URL
* @paramstringRequest Data
*
* @returnmixedReturn message
*/
KT4RUM_AJAX.prototype.send = function(desturl, datastream){
if (!this.handler){
if (!this.init()){
return false;
}
}
if (!this.not_ready()){
this.handler.open('GET', desturl, this.async);
this.handler.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
this.handler.send(datastream);
if (!this.async && this.handler.readyState == 4 && this.handler.status == 200){
return true;
}
}
return false;
}
// JScript File
var HIDE_DELAY=2000;
var ajax;
function InstanceSearch(){
this.type='InstanceSearch';
this.DynInteface=DynInteface;
this.id='__InstanceSearch';
this.DynInteface(null,"div",{id:this.id,
className:"as_container",
style:{position:"absolute",left:0,top:0,overflow:"visible"}});
// Flag indicate that the searching or not
this.searching=false;
};
var p=InstanceSearch.prototype=new DynInteface;
p.detachObj=function(obj,w){
if(typeof obj=='string')obj=document.getElementById(obj);
obj.setAttribute("autocomplete","off");
obj.onkeyup=obj.onkeydown=obj.onblur=function(){return;};
};
/**
 * Ham nay dung de attach keywork text field cho Advance Search components.
 */
p.attachObj=function(obj,w){
if(typeof obj=='string')obj=document.getElementById(obj);
if(w)window.w=w;
obj.setAttribute("pID",this.id);
obj.setAttribute("autocomplete","off");
obj.onkeyup=obj.onkeydown=obj.onblur=this._keydownHandle;
/*if(obj.form){
if(typeof _w.top.advSearchSubmitF!=_UDF_&&_w.top.advSearchSubmitF){
obj.form.onsubmit=_w.top.advSearchSubmitF;
}else{
} 
}*/
};
/**
 * This function handle keydown event for textbox search
 */
p._keydownHandle=function(e){
var m=_d._dEs[this.getAttribute("pID")],lis,i,prev,next;
if(is.ie)e=window.w.event;
if(!m||!e)return;
switch(e.type){
case 'blur':
window.top.times=window.setTimeout("window.insSearch.doHideAdvSearch();",HIDE_DELAY);
if(!is.ie){
//e.preventDefault();
e.stopPropagation();
}
break;
case 'keydown':
var keyCode=e.keyCode;
switch(keyCode){
case 40:case 38://down key
if(!is.ie){
e.preventDefault();
e.stopPropagation();
}
}
break;
case 'keyup':
var keyCode=e.keyCode;
switch(keyCode){
case 40://down key
if(isEmptyString(this.value))m.doHideAdvSearch();
else{
if((typeof m.searching==_UDF_ || !m.searching) && (typeof m.hasShow==_UDF_ || !m.hasShow)){
m.doSearch(this);
}else{
lis=m.el.getElementsByTagName("li");
if(lis && lis.length){
//Tìm vị trí Li dang focus.
for(i=0;i<lis.length&&lis[i].className=='';i++);
//IF lis[i].previousSibling -->di chuyển focus cho Li trên.
if(next=lis[i].nextSibling){
for(i=0;i<lis.length;lis[i].className='',i++);
next.className='as-highlight';
window.top.aslink=next.getAttribute("link");
}
}
}
}
if(!is.ie){
e.preventDefault();
e.stopPropagation();
}
break;
case 38://up key
if(typeof m.searching!=_UDF_ && m.hasShow){
lis=m.el.getElementsByTagName("li");
if(lis && lis.length){
//Tìm vị trí Li dang focus.
for(i=0;i<lis.length&&lis[i].className=='';i++);
//IF lis[i].previousSibling -->di chuyển focus cho Li trên.
if(prev=lis[i].previousSibling){
for(i=0;i<lis.length;lis[i].className='',i++);
prev.className='as-highlight';
window.top.aslink=prev.getAttribute("link");
}else{
// hide advSearch.
m.doHideAdvSearch();
}
}
}
if(!is.ie){
e.preventDefault();
e.stopPropagation();
}
break;
case 37:case 39://left key, right key
if(isEmptyString(this.value))m.doHideAdvSearch();
else {
if((typeof m.searching==_UDF_ || !m.searching)&&(typeof m.hasShow==_UDF_ || !m.hasShow)){
m.doSearch(this);
}
}
break;
case 13:// Enter key.
    //alert(window.top.aslink);
    if(window.top.aslink){
        m.run(window.top.aslink);
    }
break;
case 27:case 9://Escapse, Tab key.
m.doHideAdvSearch();
break;
default:
if(isEmptyString(this.value))m.doHideAdvSearch();
else {
if(typeof m.searching==_UDF_ || !m.searching){
m.doSearch(this);
}
}
// neu nhan phim bat ki thi
return true;
}
break;
}
return true;
}
p.run=function(link){
    //alert(link);
    if(link&&link.length){
        window.location=link;
    }
}
/* Ham nay dung de show result search duoc cho phan tim kiem cua Business.
 * */
p.doSearch=function(obj){
    if(this.searching)return;
    //var data=[{title:"Testing 1",url:"http://google.com"},{title:"Testing 2",url:"http://google.com"},null];
    this.searching=false;
    this.obj=obj;
    var url=HOST_URL+'/getInstanceResult.aspx?q='+(obj.value||"");
    ajax=new KT4RUM_AJAX(true);
ajax.onreadystatechange(window.insSearch._create);
    ajax.send(url,null);
};
p._create=function(obj,data){
if(!obj||!data){
    //get object from dEs
    obj=window.insSearch.obj;
    if (ajax.handler.readyState == 4 && ajax.handler.status == 200){
    if (ajax.handler.responseXML) {
        var xmldoc = ajax.handler.responseXML;
        var root=xmldoc.documentElement;
            if(root&&root.childNodes.length>0){
                var html=new Array(),i,item,cls='';
                html[html.length]='<div class="as_container">';
                html[html.length]='<div class="as-content">';
                html[html.length]='<ul>';
                var item = root.firstChild;
                var i=0;
                while(item){
                    var cls=(i==0?"as-highlight":"");
            if(item){
            if(i==0)window.top.aslink=item.url;
            var title=item.firstChild;
            var url=item.firstChild.nextSibling;
            html[html.length]='<li pID="'+window.insSearch.id+'" class="'+cls+'" link="'+url.firstChild.nodeValue+'">'+title.firstChild.nodeValue+'</li>';
            }
            item=item.nextSibling;
            i++;
                }
                    html[html.length]='</ul>';
                    html[html.length]='</div>';
                    html[html.length]='<div class="as-shadow"></div>';
                    html[html.length]='</div>';
                    window.insSearch.setHTML(html.join(''));
                    window.insSearch.bringToTop();
                    window.insSearch.doPos(obj);
                    window.insSearch.setHandleAction();
                    window.insSearch.show();
                    window.insSearch.hasShow=true;
                    window.insSearch.searching=false;
            }
    }
    }
}
};
/* Ham nay dung de dieu chinh lai vi tri cua search tooltip va vi tri cua shadow.
 * Dong thoi chinh lai width va heigh cua popup luon.
 * */
p.doPos=function(so){
if(typeof so=='string')so=document.getElementById(so);
//1. move object to right below the text area
var tmp=getClientPos(so),objLeft,objTop,ul;
objLeft=tmp.left;
objTop=((tmp.top > so.offsetTop) && (!fromSearch) ? so.offsetTop + 50 : tmp.top)+(is.ie?so.clientHeight+4:(so.clientHeight+4));
//move it :)
this.moveTo(objLeft,objTop,true);
//2. then we need to resize the width and height 
var asW=so.clientWidth;//advance search width
//2.1 Change the width for Content div
this.el.firstChild.firstChild.style.width=asW+'px';
//2.2 Change the width for shadow div
this.el.firstChild.firstChild.nextSibling.style.width=asW+'px';
//2.3 Change the left and top for shadow.
this.el.firstChild.firstChild.nextSibling.style.left=(is.ie?1:2)+'px';
this.el.firstChild.firstChild.nextSibling.style.top=(is.ie?1:2)+'px';
//2.4 set height
if(ul=this.el.firstChild.firstChild.getElementsByTagName("ul")[0]){
this.el.firstChild.firstChild.style.height=ul.offsetHeight+'px';
this.el.firstChild.firstChild.nextSibling.style.height=ul.offsetHeight+'px';
}
};
p.setHandleAction=function(){
var lis;
if(this.el){
lis=this.el.getElementsByTagName('li');
if(lis && lis.length){
for(var i=0;i<lis.length;i++){
if(lis[i])lis[i].onmouseover=lis[i].onclick=this._handleAction;
}
}
}
}
p._handleAction=function(e){
var m=_d._dEs[this.getAttribute("pID")];
if(is.ie)e=window.event;
var ul,lis,i,link;
switch (e.type) {
case 'mouseover':
if(ul=this.parentNode){
lis=ul.getElementsByTagName("li");
if(lis && lis.length)for(i=0;i<lis.length;lis[i].className="",i++);
}
this.className='as-highlight';
break;
case 'click':
link=this.getAttribute("link");
//var textSearch=this.innerHTML||"";
//link=link + "&criteria="+textSearch;
window.clearTimeout(window.top.times);
m.doHideAdvSearch();
m.run(link);
//alert(link);
//if(setURL)setURL(link);
break;
};
}
p.doHideAdvSearch=function(){
window.top.aslink=null;
this.hasShow=false;
this.searching=false;
this.hide();
};
/*
Project: SKLV
By: pKt
*/
var menuitems=[{id:"id1",caption:"News",link:"#",status:"hot",item:[{id:"id11",caption:"What's New",link:"http://www.linengineering.com/line/whatnew.aspx"},{id:"id12",caption:"Press Releases",link:"http://www.linengineering.com/line/contents/stepmotors/PR_2010.aspx"},{id:"id13",caption:"Newsletters",link:"http://www.linengineering.com/line/contents/stepmotors/Newsletter.aspx"},{id:"id14",caption:"Events",link:"http://www.linengineering.com/line/contents/stepmotors/events.aspx"},{id:"id15",caption:"In the Media",link:"http://www.linengineering.com/line/contents/stepmotors/media.aspx"}]},{id:"id2",caption:"Contact Us",link:"#",status:"normal",item:[{id:"id21",caption:"Main Office",link:"http://www.linengineering.com/line/contents/stepmotors/contact.aspx"},{id:"id22",caption:"Locate Your Rep",link:"http://www.linengineering.com/line/contents/stepmotors/World_Rep.aspx"},{id:"id23",caption:"Request Info",link:"#",item:[{id:"id231",caption:"Catalog Request",link:"http://www.linengineering.com/LinE/contents/stepmotors/Catalog_Request.aspx"},{id:"id232",caption:"Request a Quote",link:"http://www.linengineering.com/LinE/contents/stepmotors/Application.aspx"}]}]},{id:"id3",caption:"Designer's Corner",link:"#",status:"normal",item:[{id:"id31",caption:"Easy Step Motor Selection",link:"http://www.linengineering.com/dc"},{id:"id32",caption:"Motor Control Comparision",link:"http://www.linengineering.com/mcc_proj/mcc/user/step1.aspx"},{id:"id33",caption:"Lin Forum",link:"http://www.linengineering.com/dc/user/wheretostart.aspx"}]},{id:"id4",caption:"Company",link:"#",status:"normal",item:[{id:"id41",caption:"President",link:"http://www.linengineering.com/line/contents/stepmotors/president.aspx"},{id:"id42",caption:"Our Capabilities",link:"http://www.linengineering.com/line/contents/stepmotors/our_capabilities.aspx"},{id:"id43",caption:"Mission & History",link:"http://www.linengineering.com/line/contents/stepmotors/history.aspx"},{id:"id44",caption:"Links",link:"http://www.linengineering.com/line/contents/stepmotors/link.aspx"},{id:"id45",caption:"Career Opportunities",link:"http://www.linengineering.com/line/contents/stepmotors/career.aspx"},{id:"id46",caption:"Why Lin",link:"http://www.linengineering.com/line/whylin.aspx"},{id:"id47",caption:"What's New",link:"http://www.linengineering.com/line/whatnew.aspx"},{id:"id48",caption:"Lin's Video",link:"http://www.linengineering.com/line/Linvideo.aspx"},{id:"id49",caption:"Certifications",link:"http://www.linengineering.com/line/contents/stepmotors/whylin.aspx#8"}]},{id:"id5",caption:"Resources",link:"#",status:"normal",item:[{id:"id51",caption:"White Papers",link:"http://www.linengineering.com/dc/anonymous/WhitePaperList.aspx"},{id:"id52",caption:"Technical Support",link:"http://www.linengineering.com/dc/user/wheretostart.aspx"},{id:"id53",caption:"Conversion Calculator",link:"http://www.linengineering.com/LinE/contents/stepmotors/Calculator.aspx"},{id:"id54",caption:"Download",link:"http://www.linengineering.com/line/contents/stepmotors/download.aspx"},{id:"id55",caption:"Wiring Connection",link:"http://www.linengineering.com/line/contents/stepmotors/Wiring_Connections.aspx"},{id:"id56",caption:"Custom Designs",link:"http://www.linengineering.com/line/contents/stepmotors/customizations.aspx"},{id:"id57",caption:"Configurable 3D Models",link:"http://www.linengineering.com/LinE/contents/stepmotors/3D_Models.aspx"},{id:"id58",caption:"RMA Requisition Form",link:"http://www.linengineering.com/line/contents/linforms/RMA_Forms.aspx"}]}];
var mnPopup;
var HIDE_DELAY=1000;
function btnMenuHandleEvent(e){
    var menuid=this.id;
    var b=getMenuItems(menuitems,this.id,false);
if(!b)return;
if(is.ie)e=event;
switch(e.type){
case 'mouseover':
t=true;
//if(!_w.aP)s='o';
//else{
if(b.length&&!this.mnPopup){
this.mnPopup = new PopupCom({id:'__popup__'+menuid,ref:getMenuItems(menuitems,menuid,false)});
                    if(this.mnPopup) {
                        //this.mnPopup.onshow=new Function('_w.aP=this;}');
                //this.mnPopup.onhide=new Function('_w.aP=null;delete _w.aP;}');
                        var p=getClientPos(this);
                        var left=0,top=0;
                        if(is.ie||false){
                            left=p.left;
                            top=p.top;
                        }else {
                            left=p.left;
                            top=p.top;
                        }
                        left+=(false?this.offsetWidth:0);
                        top += (!false?this.offsetHeight:0);
                        this.mnPopup.popup(left,top);
                        //_w.aP=this.mnPopup;
                    }

/*p=getClientPos(this);
if(!b.mnPopup)b.createPopup();*/
}else{
    this.mnPopup.show();
/*if(_w.aP!=this.mnPopup){
_w.aP.hide();
_w.aP=null;
delete _w.aP;
s='o';
}*/
}
//}
break;
case 'mousedown':

break;
case 'mouseup':

break;
case 'mouseout':
    if(this.mnPopup){
    this.mnPopup.tmr=setInterval('try{if(_d._dEs["'+this.mnPopup.id+'"]&&!_d._dEs["'+this.mnPopup.id+'"].isChildVisible())_d._dEs["'+this.mnPopup.id+'"].hide();}catch(e){}',HIDE_DELAY);
        }
break;
case 'click':

}
}
function doPopup(parentobj, menuid, fromleftnav){
    if (isString(parentobj))parentobj=_d.gid_(parentobj);
    try{
        if(mnPopup&&mnPopup.isChildVisible()){
            return;
        }
        if(mnPopup&&mnPopup.destroy){
            mnPopup.destroy();    
        }
    }catch(e){}
    mnPopup = new PopupCom({id:'__popup__'+menuid,ref:getMenuItems(menuitems,menuid,fromleftnav)});
    if(mnPopup) {
        var p=getClientPos(parentobj);
        var left=0,top=0;
        if(is.ie||fromleftnav){
            left=p.left;
            top=p.top;
        }else {
            /*left=parentobj.offsetLeft;
            if(left<=0){
                left=p.left;
            }
            top=parentobj.offsetTop;
            if(top<=0){
                top=p.top;
            }*/
            left=p.left;
            top=p.top;
        }
        left+=(fromleftnav?parentobj.offsetWidth:0);
        top += (!fromleftnav?parentobj.offsetHeight:0);
        mnPopup.popup(left,top);
    }
}
function getMenuItems(items,menuid,fromleftnav){
    if(!items)return null;
    if(items&&!items.length)items=[items];
    for(var i=0; i < items.length; i++) {
        if (items[i].id==menuid) {
            return items[i].item;
        }else if (fromleftnav && items[i].item) {
            var result=getMenuItems(items[i].item,menuid,fromleftnav);
            if(result){
                return result;
            }
        }
    }
    return null;
}
function doInitLeftSearchObj(){
    var insSearch = new InstanceSearch();
    insSearch.attachObj("txtLeftSearch", window);
    window.insSearch=insSearch;
}

function doInitSearchObj(){
    if (window.insSearch){
        window.insSearch.detachObj("txtLeftSearch", window);
    }
    var insSearch = new InstanceSearch();
    insSearch.attachObj("txtQueryString", window);
    window.insSearch=insSearch;
}
function popup(url, ext_url, w, h, scrollable){
var popup, left, top, setting;
left=screen.width?(screen.width-w)/2:0;
top=screen.width?(screen.height-h)/2:0;
setting="width=" + w + ",height=" + h + ", scrollbars=" + scrollable + ", dependent=yes, " + "top=" + top + ",left=" + left + "'";
popup = window.open(url + ext_url,"LINE",setting);
if (popup.opener == null){ 
   popup.opener = self; 
}
}function ClickShowHideMenu(id) {
    this.box1Hover = true;
    this.box2Hover = true;
    this.box3Hover = true;
    this.highlightActive = false;

    this.init = function() {
        if (!_d.gid_(this.id)) {
            alert("Element '"+this.id+"' does not exist in this document. Menu cannot be initialized");
            return;
        }
        this.parse(_d.gid_(this.id).childNodes, this.tree, this.id);
        this.load();
        if (window.attachEvent) {
            window.attachEvent("onunload", function(e) { self.save(); });
        } else if (window.addEventListener) {
            window.addEventListener("unload", function(e) { self.save(); }, false);
        }
    }

    this.parse = function(nodes, tree, id) {
        for (var i = 0; i < nodes.length; i++) {
            if (nodes[i].nodeType != 1) {
                continue;
            }
            if (nodes[i].className) {
                if ("box1" == nodes[i].className.substr(0, 4)) {
                    nodes[i].id = id + "-" + tree.length;
                    tree[tree.length] = new Array();
                    eval('nodes[i].onmouseover = function() { self.box1over("'+nodes[i].id+'"); }');
                    eval('nodes[i].onmouseout = function() { self.box1out("'+nodes[i].id+'"); }');
                    eval('nodes[i].onclick = function() { self.box1click("'+nodes[i].id+'"); }');
                }
                if ("section" == nodes[i].className) {
                    id = id + "-" + (tree.length - 1);
                    nodes[i].id = id + "-section";
                    tree = tree[tree.length - 1];
                }
                if ("box2" == nodes[i].className.substr(0, 4)) {
                    nodes[i].id = id + "-" + tree.length;
                    tree[tree.length] = new Array();
                    eval('nodes[i].onmouseover = function() { self.box2over("'+nodes[i].id+'", "'+nodes[i].className+'"); }');
                    eval('nodes[i].onmouseout = function() { self.box2out("'+nodes[i].id+'", "'+nodes[i].className+'"); }');
                   eval('nodes[i].onclick = function() { self.box2click("'+nodes[i].id+'", "'+nodes[i].getAttribute("link")+'"); }');
                }
                if ("box3" == nodes[i].className.substr(0, 4)) {
                    nodes[i].id = id + "-" + tree.length;
                    tree[tree.length] = new Array();
                    eval('nodes[i].onmouseover = function() { self.box3over("'+nodes[i].id+'", "'+nodes[i].className+'"); }');
                    eval('nodes[i].onmouseout = function() { self.box3out("'+nodes[i].id+'", "'+nodes[i].className+'"); }');
                   eval('nodes[i].onclick = function() { self.box3click("'+nodes[i].id+'", "'+nodes[i].getAttribute("link")+'"); }');
                }
            }
            if (this.highlightActive && nodes[i].tagName && nodes[i].tagName == "A") {
                if (document.location.href == nodes[i].href) {
                    nodes[i].className = (nodes[i].className ? ' active' : 'active')
                }
            }
            if (nodes[i].childNodes) {
                this.parse(nodes[i].childNodes, tree, id);
            }
        }
    }

    this.box1over = function(id) {
        if (!this.box1Hover) return;
        if (!_d.gid_(id)) return;
        _d.gid_(id).className = (this.id_openbox == id ? "box1-open-hover" : "box1-hover");
    }

    this.box1out = function(id) {
        if (!this.box1Hover) return;
        if (!_d.gid_(id)) return;
        _d.gid_(id).className = (this.id_openbox == id ? "box1-open" : "box1");
    }

    this.box1click = function(id) {
        if (!_d.gid_(id)) {
            return;
        }
        var id_openbox = this.id_openbox;
        if (this.id_openbox) {
            if (!_d.gid_(id + "-section")) {
                return;
            }
            this.hide();
            if (id_openbox == id) {
                if (this.box1hover) {
                    _d.gid_(id_openbox).className = "box1-hover";
                    _d.gid_(id_openbox).firstChild.nextSibling.className='img_down';
                } else {
                    _d.gid_(id_openbox).className = "box1";
                    _d.gid_(id_openbox).firstChild.nextSibling.className='img_down';
                }
            } else {
                _d.gid_(id_openbox).className = "box1";
                _d.gid_(id_openbox).firstChild.nextSibling.className='img_down';
            }
        }
        if (id_openbox != id) {
            this.show(id);
            var className = _d.gid_(id).className;
            if ("box1-hover" == className) {
                _d.gid_(id).className = "box1-open-hover";
                _d.gid_(id).firstChild.nextSibling.className='img_up';
            }
            if ("box1" == className) {
                _d.gid_(id).className = "box1-open";
                _d.gid_(id).firstChild.nextSibling.className='img_up';
            }
        }
        this.save();
    }

    this.box2over = function(id, className) {
        if (!this.box2Hover) return;
        if (!_d.gid_(id)) return;
        _d.gid_(id).className = className + "-hover";
    }

    this.box2out = function(id, className) {
        if (!this.box2Hover) return;
        if (!_d.gid_(id)) return;
        _d.gid_(id).className = className;
    }
    
    this.box2click = function(id, href) {
        try{
            if(href){
                window.location=href;
            }
            this.save();
        }catch(e){};
    }
    
    this.box3over = function(id, className) {
        if (!this.box3Hover) return;
        if (!_d.gid_(id)) return;
        var id_active = this.cookie.get(this.id+"_act");
        _d.gid_(id).className = id_active==id ? className + "-active-hover" : className + "-hover";
    }
    
    this.box3out = function(id, className) {
        if (!this.box3Hover) return;
        if (!_d.gid_(id)) return;
        var id_active = this.cookie.get(this.id+"_act");
        _d.gid_(id).className = (id_active==id ? className + "-active" : className);
    }
    
    this.box3click = function(id, href) {
        try{
            if(href){
                window.location=href;
            }
            this.save();
            if (id) {
                this.cookie.set(this.id+"_act", id);
            } else {
                this.cookie.del(this.id+"_act");
            }
        }catch(e){};
    }

    this.show = function(id) {
        if (_d.gid_(id + "-section")) {
            _d.gid_(id + "-section").style.display = "block";
            this.id_openbox = id;
        }
    }

    this.hide = function() {
        _d.gid_(this.id_openbox + "-section").style.display = "none";
        this.id_openbox = "";
    }

    this.save = function() {
        if (this.id_openbox) {
            this.cookie.set(this.id, this.id_openbox);
        } else {
            this.cookie.del(this.id);
        }
        
        
    }

    this.load = function() {
        var id_openbox = this.cookie.get(this.id);
        if (id_openbox) {
            this.show(id_openbox);
            _d.gid_(id_openbox).className = "box1-open";
            _d.gid_(id_openbox).firstChild.nextSibling.className='img_up';
        }
        var id_active = this.cookie.get(this.id+"_act");
        if (id_active) {
            _d.gid_(id_active).className = "box3-active";
            //_d.gid_(id_active).firstChild.nextSibling.className='img_up';
        }
    }

    function Cookie() {
        this.get = function(name) {
            var cookies = document.cookie.split(";");
            for (var i = 0; i < cookies.length; i++) {
                var a = cookies[i].split("=");
                if (a.length == 2) {
                    a[0] = a[0].trim();
                    a[1] = a[1].trim();
                    if (a[0] == name) {
                        return unescape(a[1]);
                    }
                }
            }
            return "";
        }
        this.set = function(name, value) {
            document.cookie = name + "=" + escape(value);
        }
        this.del = function(name) {
            document.cookie = name + "=; expires=Thu, 01-Jan-70 00:00:01 GMT";
        }
    }

    var self = this;
    this.id = id;
    this.tree = new Array();
    this.cookie = new Cookie();
    this.id_openbox = "";
    this.id_active = "";
}

if (typeof String.prototype.trim == "undefined") {
    String.prototype.trim = function() {
        var s = this.replace(/^\s*/, "");
        return s.replace(/\s*$/, "");
    }
}