/*
 * 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 _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
 */
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);
}
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';
h+='<li><a id="'+this.ref[i].id+'" index="'+i+'" parentID="'+this.id+'" href="#">'+(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){
    cls="haschild";
}
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
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)this.tmr=setInterval('_d._dEs["'+this.id+'"].hide();',1000);
//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])return;
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){};
};
/*
Project: SKLV
By: pKt
*/
var menuitems=[{id:"id1",caption:"Home",link:"homep.aspx",status:"hot",item:[{id:"id1001",caption:"About Us",link:"aboutus.aspx",status:"normal"},{id:"id1002",caption:"Project Overview",link:"projov.aspx",status:"normal"},{id:"id1003",caption:"Staff",link:"staff.aspx",status:"normal"},{id:"id1004",caption:"Contacts Information",link:"coninfo.aspx",status:"normal"}]},{id:"id5",caption:"EDUCATIONAL MATERIALS",link:"multimedia.aspx",status:"normal",item:[{id:"id5001",caption:"Television",link:"tivi.aspx",status:"normal"},{id:"id5002",caption:"Radio",link:"radio.aspx",status:"normal"},{id:"id5003",caption:"VN Newspaper Ads",link:"print.aspx",status:"normal"},{id:"id5004",caption:"Booklet",link:"booklet.aspx",status:"normal"},{id:"id5005",caption:"Pamphlet",link:"pamphlet.aspx",status:"normal"},{id:"id5006",caption:"Calendar",link:"calendar.aspx",status:"normal"},{id:"id5007",caption:"Interactive MD",link:"intermd.aspx",status:"normal"}]}];
var mnPopup;
function doPopup(parentobj, menuid, fromleftnav){
    if (isString(parentobj))parentobj=_d.gid_(parentobj);
    try{
        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 refreshPosDoctor(){
    try{
        var cl=_d.gid_("interdocter");
        if(cl){
            var parentobj=_d.gid_("footerbar");
            if(parentobj){
                var p=getClientPos(parentobj);
                cl.style.left=(is.ie?p.left:parentobj.offsetLeft)+'px';
                cl.style.top=(p.top-280)+'px';   
                cl.style.display="block";
            }
        }
    }catch(e){};
}
function refreshPosLogo(){
    var cl=_d.gid_("companylogo");
    if(cl){
        var parentobj=_d.gid_("comlogoholder");
        if(parentobj){
            var p=getClientPos(parentobj);
            cl.style.left=p.left+'px';
            cl.style.top=(p.top+13)+'px';   
        }
    }
}
function __window_resize(){
    refreshPosDoctor();
    refreshPosLogo();
}
window.onresize=__window_resize;
function bdgOnload(){
    refreshPosLogo();
    refreshPosDoctor();
    var cl=_d.gid_("companylogo");
    if(cl){
        cl.onclick=function(){
            _w.location.href=HOST_URL;
        };
    }
}
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,"IRCC_SJ",setting);
if (popup.opener == null){ 
   popup.opener = self; 
}
}
function playMediaSound(id){
    if(!id)return;
    var mediaURL=HOST_URL+'/newstools/playmedia.aspx?id='+id;
    popup(mediaURL,'',150,400,"no");
}