var DHTML = new function() {

	this.ie = (navigator.userAgent.toLowerCase().indexOf('msie') > -1);
	this.ie6 = (navigator.userAgent.toLowerCase().indexOf('msie 6') > -1);
	this.ie7 = (navigator.userAgent.toLowerCase().indexOf('msie 7') > -1);
	this.ie8 = (navigator.userAgent.toLowerCase().indexOf('msie 8') > -1);
	this.firefox1 = (navigator.userAgent.toLowerCase().indexOf('firefox/1') > -1);
	this.firefox2 = (navigator.userAgent.toLowerCase().indexOf('firefox/2') > -1);
	this.firefox1Min = (navigator.userAgent.toLowerCase().indexOf('firefox/1.5') > -1);	
	this.firefox = (navigator.userAgent.toLowerCase().indexOf('firefox') > -1); 

	if (this.ie){
		this.currentBrowser = "Internet Explorer";
		this.browserRecommend ="Internet Explorer 8";	
	}else if (this.firefox){
		this.currentBrowser = "FireFox";
		this.browserRecommend = "FireFox 2";
	}
	
	this.getIEVersion = function(){
		var rv = -1;
		var ua = navigator.userAgent;
    	var re  = new RegExp("MSIE ([0-9]{1,}[\.0-9]{0,})");
    	
    	if (re.exec(ua) != null)
      		rv = parseFloat( RegExp.$1 );
		
		return rv;
	},
	
	this.direc = { w: 'Left', e: 'Right', n: 'Top', s: 'Bottom' };
	
	this.get = this.bind = function(e) { 
		if (!e) return null;
		if (!(e = DOM.get(e))) return null;

		OO.apply(e, this.Base);
		
		for (var superClass,index = 1;(superClass = arguments[index]);index++) {
			e.inherit(superClass);
		}
		
		e.ooInitSelf(e);
		return e;
	}

	this.create = function(type) {
		var e = document.createElement(type);
		if (!e) return null;
		
		OO.apply(e, this.Base);
		
		for (var superClass,index = 1;(superClass = arguments[index]);index++) {
			e.inherit(superClass);
		}
		
		e.ooInitSelf.apply(e);
		return e;
	}
	
	this._path = function(start, end, time, period) {
		period = period || 25;
		var time = Math.ceil(time / period);
		var period = Math.PI / (2 * time);
		var result = [];
		end -= start;
		for (var index = 0; index <= time; index++) { result.push(Math.round(end * Math.sin(period * index) + start)); }
		return result;
	}
	
	this.clientHeight = function() { return window.innerHeight || document.body.clientHeight; }
	this.clientWidth = function() { return window.innerWidth || document.body.clientWidth; }
	this.structure = function(s,h) { s.c = s.c || [ DHTML.Base ]; var r=DOM.structure(s); if (h) { DOM.get(h).appendChild(r); if (s.p) DHTML.matchEle(r, s.p, s.o); } return r; }

	var div = document.createElement('div');
	
	if (UTIL.def(div.style.pixelLeft)) { 
		this.setLeft = function(e, x) { e.style.right = null; e.style.pixelLeft = x; };
		this.setRight = function(e, x) { e.style.left = null; e.style.pixelRight = x; };
		this.setTop = function(e, y) { e.style.bottom = null; e.style.pixelTop = y; };
		this.setBottom = function(e, y) { e.style.top = null; e.style.pixelBottom = y; };
		//this.setWidth = function(e, w) { e.style.pixelWidth = w; }
		//this.setHeight = function(e, h) { e.style.height = h+'px'; }
	} else if (UTIL.def(div.style.left)) {
		this.setLeft = function(e, x) { delete e.style.right; e.style.left = x+'px'; };
		this.setRight = function(e, x) { delete e.style.left; e.style.right = x+'px'; };
		this.setTop = function(e, y) { delete e.style.bottom; e.style.top = y+'px'; };
		this.setBottom = function(e, y) { delete e.style.top; e.style.bottom = y+'px'; };
	}
	
	this.hasParent = function(e) { return ((e.parentNode != null) && (e.offsetParent != null)); }
	this.hasParentIE = function(e) { return ((e.parentElement != null) && (e.offsetParent != null)); }
	if (this.ie) this.hasParent = this.hasParentIE;

	this.X = this.divX = function(e, x) { res = (this.hasParent(e))?e.offsetLeft - e.offsetParent.scrollLeft:0; if (UTIL.def(x)) DHTML.setLeft(e, x); return res;}
	this.Y = this.divY = function(e, y) { res = (this.hasParent(e))?e.offsetTop - e.offsetParent.scrollTop:0; if (UTIL.def(y)) DHTML.setTop(e, y); return res;}
	this.getX = function(e, x) { return e.offsetLeft; }
	this.getY = function(e, y) { return e.offsetTop; }
	this.pageX = function(e, b) { var x = e.offsetLeft; while ((this.hasParent(e) && (e=e.offsetParent))&&(e!=b)) { e.__bl=e.__bl||DHTML.getStyleNum(e, 'borderLeftWidth'); x += (e.__bl+e.offsetLeft-e.scrollLeft); }; return x; }
	this.pageY = function(e, b) { var y = e.offsetTop; while ((this.hasParent(e) && (e=e.offsetParent))&&(e!=b)) { e.__bt=e.__bt||DHTML.getStyleNum(e, 'borderTopWidth');y += (e.__bt+e.offsetTop - e.scrollTop); }; return y; }
	
	this.setWidth = function(e, w) { e.style.width = Math.max(w, 0)+'px'; }
	this.setHeight = function(e, h) { e.style.height = Math.max(h, 0)+'px'; }
	this.padN = function(e, p) { alert(e.paddingTop); }
	this.getWidth = function(e) { return parseInt(e.offsetWidth, 10)-(DHTML.getStyleNum(e, 'paddingLeft')+DHTML.getStyleNum(e, 'paddingTop')); }
	this.getHeight = function(e) { return parseInt(e.offsetHeight, 10)-(DHTML.getStyleNum(e, 'paddingTop')+DHTML.getStyleNum(e, 'paddingBottom')); }
	this.W = function(e, w) {var r=this.getWidth(e); if(w)this.setWidth(e,w);return r;}
	this.H = function(e, h) {var r=this.getHeight(e); if(h)this.setHeight(e,h);return r;}
	this.moveTo = function(e, x, y) { this.setLeft(e, x); this.setTop(e, y); },
	this.moveBy = function(e, x, y) { this.moveTo(e, this.divX(e)+x, this.divY(e)+y); },
	this.sizeTo = function(e, w, h) { this.setWidth(e, w); this.setHeight(e, h); },
	this.setPos = function(e, x, y, d) { this[(d.indexOf('w')==1)?'setLeft':'setRight'](e,x); this[(d.indexOf('n')==0)?'setTop':'setBottom'](e,y); },
	this.setMargin = function(e, d, m) { e.style['margin'+this.direc[d]] = m+'px'; }
	this.setPadding = function(e, d, p) { e.style['padding'+this.direc[d]] = p+'px'; }
	this.setLinkCSS = function(l, css) { var t; if (l.styleSheet) l.styleSheet.cssText = css; else { t=document.createTextNode(css); if (l.firstChild) l.replaceChild(t,l.firstChild); else l.appendChild(t); } }
	
	this.show = function(e) { e.style.visibility = 'inherit'; }
	this.hide = function(e) { e.style.visibility = 'hidden'; }
	this.display = function(e, d) { var r = e.style.display; if (U.def(d)) e.style.display = d; return r; }
	this.position = function(e, p) { var r = e.style.position; if (U.def(p)) e.style.position = p; return r; }
	this.zIndex = function(e, z) { var r = parseInt(e.style.zIndex, 10); if (U.def(z)) e.style.zIndex = z; return r; },
	this.isVisible = function(e) { return (e&&(DHTML.getStyle(e, 'visibility')!='hidden')&&(DHTML.getStyle(e, 'display')!='none'))}
	
	this.pagePosition = function(e, b) { 
		var r=DHTML.divPosition(e); 
		try{
		while ((e=e.offsetParent)&&(e!=b)) {
			e.__bl=e.__bl||DHTML.getStyleNum(e, 'borderLeftWidth');
			e.__bt=e.__bt||DHTML.getStyleNum(e, 'borderTopWidth');
			r.x += (e.__bl+e.offsetLeft-e.scrollLeft);
			r.y += (e.__bt+e.offsetTop - e.scrollTop); 
		} 
		}
		catch(err){}
		return r; 
	}
	
//	this.pagePosition = function(e, b) { return { x: DHTML.pageX(e, b), y: DHTML.pageY(e, b), w: DHTML.getWidth(e, b), h: DHTML.getHeight(e, b) } };
	this.divPosition = function(e, b) { return { x: DHTML.divX(e), y: DHTML.divY(e), w: DHTML.getWidth(e), h: DHTML.getHeight(e) } };
	this.backgroundImage = function(e, img) { e.style.backgroundImage = 'url('+img+')'; };
	this.backgroundPosition = function(e, x, y) { e.style.backgroundPosition = x+'px '+y+'px'; };
	this.backgroundPNG = function(e, img) { e.style.backgroundColor='transparent';if (this.ie6) e.style.filter = 'progid:DXImageTransform.Microsoft.AlphaImageLoader(src=\''+img+'\',sizingMethod=\'crop\')'; else e.style.backgroundImage = 'url('+img+')'; };
	
	this.classState = function(e, s, r) { r = r || /normal|hover|selected/; e.className = e.className.replace(r, s); }
	
	this.containsPoint = function(e, x, y, t, r, b, l) { t=t||0;r=r||0;b=b||0;l=l||0;var px = this.pageX(e), py = this.pageY(e), w = this.getWidth(e), h = this.getHeight(e); return ((x >= (px-l)) && (x <= (px+w+r)) && (y >= (py-t)) && (y <= (py+h+b))); }
	
	this.qShow = function(e) { if (!U.def(e.dqShow))e.dqShow=-1; if (!++e.dqShow) this.show(e); }
	this.qHide = function(e) { if (!U.def(e.dqShow))e.dqShow=1; if (!e.dqShow--) this.hide(e); }
	
	this.isHidden = function(e) { return ((DHTML.getStyle(e, 'visibility')=='hidden')||(DHTML.getStyle(e, 'display')=='none')); }
	this.matchEle = function(e, m, o) {  
		var E = DHTML.pagePosition(e.offsetParent);
		var M = DHTML.pagePosition(m);
		o = o || { t:0,r:0,b:0,l:0 }

		DHTML.sizeTo(e, M.w+o.l+o.r, M.h+o.t+o.b);
		DHTML.moveTo(e, M.x-(E.x+o.l), M.y-(E.y+o.t));
	}
	
	this.center = function(ele, h, v, e) {
		e = DOM.get(e) || ele.offsetParent;
		if (h) { this.setLeft(ele, Math.round((this.getWidth(e) - this.getWidth(ele)) / 2)); }
		if (v) { this.setTop(ele, Math.round((this.getHeight(e) - this.getHeight(ele)) / 2)); }
	}
	
	if (UTIL.def(div.style.filter)) {
		this.setOpacity = function(e, o) { e.style.filter = 'alpha(opacity='+o+')'; };
	} else if (UTIL.def(div.style.MozOpacity)) {
		this.setOpacity = function(e, o) { e.style.MozOpacity = Math.min(o / 100, 0.9999); };
	} else {
		this.setOpacity = function(e, o) { e.style.opacity = Math.min(o / 100, 0.9999); };
	}

	this.clipToEle = function(e, f) { 
		var eX=this.pageX(e),eY=this.pageY(e),eW=this.getWidth(e),eH=this.getHeight(e);
		var fX=this.pageX(f),fY=this.pageY(f),fW=this.getWidth(f),fH=this.getHeight(f);
		e.style.clip = 'rect('+Math.max(0,fY-eY)+'px '+(eW-Math.max(0,(eX+eW)-(fX+fW)))+'px '+(eH-Math.max(0,(eY+eH)-(fY+fH)))+'px '+Math.max(0,fX-eX)+'px)';
	}
	
	this.insertAfter = function(e, a) {
		var p = a.parentNode;
		
		if (a.nextSibling) p.insertBefore(e, a.nextSibling);
		else p.appendChild(e)	
	},
	
	this.insertChild = function(e, p, i) {
		i = Math.max(0, i); 
		if (i<p.childNodes.length) p.insertBefore(e, p.childNodes[i]); else p.appendChild(e);
	},
	
	this.removeSelf = function(e) {  
		if (!e) return;
		if (!this.trashEle) this.trashEle = DOM.structure({ y: { top: '-100px', position: 'absolute', height: '1px', display: 'none' }, e: { stat: 'trashNode' } });
		if (!this.trashEle.parentNode) document.body.appendChild(this.trashEle);
		
		this.trashEle.appendChild(e);
		this.trashEle.innerHTML = '';
	}
	this.removeFromParent = function(e) {
		if (e.parentNode) e.parentNode.removeChild(e);
	},
	
	this.clearElement = function(e) { while (e.firstChild) this.removeSelf(e.firstChild); }	
	this.finalCleanup = function(e) { if (e.parentNode) this.removeSelf(e); }
	
	this.nextObject = function(e) { do {e = e.nextSibling} while (e && (e.nodeType != 1)); return e; }
	this.previousObject = function(e) { do {e = e.previousSibling} while (e && (e.nodeType != 1)); return e; }
	
	this.getStyle = function(e, rule) {
		var y, cs = e.currentStyle;
	
		if (!cs&&window.getComputedStyle) cs = ((document.defaultView)?document.defaultView.getComputedStyle(e,null):window.getComputedStyle(e, null));
		return cs[rule];
	}
	this.getStyleNum = function(e, rule) {
		var result = parseInt(this.getStyle(e, rule), 10);
		return (isNaN(result))?0:result;
	}
	this.setWidthFull = function(e, width) {
		var p = this.getStyleNum(e, 'border-left-width')+this.getStyleNum(e, 'border-right-width');
		var b = this.getStyleNum(e, 'padding-left')+this.getStyleNum(e, 'padding-right');
		this.setWidth(e, Math.max(0, width-(b+p)));
	}
	this.getWidthFull = function(e) {
		return this.getWidth(e)-(this.getStyleNum(e, 'border-left-width')+this.getStyleNum(e, 'border-right-width')+this.getStyleNum(e, 'padding-left')+this.getStyleNum(e, 'padding-right'));
	}
	
	this.setClassname = function() { 
		var idList,cn,id,ele,ids,i=0;
		while ((idList = arguments[i])&&(cn=arguments[i+1])) {
			ids = idList.split(',');
			
			while (id=ids.pop()) if (ele=DOM.get(id)) ele.className=cn;
			i+=2;
		}
	}
	
	this.style = function(ids, attr, val) {
		ids = ids.split(',');
		for (var i=0,id,e;(id=ids[i]);i++) if (e=DOM.get(id)) e.style[attr]=val;
	}
}

$STYLE = DHTML.style;

DHTML.Base = function() {
	
	this.Base = { o: 100 };
}


DHTML.Base.prototype = {
	divX: function(x) { return DHTML.divX(this, x); },
	divY: function(y) { return DHTML.divY(this, y);  },
	
	initSelf: function() {
		var oThis = this;
		this.setLeft = function(x) { DHTML.setLeft(oThis, x); };
		this.setRight = function(x) { DHTML.setRight(oThis, x); };
		this.setTop = function(y) { DHTML.setTop(oThis, y); };
		this.setBottom = function(y) { DHTML.setBottom(oThis, y); };
		this.X = this.divX;
		this.Y = this.divY;
		
		if (UTIL.def(this.style.filter)) {
			this.setOpacity = function(o) { this.Base.o = o; this.style.filter = 'alpha(opacity='+o+')'; };
		} else if (UTIL.def(this.style.MozOpacity)) {
			this.setOpacity = function(o) { this.Base.o = o; this.style.MozOpacity = Math.min(o / 100, 0.9999); };
		} else {
			this.setOpacity = function(o) { this.Base.o = o; this.style.opacity = Math.min(o / 100, 0.9999); };
		}
		
		this.CQ('X,Y,setTop,setBottom,setRight,setLeft,setOpacity');
	},
	
	W: function(w) { r = this.getWidth(); if (U.def(w)) this.setWidth(w); return r; },
	H: function(h) { r = this.getHeight(); if (U.def(h)) this.setHeight(h); return r; },
	
	hScroll: function(l) { result = this.scrollLeft; if (U.def(l)) this.scrollLeft = l; return result; },
	setWidth: function(w) { DHTML.setWidth(this, w); },
	setHeight: function(h) { DHTML.setHeight(this, h); },
	moveTo: function(x, y) { DHTML.moveTo(this, x, y); },
	moveBy: function(x, y) { DHTML.moveBy(this, x, y); },
	sizeTo: function(w, h) { DHTML.sizeTo(this, w, h); },
	setOpacity: function(o) { this.Base.o = o; DHTML.setOpacity(this, o); },

	getWidth: function() { return DHTML.getWidth(this); },
	getHeight: function() { return DHTML.getHeight(this); },
	
	setMargin: function(d, m) { return DHTML.setMargin(this, d, m); },
	setPadding: function(d, p) { return DHTML.setPadding(this, d, p); },

	getOpacity: function() { return this.Base.o; },
	
	fontSize: function(newSize) { var result = parseInt(this.style.fontSize, 10); if (typeof(newSize) != 'undefined') this.style.fontSize = newSize+'px'; return result; },
	
	center: function(h, v, e) { DHTML.center(this, h, v, e); },
	
	pageX: function(r) { return DHTML.pageX(this, r); },
	pageY: function(r) { return DHTML.pageY(this, r); },

	show: function() { DHTML.show(this); },
	hide: function() { DHTML.hide(this); },
	qShow: function() { DHTML.qShow(this); },
	qHide: function() { DHTML.qHide(this); },
	display: function(d) { return DHTML.display(this, d); },
	position: function(p) { return DHTML.position(this, p); },
	zIndex: function(z) { return DHTML.zIndex(this, z); },	

	backgroundImage: function(img) { DHTML.backgroundImage(this, img); },
	backgroundPosition: function(x, y) { DHTML.backgroundPosition(this, x, y) },
	
	classState: function(s, r) { DHTML.classState(this, s, r); },
	
	pagePosition: function() { return DHTML.pagePosition(this); },
	
	containsPoint: function(x, y, t, r, b, l) { return DHTML.containsPoint(this, x, y, t, r, b, l); },
	
	pos: function(s) { var key; for (key in s) this[key](s[key]); },
	matchEle: function(m, o) { DHTML.matchEle(this, m, o); },
	
	nextObject: function() { return DHTML.nextObject(this); },
	previousObject: function() { return DHTML.previousObject(this); },

	removeSelf: function() { DHTML.removeSelf(this); },	
	removeFromParent: function() { DHTML.removeFromParent(this); },	
	clearElement: function() { DHTML.clearElement(this); },	

	disposeSelf: function() { setTimeout(U.FN(DHTML, DHTML.finalCleanup, this), 10); }
}


DHTML.Anim = function() {
	this.Anim = { };
	this.inherit(OO.Timer);
}


DHTML.Anim.prototype = {
	
	initSelf: function() {
		this.animDeferCount = 0;
		this.F = this.fontSize;
		this.SL = this.hScroll;
		this.oX = function(offset) { if (U.def(offset)) { this.divX(this.divX()+offset); if (this._offsetX) this._offsetX(offset); } return 0;};
		this.oY = function(offset) { if (U.def(offset)) { this.divY(this.divY()+offset); if (this._offsetY) this._offsetY(offset); } return 0;};
		this.O = function(o) { r = this.getOpacity(); if (U.def(o)) this.setOpacity(o); return r; };
	},
	
	stopAnimation: function() {
		this.clearTimeout('animate');
		this.clearInterval('animate');
		this.Anim = null;
	},
	
	stopDelay: function() {
		if (!this.Anim.started) {
			this.clearTimeout('animate');
			this.clearInterval('animate');
			this.Anim = null;
		}
	},
	
	animate: function(s, t, d, fn, param) {
		this.stopAnimation();
		if (d) { this.setTimeout('animate', d, this.animate, s, t, 0, fn, param); this.animDeferCount++; return; }
		this.Anim = { current: 0, direc: 1, paths: { }, fn: fn, param: param };
		var key;
		for (key in s) { 
			this.Anim.paths[key] = DHTML._path(this[key](), s[key], t);  
			if ((key == 'oX') || (key == 'oY')) {
				var total = 0;
				for (index = 0; index < this.Anim.paths[key].length; index++) {
					this.Anim.paths[key][index] -= total;
					total += this.Anim.paths[key][index];
				}
			}
		}
		
		this.setInterval('animate', 25, this._animate);
	},
	
	reverse: function(fn) {
		if (this.Anim) {
			this.Anim.direc = -1;
			this.Anim.fn = fn;
		} else {
			this.stopAnimation();
		}
	},
	
	_animate: function() {
		var val;
		if (!this.Anim) return this.clearInterval('animate');
		this.Anim.started = true;
		for (key in this.Anim.paths) {	
			if (!U.def(val = this.Anim.paths[key][this.Anim.current])) { 
				this.clearInterval('animate');
				if (this.Anim.fn) this.Anim.fn.call(this, this.Anim.param);
				this.Anim = null;
				return; 
			}
			this[key](val);
		}
		this.Anim.current += this.Anim.direc;
	}
}

DHTML.Event = function() {
	this.Events = {  }
}

DHTML.Event.prototype = {
	EventHandler: function(e) {
		e = EVENT._event(e);
		var list; 
		if (!(list = this.Events[e.type])) return;
		
		for (var h,i=0;(h = list[i]);i++) if (h.call(this, e)==false) return false;
	},
	
	addListener: function(type, fn) {
		this['on'+type] = this.EventHandler;
		(this.Events[type] = this.Events[type] || [ ]).unshift(fn);
	}
}

DHTML.Drag = function() {
	this.inherit(DHTML.Anim);
}
DHTML.Drag.prototype = {

	initSelf: function() {
		this.Drag = { active: false, clone: null, constrain: null, enabled: true };
		EVT.attach(this, 'mousedown', this._dragMousedown, this);
		this.ctrlKey=0;
		
		this.CQ('Drag,dragHandleFor');
	},
	
	setClone: function(clone) { this.Drag.clone = DOM.get(clone);	},
	setDragHandle: function(handle) { this.Drag.handle = handle; },
	enableDrag: function() { this.Drag.enabled = true; },
	disableDrag: function() { this.Drag.enabled = false; },	
	setScroll: function(scrollEle, withinScroller) { 
		this.Drag.scrollEle = DHTML.bind(scrollEle); 
		this._withinScroller = withinScroller;
	},
	
	setConstrain: function(constrainEle, t, r, b, l) {
		this.Drag.constrainDelta = { t: (t) ? t : 0, r: (r) ? r : 0, b: (b) ? b : 0, l: (l) ? l : 0 };
		this.Drag.constrainEle = constrainEle;
	},
	
	_dragMousedown: function(e) {
		var oThis = this;
		
		if (DHTML.Drag.Dragging) return;
		if (!this.Drag.enabled) return;

		if (!this.testDrag()) return;
		if (this.Drag.active) return;
		if (!this.testDragTarget(e.target)) return;
		this.Drag.init = {	event: e, startX: e.pageX, startY: e.pageY, moveCount: 0,
								mousemove: EVT.attach(this, 'mousemove', this._dragInit),
								mouseup: EVT.attach(this, 'mouseup', this._dragAbort) };
		return false;
	},
	
	testDrag: function() { return true; },
	
	_dragInit: function(e) { 
		this.Drag.init = this.Drag.init || { event: 0, moveCount: 2, mousemove: 0, mouseup: 0, startX: e.pageX+10, startY: e.pageY+10 };
		if ((++this.Drag.init.moveCount)<2) return;
		e = this.Drag.init.event || e;
		var oThis = this;
		var scroll = (this.Drag.scrollEle&&!this._withinScroller);
		
		EVT.remove(this.Drag.init.mousemove);		
		EVT.remove(this.Drag.init.mouseup);		
		if (this.Drag.clone) { 
			this.Drag.clone._cloneDrag(this, e);
			
			EVENT.stopAll(e);
			return false;
		}
		
		this.Drag.dragHandle = e.target; 
		this.Drag.start = { x: this.X(), y: this.Y(), h: this.H(), w: this.W(), mX: e.pageX, mY: e.pageY, sL: 0, sT: 0 }; 
		this.Drag.delta = { x: 0, y: 0 };
		this.Drag.scroll = { t: (scroll)?scroll.scrollTop:0, l: (scroll)?scroll.scrollLeft:0 }
		this.Drag.current = U.copy(this.Drag.start);
		this.Drag.actual = U.copy(this.Drag.start);

		this.Drag.events = {	mousemove: EVT.attach(this, 'mousemove', this._dragMousemove),
								mouseup: EVT.attach(this, 'mouseup', this._dragMouseup) };
		this.setDragConstraints();
		this.onDragStart();
		
		this.Drag.active = true;
		DHTML.Drag.Dragging = true;
		
		return false;
	},
	
	_dragAbort: function() {
		EVT.remove(this.Drag.init.mousemove);
		EVT.remove(this.Drag.init.mouseup);
		this.Drag.init = { };
		DHTML.Drag.Dragging = false;
	},
	
	_dragMousemove: function(e) { 
		var sT,sL,scr = this.Drag.scrollEle;
		
		if (!this.Drag.active) return;
		if (scr) { sL = scr.scrollLeft; sT=scr.scrollTop; }
		dX = e.pageX - this.Drag.current.mX;
		dY = e.pageY - this.Drag.current.mY;
		
		this.Drag.actual.x  = (this.Drag.current.x += dX)+this.Drag.current.sL; 
		this.Drag.actual.y  = (this.Drag.current.y += dY)+this.Drag.current.sT;
		this.Drag.delta.x = (this.Drag.actual.x - this.Drag.start.x);
		this.Drag.delta.y = (this.Drag.actual.y - this.Drag.start.y);
		this.Drag.current.mX = e.pageX;
		this.Drag.current.mY = e.pageY;

		this._dragConstrain();
		this.Drag.delta.x = (this.Drag.actual.x - this.Drag.start.x);
		this.Drag.delta.y = (this.Drag.actual.y - this.Drag.start.y);
		
		this.onDrag();
		this.onDragMove();
		if (scr) {
			if (!this._withinScroller) {
				this.Drag.current.sL-=(sL-scr.scrollLeft);
				this.Drag.current.sT-=(sT-scr.scrollTop);
			}
			this._scrollCheck();
		}
		return false;
	},
	
	_dragMouseup: function(e) {
		EVT.remove(this.Drag.events.mousemove);
		EVT.remove(this.Drag.events.mouseup);
		this.clearInterval('dragging');
		this.clearInterval('scrolling');

		this.ctrlKey = e.ctrlKey; //record if the control key was being held at the end of the drag
		
		this.Drag.active = false;
		this.onDragEnd();

		DHTML.Drag.Dragging = false;
		
		EVT.killNextClick();
		
		return false;
	},

	_dragConstrain: function() {
		if (this.Drag.constrain) {
			this.Drag.actual.x = Math.max(this.Drag.constrain.minX, Math.min(this.Drag.constrain.maxX, this.Drag.actual.x));
			this.Drag.actual.y = Math.max(this.Drag.constrain.minY, Math.min(this.Drag.constrain.maxY, this.Drag.actual.y));
		}
	},
	
	_offsetX: function(offset) { if (this.Drag.current) this.Drag.current.x += offset; },
	_offsetY: function(offset) { if (this.Drag.current) this.Drag.current.y += offset; },
	
	_cloneDrag: function(ele, e) {
		this.Drag.dragEle = ele;
		this.Drag.init = ele.Drag.init;
		this.innerHTML = '';
		this.appendChild(ele.cloneNode(true));
		this.firstChild.id = '';
		this.matchEle(ele);
		this.show(this);
		this._dragInit(e);
	},
	
	_scrollCheck: function(indirect) {
		if (!this.Drag || !this.Drag.active) return;
		var s = this.Drag.scrollEle;
		var sW = s.getWidth(), sH = s.getHeight();
		var px = s.pageX(), py = s.pageY();
		var t =  this.Drag.current.mY - py, l =  this.Drag.current.mX - px;
		var b =  py + sH - this.Drag.current.mY, r =  px + sW - this.Drag.current.mX;
		var sT = s.scrollTop, sL = s.scrollLeft;
		var dx=0, dy=0;

		if (t < 20) s.scrollTop-= (dy=20-Math.max(t, 0));
		else if (b < 20) s.scrollTop -= (dy=Math.max(b, 0)-20);
		if (l < 20) s.scrollLeft -= (dx=20-Math.max(l, 0))
		else if (r < 20) s.scrollLeft -= (dx=Math.max(r, 0)-20);
		
		if (!this._withinScroller) {
			this.Drag.current.sL-=(sL-s.scrollLeft);
			this.Drag.current.sT-=(sT-s.scrollTop);
		}
		if (indirect) this._dragMousemove(EVT._current);
		
		if (sT | sL) this.setTimeout('_scrollCheck', 100, this._scrollCheck, true);
	},
	
	onDragMove: function() { this.moveTo(this.Drag.actual.x, this.Drag.actual.y); },
	onDrag: function() { },
	onDragStart: function() { },
	onDragEnd: function() { },

	testDragTarget: function(t) { 
		if (!t) return false;
		if (t.noDrag) return false;
		if (t.dragHandleFor == this) return true;
		if (this.Drag.handle) { 
			if (t == this) return false;
			if (t == this.Drag.handle) return true;
			return this.testDragTarget(t.parentNode);
		}
		if (t == this) return true;
		
		return this.testDragTarget(t.parentNode);
	},
	
	setDragConstraints: function() {
		var ce = this.Drag.constrainEle;
		if (ce) {
			var d = this.Drag.constrainDelta;
			var x = DHTML.pageX(ce) - DHTML.pageX(this.offsetParent);
			var y = DHTML.pageY(ce) - DHTML.pageY(this.offsetParent);
			this.setConstraintRect(y + d.t, x + DHTML.getWidth(ce) - d.r, y + DHTML.getHeight(ce) - d.b, x + d.l);
		} else {
			this.setConstraintRect(0, DHTML.clientWidth(), DHTML.clientHeight(), 0);
		}
	},
	
	setConstraintRect: function(minY, maxX, maxY, minX) {
		this.Drag.constrain = { minX: minX, minY: minY, maxX: maxX - this.W(), maxY: maxY - this.H() };
	},
	
	disposeSelf: function() {
		this.Drag = null;
	}
}
	
DHTML.PageResizer = function() {
	this.inherit(OO.Timer, OO.Broadcaster);
	this.Page = { width: 0, height: 0 };
	}
DHTML.PageResizer.prototype = {
	initSelf: function(controller) {
		this.setInterval('pageResizeCheck', 200, this._resizePage);
		this.addListener(controller); 
	},
	
	_resizePage: function() {
		var width = DHTML.clientWidth();
		var height = DHTML.clientHeight();

		if ((width == this.Page.width) && (height == this.Page.height)) return;
	
		this.Page.width = width;
		this.Page.height = height;
		this.sendMessage('pageResized', { width: width, height: height } );
	}
}

DHTML.EditField = function() {
	this.inherit(OO.Timer);
}

DHTML.EditField.prototype = {
	initSelf: function() {
		this.clickEvent = EVT.attach(this, 'dblclick', this.editMode, this);
		this.inEditMode = false;
		this.disabledMode = false;
		this.allowEmptyText = true;
		this.useClassName = 'editField';
	},

	checkPress:function(e){
	
		var unicode=e.charCode? e.charCode : e.keyCode
				
		if (unicode == 13){
			this.parent.blurFN();
		}else if (unicode == 27){
			this.parent.cancelEdit();
		}
		
	},
		
	addCallback: function(fn ,o) {
		this.callback = { o: o || this, fn: fn }
	},
	
	checkBlur: function(e) {
		if (e.target != this.input) this.blurFN();	
		else return false;	
	},
	
	editMode: function(e) { 
		if (this.inEditMode || this.disabledMode) return;

		this.blurFN();
		
		if (DHTML.ie){
			this.fContent= this.innerText;
			this.beforeEdit = this.innerText;
		}else{
			this.fContent= this.textContent;
			this.beforeEdit = this.textContent;
		}
		
		this.input = DOM.structure( { t: 'input', e: {id:"editInputBox", className: this.useClassName, value: this.fContent, onblur: this.blurFN, noDrag: 1 } });
		this.parentNode.replaceChild(this.input, this);
		this.input.parent = this;
		this.keyEvent = EVT.attach(this.input, 'keyup', this.checkPress, this.input);
		this.blurEvent = EVT.attach(this, 'click', this.checkBlur);
		
		/* there is an annoying bug with firefox (https://bugzilla.mozilla.org/show_bug.cgi?id=236791)
		   that causes an error message when changing focus or select etc - workaround is to disable 
		   autocomplete */
		var tmp;
		tmp = document.getElementById("editInputBox");
		tmp.setAttribute('autocomplete', 'off');
		HELPERS.enableSelection(tmp);		
		this.input.select();
		tmp.select(); /* get select working in IE */
		this.inEditMode = true;
		
		DHTML.currentEdit = this;
		
		/* added if (e) to front to allow me to run this without having to have e.*/
		if (e) return false;
	},
	
	blurFN: function() { //alert(1);
		if (DHTML.currentEdit) DHTML.currentEdit.doBlur();
	},
	
	doBlur: function(confirm) {
		this.normalMode();
		if (this.callback) this.callback.fn.call(this.callback.o);
		DHTML.currentEdit = null;
	},
	
	normalMode: function(e) {
		if (!this.inEditMode) return;
		
		if (this.allowEmptyText)
			this.innerHTML = this.fContent = this.input.value;
		else if (!this.allowEmptyText && this.input.value != "")
			this.innerHTML = this.fContent = this.input.value;
			
		this.input.parentNode.replaceChild(this, this.input);
		this.input.parent = null;
		this.input = null;
		this.inEditMode = false;
		EVT.remove(this.keyEvent);
		EVT.remove(this.blurEvent);
	},
	
	cancelEdit: function(e) {
		if (!this.inEditMode) return;
		
		this.innerHTML = this.fContent = this.beforeEdit;
		
		this.input.parentNode.replaceChild(this, this.input);
		this.inEditMode = false;
		EVT.remove(this.keyEvent);
	},
	
	disable: function(d) { this.disabledMode = true; },
	enable: function(d) { this.disabledMode = false; },
	
	disposeSelf: function() {
		EVT.remove(this.clickEvent);
		this.callback = null;
	}
}


PNG = {
	create: function(src, w, h, alt, className) {
		var imgSpec = { src: src };
	
		if (U.def(w)) imgSpec.width = w;
		if (U.def(h)) imgSpec.height = h;
		if (U.def(alt)) imgSpec.alt = alt;
		if (U.def(className)) imgSpec.className = className;
		
		return this.createPNG(imgSpec);
	},
	
	bind: function(id) {
		var img = DOM.get(id);
		
		if (!img) return null;
		
		if (DHTML.ie6) { 
			img.onreadystatechange = this.onReadyStateChange;
			if (img.readyState == 'complete') img.onreadystatechange();
		}
		
		return img;
	},
	
	createPNG_moz: function(imgSpec) {
		return DOM.structure({ t: 'img', e: imgSpec });
	},
		
	createPNG_ie6: function(imgSpec) {
		imgSpec.onreadystatechange = PNG.onReadyStateChange;

		return result = DOM.structure({ t: 'img', e: imgSpec });
	},
	
	onReadyStateChange: function() {
		if (this.readyState != 'complete') return;
		if (this.src.indexOf('.png') == -1) return;
		var img = DOM.structure({ t: 'img', e: { src: this.src } });
		
		this.src = '/_fc/images/spacer.gif';
		this.style.filter = 'progid:DXImageTransform.Microsoft.AlphaImageLoader(src=\''+img.src+'\',sizingMethod=\'scale\');';
		this.style.width = img.width+'px';
		this.style.height = img.height+'px';
	}
	
}
PNG.createPNG = (DHTML.ie6) ? PNG.createPNG_ie6 : PNG.createPNG_moz;

	/*this.png = function(src, w, h, alt, className) {
		var imgSpec = { src: (this.ie6) ? '/_fc/images/spacer.gif' : src, setSrc: this.setPNGSrc };
		
		if (U.def(w)) imgSpec.width = w;
		if (U.def(h)) imgSpec.height = h;
		if (U.def(alt)) imgSpec.alt = alt;
		if (U.def(className)) imgSpec.className = className;

		var result = DOM.structure({ t: 'img', e: imgSpec });
				
		if (this.ie6) {
			DHTML.hide(result);
			//result.onload = this.updateIEPng;
			setTimeout(U.FN(result, result.setSrc, src), 10);
			//result.setSrc(src);
			//DHTML.hide(result);
		}
		return result;
	}
	if (this.ie6) { 
		this.setPNGSrc = function(src) { 
			var imgSpec = { src: src,
							id: this.id,
							alt: this.alt,
							title: this.title,
							onload: DHTML.updateIEPng,
							setSrc: DHTML.setPNGSrc,
							parentImg: this
						}
			
			if (this.replacementImg) this.replacementImg.parentImg = null;
			this.src = '/_fc/images/spacer.gif';
			
			this.replacementImg = DOM.structure({ t: 'img', e: imgSpec });
		}
			
		this.updateIEPng = function() {
			var img = this.parentImg;
			if (!img) return;
			
			//alert(this.width+'x'+this.height+' - '+this.src);
			img.src = '/_fc/images/spacer.gif';
			img.style.width = this.width+'px';
			img.style.height = this.height+'px';
			img.style.display = 'inline-block';
			img.style.visibility = 'visible';
			img.style.filter = 'progid:DXImageTransform.Microsoft.AlphaImageLoader(src=\''+this.src+'\',sizingMethod=\'crop\');'
			this.parentImg = null;
		}
	} else {
		this.setPNGSrc = function(src) { this.src = src; }
	}
	
*/