/* dynlite dhtml dom api - images dynamic popup object
 * peter assenov- aip solutions ltd' 2001-2009
 * @version: 2.3.02 - 2009-02-11
 */
/* environment creation if used standalone */
if(!window.dl)
{	dl={ver:2.3, dev:true, w:window, d:document};
	dl.is={tr:(dl.d.all)? 1:0}
	dl.log=['- dynamic popup initialization -'];
	dl.els=[];
	dl.el=function(id,ob)
	{	if(dl.els[id]) return dl.els[id];
		var el=dl.d.getElementById(id);
		if(!el)	{dl.error('no element with id='+id+' found','dynlite.js','dl.el()','Runtime');return 0;}
		if(ob) el.ob=ob;
		el.attr=function(attr,val)
		{	if(!val) return (attr=='class')? el.className : (!dl.is.tr&&el.hasAttribute(attr))? el.getAttribute(attr):el[attr];
			else (attr=='class')? el.className=val:el.setAttribute(attr,val,false);
		return el;
		}
		el.on=function(disp){el.style.display=disp||'block'; return el;}
		el.off=function(){el.style.display='none'; return el;}
		dl.els[id]=el;
	return el;
	}
	dl.dom={
		el:function(tag,par,attr,text)
		{	var id=(attr&&attr.id)? attr.id:dl.els.length;
			if(dl.els[id]) return dl.els[id];
			var el=dl.d.createElement(tag);
				el.id=id;
			(par)?  par.appendChild(el) : dl.d.body.appendChild(el);
			dl.log.push('# '+tag+' element with id="'+id+'" created.')
			var del=dl.el(id);
			if(attr&&typeof(attr)=='object')
				for(i in attr)
					del.attr(i,attr[i]);
			if(text) el.appendChild(dl.d.createTextNode(text));
		return del;
		},
		evt:function(_this,evt){if(_this[evt]) return (function(){return _this[evt](this);});} /* closure */
	}
	/** Event handler for mouse wheel event. 
		Thanks to Adomas Paltanavičius
		http://adomas.org/javascript-mouse-wheel/
	*/
	function wheel(event){
        var delta = 0;
        if (!event) /* For IE. */
                event = window.event;
        if (event.wheelDelta) { /* IE/Opera. */
                delta = event.wheelDelta/120;
                /** In Opera 9, delta differs in sign as compared to IE.
                 */
                if (window.opera)
                        delta = -delta;
        } else if (event.detail) { /** Mozilla case. */
                /** In Mozilla, sign of delta is different than in IE.
                 * Also, delta is multiple of 3.
                 */
                delta = -event.detail/3;
        }
        /** If delta is nonzero, handle it.
         * Basically, delta is now positive if wheel was scrolled up,
         * and negative, if wheel was scrolled down.
         */
        if (delta) {
        	if(document.activeScroll) document.activeScroll.wheel(delta);
        	if(dl.scr&&dl.scr.length) dl.scr[0].wheel(delta);
        }
        /** Prevent default actions caused by mouse wheel.
         * That might be ugly, but we handle scrolls somehow
         * anyway, so don't bother here..
         */
        if (event.preventDefault)
                event.preventDefault();
	event.returnValue = false;
}

/** Initialization code. 
 * If you use your own event management code, change it as required.
 */
if (window.addEventListener)
        /** DOMMouseScroll is for mozilla. */
        window.addEventListener('DOMMouseScroll', wheel, false);
/** IE/Opera. */
window.onmousewheel = document.onmousewheel = wheel;

}
/* scroll class */
vscroll=function(id)
{	this.id=id;
	this.el=dl.el(this.id);
	this.el.onselectstart=function(){return false};
	this.cont={t:this.el.offsetTop,l:this.el.offsetLeft,w:this.el.offsetWidth,h:this.el.offsetHeight}
	this.data={t:0,l:0,w:this.el.scrollWidth,h:this.el.scrollHeight}
/* if the content is not enough to require scrolling do nothing */
	if(this.data.h<=this.cont.h) return;
/* created elements */
	this.bar=dl.dom.el('DIV',this.el.parentNode,{'class':'bar'});
	var bs = this.bar.style;
		bs.top=this.cont.t+'px';
		bs.left=this.cont.l+this.cont.w+7+'px';
		bs.height=this.cont.h+'px';	
	this.knob=dl.dom.el('DIV',this.bar,{'class':'knob'});
	this.knob.ob=this;
	this.knob.onmousedown=function(e)
	{	if(!e) e=event; 
		this.ob.start(e); 
		dl.d.onselectstart=function(){return false; }
	};
	this.pos={ktMin:0,ktMax:(this.bar.offsetHeight-this.knob.offsetHeight)};
	this.d=(this.data.h-this.cont.h)/(this.pos.ktMax-this.pos.ktMin);
	this.wheelInc=-parseInt(15/this.d); //20 is the line height in px	
	if(!dl.scr) dl.scr=[this];
	else dl.scr.push(this);

/* public methods */
	this.start=function(e)
	{	dl.d.activeScroll = this;
		dl.d.onmousemove=function(e)
		{	if(!e) e=event; 
			if(this.activeScroll) this.activeScroll.mouse(e)};
	        if(e.stopPropagation) e.stopPropagation();
	        if(e.preventDefault)  e.preventDefault();
			e.returnValue = false;
		dl.d.onmouseup=function(e){ if(this.activeScroll) this.activeScroll.stop()};
		this.pos.okt=(dl.is.tr)? e.offsetY : e.layerY;
		this.pos.dkt=e.clientY-this.pos.okt-this.knob.offsetTop;
	}
	this.stop=function()
	{	dl.d.activeScroll = 0;
		dl.d.onselectstart=function(){return true; }
	}
	this.mouse=function(e)
	{	if(!dl.d.activeScroll) return;
		var kt=e.clientY-this.pos.dkt-this.pos.okt;
		this.move(kt);
	}
 	this.wheel=function(dw)
 	{	var kt=parseInt(this.knob.offsetTop+this.wheelInc*dw);
 		this.move(kt);
 	}
 	this.move=function(kt)
 	{	if(kt<this.pos.ktMin)
		{	kt=0;
			this.stop();
		}
		if(kt>this.pos.ktMax)
		{	kt=this.pos.ktMax;
			this.stop();
		}
		this.knob.style.top=kt+"px";
		var dy = kt*this.d;
		this.el.style.top=parseInt(this.cont.t-dy)+"px";
		this.el.style.height = this.cont.h+dy+"px";
		this.el.style.clip="rect("+dy+"px, "+this.cont.w+"px, "+(this.cont.h+dy)+"px, 0px)";
 	}
}
/* code end- enjoy... */
load.push("make('DIV')");
