/*Npaper components - Powered by Wehaa*/

function calendar(o){
	o=(typeof o=='string')?ge(o):o;
	if(!o)return;
	var call=this,drawed=false,tbl,r=function(s){return Math.round(s);},fSel=null,tSel,selRange;
	this.mSel=true;
	aO(Date.prototype,{gY:function(){ return this.getFullYear();},sY:function(a){return this.setYear(a);},gM:function(){return this.getMonth();},sM:function(m){return this.setMonth(m);},gD:function(){ return this.getDay();},gDt:function(){ return this.getDate();},sD:function(a){ return this.setDate(a);},gT:function(){ return this.getTime();}});

	this.str={
		months_:['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'],
		months:['January','February','March','April','May','June','July','August','September','October','November','December'],
		days_:['Sun','Mo','Tu','We','Th','Fr','Sa'],
		days:['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday']
		};
		
	this.month=-1;
	this.year=-1; 
	this.onOpen=function(m,y){ return true;}
	this.onselect=function(date){ }
    this.isDisabled=function(d,m,y){ return false; }

	
	this.draw=function(){ 
	 o.innerHTML='<table width="100%"cellpadding=0 cellspacing=0><tr class=hd></tr></table>';
	 tbl=o.firstChild;
	 cancellsl(tbl);
	 var hdr=tbl.rows[0],dl=this.str.days_.length;
	  for(var k=0; k<dl; k++){
		with(hdr.insertCell(k)){ title=this.str.days[k]; innerHTML=this.str.days_[k];}
	   }
	   with(tbl.insertRow(1).insertCell(0)){ colSpan=dl; height='7'; }
	   with(tbl.insertRow(2).insertCell(0)){ colSpan=dl; height='7';  }

	   drawed=true;
	   this.dToday=this.today();
	   this.open(this.dToday['m']+'-'+this.dToday['y']);
	}
	
	 
	this.cleanC=function(){ if(!drawed)return;
	  var to=(tbl.rows.length>3)?tbl.rows.length-1:2;
	  for(var k=2; k<to; k++){tbl.deleteRow(k); k--; to--;}
	}

    this.d=function(){ var d=new Date(); return new Date(d.gY(),d.gM(),d.gDt()); }
	this.today=function(m){var d=this.d(); d['y']=d.gY(); d['m']=d.gM()+1; d['d']=d.gDt(); d['dd']=d.gD(); if(!m)return d; else if(m==1)return d['m']+'-'+d['y'];}

	this.getDate=function(d){
		var iS=typeof d=='string';
	    if(iS || (d[0] && d[1])){d=(iS)?d.split('-'):d; var nDay=d.length==2; d=(nDay)?new Date(r(d[1]),r(d[0])-1):new Date(r(d[2]),r(d[1])-1,r(d[0])); d['nDay']=nDay;}
		else if(d.dS && d.d)return d;
		d['y']=d.gY(); d['m']=d.gM()+1; d['d']=d.gDt(); d['dd']=d.gD();
		if(d['d']==1)d['dS']=d.gD();
		else{ var tD=d['d']; d.sD(1); d['dS']=d.gD(); d.sD(tD); }
		d['dM']=[31,(d['y']%4==0)? (!((d['y']%100==0) && (d['y']%400)!=0)? 28 :29): 29,31,30,31,30,31,31,30,31,30,31];
		d['days']=d['dM'][d['m']-1];
		return d;
	}
	
	this.eachCell=function(f){
		for(k=2;k<(tbl.rows.length-1);k++){
		  for(cll=0;cll<tbl.rows[k].cells.length;cll++)if(-1==f(tbl.rows[k].cells[cll],tbl.rows[k])){ return -1; }
		 }
	}
	
	this.eachSelCell=function(fSel,tSel,fC,fCl){ if(!fSel || !tSel)return;
	  var k,cll,fR=fSel.parentNode,tR=tSel.parentNode,f=fR.rowIndex,t=tR.rowIndex,c,r;

	 if(fC){
	   if(t==f){f=fSel.cellIndex; t=tSel.cellIndex; if(t>f){for(cll=f; cll<=t; cll++)fC(fR.cells[cll]);}else{for(cll=f; cll>=t; cll--)fC(fR.cells[cll]);}  r=0; }
	   else if(t>f){r=1; 
			 for(k=f; k<=t; k++){
				 if(k==f)for(cll=fSel.cellIndex; cll<fR.cells.length; cll++)fC(fR.cells[cll]);
				 else if(k==t)for(cll=0; cll<=tSel.cellIndex; cll++)fC(tR.cells[cll]);
				 else for(cll=0; cll<tbl.rows[k].cells.length; cll++)fC(tbl.rows[k].cells[cll]);
			 }
			
	    }else{ r=2;
		    for(k=t; k<=f; k++){
				 if(k==f)for(cll=0; cll<=fSel.cellIndex; cll++)fC(fR.cells[cll]);
				 else if(k==t)for(cll=tSel.cellIndex; cll<tR.cells.length; cll++)fC(tR.cells[cll]);
				 else for(cll=0; cll<tbl.rows[k].cells.length; cll++)fC(tbl.rows[k].cells[cll]);
			 }
		   }
	    }
		if(fCl){this.eachCell(fCl);}
		return r;
	 }
	 
	 
	 this.tSel=function(o,e){
		 if(!this.mSel || !fSel)return;
		 cls();
		 tSel=o;
         this.sel(fSel,tSel,true);
	 }
	 
	 this.cleanSel=function(){
	   if(selRange){
		this.eachSelCell(selRange.cll[0],selRange.cll[1],function(c){c.sel=0; c.onmouseout(); });
	    selRange=null; 
	   }
	 }
	
	
	 this.sel=function(f,t,Nsl){
		var k=new Date().gT(),c_= (f.cellIndex==t.cellIndex && f.parentNode.rowIndex==t.parentNode.rowIndex)?'s':'s_m',sD,eD,sD_,eD_; 
		var r=this.eachSelCell(f,t,function(c){if(c.dsb)return; if(!sD)sD=c; eD=c; c.className=c.today?'seltoday':(c.date[1]!=call.month)?'dsb '+c_:c_; c.sel=1; c.tm=k;},function(c){ if(c.sel==1 && c.tm!=k){c.sel=0; if(c.date[1]!=call.month){ c.className=c.dsb?'dsb ndsb':'dsb'; }else{c.onmouseout();} }});
        if((sD.date[0]>eD.date[0] && sD.date[1]==eD.date[1]) || (sD.date[1]>eD.date[1]) || (sD.date[2]>eD.date[2])){eD_=sD; sD_=eD;}else{eD_=eD; sD_=sD;}
		
		selRange={cll:[sD_,eD_],date:[sD_.date,eD_.date]};
		if(!Nsl)this.onselect(selRange);
     }
	 
	 this.join=function(v,m){
		var m= m || '/',l=v.length,r='';
		for(var k=0;k<l;k++){r+=(v[k]<=9 && v[k].toString().indexOf('0')==-1)?'0'+v[k]:v[k]; if(k<l-1)r+=m; } 
		return r;
	 }
	 
	 this.sSel=function(o,e){
		 if(!this.mSel)return;
		 cls();
		 this.sel(o,o,true);
		 fSel=o;
		 var uE=attachEventList('onmouseup',function(){ 
		   call.onselect(selRange);
		   tSel=null; fSel=null;
		   uE.stop();
		 });
	 }
	
    this.findD=function(day,m){
	  var cll=null;
	  this.eachCell(function(c){ if(day==c.date[0] && m==c.date[1]){cll=c; return -1;} });
	  return cll;
	}
	
	this.select=function(from,to,n){
		if(from && to){
		 var f=this.getDate(from),t=this.getDate(to),c1,c2;  
		  if(f['y']!=t['y'])return;

		  c1=this.findD(f['d'],f['m'])
		  c2=this.findD(t['d'],t['m'])
		  if(c1 && c2){ this.sel(c1,c2); }
		  else{ if(n)return; var m=Math.abs(f['m']-t['m']); if(m!=0)m-=1; this.open((f['m']+m)+'-'+f['y']); this.select.apply(this,[from,to,1]);  } 
	   }else{ 
		var f=this.getDate(from),cll;   

		 if(this.month!=f.m || this.year!=f.y)this.open(f);
		 if(cll=this.findD(f['d'],f['m'])){
			 this.sel(cll,cll);
		  }
		}
    }
	
	this.getSel=function(){
		if(!selRange)return null;
		var r={from:selRange.date[0],to:selRange.date[1],days:[]};
		  this.eachCell(function(c){ if(c.dsb)return;
			if(c.date[0]>=r.from[0] && c.date[0]<=r.to[0])r.days.push(c.date);						
		  });
		  
		return r;
	 }
	 
	this.next=function(){
		var d=new Date(this.year,this.month-1); d['nDay']=true;
		d.sM(d.gM()+1);
		this.open(d);
    }
	
	this.prev=function(){
		var d=new Date(this.year,this.month-1); d['nDay']=true;
		d.sM(d.gM()-1);
		this.open(d);
	}
	
	this.open=function(d){
	  if(!drawed)return;
		 d=this.getDate(d);
		 
		 if(this.month==d['m'] && this.year==d['y']){
			this.select(d); return;
		 }
		 
		 if(false===this.onOpen(d.m,d.y))return;
		 
		 this.month= d['m'];
		 this.year = d['y']; 
		 this.cleanC();
		 
		 var dateS,dateE,today=this.today(),nCell=0,rw,cll,f=function(cell){
			  if(nCell==0)rw=tbl.insertRow(tbl.rows.length-1);
			  cll=rw.insertCell(rw.cells.length);
			  nCell++;
			  if(nCell>6)nCell=0;
			  return cll;
			 };
			 
		 
		 if(d.dS!=0){
			var prD=(d.m==1)?'12-'+(d.y-1):(d.m-1)+'-'+d.y, prevD=this.getDate(prD);
			for(var k=0; k<d.dS; k++){cll=f();
				cll.date=[prevD.days-(d.dS-(k+1)),prevD['m'],prevD['y']];
				if(k==0)dateS=cll.date;
				cll.onclick=function(){ if(!this.dsb){call.open(this.date[0]+'-'+prD);}}
				cll.onmousedown=function(){ if(this.dsb)return; call.sSel(this); };
				cll.onmouseover=function(){ if(!this.dsb){call.tSel(this);} };
				cll.innerHTML=cll.date[0];
				
				if(cll.dsb=this.isDisabled.apply(this,cll.date)){
				  cll.className='dsb ndsb';
				}else cll.className='dsb';
			}
		 }
			
			for(var k=1; k<=d.days; k++){
				cll=f(); cll.date=[k,d['m'],d['y']];
				
				if(today['y']==d['y'] && today['m']==d['m'] && today['d']==k){cll.className='today'; cll.title="Today"; cll.today=1;}
				cll.onmouseover=function(){ if(this.dsb)return; call.tSel(this);  if(this.sel)return; this.className='ov'; }
				cll.onmouseout=function(){ if(this.dsb)return; if(this.sel)return; this.className=(this.today)?'today':'';  }
				cll.onmousedown=function(){ if(this.dsb)return; call.sSel(this); };
				cll.onclick=function(){ if(this.dsb)return; call.sel(this,this); };
				
				if(cll.dsb=this.isDisabled.apply(this,cll.date)){
				  cll.className='ndsb';
				}else{
				  if(!d['nDay'] &&  d['d']	== k ){ call.sel(cll,cll); }
				}
				cll.innerHTML=k;
			}
			
		
		  if(nCell!=0){
			var tCell=cll, nxD=(d.m==12)?'1-'+(d.y+1):(d.m+1)+'-'+d.y, nextD=this.getDate(nxD), d_=0;
			for(var k=nCell; k<=6; k++){ d_++; cll=f();
			    cll.date=[d_,nextD['m'],nextD['y']];
				if(k==6)dateE=cll.date;
				
			    cll.onclick=function(){ if(!this.dsb){  call.open(this.date[0]+'-'+nxD);  }}
				cll.onmousedown=function(){ if(this.dsb)return; call.sSel(this); };
			    cll.onmouseover=function(){ if(!this.dsb){ call.tSel(this); } };
				cll.innerHTML=d_;
				
				if(cll.dsb=this.isDisabled.apply(this,cll.date)){
				  cll.className='dsb ndsb';
				}else cll.className='dsb';
			}
		  }
		  

		  if(selRange){
			var df=selRange.date[0],dt=selRange.date[1];
			if(df[2]==d['y'] && this.findD(df[0],df[1]) && this.findD(dt[0],dt[1])){
			 this.select(df.join('-'),dt.join('-'));
		   }
			
		 }
    }
 }
 var ua = navigator.userAgent.toLowerCase();
 isIE=(ua.indexOf("msie") != -1) && (ua.indexOf("opera")==-1) && (ua.indexOf("webtv")==-1);

 function ge(id){return document.getElementById(id);}
 function g(id){return ge(id); }
 function attev(obj,event,func){eval('var o=obj.'+event+';'); if(!o || typeof(o)=='undefined'){ eval('obj.'+event+'=func;'); return true; }else{ if(obj.attachEvent){ obj.attachEvent(event,func); return true; }else if(obj.addEventListener){ obj.addEventListener(event.replace('on',''),func,false);  return true; }else return false;  } }
 function addevent(o,event,method){if(o.attachEvent){ o.attachEvent(event,method);}else{o.addEventListener(event.replace('on',''),method,1);} }
 function addevarry(obj,arry,funct){for(var k in arry){addevent(obj,String(arry[k]),funct); } }
 function aO(A,B,Nc){ for(var k in B){ if(typeof B[k]=='object' && !Nc){ if(B[k]==null){A[k]=null; continue;} if(B[k].nodeType)continue; A[k]=aO((B[k].join)?[]:{},B[k]); }else A[k]=B[k]; } return A;}
 function cls(){try{if(document.selection){document.selection.empty();}else if (window.getSelection){window.getSelection().removeAllRanges(); } }  catch(e){ } }	 
 function PosObj(obj){ var returns = {x:obj.offsetLeft,y:obj.offsetTop};if (obj.offsetParent) {var tmp = PosObj(obj.offsetParent);returns.x += tmp.x;returns.y += tmp.y;}return returns;}
 function getSizeWin(){var t=[0,0],dc=arguments[0]?arguments[0]:[document,window]; if(typeof(dc[1].innerWidt )=='number') {t=[dc[1].innerWidth,dc[1].innerHeight]; }else if(dc[0].documentElement && (dc[0].documentElement.clientWidth || dc[0].documentElement.clientHeight)){ t=[dc[0].documentElement.clientWidth,dc[0].documentElement.clientHeight];}else if(dc[0].body && ( dc[0].body.clientWidth || dc[0].body.clientHeight)){ t=[dc[0].body.clientWidth,dc[0].body.clientHeight];} return t;}
 function getScrollPos(){var dc=arguments[0]?arguments[0]:document; if(typeof(dc.documentElement)!= 'undefined' && typeof(dc.documentElement.scrollTop)!= 'undefined')return [dc.documentElement.scrollTop,dc.documentElement.scrollLeft];else if(typeof(dc.body.scrollTop)!= 'undefined' && typeof(dc.body.scrollLeft)!= 'undefined')return [dc.body.scrollTop,dc.body.scrollLeft];else [0,0];} 
 function hidde_selects(visible){if(!isIE)return; var mp1,tmp2,t=document.getElementsByTagName('select'),calledPos=typeof(arguments[1]) != 'undefined',nosel=!isArray(arguments[2]) ? [] : arguments[2]; for(var i=0; i<t.length; i++){if(nosel.find(t[i]))continue;if(calledPos){pSel=PosObj(t[i]);  if((pSel.x+t[i].offsetWidth)>arguments[1].x && (arguments[1].x+arguments[1].w)>pSel.x && (pSel.y+t[i].offsetHeight)>arguments[1].y && (arguments[1].y+arguments[1].h)>pSel.y){t[i].style.visibility = visible ? 'visible': 'hidden';}}else t[i].style.visibility=visible?'visible': 'hidden';}} 
 function isu(s){ return typeof s=='undefined'; }
 function sI(f,i,p){return setInterval(f,i);}
 function sO(f,i){return setTimeout(f,i);}
 function cI(i){return clearInterval(i);}
 function is_clicked(obj,method){if(method(obj)){return true;}else if(obj.parentNode){return is_clicked(obj.parentNode,method);}}
 function MkEv(e,ev){ try{ var e=e || window.event; if(!e && ev)e=ev; return {event:e,obj:(e.srcElement)?e.srcElement:e.target,key:e.keyCode,cursor:getCur(e),but:e.which || e.button,type:e.type,ctrl:e.ctrlKey,alt:e.altKey}; }catch(e){} }
 function getCur(e){ e = e || window.event;  var cursor = {x:0, y:0};  if (e.pageX || e.pageY) { cursor.x = e.pageX;cursor.y = e.pageY;}else {var de = document.documentElement; var b = document.body;  cursor.x = e.clientX + (de.scrollLeft || b.scrollLeft) - (de.clientLeft || 0); cursor.y = e.clientY + (de.scrollTop || b.scrollTop) - (de.clientTop || 0);} return cursor;}
 function nw_ajx(){var C=null;try{C=new ActiveXObject("Msxml2.XMLHTTP");}catch(e){try{C=new ActiveXObject("Microsoft.XMLHTTP");}catch(sc){C=null;}}if(!C&&typeof XMLHttpRequest!="undefined"){C=new XMLHttpRequest();}return C;}
 function compare(A,B){for(var i in A){if(typeof B[i]=='undefined')return false; if(typeof A[i]=='object'){ if(!A[i].nodeType){ if(typeof B[i]!='object')return false; if(!compare(A[i],B[i]))return false; } }else if(A[i]!=B[i]){ return false;}} return true;}
 function print_r(obj){var h=''; for(var x in obj){h+=' '+x+' => ';h+=obj[x]+',<br>\r\n';} return h;}
 Array.prototype.find =function(txt){ for(var i=0; i<this.length; i++){if(this[i]==txt)return i;}return false;}
 function getChildByType(obj){var type = (arguments[1])?arguments[1]:1; if(typeof obj.childNodes=='undefined')return null;var nodes=[]; for(var i=0; i<obj.childNodes.length; i++){if(obj.childNodes[i].nodeType==type){nodes[nodes.length]=obj.childNodes[i];}}return nodes;}
 
 function cancellsl(ob){
   if(arguments[1]){
     ob.style.MozUserSelect=''; 
     ob.onselectstart=function(){};
   }else{
     ob.style.MozUserSelect='none'; 
     ob.onselectstart=function(){return false;};
   }       
 }
 
 function attachEventList(ev,f){ var arry; try{eval('var t=typeof EvH_'+ev);}catch(e){var t=null;}
		if(t=='undefined' || !t){
		 eval('EvH_'+ev+'=[]; arry=EvH_'+ev+';');
		 attev(document,ev,function(){for(var i=0;i<arry.length;i++)arry[i].f.apply(null,arguments); });
		}else eval('arry=EvH_'+ev+';');
		 
		 var o={k:arry.length,arry:arry,f:f,stop:function(){arry.splice(this.k,1);  for(var k=0;k<arry.length;k++)arry[k].k=k; }};
		 arry.push(o);
	return o;
}	 
		
	function dv(){ // create div
	    if(document.body==null)return false; 
		var call=this;
		var created=false;
		this.getSizeContent= getSizeRx;
		this.append=(typeof arguments[0]=='object')? arguments[0] : document.body;
		
		if(!this.append || !this.append.ownerDocument)return;
		
		var _doc_=this.append.ownerDocument;
		
		if(typeof dvElements=='undefined')dvElements=[];
		
		this.visible=false
		try{
		if(typeof arguments[1]=='object'){
		 this.obj=arguments[1];
		}else{
		 this.obj=_doc_.createElement('DIV');
	     this.append.appendChild(this.obj);
		}
		}catch(e){ return false; }
		
		
		
		this.obj.id = typeof arguments[1]=='string' ? arguments[1] : '-'+(Math.round(Math.random()*100))+'-';
		this.id=this.obj.id;
		
		this.obj.style.display='none';
        this.obj.style.position='absolute';
		this.obj.style.overflow='hidden';
		this.obj.innerHTML='';
	
		

		this.inner = '';	
		this.autoHideClick = true;
		this.hiddenClicked = false;
		this.timeHidden = 0;
		this.nid =[];
		
		this.onhidden = function(){return true;};
    
		this.rS=function(f){var o=this.obj; o.style.visibility='hidden'; o.style.display='';f.apply(this,arguments);o.style.display='none'; o.style.visibility='visible';}
		
		this.display = function(pos){ 
		   if(this.obj==null)return false;
			if(typeof pos!='object')return false; var o=this.obj;
			
			 if(isu(pos.x) && isu(pos.y) && isu(pos.b) && isu(pos.r)){
			   if(pos.nodeType==1)pos=PosObj(pos);
			   else pos={x:0,y:0};
		     }else{    
			  if(typeof pos.ob!='undefined'){var tmp=PosObj(pos.ob); pos.x+=tmp.x; pos.y+=tmp.y;}
			 }

			if(this.inner!==false)o.innerHTML=this.inner;
			
			if(!isu(pos.x))o.style.left=pos.x+'px';
			if(!isu(pos.y))o.style.top=pos.y+'px';
			if(!isu(pos.r))o.style.right=pos.r+'px';
			if(!isu(pos.b))o.style.bottom=pos.b+'px';
			o.style.display  ='block';
			
			this.visible=true;
			return pos;
		}
			
	     this.hidden = function (){
			 if(this.onhidden()){
			 this.obj.style.display='none';
			 this.visible=false;
			  }
			 }
		
		this.free= function(){  

		 if(this.obj==null)return;
		 try{
			this.obj.parentNode.removeChild(this.obj);
			this.obj=null;
			dvElements.splice(this.l,1);
			for(var i=0; i<dvElements.length; i++){
				dvElements[i].l=i;
				}
		       }catch(e){}
			};
			
		this.hdn = function(){
			if(this.timeHidden!=0){ 
	         sO(function(){ call.hidden(); },call.timeHidden);
			}else call.hidden();
		}
			
		function changeID(id){
			this.id=id;
			if(this.obj)this.obj.id=id;
			}	
	   
	   
	    if(typeof adevud=='undefined'){ 
		adevud=true;
		var method=function(e){ var e = e || window.event,io= (e.srcElement) ? e.srcElement: e.target,tmp; 
												 
												 for(var n=0; n<dvElements.length; n++){
													 tmp=dvElements[n];
													 if(tmp.visible === true && tmp.autoHideClick){
														    if(!tmp.hiddenClicked){
															   if(is_clicked(io,function(o){  return (o.id==tmp.obj.id || tmp.nid.find(o.id)); })){
																   continue;
																   }
															  }
                                                            
															tmp.hdn();
															
															
														 }
													 }
												 };
		
		
	     addevent(_doc_,'onmousedown',method);
		}
		
         
		this.l=dvElements.length;
        dvElements.push(this);
		return true;
}		
		
  function getSizeRx(text,ap,maxw,maxh){
	 var append=ap || document.body;
	 var tmp=ce('DIV');
	 with(tmp.style){ top='1px'; left='1px'; position='absolute';  visibility='hidden'; }
	 tmp.innerHTML=text;
	
	 append.appendChild(tmp);
	 if(maxw && tmp.offsetWidth>maxw)tmp.style.width=(maxw)+'px';
	 if(maxh && tmp.offsetWidth>maxh)tmp.style.height=(maxh)+'px';
	  
	 var rtn={w:tmp.offsetWidth,h:tmp.offsetHeight};
	 append.removeChild(tmp); 
	 tmp=null;
	 
	 return rtn;
 }
 
function nwsubmn(){
	   var opt=[],call=this;
	   
	   this.eShade =true;
	   this.shade  = new dv; 
	   this.shade.nid=['-menu-'];
	   
	   var append= (arguments[1])? arguments[1] : document.body;
	    var _doc_=append.ownerDocument,_wn_=(arguments[2])? arguments[2] :  window;
	
	   this.menu = new dv(append); 
	   this.menu.obj.id='-menu-';
	   this.menu.inner=false;

	   this.menu.onhidden= function(){ hidde_selects(true); return true;}
	   this.onclick=function(){}
	   cancellsl(this.menu.obj);
	   
	   this.style = typeof arguments[0]!='object' ?  {} : arguments[0];

	   if(!this.style.h)this.style.h=-1; 
	   if(typeof this.style.scroll=='undefined')this.style.scroll=false; 
	   
	   this.menu.obj.oncontextmenu=function(){ return false;};
	    with(this.menu.obj.style){
	    backgroundColor='white';
		border='1px solid #999999';
		font='0.75em arial';
		zIndex='1';
		overflowY='auto';
		overflowX='hidden';
		}
	   
	   
	   this.shade.inner=false;
	   this.shade.obj.innerHTML='<div></div> <div></div>   <div></div>  <div></div>  <div></div> <div></div>';
	
	   
	   this.opt=function(o){
		  o.t=o.t || 1; // type
		  o.o=_doc_.createElement('DIV');
		  o.o.style.clear='both';
		  switch(o.t){
			  case 1:
			  default:
			  o.disable=false;
			  o.o.style.padding='3px 0px 3px 0px';
			  o.o.style.cursor='default';
			  o.o.innerHTML='<img src="img/ine_.gif" width=12 height=17 style="float:left; margin-right:5px; visibility:hidden" onmousedown="return false;" onmousemove="return false;"> <div style="float:left; padding-right:20px;">'+o.inner+'</div> <div style="clear:both"></div>';
			  o.o.onmouseover=function(){if(o.disable)return;  this.style.backgroundColor='#DAE9FE';};
			  o.o.onmouseout=function(){this.style.backgroundColor='white';};
			  o.o.onclick=function(){if(o.disable)return; this.onmouseout(); call.onclick(); if(typeof o.onclick=='function')o.onclick(o); call.hidden();}
			  
			  this.menu.obj.appendChild(o.o);
			  break;
			  case 2 :
			  o.o.style.borderTop='1px solid #999999';
			  this.menu.obj.appendChild(o.o);
			  break;
			  }
		 }
	   
	   this.setOptions= function(options,cl){
		   if(cl){opt=[]; this.menu.obj.innerHTML='';}
		
		   for(var i=0; i<options.length; i++){
			   this.opt(options[i]);
			   opt.push(options[i]);
		       }
		}
		   
		   
		this.draw = function(obj){ var op,focus=null;
			for(var i=0; i<opt.length; i++){op=opt[i];
				if(op.t!=1)continue;
				if(typeof op.active=='function'){
					if(op.active(op)){
						focus=op; op.o.firstChild.style.visibility ='visible'; 
				    }else{
						op.o.firstChild.style.visibility ='hidden'; 
					}
			    }
				  
				if(typeof op.disabled=='function'){
                 if(op.disabled()){
				  op.disable=true;
				  op.o.style.color='#666666';
				 }else if(opt[i].disable){
				  op.disable=false;
				  op.o.style.color='black';
				  }
			   }
			}
			
			
		   if(typeof obj.x!='undefined' && typeof obj.y!='undefined'){
		     this.menu.display(obj);
		   }else if(obj.nodeType==1){  
			 var poso=PosObj(obj),szw=getSizeWin([_doc_,_wn_]),scrll=getScrollPos(_doc_),pos={x:poso.x,y:poso.y+obj.offsetHeight+1};
			   szw[0]+=scrll[1];
			   szw[1]+=scrll[0]
				
				this.menu.obj.style.visibility='hidden';
				this.menu.obj.style.display='';
				
				this.menu.obj.style.height='auto';
				var w=this.menu.obj.offsetWidth,h=this.menu.obj.offsetHeight;
				
				this.h=300;
				
				if(h>this.h){
			    this.menu.obj.style.height=(this.h)+'px';
				 if(focus){var h_=focus.o.offsetTop+focus.o.offsetHeight;
					 if(h_>this.menu.obj.scrollTop+this.h || this.menu.obj.scrollTop<h_){
						this.menu.obj.scrollTop=(focus.o.offsetTop-((this.h+focus.o.offsetHeight)/2)); 
					   }
				    }
				 h=this.menu.obj.offsetHeight; w=this.menu.obj.offsetWidth;
				}
				
				this.menu.obj.style.visibility='visible';
				this.menu.obj.style.display='none';


			    if((pos.y+h)>szw[1])pos.y=poso.y-h-1;

                if((pos.x+w)>szw[0])pos.x=szw[0]-w-8;
			
				if(this.eShade){
			    this.shade.obj.style.width=(w)+'px';
				this.shade.obj.style.height=(h)+'px';
			    var chd=getChildByType(this.shade.obj);
			  
				    with(chd[0].style){position='absolute';left=(w-12)+'px';top='0px';width='12px';height='11px';fontSize='0px';stAlp(chd[0],'img/shdmn/tr.png');}
				    with(chd[1].style){position='absolute'; display='block'; left=(w-12)+'px';top='11px';width='12px'; if(isIE){var a=h-22;   height=a%2==0?a:a+1; }else{ height=(h-22)+'px'; }   fontSize='0px';stAlp(chd[1],'img/shdmn/rgr.png');}
				    with(chd[2].style){position='absolute';left=(w-12)+'px';top=(h-11)+'px';  width='12px';height='11px';fontSize='0px';  var ise=[parseInt(top)%2,w];  if(ise[0]==0 || !isIE){stAlp(chd[2],'img/shdmn/br.png');}else{ stAlp(chd[2],'img/shdmn/br2.png'); width='15px';height='15px';left=(w-15)+'px';top=(h-15)+'px';}  }
				    with(chd[3].style){position='absolute';left=(12)+'px';top=(h-11)+'px'; width=(w-24)+'px'; height='11px'; fontSize='0px';stAlp(chd[3],'img/shdmn/rgb.png');}
				    with(chd[4].style){position='absolute';left='0px';top=(h-11)+'px';width='12px'; height='11px'; fontSize='0px'; stAlp(chd[4],'img/shdmn/bl.png');}
				    with(chd[5].style){position='absolute'; left='0px';top='0px';width=(w-12)+'px'; height=(h-11)+'px'; fontSize='0px'; backgroundColor='black';}
				
				   this.shade.display({x:pos.x+5,y:pos.y+5});
				 }

			      this.menu.display(pos);
				   if(isIE)hidde_selects(false,{x:pos.x+5,y:pos.y+5,w:this.menu.obj.offsetWidth,h:this.menu.obj.offsetHeight})
			   }
		   
		} 
		
		
		 this.menu.onhidden=function(){
			call.shade.hidden();
			 return true;
			 }
		 this.hidden= function(){
		 this.shade.hidden();
		 this.menu.hidden();
		  hidde_selects(true);
		} 
}
function sTab(o,focus,fActive,fDeactive,fOver,fOut,fFilter){
	var call=this,tbs=[],ch,o=(typeof o=='string')?ge(o):o,
	fActive=fActive || function(o){o.className='on';},fDeactive=fDeactive || function(o){o.className='';},
	onp=function(k){ var o=tbs[k]; o.k=k+1; if(focus==o.k){call.change(o.k);} if(fOver)addevent(o,'onmouseover',function(){ fOver(o); }); if(fOut)addevent(o,'onmouseout',function(){ fOut(o); }); addevent(o,'onclick',function(){ call.change(o.k); }); }; 
	
	if(!o)return; 
	
	if(fFilter){ch=getChildByType(o); for(var k=0;k<ch.length;k++)if(fFilter(ch[k],k))tbs.push(ch[k]); ch=null;}
	else tbs=getChildByType(o);
	this.onchange =function(){};
	this.change   =function(k,s){ if(this.focus){ fDeactive(tbs[this.focus-1]); } if(k==-1)return; fActive(tbs[k-1]); if(!s)this.onchange(k); this.focus=k; };

	this.focus=focus;
    for(var k=0;k<tbs.length;k++)onp(k);
  }

function mOutObj(callback,obj){
		var tmp,hdI=null,IntV=arguments[2]?arguments[2]:100,args=arguments;
		for(var k=0;k<obj.length;k++){
			tmp=typeof(obj[k])=='string'?ge(obj[k]):obj[k];
			addevent(tmp,'onmouseout',function(){hdI=sO(function(){if(!hdI)return; callback.apply(this,args);},IntV);});
			addevent(tmp,'onmouseover',function(){if(hdI){cI(hdI); hdI=false; } });
			}
	}
	
function toAjax(o,oA){
	 o= (typeof o=='object') ? o : {};
	 if(!o.method)o.method='GET';
	 if(isu(o.reportE))o.reportE=true;
	 if(!o.url)o.url=rmpl_param('ajx',1,location.href,false); 

	 if(!o.param)o.param=''; 
     o.method=o.method.toUpperCase();
	 o.url=rmpl_param('tmn',Math.random(),o.url,false); 
	 
	 var r={ab:0,abort:function(){ r.ab=1; try{r.o.abort();}catch(e){} },o:oA || nw_ajx()},a=r.o;

	 a.open(o.method,o.url);
	 a.onreadystatechange=function(){if(r.ab)return;
			  if(a.readyState==4){
				    if(a.status=='200'){
						 if(typeof _Nss_=='undefined' || !_Nss_){
						   if(a.responseText=='NLOGGED'){alert('Session has bee closed'); location.href=(typeof _u_Nss_!='undefined')?_u_Nss_ : location.href; return;}
						 }
					 if(typeof o.func=='function')o.func(a.responseText,a.getAllResponseHeaders(),a);
					}else{
					  if(o.reportE)alert('return: \nstatus:'+a.status+', msg:'+a.statusText);
					  }
				  }
			 }
	 
	  if(o.method=='POST'){
	  a.setRequestHeader('Content-Type','application/x-www-form-urlencoded; charset=UTF-8');
	  a.send(o.param);
	  }else{
	  a.send(null);
	  }
	 return r;
}	 

function rmpl_param(param,value){
	 var u=arguments[2] ? arguments[2] : location.href,autored=typeof arguments[3]=='undefined'? true : arguments[3];
	 eval('var r=/(\\?|\&)'+param+'=([^\&]*)/gi');
	  if(r.test(u)){
		u=u.replace(r,'$1'+param+'='+value);
		}else{
		u=(u.indexOf('?')==-1)? u+'?'+param+'='+value : u+'&'+param+'='+value 
	   }

	 if(autored)location.href=u;
	 return u;
  }
	 

/* Methods */
 function gD(k){var o=calHdl;
	 if(k==1){ return [o.today()]; } 
	// else if(k==2){var y=o.d(); y.sD(y.gDt()-1); return [y];}
	 else if(k==2){var nw=o.d(),d=nw.gD(),f=o.d(),t=o.d(); f.sD(nw.gDt()-d); t.sD(nw.gDt()+(6-d)); return [f,t]; }
	 //else if(k==4){var nw=o.d(),d=nw.gD(),f=o.d(),t=o.d(); f.sD((nw.gDt()-d)-7); t.sD(nw.gDt()-d-1); return [f,t];}
	 else if(k==3){var d=o.getDate(o.today()),f=o.d(),t=o.d(); f.sD(1); t.sD(d['days']); return [f,t];}
 }
 
 function chgCal(k){
	 calHdl.select.apply(calHdl,gD(k));
 }
 
 function calOpen(M,Y){ if(!this.ldM)this.ldM={}; var K,o=this,f=function(c){o.eachCell(function(cll){var d=cll.date; if(d[0]<10)d[0]='0'+d[0]; if(d[1]<10)d[1]='0'+d[1];if((K=c['dates'].find(d[2]+'-'+d[1]+'-'+d[0]))!==false){cll.style.color='#BA2336'; cll.title=c['names'][K];}});};
	 ge('m_d').innerHTML=this.str.months_[M-1];
	 ge('y_d').innerHTML=Y;
	 sO(function(){
	 if(!o.ldM[M+'_'+Y]){
		 toAjax({url:'ajx/get_dates.php?y='+Y+'&m='+M,func:function(c){eval('c='+c+';'); o.ldM[M+'_'+Y]=c; f(c); }});
	  }else{ 
	     f(o.ldM[M+'_'+Y]); 
		  }
	 },1);
  }
  
  function calSel(sel){if(!sel)return; var o=this,cn=ge('content'); 
     if(o.bksl && compare(sel.date,o.bksl))return;
	  o.bksl=sel.date;
     var dt=sel.date[1],df=sel.date[0],t=o.join(dt),f=o.join(df),fD=o.getDate(df),tD=o.getDate(dt),f_=fD.gT(),t_=tD.gT(),s_=0;

     for(var k=1; k<=3; k++){v=gD(k);
	    if(v.length==2){v[0]=v[0].gT(); v[1]=v[1].gT(); if((f_==v[0] && t_==v[1])||(t_==v[0] && f_==v[1])){ sPubs.change(k,true); s_=1; break; }
	   }else{ v[0]=v[0].gT(); if(f_==v[0] && t_==v[0]){sPubs.change(k,true); s_=1; break; }}
	 }
	 if(!s_){
	  sPubs.change(-1);
	   ge('seecp').innerHTML=(t==f)?
	   'Publications of '+o.str.days[fD.gD()]+', '+f:
	   'Publications of  '+o.str.days[fD.gD()]+', '+f+' to '+o.str.days[tD.gD()]+', '+t;
	 }else{
	   var s=['Today','This Week','This Month'];
	   ge('seecp').innerHTML='Publications of '+s[k-1];
	 }
	 cn.innerHTML='<span class="ld">Loading publications...</span>';
	
	  toAjax({url:'ajx/get_pubs.php?f='+f+'&t='+t,func:function(c){ eval('c='+c+';');
																		 if(c.length==0){cn.innerHTML='<span class="ld">Not found publications.</span>'; return;}
																		 var sz,url,h='<table><tr>';
																
																for(var k=0; k<c.length; k++){
																	if((k%2)===0 && k!=0){h+='</tr><tr>';}
																	
																	h+='<td valign="top" align=center class="tdpub">';
																	if(c[k]['thumb']){
																		sz=c[k]['thumb_sz'].split('x');
																	  h+='<a href="'+c[k]['url']+'"><img src="'+c[k]['thumb']+'" width="'+sz[0]+'" height="'+sz[1]+'" border=0></a><br>';
																	}
																	h+='<a href="'+c[k]['url']+'" class="tlk">'+c[k]['name']+'</a>';
																	h+='</td>';
																	}
																
																h+='</tr></table>';
																cn.innerHTML=h;}});
  }
	 
 function calA(o,k,a,e){
	 if(a==1){ if(o.nH)return;
	 o.style.backgroundColor='white';
	 o.lastChild.style.visibility='visible';
	 }else if(a==2){ if(o.nH)return;
	 o.style.backgroundColor='transparent';
	 o.lastChild.style.visibility='hidden';
	 }else if(a==3){
	  //open menu
	   if(o.ed)return;
		 if(typeof mCal=='undefined'){
	     mCal= new nwsubmn(false); 
		 mCal.eShade=false;
	     mCal.menu.onhidden=function(){ if(mCal.o_){ mCal.o_.nH=false; mCal.o_.onmouseout(); mCal.o_=null; }  return true;}
		 }
		var op=[];
		if(k==1){ for(var k=1; k<=12; k++)op.push({m:k,inner:calHdl.str.months[k-1],active:function(){return calHdl.month==this.m;},onclick:function(){calHdl.open(this.m+'-'+calHdl.year); }});
		}else{ for(var k=calHdl.year-3; k<=calHdl.year+3; k++)op.push({y:k,inner:k,active:function(){return calHdl.year==this.y;},onclick:function(){calHdl.open(calHdl.month+'-'+this.y); }});}
	
	    mCal.o_=o.parentNode; mCal.o_.onmouseover(); mCal.o_.nH=true;
	    mOutObj(function(){mCal.menu.hidden(); },[mCal.o_,mCal.menu.obj],50);
		mCal.setOptions(op,true);
		mCal.draw(o);
		
	 }else if(a==4){
		var m,y;
		if((MkEv(e).cursor.y-PosObj(o).y)<(o.offsetHeight/2)){
		  if(k==1)calHdl.open((calHdl.month==1?12:calHdl.month-1)+'-'+calHdl.year);
		  else calHdl.open(calHdl.month+'-'+(calHdl.year-1));
		}else{
		  if(k==1)calHdl.open((calHdl.month==12?1:calHdl.month+1)+'-'+calHdl.year); 
		  else calHdl.open(calHdl.month+'-'+(calHdl.year+1));
	    }
	 }else if(a==5){
	   if(typeof mCal!='undefined')mCal.menu.hidden();
	   o.parentNode.onmouseover();
	   o.ed=true; o.parentNode.nH=true;
	   editBx(o,function(value,valuep,o){o.ed=false; o.parentNode.nH=false; o.parentNode.onmouseout(); var y=i(value); if(!isNaN(y) && y>1000 && y<9999){ calHdl.open(calHdl.month+'-'+y);}else{o.innerHTML=calHdl.year; } o.parentNode.onmouseout(); });
	 }
 } 
