﻿//debug.innerHTML+="<br/>"+map.length+":"+keys.toString(16);

/*  kelex Web Page Control Engine, version 2.0
 *  (c) 2008-2009 hechao
 *
 *  web site: http://www.kelex.net.cn/
 *  QQ:345056712
 *  e-mail:345056712@qq.com
/*--------------------------------------------------------------------------*/

/*********************************************************************************************
☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆内置方法☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆
*********************************************************************************************/

/*
*createElement
*根据提供的模板对象创建页面元素
*@param o - 指定模板元素
*@return 创建后的网页元素对象
*/
function $(id){
	var e=null;
	if (arguments.length > 1){
		for (var i = 0, e = [], length = arguments.length; i < length; i++)
			e.push($(arguments[i]));
	}else if ($$str(id)){
		e = Element.extend($d().getElementById(id));
	}
	return e;
};

function $c(json){
	var e=Element.extend($d().createElement(json.tagName),kelex.dom.Element);
	for(var p in json){
		if("tagName"!=p){
			if("style"==p){
				e.setStyle(json[p]);
			}else{
				e[p]=json[p];
			}
		}
	}
	return e;
};
function $d(e){return e?$w(e).document:document};
function $w(e){return e?Window.extend(e.contentWindow):window};
function $num(a){return Number(a)};
function $str(s){return String(s)};
function $$obj(a){return null==a?false:"object"==typeof a};
function $$fun(a){return "function"==typeof a};
function $$arr(a){return a instanceof Array};
function $$str(a){return "string"==typeof a};
function $$id(a){return $$num(a) && 0<a};
function $$num(a){return "number"==typeof a};
function $$int(a){return parseInt(a)===a}
function $$def(a){return "undefined" != typeof a};

var kelex={
	version:"kelex v2.0",
	w3c:!$$def(window.ActiveXObject),
	trident:/Trident\//.test(navigator.userAgent) || /MSIE/.test(navigator.userAgent),
	gecko:/Gecko\//.test(navigator.userAgent),
	presto:/Presto\//.test(navigator.userAgent),
	khtml:/Konqueror|Safari|KHTML/.test(navigator.userAgent),
	sic:{},
	dom:{form:{}},
	tween:{},
	util:{}
};

kelex.Object={
	pack:"kelex",
	cls:"Object",
	/*
	*终态数据寄存器
	*/
	final:{offset:kelex.w3c?0:/MSIE 8.0/.test(navigator.userAgent)?2:0},
	/*
	*静态数据寄存器
	*/
	static:null,
	/**
	*句柄寄存器
	*/
	cache:null,
	/*
	*事件回调寄存器
	*/	
	invoke:null,
	/**
	*值寄存器
	*/
	value:null,
	newInvoke:function(a){
		var o={};
		for(var i=0;i<a.length;i++)
			o[a[i]]=null;
		return o;
	},
	setListener:function(key,method){
		var om=this.invoke[key];
		this.invoke[key]=method;
		return om;
	},
	invokeListener:function(k,t,e){
		var iv=this.invoke;
		return $$obj(iv[k])&&$$fun(iv[k][k])?iv[k][k](this,t,e):$$fun(iv[k])?iv[k](this,t,e):true;
	},
	getListener:function(k){
		return this.invoke[k];
	},
	initialize:function(){this.Super(arguments);},
	getClass:function(){return this.pack+"."+this.cls;},
	Super:function(as){this.Init(as);},
	Init:function(as){return;}
};

var Class = {
	create: function(){
		return function(){
			this.initialize.apply(this, arguments);
		}
	}
};

Object.extend = function(destination, source) {
	if(!!destination && !!source)
		for (var property in source)
			destination[property] = source[property];
	return destination;
};
Object.refactor = function(destination, source) {
	if(!!destination && !!source)
		for(var property in source)
			!(property in destination)&&(destination[property]=source[property]);
	return destination;
};

Object.extend(Array.prototype,{
	each:function(fun){
		for(var i=0;i<this.length;i++)
			fun(this[i]);
	},
	checkLength:function(min,max){
		var len=this.length;
		return !(min>len||max<len);
	},
	indexOf:function(e){
		for(var i=0;i<this.length;i++) if(e==this[i]) return i;
		return -1;
	},
	remove:function(e){
		var i=this.indexOf(e);
		return -1<i?this.splice(i,1):null;
	},
	clone:function() {
		return [].concat(this);
	}
});

Object.extend(Object,{
  keys: function(obj) {
    var k = [];
    for (var p in obj)
      k.push(p);
    return k;
  },
  values: function(obj) {
    var v = [];
    for (var p in obj)
      v.push(obj[p]);
    return v;
  }
});

Object.extend(String,{
	regexp:{
		url:/^((http|https|mms|ftp|rtsp|pnm|ssl|sftp):\/\/((\w+\.)+\w+)(:\d+)?(\/[^\/?*"<>|]+)*\/*\??(.+=.*&*)*)$/,
		phone:/^(((\d{3,4}-)\d{7,8})|([02356789]\d{6,7}))$/,
		mobile:/^1\d{10}$/,
		mail:/^[a-zA-Z0-9]+\w*[a-zA-Z0-9]@\w{2,}.(((com|net|org|gov)(.cn)?)|cn|name|mobi|biz|cc|tv|hk|info)$/,
		account:/^[a-zA-Z]+\w*[a-zA-Z0-9]$/,
		password:/^[a-zA-Z0-9]{6}$/
	}
});

Object.extend(String.prototype,{
	checkLength:function(min,max){
		var len=this.length;
		return !(min>len || max<len);
	},
	checkLengthb:function(min,max){
		var len=this.sizeof();
		return !(min>len || max<len);
	},
	sizeof:function(){
		var l=0;
		for(var i=0;i<this.length;i++)
			l+=(this.charCodeAt(i)>255?2:1);
		return l;
	},
	beheaded:function(i){		
		return this.substring(i,this.length);
	},
	save:function(i){
		return this.substring(0,i);
	},
	startsWith:function(s){
		return s==this.substring(0,s.length);
	},
	trim:function(){
		return this.replace(/^\s+/,"").replace(/\s+$/,"");
	},
	toArray:function(s){
		return this.split(String(s)?s:"");
	},
	toTag:function(t){
		return $c({tagName:t,innerHTML:this});
	},
	toNum:function(){
		return $num(this);
	},
	getKey:function(){
		var i=this.indexOf("=");
		return -1<i?this.save(i):this;
	},
	getValue:function(){
		var i=this.indexOf("=");
		return -1<i?this.beheaded(++i):"";
	}
});

kelex.dom.Document={
	extended:true,
	first:function(){
		return Element.extend(this.firstChild);
	},
	last:function(){
		return Element.extend(this.lastChild);
	},
	removeAll:function(){
		while(this.childNodes[0])
			this.removeChild(this.childNodes[0]);
	},
	cleanWhitespace:function(){
		var nextNode,node = this.firstChild;
		while(node){
		  nextNode=node.nextSibling;
		  if(node.nodeType == 3 && !/\S/.test(node.nodeValue))
			this.removeChild(node);
		  node = nextNode;
		}
		return this;
	},
	childElements:function(){
		var elements=[];
		for(var i=0,nodes=this.childNodes;i<nodes.length;i++)
			if(1==nodes[i].nodeType) elements.push(Element.extend(nodes[i]));
		return elements;
	},
	insertAfter:function(n,r){
		return (this==r.parentNode)?r.insertNext(n):null;
	},
	addEvent:function(k,m,b){
		this.attachEvent?this.attachEvent("on"+k,m):this.addEventListener(k,m,b);
	},
	removeEvent:function(k,m,b){
		this.detachEvent?this.detachEvent("on"+k,m):this.removeEventListener(k,m,b);
	}
};

kelex.dom.Element={
	getStyle:function(s){
		var v=this.style[s];
		if("opacity"==s){
			if(v) return parseFloat(v);
			if(v = (this.style.filter || '').match(/\d+/))
				if(v[1]) return parseFloat(v[1]) / 100;
			v=1.0;
		}else if("cssFloat"==s){
			if(!v) v=this.style["styleFloat"];
		}
		return v;
	},
	setStyle:function(s){
		var v;
		for(var n in s){
			v=s[n];
			if(!$$def(this.style[n])){
				if("opacity"==n){
					this.style.filter=(1>v && 0<=v?"alpha(opacity="+(100*v)+")":"");
					continue;
				}else if("cssFloat"==n){
					this.style.cssFloat=v;
					continue;
				}
			}
			this.style[n]=v;
		}
	},
	center:function(e){
		this.setStyle({position:"absolute"});
		this.left(e.offsetWidth/2-this.getWidth()/2+e.getBoundingClientRect().left);
	},
	middle:function(e){
		this.setStyle({position:"absolute"});
		this.top(e.offsetHeight/2-this.getHeight()/2+e.getBoundingClientRect().top);
	},
	out:function(){
		var parent=this.parentNode;
		parent && parent.removeChild(this);
	},
	parent:function(){
		return Element.extend(this.parentNode);
	},
	next:function(){
		return Element.extend(this.nextSibling);
	},
	previous:function(){
		return Element.extend(this.previousSibling);
	},
	insertPrevious:function(n){
		return this.parentNode.insertBefore(n,this);
	},
	insertNext:function(n){
		var next=this.nextSibling;
		return !next?this.parentNode.appendChild(n):next.parentNode.insertBefore(n,next);
	},
	getWidth:function(){
		return this.style.width.toNum() || this.offsetWidth;
	},
	setWidth:function(w){
		if($$num(w) && 0<w)
			this.style.width=w+"px";
	},
	getHeight:function(){
		return this.style.height.toNum() || this.offsetHeight;
	},
	setHeight:function(h){
		if($$num(h) && 0<h)
			this.style.height=h+"px";
	},
	getRect:function(){
		return this.getBoundingClientRect();
	},
	left:function(d){
		return this.boundProperty(d,"left");
	},
	top:function(d){
		return this.boundProperty(d,"top");
	},
	bottom:function(d){
		return this.boundProperty(d,"bottom");
	},
	right:function(d){
		return this.boundProperty(d,"right");
	},
	boundProperty:function(d,p){
		return $$num(d)?d||(this.style[p]=d+"px"):this.getBoundingClientRect()[p];
	},
	move:function(x,y){
		this.left(x);
		this.top(y);
	},
	visible:function(b){
		return "none"!=this.style.display;	
	},
	show:function(){
		this.style.display="";
	},
	hide:function(){
		this.style.display="none";
	}
};
Object.extend(kelex.dom.Element,kelex.dom.Document);

kelex.dom.form.Serializers={
	input:function(element){
		switch (element.type.toLowerCase()) {
			case 'checkbox':
			return this.multipleSelector(element.name);
			case 'radio':
			return this.singleSelector(element.name);
			default:
			return this.textarea(element);
		}
	},
	singleSelector:function(name){
		var elements=$d().getElementsByName(name);
		for(var i=0;i<elements.length;i++)
			if(elements[i].checked)
				return elements[i].value;
		return null;
	},
	multipleSelector:function(name){
		var values=[],elements=$d().getElementsByName(name);
		for(var i=0;i<elements.length;i++)
			elements[i].checked&&values.push(elements[i].value);
		return values;
	},
	textarea:function(element){
		return element.value;
	},
	select:function(element){
		return this[element.type == 'select-one' ?
		  'selectOne' : 'selectMany'](element);
	},
	selectOne: function(element) {
		var index = element.selectedIndex;
		return index >= 0 ? element.options[index].value : null;
	},
	selectMany: function(element) {
		var values=[], length = element.length;
		if (!length) return null;
		for (var i = 0; i < length; i++) {
			var opt = element.options[i];
			if (opt.selected) values.push(opt.value);
		}
		return values;
	}
};

kelex.dom.form.Element={
	getValue:function(){
		var method=this.tagName.toLowerCase();
		return kelex.dom.form.Serializers[method](this);
	}
};

if(!Window)
	var Window=new Object();

Window.extend=function(wind){
	if(!wind.extended){
		Object.extend(wind,{
			extended:true,
			getSelection:function(){
				var selection=this.document.selection;
				!selection.extended && Object.extend(selection,{
					extended:true,
					KELEX_RANGE_CACHE:null,
					KELEX_TEXT_RANGE_CACHE:null,
					rangeCount:0,
					getRangeAt:function(i){
						var copyRange;
						var range=this.KELEX_RANGE_CACHE;
						var tRange=this.KELEX_TEXT_RANGE_CACHE;
						if("Control"==this.type){
							if(range.length<i || 0>i)
								throw "Kelex engine returned failure:out of range size";
							copyRange=getControlRange(range,i);
						}else{
							copyRange=getTextRange(range,tRange);
						}
						
						!copyRange.extended && Object.refactor(copyRange,{
							extended:true,
							select:function(){
								range.select();
							},
							pasteHTML:function(html){
								try{
									if("Control"==selection.type){
										tRange.moveToElementText(range.item(0));
										range=tRange;
									}
									range.pasteHTML(html);
									return true;
								}catch(e){
									alert("区域转换错误。");
									return false;
								}
							}
						});
						
						/**
						*得到指定的节点在其父节点中的索引位置
						*/
						function getControlRange(range,index){
							var j=0;
							var child=range.item(index);
							var parent=child.parentNode;
							var childs=parent.childNodes;
							for(;j<childs.length;j++)
								if(childs[j]==child)
									break;
							return {
								startContainer:parent,
								startOffset:j,
								endContainer:parent,
								endOffset:j+1
							}
						};
						
						/**
						*获取选区在IE下的 Range 对象。... 
						*@return 选区在IE下的 Range 对象。
						*/
						function getTextRange(range,tRange){
							var sl,el,len,mask;
							len=range.text.replace(/\r/g,"").length;
							mask=range.getBookmark();
							range.collapse(true);
							if(!!(sl=createLocator(range,tRange))){
								range.moveToBookmark(mask);
								range.select();
								if(0==len){
									el=sl;
								}else{
									range.collapse(false);
									range.select();
									el=createLocator(range,tRange);
									range.moveToBookmark(mask);
									range.select();
								}
								if(!!el){
									return {
										startContainer:sl.container,
										startOffset:sl.offset,
										endContainer:el.container,
										endOffset:el.offset
									}
								}
							}
							return null;
						};
						
						/**
						*创建临时光标插入点从而捕获光标当前位置的信息。
						*@return 光标当前位置的信息。
						*/
						function createLocator(range,tRange){
							var next,previous,child,containe;
							var i=0,off=-1;
							var id='TEMP$NODE';
							var parent=range.parentElement();
							if(pasteHTML(range,tRange,"<CODE id="+id+" />")){
								var childs=parent.childNodes;
								for(;i<childs.length;i++){
									if(id==childs[i].id && "CODE"==(child=childs[i]).tagName){
										next=child.nextSibling;
										previous=child.previousSibling;
										child.parentNode.removeChild(child);
										if(!!next && 3==next.nodeType){
											if(!!previous && 3==previous.nodeType){
												off=previous.nodeValue.length;
												containe=previous;
												previous.nodeValue+=next.nodeValue;
												next.parentNode.removeChild(next);
											}else{
												off=0;
												containe=next;
											}
										}else{
											if(!!previous && 3==previous.nodeType){
												off=previous.nodeValue.length;
												containe=previous;
											}else{
												off=0,
												containe=parent;
											}
										}
									}
								}
								return {
									container:containe,
									offset:off
								}
							}else{
								return null;
							}
						};
						
						/**
						*向当前选区中添加指定的 html 代码，并替换选区中的内容。
						*@param s - 要添加在当前选区中的 html 代码。
						*/
						function pasteHTML(range,tRange,html){
							try{
								if("Control"==selection.type){
									tRange.moveToElementText(range.item(0));
									range=tRange;
								}
								range.pasteHTML(html);
								return true;
							}catch(e){
								alert("区域转换错误。");
								return false;
							}
						};
						return copyRange;
					}
				});
				var range=selection.createRange();
				selection.rangeCount=("None"==selection.type?0:1);
				selection.KELEX_RANGE_CACHE=range;
				selection.KELEX_TEXT_RANGE_CACHE=this.document.body.createTextRange();
				return selection;
			}
		}
		);
	}
	
	if(!wind._getSelection){
		wind._getSelection=wind.getSelection;
		Object.extend(wind,{
			getSelection:function(){
				var selection=this._getSelection();
				if(!selection._getRangeAt){
					selection._getRangeAt=selection.getRangeAt;
					Object.extend(selection,{
						getRangeAt:function(i){
							var range=this._getRangeAt(i);
							!range.extended && Object.extend(range,{
								select:function(){return;}
							});
							return range;
						}
					});
				}
				return selection;
			}
		});
	}
	
	var doc=wind.document;
	
	if(!doc.extended)
		Object.extend(doc,kelex.dom.Document);
	
	if(!doc._execCommand || !doc.editable){
		doc._execCommand=doc.execCommand;
		Object.extend(doc,{
			KELEX_WINDOW_CACHE:null,
			editable:function(b){
				kelex.w3c?(this.designMode=(b?"on":"off")):(this.body.contentEditable=b);
			},
			execCommand:function(com,show,value){
				var command=com.toLowerCase();
				switch(command){
					case "inserthtml":
						var range;
						if(!!(range=this.KELEX_WINDOW_CACHE.getSelection().KELEX_RANGE_CACHE))
							return range.pasteHTML(value);
					break;
					case "refresh":
						return this.body.innerHTML=kelex.w3c?"<br/>":"";
					break;
					case "hilitecolor":
					case "backcolor":
						command=kelex.w3c?"hilitecolor":"backcolor";
					break;
				}
				return this._execCommand(command,!!show,value);
			}
		});
		doc.KELEX_WINDOW_CACHE=wind;
	}
	return wind;
};
Window.extend(window);

if(typeof HTMLElement!="undefined"){
	Object.extend(HTMLElement.prototype,kelex.dom.Element);
	[HTMLInputElement,HTMLTextAreaElement, HTMLSelectElement].each(function(obj){
		Object.extend(obj.prototype,kelex.dom.form.Element);
	});
}else{
	var Element=new Object();
};

Element.extend = function(e) {
	if(!e || window===e || 3 == e.nodeType || !!e.extended) return e;
	Object.extend(e,kelex.dom.Element);
	if (-1<['INPUT','TEXTAREA','SELECT'].indexOf(e.tagName))
		Object.extend(e,kelex.dom.form.Element);
	return e;
};

/*********************************************************************************************
☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆事件核心☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆
*********************************************************************************************/

var HEventProxy=new function(){
	var map={};
	var current=null;
	var keys=0x000000;
	var events=getEventSrc();
	var power=true;
	//-----------------------------------------------------//
	//manage pool function//
	function push(s,k){
		var i=0;
		var sic=map[s.cache.eoIdx];
		if(sic){
			for(var j in sic){
				if(s===sic[j][0]){
					i++;
					break;
				}
			}
			0==i?sic.push([s,k]):(sic[j][1]|=k);
		}else{
			map[s.cache.eoIdx]=[[s,k]];
		}
		if(0x001000==k)
			addEvent(0x001000);
	};
	function pop(s,k){
		var key=0;
		var sic=map[s.cache.eoIdx];
		if(sic){
			for(var i in sic){
				if(s===sic[i][0]&&inKey(k,sic[i][1])){
					if(0==(key=sic[i][1]^k)){
						sic.splice(i,1);
					}else{
						sic[i][1]=key;
					}
					break;
				}
			}
		}
		if(0x001000==k)
			removeEvent(0x001000);
	};
	//manage pool end function//
	//-----------------------------------------------------//
	//add/remove event function//

	function removeEvent(e){
		if(inKey(e,keys)){
			var i=0;
			var s=events[e];
			for(var j in map)
				if(inKey(e,map[j][1])) i+=1;
			0==i && ((keys^=e) & $d().removeEvent(s[0],s[1],false));
		}
	};

	function addEvent(e){
		if(!inKey(e,keys)){
			var s=events[e];
			document.addEvent(s[0],s[1],false);
			keys|=e;
		}
	};
	//add/remove event end function//
	//-----------------------------------------------------//
	//add/remove event interface//
	this.interface=function(s,k,b){
		var key=0x000000;
		switch(k){
			case "mousedown":
				key=0x000001;
			break;
			case "mouseup":
				key=0x000010;
			break;
			case "mouseover":
				key=0x001000;
			break;
			case "motion":
				key=0x000111;
			break;
			default:
				return;
			break;
		};
		b?push(s,key):pop(s,key);
	};
	this.power=function(b){
		power=b;
	};
	this.release=function(){
		destroy();
	};
	this.join=function(o,e){
		thirdPartyEvent(true,Object.refactor(o,kelex.dom.Document),e);
	};
	this.detach=function(o,e){
		thirdPartyEvent(false,o,e);
	};
	/**
	*thirdPartyEvent
	*/
	function thirdPartyEvent(b,o,e){
		if($d()!=o){
			var k=getKey(e);
			if(0<k){
				var s=events[k];
				b?o.addEvent(s[0],s[1],false):o.removeEvent(s[0],s[1],false);
			}
		}
	};
	//add/remove event end interface//
	//-----------------------------------------------------//
	//mouse over function//
	function W3C_MOUSE_OVER(e){
		power&&mouseOver(e.target,e);
	};
	function _MOUSE_OVER(e){
		power&&mouseOver(e.srcElement,bindingDefault(e));
	};
	function mouseOver(t,e){
		var mapping=(0<t.id.length?getMapping(t.id):null);
		if(mapping){
			var cur=current;
			for(var i=0;i<mapping.length;i++){
				var m=mapping[i];
				var k=m[1];
				if(inKey(k,0x001000)){
					var sic=m[0];
					!!cur&&cur[0].cache.infection&&!contains(sic,cur[0])&&destroy();
					(sic.mouseoverProxy("mouseover",t,e)&&!!!current)&&(current=m);
				}
			}
		}
	};
	//mouse over end function//
	//-----------------------------------------------------//
	//mouse down function//
	function W3C_MOUSE_DOWN(e){
		power&&0==e.button&&mousedown(e.target,e);
	};
	function _MOUSE_DOWN(e){
		power&&1==e.button&&mousedown(e.srcElement,bindingDefault(e));
	};
	function mousedown(target,e){
		var mapping=(0<target.id.length?getMapping(target.id):null);
		if(mapping){
			var b=false;
			for(var i=0;i<mapping.length;i++){
				var m=mapping[i];
				var k=m[1];
				inKey(k,0x000010)&&(addEvent(0x000010)&(b=true));
				if(inKey(k,0x000001)){
					inKey(k,0x000100)&&addEvent(0x000100);
					var sic=m[0];
					var cur=current;
					b=true;
					cur&&cur[0].cache.infection&&!contains(sic,cur[0])&&destroy();
					sic.mousedownProxy("mousedown",target,e)&&(current=m);
				}
			}
			if(b)
				return;
		}
		destroy();
	};
	//mouse down end function//
	//-----------------------------------------------------//
	//mouse up function//
	function W3C_MOUSE_UP(e){
		power&&0==e.button&&mouseup(e.target,e);
	};
	function _MOUSE_UP(e){
		power&&1==e.button&&mouseup(e.srcElement,bindingDefault(e));
	};
	function mouseup(target,e){
		var cur=current;
		var mapping=(0<target.id.length?getMapping(target.id):null);
		if(mapping){
			var b=false;
			for(var i=0;i<mapping.length;i++){
				var m=mapping[i];
				var k=m[1];
				if(inKey(k,0x000010)){
					var sic=m[0];
					b=true;
					!!cur&&cur[0].cache.infection&&!contains(sic,cur[0])&&destroy();
					sic.mouseupProxy("mouseup",target,e)&&!!!current&&(current=m);
				}
			}
			if(b)
				return;
		}
		cur&&cur[0].mouseupProxy(target,e);
		removeRedundantEvents();
	};
	//mouse up end function//
	//-----------------------------------------------------//
	//mouse move function//
	function W3C_MOUSE_MOVE(e){
		mousemove(e.target,e);
		return false;
	};
	function _MOUSE_MOVE(e){
		mousemove(e.srcElement,bindingDefault(e));
		return false;
	};
	function mousemove(t,e){
		kelex.dom.Range.getSelection().removeAllRanges();
		current&&current[0].mousemoveProxy("mousemove",t,e);
	};
	//mouse move end function//
	function bindingDefault(e){
		e.preventDefault=function(){
			$w().event.returnValue = false;
		}
		return e;
	};
	function getEventSrc(){
		if(kelex.w3c){
			return {
				0x000001:["mousedown",W3C_MOUSE_DOWN],
				0x000010:["mouseup",W3C_MOUSE_UP],
				0x000100:["mousemove",W3C_MOUSE_MOVE],
				0x001000:["mouseover",W3C_MOUSE_OVER]
			}
		}else{
			return {
				0x000001:["mousedown",_MOUSE_DOWN],
				0x000010:["mouseup",_MOUSE_UP],
				0x000100:["mousemove",_MOUSE_MOVE],
				0x001000:["mouseover",_MOUSE_OVER]
			}
		}
	};
	function getKey(e){
		for(var i in events)
			if(e==events[i][0])
				return i;
		return 0;
	};
	function inKey(o,h){
		return 0!=(o&h);
	};
	function destroy(){
		null!=current&&(current[0].end()&(current=null));
	};
	function removeRedundantEvents(){
		inKey(0x000010,keys)&&removeEvent(0x000010);
		inKey(0x000100,keys)&&removeEvent(0x000100);
	};
	/**
	*判断指定的对象之间是否存在包含（子级、父级）关系。
	*@param c - 指定要查找的子级对象。
	*@param p - 指定被查找的父级对象。
	*@return 如果存在包含关系返回 true。
	*/
	function contains(c,p){
		var sic,mapping,childs;
		var i=0,j,k;
		var cur=c,keys=Object.keys(map);
		while(true){
			if(i>=keys.length) return false;
			mapping=map[keys[i]];
			for(j=0;j<mapping.length;j++){
				sic=mapping[j][0];
				childs=sic.cache.childs;
				for(k=0;k<childs.length;k++){
					if(cur===childs[k]){
						if(p===sic) return true;
						cur=sic;
						i=-1;
						break;
					}
				}
				if(-1==i)
					break;
			}
			i++;
		}
	};
	function getMapping(t){
		var i=t.lastIndexOf("_");
		return -1<i?map[t.substring(0,i)]:null;
	};
	addEvent(0x000001);
};

/*********************************************************************************************
☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆基类☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆
*********************************************************************************************/

kelex.Target={
	mode:true,
	dc:null,
	cc:null,
	/**
	*事件寄存器
	*/
	initialize:function(){
		with(this){
			value=null;
			invoke=this.newInvoke(["mousedown","mouseup","mousemove","mouseover","change"]);
			cache=this.newCache();
			Super(arguments);
		}
	},
	newCache:function(){
		/**
		*buffer
		*通过指定逻辑值设置当前组件对象中任意一个控件发生事件时是否要缓存控件事件。事件控制器通过缓存控件事件来保证当前组件对象中只有一个控件处于响应状态。
		*/
		/**
		*infection
		*通过指定逻辑值设置当前组件对象中任意一个控件发生事件时是否连带影响其它同组控件发生事件改变。
		*/
		return {eoIdx:null,aoIdx:null,eoCache:null,aoCache:null,current:null,childs:new Array(),infection:false,buffer:false};
	},
	mousedownProxy:function(k,t,e){
		if(!this.invokeListener(k,t,e)) return false;
		this[k](t,e);
		return this.cache.buffer;
	},
	mouseupProxy:function(k,t,e){
		if(!this.invokeListener(k,t,e)) return false;
		this[k](t,e);
		return this.cache.buffer;
	},
	mouseoverProxy:function(k,t,e){
		if(!this.invokeListener(k,t,e)) return false;
		this[k](t,e);
		return this.cache.buffer;
	},
	mousemoveProxy:function(k,t,e){
		this.invokeListener(k,t,e);
		this[k](t,e);
	},
	changeProxy:function(v){
		this.invokeListener("change",v);
	},
	eoIdx:function(id){
		var c=this.cache;
		return !id?c.eoIdx:(c.eoIdx=$str(id));
	},
	aoIdx:function(id){
		var c=this.cache;
		return !id?c.aoIdx:(c.aoIdx=$str(id));
	},
	getSnByEoId:function(id){
		var idx=this.cache.eoIdx+"_";
		return id.startsWith(idx)?id.slice(idx.length):null;
	},
	getEoBySn:function(sn){
		var idx=this.cache.eoIdx;
		return idx?$(idx+"_"+sn):null;
	},
	getAoBySn:function(sn){
		var idx=this.cache.aoIdx;
		return idx?$(idx+"_"+sn):null;
	},
	setEoClassName:function(e){
		var ch=this.cache;
		var eo=ch.eoCache;
		eo&&this.setClassName(eo,e,ch.current);
	},
	setAoClassName:function(e){
		var ch=this.cache;
		var ao=ch.aoCache;
		ao&&this.setClassName(ao,e,ch.current);
	},
	setClassName:function(o,e,sn){
		if(sn){
			var _t=this;
			e?(o.className=(_t.mode?_t.cc:_t.cc+sn)):(o.className=(_t.mode?_t.dc:_t.dc+sn));
			//alert(e+":"+o.className);
		}
	},
	/**
	*根据指定的逻辑值控制当前响应元素是否隐藏
	*/
	displayAo:function(b){
		var ao=this.cache.aoCache;
		ao&&(b?ao.show():ao.hide());
	},
	register:function(e,a,sn){
		with(this.cache){
			eoCache=e;
			aoCache=a;
			current=sn;
		}
	},
	repeal:function(){
		with(this.cache){
			eoCache=null;
			aoCache=null;
			current=null;
		}
	},
	//values function//
	/**
	*更新值
	*/
	update:function(value){
		var v=this.value;
		this.value=$str(value);
		this.changeProxy(v);
	},
	/**
	*添加值
	*/
	addValue:function(value){
		var v=this.value.clone();
		-1==v.indexOf(value)&&this.value.push(value);
		this.changeProxy(v);
	},
	/**
	*删除值
	*/
	removeValue:function(value){
		var v=this.value.clone();
		var i=v.indexOf(value);
		-1<i&&this.value.splice(i,1);
		this.changeProxy(v);
	},
	//values end//
	//--------------------------------------------------------------------------------------//
	//event function//
	addEvent:function(e){
		HEventProxy.interface(this,e,true);
	},
	removeEvent:function(e){
		HEventProxy.interface(this,e,false);
	}
	//event end//
	//--------------------------------------------------------------------------------------//
};
Object.refactor(kelex.Target,kelex.Object);
/*********************************************************************************************
☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆单行类☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆
*********************************************************************************************/
kelex.sic.Mono={
		pack:"kelex.sic",
		cls:"Mono",
		mousedown:function(t,e){
			this.mouseEvent(t,e);
		},
		mouseup:function(t,e){
			this.mouseEvent(t,e);
		},
		mouseover:function(t,e){
			this.mouseEvent(t,e);
		},
		mouseEvent:function(t,e){
			var sn=this.getSnByEoId(t.id);
			this.start(sn);
		},
		start:function(sn){
			var eo=this.getEoBySn(sn);
			if(eo){
				var ao=this.getAoBySn(sn);
				with(this){
					end();
					register(eo,ao,sn);
					setEoClassName(true);
					displayAo(true);
					update(sn);
				}
			}
		},
		end:function(){
			var c=this.cache.childs;
			for(var i=0;i<c.length;i++)
				c[i].cache.infection&&c[i].end();
			this.setEoClassName(false);
			this.displayAo(false);
			this.repeal();
		}
};
Object.refactor(kelex.sic.Mono,kelex.Target);

//////////////////////////////////////////////////////////////////////////////////////////////

var HClip=Class.create();
HClip.prototype={
	cls:"HClip",
	Super:function(args){
		with(this){
			value="";
			eoIdx(args[0]);
			aoIdx(args[1]);
			Init(args);
		}
	}
};
Object.refactor(HClip.prototype,kelex.sic.Mono);


//////////////////////////////////////////////////////////////////////////////////////////////

var HRadio=Class.create();
HRadio.prototype={
	cls:"HRadio",
	Super:function(args){
		with(this){
			value="";
			eoIdx(args[0]);
			Init(args);
		}
	}
};
Object.refactor(HRadio.prototype,kelex.sic.Mono);

//////////////////////////////////////////////////////////////////////////////////////////////

var HMenu=Class.create();
HMenu.prototype={
	cls:"HMenu",
	Super:function(args){
		with(this){
			value="";
			cache.buffer=true;
			cache.infection=true;
			eoIdx(args[0]);
			aoIdx(args[1]);
			Init(args);
		}
	},
	addChild:function(o){
		var c=this.cache.childs;
		o!=c&&-1==c.indexOf(o)&&c.push(o);
	},
	child:function(index){
		var c=this.cache.childs;
		return $$num(index)?c[index]:c;
	},
	removeChild:function(index){
		var i=-1;
		var c=this.cache.childs;
		i=(index>c.length||0>index)?-1:index;
		return (-1==i)?null:c.splice(i,1);
	}
};
Object.refactor(HMenu.prototype,kelex.sic.Mono);
/*********************************************************************************************
☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆并行类☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆
*********************************************************************************************/

kelex.sic.Multi={
	pack:"kelex.sic",
	mouseup:function(t,e){
		this.mouseEvent(t,e);
	},
	mousedown:function(t,e){
		this.mouseEvent(t,e);
	},
	mouseover:function(t,e){
		this.mouseEvent(t,e);
	},
	mouseEvent:function(t,e){
		var sn=this.getSnByEoId(t.id);
		-1==this.value.indexOf(sn)?this.start(sn):this.end(sn);
	},
	start:function(sn){
		var eo=this.getEoBySn(sn);
		if(eo){
			var ao=this.getAoBySn(sn);
			with(this){
				register(eo,ao,sn);
				setEoClassName(true);
				displayAo(false);
				repeal();
				addValue(sn);
			}
		}
	},
	end:function(sn){
		var eo=this.getEoBySn(sn);
		if(eo){
			var ao=this.getAoBySn(sn);
			with(this){
				register(eo,ao,sn);
				setEoClassName(false);
				displayAo(true);
				repeal();
			}
			this.removeValue(sn);
		}
	}
};
Object.refactor(kelex.sic.Multi,kelex.Target);

//////////////////////////////////////////////////////////////////////////////////////////////

var HView=Class.create();
HView.prototype={
	cls:"HView",
	Super:function(args){
		with(this){
			value=[];
			eoIdx(args[0]);
			aoIdx(args[1]);
			Init(args);
		}
	}
};
Object.refactor(HView.prototype,kelex.sic.Multi);

//////////////////////////////////////////////////////////////////////////////////////////////

var HCheck=Class.create();
HCheck.prototype={
	cls:"HCheck",
	Super:function(args){
		with(this){
			value=[];
			eoIdx(args[0]);
			Init(args);
		}
	}
};
Object.refactor(HCheck.prototype,kelex.sic.Multi);

/********************************************************************************************
☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆窗体类☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆
********************************************************************************************/

kelex.sic.Wind={
	pack:"kelex.sic",
	cls:"Wind",
	margin:10,
	container:null,
	scaleX:0,
	scaleY:0,
	localizer:null,
	focus:false,
	value:"",
	static:{brother:null,fix:"B",zIndex:100,position:{left:0,top:0}},
	Super:function(args){
		with(this){
			cache.buffer=true;
			eoIdx(args[0]);
			$$str(args[1])?aoIdx(args[1]):aoIdx(args[0]);
			createLocalizer();
			Init(args);
		}
	},
	mousedown:function(t,e){
		var sn=this.getSnByEoId(t.id);
		var eo=this.getEoBySn(sn);
		var ao=this.getAoBySn(sn);
		if(eo&&ao){
			var r=ao.getBoundingClientRect();
			var o=this.final.offset;
			with(this){
				static.brother=ao;
				register(eo,ao,sn);
				setCoordinates(e.clientX-r.left+o,e.clientY-r.top+o);
				setAoClassName(true);
				start(sn,e);
			}
		}
	},
	mousemove:function(t,e){},
	mouseup:function(t,e){},
	scale:function(){
		return {x:this.scaleX,y:this.scaleY};
	},
	end:function(){
		with(this){
			setAoClassName(false);
			static.brother=null;
			repeal();
		}
	},
	/**
	*设置元素Z轴深度
	*/
	setZ:function(){
		this.cache.aoCache.style.zIndex=(this.static.zIndex+=1);
	},
	/**
	*设置元素距容器边框的偏移量
	*/
	setCoordinates:function(l,t){
		with(this.static.position){
			left=l;
			top=t;
		}
	},
	/**
	*初始化定位器元素
	*/
	createLocalizer:function(){
		this.localizer=$c({tagName:"div",style:{opacity:0.5,backgroundColor:"#3979e3",position:"absolute",overflow:"hidden",display:"none",zIndex:1410065405}});
	},
	/**
	*显示定位器元素
	*/
	localizerDisplay:function(e){
		var l=this.localizer;
		if(e){
			l.show();
			$d().body.appendChild(l);
			return;
		}
		l.hide();
		l.parentNode.removeChild(l);
	}
}
Object.refactor(kelex.sic.Wind,kelex.Target);

//////////////////////////////////////////////////////////////////////////////////////////////

var HDrag=Class.create();
HDrag.prototype={
	cls:"HDrag",
	start:function(sn,e){
		var ao=this.cache.aoCache;
		with(this.localizer.style){
			width=ao.offsetWidth+"px";
			height=ao.offsetHeight+"px";
		}
		with(this){
			update(sn);
			localizerDisplay(true);
			mousemove(sn,e);
			setZ();
		}
	},
	mousemove:function(t,e){
		var ao=this.cache.aoCache;
		if(ao){
			var c=this.container;
			var s=this.static;
			var o=this.final.offset;
			var ww,wh,wx,wy;
			
			ww=ao.offsetWidth;
			wh=ao.offsetHeight;
			
			wx=e.clientX-s.position.left;
			wy=e.clientY-s.position.top;
			if(c){
				var m=this.margin;
				var cw=c.offsetWidth;
				var ch=c.offsetHeight;
				var cr=c.getBoundingClientRect();
				var cl=cr.left-o;
				var ct=cr.top-o;
				var ox=cl+cw-ww-m;
				var oy=ct+ch-wh-m;
				
				cl+=m;
				ct+=m;
				
				wx=wx<cl?cl:wx>ox?ox:wx;
				wy=wy<ct?ct:wy>oy?oy:wy;
			}
			with(this.localizer.style){
				left=wx+$d().documentElement.scrollLeft+"px";
				top=wy+$d().documentElement.scrollTop+"px";
			}
		}else{
			this.repeal();
		}
	},
	mouseup:function(t,e){
		var ao=this.cache.aoCache;
		if(!ao) return;
		var lr=this.localizer.getBoundingClientRect();
		var pn=ao.parentNode;
		var pnx,pny,pnr;
		if(!pn || !(pnr=pn.getBoundingClientRect())){
			pnx=pny=0;
		}else{
			pnx=pnr.left;
			pny=pnr.top;
		}
		this.localizerDisplay(false);
		!this.focus&&this.setAoClassName(false);
		ao.move(lr.left-pnx,lr.top-pny);
	}
};
Object.refactor(HDrag.prototype,kelex.sic.Wind);

//////////////////////////////////////////////////////////////////////////////////////////////

var HPanel=Class.create();
HPanel.prototype={
	cls:"HPanel",
	tooltip:null,
	Init:function(as){
		this.container=new Array();
		this.createTooltip();
	},
	/**
	*判断指定的元素和容器数组中的元素是否为同一个元素
	*/
	inContainer:function(element){
		var i,c=this.container;
		return -1<(i=c.indexOf(element))?c[i]:null;
	},
	/**
	*初始化注解元素
	*/
	createTooltip:function(){
		this.tooltip=$c({tagName:"div",style:{position:'absolute',overflow:'hidden',display:'none',zIndex:1410065406}});
	},
	/**
	*显示注解元素
	*/
	tooltipDisplay:function(e){
		var t=this.tooltip;
		if(e){
			t.show();
			$d().body.appendChild(t);
			return;
		}
		t.hide();
		t.parentNode.removeChild(t);
	},
	start:function(sn,e){
		with(this){
			tooltip.innerHTML=this.cache.aoCache.title;
			update(sn);
			tooltipDisplay(true);
			localizerDisplay(true);
			tooltipMove(e.clientX,e.clientY);
		}
	},
	mousemove:function(t,e){
		var rn,ao;
		var x=e.clientX;
		var y=e.clientY;
		this.tooltipMove(x,y);
		if(rn=this.inContainer(t)){
			this.static.brother=null;
			this.localizerToContainer(rn,x,y);
		}else if(ao=this.getAoBrother(t)){
			this.static.brother=ao;
			this.localizerToPanel(ao,x,y);
		}
	},
	mouseup:function(t,e){
		var ao=this.cache.aoCache;
		this.tooltipDisplay(false);
		if(ao){
			var s=this.static;
			var br=s.brother;
			if(this.inContainer(t)){
				t.appendChild(ao);
			}else if(null!=br && ao!=br){
				"B"==s.fix || "R"==s.fix ? br.insertNext(ao) : br.insertPrevious(ao);
			} 
		}
		!this.focus&&this.setAoClassName(false);
		this.localizerDisplay(false);
	},
	/**
	*得到当前响应元素的兄弟元素
	*/
	getAoBrother:function(e){
		var ao,c=this.cache;
		if(null==e || e==c.eoCache || null==(ao=c.aoCache) || e==ao) return null;
		var po=e;
		while(true){
			var tag=po.tagName;
			if("BODY"==tag || "HTML"==tag || null==tag) break;
			if(""==po.id){
				po=po.parentNode;
				continue;
			}
			if(po.id.startsWith(c.aoIdx+"_")) return po;
			po=po.parentNode;
		};
		return null;
	},
	/**
	*将定位器定位到当前所在面板的坐标处
	*/
	localizerToPanel:function(t,x,y){
		var s=this.static;
		var of=this.final.offset;
		var r=t.getBoundingClientRect();
		var lx=ly=lw=lh=0;
		var th=t.offsetHeight;
		var tw=t.offsetWidth;
		var rt=r.top;
		var rl=r.left;
		var y1=y-rt;
		var y2=th-y1;
		var x1=x-rl;
		var x2=tw-x1;
		s.fix=y1<y2?y1<x1?y1<x2?"T":"R":x1<x2?"L":"R":y2<x1?y2<x2?"B":"R":x1<x2?"L":"R";
		switch(s.fix){
			case "T":
				lx=rl;
				ly=rt-5;
				lw=tw;
				lh=5;
			break;
			case "B":
				lx=rl;
				ly=rt+th;
				lw=tw;
				lh=5;
			break;
			case "L":
				lx=rl-5;
				ly=rt;
				lw=5;
				lh=th;
			break;
			case "R":
				lx=rl+tw;
				ly=rt;
				lw=5;
				lh=th;
			break;
		};
		this.setLocalizerRect(lx-of,ly-of,lw,lh);
	},
	/**
	*将定位器定位到预容器的开始处
	*/
	localizerToContainer:function(t,x,y){
		var c=t.childNodes;
		var len=c.length-1;
		for(var i=len;0<=i;i--)
			if(1==c[i].nodeType){
				return this.localizerToPanel(c[i],x,y);
			}
		var of=this.final.offset;
		var tr=t.getBoundingClientRect();
		this.setLocalizerRect(tr.left-of+$d().documentElement.scrollLeft,tr.top-of+$d().documentElement.scrollTop,t.offsetWidth,5);
	},
	/**
	*重置定位宽高和坐标
	*/
	setLocalizerRect:function(x,y,w,h){
		with(this.localizer.style){
			left=x+"px";
			top=y+"px";
			width=w+"px";
			height=h+"px";
		}
	},
	/**
	*移动注解元素到指定的坐标处
	*/
	tooltipMove:function(x,y){
		this.tooltip.move(x+10+$d().documentElement.scrollLeft,y+10+$d().documentElement.scrollTop);
	}
};
Object.refactor(HPanel.prototype,kelex.sic.Wind);

/********************************************************************************************
☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆通讯组件☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆
********************************************************************************************/

var HSocket=Class.create();
HSocket.getHttp=function(){
	return $w().ActiveXObject?(new ActiveXObject("Microsoft.XMLHTTP") || new ActiveXObject('Msxml2.XMLHTTP')):$w().XMLHttpRequest?new XMLHttpRequest():null;
};
HSocket.cleanWhitespace=function(xml){
		var nextNode,node = xml.firstChild;
		while(node){
		  nextNode=node.nextSibling;
		  if(node.nodeType == 3 && !/\S/.test(node.nodeValue))
		 	xml.removeChild(node);
		  node = nextNode;
		}
		return xml;
};
HSocket.serializer=function(xml){
	return kelex.w3c?(new XMLSerializer()).serializeToString(xml):xml.xml;
};
HSocket.prototype={
	pack:"kelex.http",
	cls:"HSocket",
	xmlHttp:null,
	contentType:"application/x-www-form-urlencoded",
	method:"post",
	url:"",
	async:false,
	encode:"UTF-8",
	headers:{
		"X-Requested-With": "XMLHttpRequest",
		"X-Prototype-Version": kelex.version,
		"Accept": "text/javascript, text/html, application/xml, text/xml, */*",
		"Connection": "close"
	},
	mode:"html",
	timer:null,
	time:5000,
	receipt:null,
	status:false,
	initialize:function(){
		var args=arguments;
		with(this){
			xmlHttp=HSocket.getHttp();
			url=args[0];
			async=args[1];
			invoke=this.newInvoke(["callback"]);
			Super(args);
		}
	},
	setRequestHeader:function(k,v){
		this.headers[k]=v;
	},
	getResponseHeader:function(k){
		try{
			return this.xmlHttp.getResponseHeader(k);
		}catch(e){
			return null;
		}
	},
	getAllResponseHeaders:function(){
		try{
			return this.xmlHttp.getAllResponseHeaders();
		}catch(e){
			return null;
		}
	},
	callback:function(m){
		return !$$def(m)?this.invoke["callback"]:this.setListener("callback",m);
	},
	send:function(p){
		this.abort();
		var _t=this;
		var h=this.xmlHttp;
		h.open(this.method,this.url,this.async);
		if(kelex.w3c){
			h.onload=function(){_t._callback()};
		}else{
			h.onreadystatechange=function(){_t._callback()};
		}
		if("post"==this.method) this.headers["Content-Type"]=this.contentType+(null==this.encode ? "" : "; charset=" + this.encode);
		for(var i in this.headers) h.setRequestHeader(i,this.headers[i]);
		try{
			h.send(p?p:null);
			return true;
		}catch(e){
			return false;
		}
	},
	abort:function(){
		clearInterval(this.timer);
		with(this){
			status=false;
			timer=null;
			value=null;
			xmlHttp.abort();
		}
	},
	_callback:function(){
		var _t=this;
		var h=this.xmlHttp;
		var m=this.mode;
		clearInterval(this.timer);
		this.timer=null;
		if(4==h.readyState){
			if(200==h.status){
				this.status=true;
				this.value=("html"==m?h.responseText:"xml"==m?h.responseXML.documentElement:null);
			}else{
				this.status=false;
				this.value=null;
			}
			this.invokeListener("callback",undefined,undefined);
			return;
		}
		0<this.time?(this.timer=$w().setTimeout(function(){_t.xmlHttp.abort();_t.invoke.callback(_t);},this.time)):_t.invoke.callback(_t);
	}
};
Object.refactor(HSocket.prototype,kelex.Object);

/********************************************************************************************
☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆回调组件☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆
********************************************************************************************/
var Valve={
	left:null,
	right:null,
	callback:function(e,c){
		var m=this.left;
		try{
		e?$$obj(m=this.left)&&$$fun(m.left)?m.left(c):$$fun(m)?m(c):0:$$obj(m=this.right)&&$$fun(m.right)?m.right(c):$$fun(m)?m(c):0;
		}catch(e){alert('data callback anomalies.')};
		return e;
	}
};




var HFilter={
	pack:"kelex.transitions",
	cls:"HFilter",
	easeInOut:function(r){
		return {
			radix:r,
			step:function(index,frame,offset){
				debug.out(index+":"+frame+":"+offset);
			}
		}
	}
}
Object.extend(HFilter,kelex.Object);
var HTween=Class.create();
HTween.prototype={
	pack:"kelex.transitions",
	cls:"HTween",
	state:-1,
	prototype:null,
	element:null,
	frame:24,
	begin:0,
	end:0,
	offset:0,
	sign:1,
	index:0,
	time:0,
	millisec:-1,
	timer:null,
	algorithm:null,
	initialize:function(){
		var args=arguments;
		with(this){
			element=args[0];
			prototype=args[1];
			algorithm=args[2];
			begin=args[3];
			end=args[4];
			frame=args[5];
			time=args[6];
			sign=args[3]<args[4]?1:-1;
			frame=args[6]/1000*args[5];
			millisec=args[6]/this.frame;
			offset=Math.abs(args[3]-args[4])/this.frame;
			invoke=newInvoke(["stop","pause","finish","frame"]);
			initCache();
			Super(args);
		}
	},
	clearTimer:function(){
		clearInterval(this.timer);
		this.timer=null;
	},
	initCache:function(){
		this.cache={index:this.frame,value:this.begin};
	},
	index:function(){
		return -1==this.state?0:(this.frame-this.cache.index+1);
	},
	callback:function(p,l,b,i){
		var val;
		var _this=this;
		this.clearTimer();
		var val=this.begin+this.sign*((this.frame-p.index+1)*this.offset);
		p.value=(b?(1>=i?this.end:val):(this.frame<=i?this.begin:val));
		var prototype={};
		prototype[this.prototype]=p.value;
		this.element.setStyle(prototype);
		0<p.value?this.element.show():this.element.hide();
		this.invokeListener("frame");
		if(l){
			if(b?1<=--i:this.frame>=++i){
				this.timer=window.setTimeout(function(){_this.callback(p,l,b,p.index=i)},this.millisec);
			}else{
				this.state=2;
				this.invokeListener("finish");
			}
		}
	},
	pause:function(){
		this.clearTimer();
		if(0==this.state){
			this.state=1;
			this.invokeListener("pause");
		}
	},
	stop:function(){
		this.clearTimer();
		if(-1!=this.state){
			this.state=-1;
			this.element.style[this.prototype]=this.begin+"px";
			this.initCache();
			this.invokeListener("stop");
		}
	},
	goto:function(i){
		this.gotoFrame(i,false);
	},
	gotoAndPlay:function(i){
		this.gotoFrame(i,true);
	},
	gotoFrame:function(i,l){
		this.clearTimer();
		if(this.frame>=i && 0<=i){
			this.state=1;
			this.cache.index=this.frame-i+1;
			this.callback(this.cache,l,true,this.cache.index);
		}else{
			//HException.index(this,i,0,this.length);
		}
	},
	back:function(){
		this.callback(this.cache,true,false,this.cache.index);
	},
	play:function(){
		if(!this.cache || 1!=this.state || -1==this.state)
			this.initCache();
		this.state=0;
		this.callback(this.cache,true,true,this.cache.index);
		//debug.out("元素:"+this.element);
		//debug.out("属性:"+this.prototype);
		//debug.out("起始值:"+this.begin);
		//debug.out("结束值:"+this.end);
		//debug.out("运行时间:"+this.time);
		//debug.out("符号:"+this.sign);
		//debug.out("索引计数器:"+this.index);
		//debug.out("间隔时间:"+this.millisec);
		//debug.out("偏移量:"+this.offset);
	}
}
Object.refactor(HTween.prototype,kelex.Object);


