﻿/*@Version:1.1
* @Author: Borllor Lee*/
var XYLK = { Required: "必填",InputAcross: "输入通过",PasswordsNotEqual: "两次密码输入不一致",RequiredValue_Argument1: "{0}不能为空",RequiredInputValue_Argument1: "请输入{0}",RequiredSelectValue_Argument1: "请选择{0}",ValueBetweenMaxAndMin_Argument3: "{0}控制在{1}-{2}字符之间",ErrorInputValue_Argument1: "输入的{0}错误，请重新输入",RequiredInputOrSelectValue_Argument1: "请选择或输入{0}",RequiredUploadWork: "请先上传创意作品，再提交",UploadError_Argument1: "上传{0}出现错误",NoExistsWorks: "未能找到您想要的作品",IsNewestCritisim: "这已经是最新版本的评析",IsOldestCritisim: "这已经是最旧版本的评析",PleaseUplodSourceFile: "请提供你作品的源文件及创作过程中使用的参考资料",NotBothEmpty_Argument2: "{0}{1}不能同时为空",BothPassWordNotEqual: "两次密码输入不一致",ErrorFormat_Argument1: "{0}格式不正确，请正确填写",RequiredSelectYouValue_Argument1: "请选择您的{0}",SomeErrorEmailFormat_Argument1: "您输入的第{0}个Email地址格式不正确，请正确填写",UserRecommenedSuccessful_Argument1: "成功推荐的用户{0}",RequiredInteger_Argument1: "{0}必需为整数，请正确填写",RequiredAwardLogo: "请上传礼品的logo",CheckCodeError: "验证码错误",UserNameExists: "此用户名已经被注册",EmailExists: "此邮箱已经被注册",AgreeUserAgreement: "您必须同意并接受思酬之路用户注册协议",AgreeWorkAgreement:"你必须同意并接受思酬网络作品上传协议",PleaseInputCode:"请输入验证码",PleaseSelectDeleteObject_Argument1: "请选择你要删除的{0}" };
var whoids__s = "whoids", whisod__s = "whisod", Sys = {}, ua = navigator.userAgent.toLowerCase(), s; (s = ua.match(/msie ([\d.]+)/)) ? Sys.ie = s[1]:(s = ua.match(/firefox\/([\d.]+)/)) ? Sys.firefox = s[1]:(s = ua.match(/chrome\/([\d.]+)/)) ? Sys.chrome = s[1]:(s = ua.match(/opera.([\d.]+)/)) ? Sys.opera = s[1]:(s = ua.match(/version\/([\d.]+).*safari/)) ? Sys.safari = s[1]:0; Sys.ie6 = Sys.ie && ([/MSIE (\d)\.0/i.exec(navigator.userAgent)][0][1] == 6);
var Class = function(properties){
	var klass = function(){
		return (arguments[0] !== null && this.initialize && $type(this.initialize) == 'function') ? this.initialize.apply(this, arguments) : this;
	};
	$extend(klass, this);
	klass.prototype = properties;
	klass.constructor = Class;
	return klass;
};
Class.prototype = {
	extend: function(properties){
		var proto = new this(null);
		for (var property in properties){
			var pp = proto[property];
			proto[property] = Class.Merge(pp, properties[property]);
		}
		return new Class(proto);
	},
	implement: function(){
		for (var i = 0, l = arguments.length; i < l; i++) $extend(this.prototype, arguments[i]);
	}

};
Class.empty = function(){};
Class.Merge = function(previous, current){
	if (previous && previous != current){
		var type = $type(current);
		if (type != $type(previous)) return current;
		switch(type){
			case 'function':
				var merged = function(){
					this.parent = arguments.callee.parent;
					return current.apply(this, arguments);
				};
				merged.parent = previous;
				return merged;
			case 'object': return $merge(previous, current);
		}
	}
	return current;
};
function $merge(){
	var mix = {};
	for (var i = 0; i < arguments.length; i++){
		for (var property in arguments[i]){
			var ap = arguments[i][property];
			var mp = mix[property];
			if (mp && $type(ap) == 'object' && $type(mp) == 'object') mix[property] = $merge(mp, ap);
			else mix[property] = ap;
		}
	}
	return mix;
};
var $extend = function(){
	var args = arguments;
	if (!args[1]) args = [this, args[0]];
	for (var property in args[1]) {
	    var val = args[1][property];
	    if (property.toLowerCase() == "style" && $type(val) == "object"){
	        for (var p in val){
	            args[0][property][p] = val[p];
	        }
	    }else{
	        args[0][property] = val;
	    }
    }	    
	return args[0];
};
var $native = function(){
	for (var i = 0, l = arguments.length; i < l; i++){
		arguments[i].extend = function(props){
			for (var prop in props){
				if (!this.prototype[prop]) this.prototype[prop] = props[prop];
				if (!this[prop]) this[prop] = $native.generic(prop);
			}
		};
	}
};
$native.generic = function(prop){
	return function(bind){
		return this.prototype[prop].apply(bind, Array.prototype.slice.call(arguments, 1));
	};
};
$native(Function, Array, String, Number);
function $(id){
	return "string" == typeof id ? document.getElementById(id) : id;
}
function $event(e){
	var oEvent = (e) ? e : window.event;
	if (window.event) {
		if (typeof(oEvent.pageX) === "undefined"){oEvent.pageX = oEvent.clientX + document.documentElement.scrollLeft;}
		if (typeof(oEvent.pageY) === "undefined"){oEvent.pageY = oEvent.clientY + document.documentElement.scrollTop;}
		oEvent.stopPropagation = function(){
			this.cancelBubble = true;
		};
		if (typeof(oEvent.target) === "undefined"){oEvent.target = oEvent.srcElement;}
	}
	oEvent.keyValue = oEvent.keyCode ? oEvent.keyCode : oEvent.which;
	oEvent.activeElement = document.activeElement ? document.activeElement : oEvent.explicitOriginalTarget;
	return oEvent;
}
function $create(type){
	return document.createElement(type);
}
function $b(object, fun){
	var slice = Array.prototype.slice;
	var args = slice.call(arguments, 2);
	return function() {
		return fun.apply(object, args.concat(slice.call(arguments)));
	}	
}
function $be(object, fun){
	var slice = Array.prototype.slice;
	var args = slice.call(arguments, 2);
	return function(event) {
		return fun.apply(object, [(event || window.event)].concat(args));
	}		
}
function $each(list, fun){
	for (var i = 0, len = list.length; i < len; i++) {
		fun(list[i], i);
	}
}
function $timeout(){}
function ___doPostBack(eventTarget, eventArgument){
	if (typeof(theForm) == "undefined" || !theForm) {
		theForm = $("aspnetForm");
	}
	if (!theForm.onsubmit || (theForm.onsubmit() != false)) {
		var ta = $("__EVENTTARGET");
		var ar = $("__EVENTARGUMENT");
		if (!ta) {
			ta = createHidden("__EVENTTARGET", "");
			theForm.appendChild(ta);
		}
		if (!ar) {
			ar = createHidden("__EVENTARGUMENT", "");
			theForm.appendChild(ar);
		}
		ta.value = (eventTarget) ? eventTarget : "";
		ar.value = (eventArgument) ? eventArgument : "";
		
		theForm.submit();
	}
}
function createHidden(name, val){
	var e = $(name);
	if (e){
	    e.parentNode.removeChild(e);
	}
    e = $create("input");
	e.type = "hidden";
	e.name = e.id = name;
	e.value = val;
	return e;
}
function createDiv(id, val){
	var e = $(id);
	if (e){
	    e.parentNode.removeChild(e);
	}
    e = $create("div");
	e.id = id;
	e.innerHTML = val;
	return e;
}
function setWindowVarible(key, val){
	window[key.replace(/\$/g, "11_11")] = val;
}
function getWindowVarible(key){
	return window[key.replace(/\$/g, "11_11")];
}
function buildUrl(url, params){
	var pairs = new Array();
	var result = url;
	if (params) {
		for (var key in params) {
			pairs.push(key + "=" + encodeURIComponent(params[key].toString()));
		}
		result += "?" + pairs.join("&");
	}
	return result;
}
function redirect(url,params){
    _jumpPage(buildUrl(url,params));
}
function setElementValue(element, val){
	var elm = $(element);
	if (elm && elm.tagName) {
		var tn = elm.tagName.toLowerCase();
		if (tn === "input") {
			elm.value = val;
		} else if (tn === "div") {
			elm.innerHTML = val;
		}
	}
};
function _jumpPage(url) {  
    if (getIEVersion() > 0) {  
        var tempa = document.createElement("a");  
        tempa.href = url;  
        document.getElementsByTagName("body")[0].appendChild(tempa);  
        tempa.click();  
    } else {
        window.location.href = url;  
    }  
}  
function getIEVersion() {  
    var rv = -1; // Return value assumes failure.    
    if (navigator.appName == "Microsoft Internet Explorer") {  
        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;  
}  
function newWin(url){
    window.open(url, "newwin");
}
function CurrentStyle(element){
	return element.currentStyle || document.defaultView.getComputedStyle(element, null);
}
function $postback(){
	var cid = null; var data = null; var evt = null; var adi = null;
	cid = arguments[0] ? arguments[0] : "";//引发事件的控件
	data = arguments[1] ? arguments[1] : null;//给服务器的数据
	adi = arguments[2] ? arguments[2] : null; //要更新的控件集合
	evt = arguments[3] ? arguments[3] : null; //事件
	if (cid) {
		cid = cid.replace(/\_/g, "$");
	}
	if (evt) {
		if (!data) {
			data = new Object()
		};
		evt = $event(evt);
		$extend(data, {target: evt.target.id ? evt.target.id.replace(/\_/g, "$") : cid});
	}
    MyFCKObject.UpdateEditorFormValue();
	var str = data ? Object.toQueryString(data) : "";
	var wwh = getWindowVarible(whoids__s);
	if (typeof(wwh) != "undefined" && wwh) {
	    if ($("aspnetForm")){$("aspnetForm").appendChild(createHidden(whoids__s, wwh));}
		else { document.body.appendChild(createHidden(whoids__s, wwh)); }
	}
	var wst = getWindowVarible(whisod__s);
	if (typeof(wst) != "undefined" && wst) {
	    if ($("aspnetForm")){$("aspnetForm").appendChild(createHidden(whisod__s, wst));}
		else { document.body.appendChild(createHidden(whisod__s, wst)); }
	}	
	if (typeof(window.__doPostBack) === "function") {
		window.__doPostBack(cid, str, adi);
	} else {
		___doPostBack(cid, str);
	}
}
window["request_userIsLogin"] = $time();
function $pl(){
	var args = []; var callback = null; var tme = $time(); var msg = "你已经离线或还未登录，点[确定]在弹出框中登录，点[取消]返回此页面"; 
	for (var i = 0; i < arguments.length; i++) {
		if (i == 0) { callback = arguments[i]; }
		if (i == 1) { if (arguments[i]) { msg = arguments[i]; } }
        if (i >= 2) { args.push(arguments[i]); }
	}
	if (!window["userIsLogin"] || window["userIsLogin"] === false) {
		$confirm(msg, showUserLogin);
	} else {
	    if (window["request_userIsLogin"] && (tme - window["request_userIsLogin"] < 300000)){
            window["request_userIsLogin"] = tme; callback.apply(this, args); return;
	    } else {
            new Ajax("/handler/commonhandler.ashx", {method: "get", onSuccess: function(aj, rsp){
                var isl = window["userIsLogin"] = (rsp.text === "true" ? true : false);
                if (isl == true) {
                    window["request_userIsLogin"] = $time(); callback.apply(this, args);
                } else {
                    $confirm(msg, showUserLogin);
                }
            }}).request({t: "j", n: "login"});
        }
	}
}
function $p(){
	var cid = null; var data = null; var evt = null; var adi = null;
	cid = arguments[0] ? arguments[0] : "";//引发事件的控件
	data = arguments[1] ? arguments[1] : null;//给服务器的数据
	adi = arguments[2] ? arguments[2] : "all"; //要更新的控件集合
	evt = arguments[3] ? arguments[3] : null; //事件
	$postback(cid, data, adi, evt);
}
function $pp(){
	var cid = null; var data = null; var evt = null; var adi = null;
	cid = arguments[0] ? arguments[0] : "";//引发事件的控件
	data = arguments[1] ? arguments[1] : null;//给服务器的数据
	adi = arguments[2] ? arguments[2] : []; //要更新的控件集合
	evt = arguments[3] ? arguments[3] : null; //事件
	$postback(cid, data, adi, evt);
}
function $post(){
	var data = null; var evt = null; var adi = null;	
	data = arguments[0] ? arguments[0] : null;//给服务器的数据
	adi = arguments[1] ? arguments[1] : "all";//要更新的控件集合
	evt = arguments[2] ? arguments[2] : null;//事件
    $postback("", data, adi, evt);
}
function $defined(obj){
	return (typeof(obj) !== "undefined");
};
function $time(){
	return new Date().getTime();
};
function $type(obj){
	if (!$defined(obj)) {
		return false;
	}
	if (obj == null) {
		return "null";
	}			
	if (obj.htmlElement) {
		return 'element';
	}
	var type = typeof obj;
	if (type == 'object' && obj.nodeName) {
		switch (obj.nodeType) {
			case 1:
				return 'element';
			case 3:
				return (/\S/).test(obj.nodeValue) ? 'textnode' : 'whitespace';
		}
	}
	if (type == 'object' || type == 'function') {
		switch (obj.constructor) {
			case Array:
				return 'array';
			case RegExp:
				return 'regexp';
			case Class:
				return 'class';
		}
		if (typeof obj.length == 'number') {
			if (obj.item) {
				return 'collection';
			}
			if (obj.callee) {
				return 'arguments';
			}
		}
	}
	return type;
};
function $script(content){
	var script, scripts;
	if ((/(ecma|java)script/).test(content)) {
		scripts = content;
	} else {
		scripts = [];
		var regexp = /<script[^>]*>([\s\S]*?)<\/script>/gi;
		while ((script = regexp.exec(content))) {
			scripts.push(script[1]);
		}
		scripts = scripts.join('\n');
	}
	if (scripts){
		if (window.execScript) {
			window.execScript(scripts);
		} else {
			window.setTimeout(scripts, 0);
		}
    }		
};
Object.toQueryString = function(source){
    if ($type(source) == "string"){return source;}
	var queryString = [];
	for (var property in source) {
		queryString.push(encodeURIComponent(property) + '=' + encodeURIComponent(source[property]));
	}
	return queryString.join('&');
};
String.format = function(){
	if (arguments.length == 0) {
		return null;
	}
	var str = arguments[0];
	for (var i = 1; i < arguments.length; i++) {
		var re = new RegExp('\\{' + (i - 1) + '\\}', 'gm');
		str = str.replace(re, arguments[i]);
	}
	return str;
}
if(!Array.prototype.push) {
    Array.prototype.push = function () {
        var startLength = this.length;
        for(var i = 0; i < arguments.length; i++) {
            this[startLength + i] = arguments[i];
        }
        return this.length;
    }
};
Array.extend({
	forEach: function(fn, bind){
		for (var i = 0, j = this.length; i < j; i++) {
			fn.call(bind, this[i], i, this);
		}
	},
	filter: function(fn, bind){
		var results = [];
		for (var i = 0, j = this.length; i < j; i++) {
			if (fn.call(bind, this[i], i, this)) {
				results.push(this[i]);
			}
		}
		return results;
	},
	map: function(fn, bind){
		var results = [];
		for (var i = 0, j = this.length; i < j; i++) {
			results[i] = fn.call(bind, this[i], i, this);
		}
		return results;
	},
	indexOf: function(item, from){
		var len = this.length;
		for (var i = (from < 0) ? Math.max(0, len + from) : from || 0; i < len; i++) {
			if (this[i] === item) {
				return i;
			}
		}
		return -1;
	},
	remove: function(item){
		var i = 0;
		var len = this.length;
		while (i < len) {
			if (this[i] === item) {
				this.splice(i, 1);
				len--;
			} else {
				i++;
			}
		}
		return this;
	},
	contains: function(item, from){
		return this.indexOf(item, from) != -1;
	},
	extend: function(array){
		for (var i = 0, j = array.length; i < j; i++) {
			this.push(array[i]);
		}
		return this;
	},
	merge: function(array){
		for (var i = 0, l = array.length; i < l; i++) {
			this.include(array[i]);
		}
		return this;
	},
	getLast: function(){
		return this[this.length - 1] || null;
	}
	
});
function ValidateCodePic(ctrId){
	var ctr = $(ctrId);
	if (ctr != null) {
		ctr.src = "createvalidatecode.ashx?ts=" + $time();
	}
};
var CommonRegex = {};
CommonRegex.Email = /\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*/;			
CommonRegex.DateTime = /^(\d{1,4})(-|\/)(\d{1,2})\2(\d{1,2})$/;	
CommonRegex.Password = /^.{6,16}$/;	
CommonRegex.UserName = /^[\u4e00-\u9fa5\s|\w\s]{2,16}$/;	
CommonRegex.PositiveNum = /^\d+$/;	
CommonRegex.PostCode = /^[1-9]\d{5}(?!\d)$/;
CommonRegex.CheckCode = /^[0-9a-zA-Z]{5}$/;	
CommonRegex.KeyRegexExpression = /^([0-9A-Fa-f]{32})$/;		

function isNullOrEmpty(arg){
	if (typeof(arg) == 'undefined') {
		return true;
	}
	if (arg) {
		return false;
	}
	return true;
}
function isEmpty(ctrOrCtrId){
	var ctr = $(ctrOrCtrId);
	return isNullOrEmpty(ctr.value);
}
String.extend({
	/*
	 *"I like cookies".test("cookie"); // returns true
	 *"I like cookies".test("COOKIE", "i") // ignore case, returns true
	 *"I like cookies".test("cake"); // returns false
	 */
	test: function(regex, params){
		return (($type(regex) == 'string') ? new RegExp(regex, params) : regex).test(this);
	},
	//Returns: either an int or "NaN" if the string is not a number.
	toInt: function(){
		return parseInt(this, 10);
	},
	//Returns: either a float or "NaN" if the string is not a number.
	toFloat: function(){
		return parseFloat(this);
	},
	toBoolean: function(){
		return this === "true" ? true : false;
	},
	/* 验证相关*/
	isInt: function(){
		return this.toInt() != "NaN" ? true : false;
	},
	isFloat: function(){
		return this.toFloat() != "NaN" ? true : false;
	},	
	isBoolean: function(){
		return (this === "true" || this === "false") ? true : false;
	},
	isKey: function(){
	    if (this.isNullOrEmpty()) {return false;}
		if (CommonRegex.KeyRegexExpression.test(this)) {
			return true;
		}
		return false;
	},
	isEmail: function(){
	    if (this.isNullOrEmpty()) {return false;}
		if (CommonRegex.Email.test(this)) {
			return true;
		}
		return false;
	},	
	isUserName: function(){
	    if (this.isNullOrEmpty()) {return false;}
		if (CommonRegex.UserName.test(this)) {
			return true;
		}
		return false;
	},
	isPassword: function(){
	    if (this.isNullOrEmpty()) {return false;}
		if (CommonRegex.Password.test(this)) {
			return true;
		}
		return false;
	},	
	isDateTime: function(){
	    if (this.isNullOrEmpty()) {return false;}
		if (CommonRegex.DateTime.test(this)) {
			return true;
		}
		return false;
	},
    isURL: function(){
        var re = /(ftp|http|https):\/\/(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?/;
        return re.test(this.toString());
    },		
	isCheckCode: function(){
	    if (this.isNullOrEmpty()) {return false;}
		if (CommonRegex.CheckCode.test(this)) {
			return true;
		}
		return false;
	},	
	isEqual: function(str){
		if (this == str) {
			return true;
		} else {
			return false;
		}
	},	
	isNullOrEmpty: function(){
		if (typeof(this) == 'undefined') {
			return true;
		}
		if (this.toString() !== "") {
			return false;
		}
		return true;
	},	
	isBetweenLen: function(minlen, maxlen){
		var l = this.len();
		if (l >= minlen & l <= maxlen) {
			return true;
		} else {
			return false;
		}		
	},	
	isBetweenLength: function(minlen, maxlen){
		var l = this.length;
		if (l >= minlen & l <= maxlen) {
			return true;
		} else {
			return false;
		}		
	},	
	/* 验证相关*/	
	//"    i like cookies     ".trim() //"i like cookies"
	trim: function(){
		return this.replace(/^\s*|\s*$/g, '');
	},
	//"    i like cookies     ".trim() //"i like cookies     "
	ltrim: function(){
		return this.replace(/(^\s*)/g, "");
	},
	//"    i like cookies".trim() //"    i like cookies"
	rtrim: function(){
		return this.replace(/(\s*$)/g, "");
	},
	//" i      like     cookies      \n\n".clean() //"i like cookies"
	clean: function(){
		return this.replace(/\s{2,}/g, ' ').trim();
	},
	/*
	 *"rgb(17,34,51)".rgbToHex(); //"#112233"
	 *"rgba(17,34,51,0)".rgbToHex(); //"transparent"
	 *"rgb(17,34,51)".rgbToHex(true); //['11','22','33']
	 */
	rgbToHex: function(array){
		var rgb = this.match(/\d{1,3}/g);
		return (rgb) ? rgb.rgbToHex(array) : false;
	},
	//"#112233".hexToRgb(); //"rgb(17,34,51)"
	hexToRgb: function(array){
		var hex = this.match(/^#?(\w{1,2})(\w{1,2})(\w{1,2})$/);
		return (hex) ? hex.slice(1).hexToRgb(array) : false;
	},
	//'a b c'.contains('c', ' '); //true
	contains: function(string, s){
		return (s) ? (s + this + s).indexOf(s + string + s) > -1 : this.indexOf(string) > -1;
	},
	rep: function(oldS, newS){
		return this.replace(/oldS/g, newS);
	},
	len: function(){
		var l = 0;
		for (var i = 0; i < this.length; i++) {
			if (this.charCodeAt(i) < 128) 
				l++;
			else 
				l += 2;
		}
		return l;
	},
	//'{name: 'john', age: 20}' -> object
	toJson: function(){
		return eval('(' + this + ')');
	}
});
function updateOptionText(selId, text, value){
	var select = $(selId);
	var opt = null;
	for (var i = 0; i < select.length; i++){
	    opt = select.options[i];
		var val = opt.value;
		if (!val){continue;}
		if (val == value){
			opt.text = text;
			break;
		} else {opt = null;}
	}
	return opt;
}
function removeOption(selId, value){
	var select = $(selId);
	var index = -1;
	for (var i = 0; i < select.length; i++){
		var val = select.options[i].value;
		if (!val){val = select.options[i].text;}
		if (val == value){
			index = i;
			break;
		}
	}
	if (index > -1){
	    if (select.options.remove){
	        select.options.remove(index);
	    } else {
	        select.remove(index);
	    }	
	}
}
function appendOption(selId, text, value){
	var selcted = true; var pop = false;
	if ($defined(arguments[3])){
		selcted = arguments[3];
	}
	var select = $(selId);
	var option = updateOptionText(select, text, value);
	if (option == null){
	    option = createOption(text, value);
	    if (select.options.add){
	        select.options.add(option);
	    } else {
	        select.add(option, null);
	    }
        option.appendChild(document.createTextNode(text));
	    option.value = value;
	    if (selcted == true){
		    option.selected = true;
	    }
	}
	return option;
}
function createOption(text, value){
	var option = $create("option");
	//option.text = text;
	//option.value = value;
	return option;
}
function removeElement(node){
	var element = $(node);
	if (element && element.parentNode) {
		element.parentNode.removeChild(element);
	}
}
function setVisible(divName, onOrOff){
	var tempDiv = $(divName);
	if (!tempDiv) {
		return;
	}
	if (onOrOff) {
		tempDiv.style.visibility = "visible";
	}
	else {
		tempDiv.style.visibility = "hidden";
	}
}
function openDiv(elName){
	var theElemenet = $(elName);
	if (theElemenet) {
		theElemenet.style.display = "block";
	}
}
function closeDiv(elName){
	var theElemenet = $(elName);
	if (theElemenet) {
		theElemenet.style.display = "none";
	}
}
function showInline(elName){
	var theElemenet = $(elName);
	if (theElemenet) {
		theElemenet.style.display = "inline";
	}
}
function hideInline(elName){
	var theElemenet = $(elName);
	if (theElemenet) {
		theElemenet.style.display = "none";
	}
}
function blurElement(elName){
	var theElement = $(elName);
	if (theElement) {
		theElement.blur();
	}
}
function focusElement(elName){
	var theElement = $(elName);
	if (theElement) {
		theElement.focus();
	}
}
function disabledElement(ctrId){
	var ctr = getElement(ctrId);
	if (ctr != null) 
		ctr.disabled = true;
}
function enabledElement(ctrId){
	var ctr = getElement(ctrId);
	if (ctr != null) 
		ctr.disabled = false;
}
function showAndHideElement(node){
	var element = $(node);
	if (element) {
		if (element.style.display == "block") {
			element.style.display = "none";
		} else {
			element.style.display = "block";
		}
	}
}
function resize_iframe(elid, delta){
	var el = $(elid);
	if (parseInt(el.height) + parseInt(delta) < 20) {
		el.height = 20;
	} else {
		el.height = parseInt(el.height) + parseInt(delta);
	}
}
function moreOrLess(aLink, shortText, longText){
    var aCtr = $(aLink); var val = aCtr.innerHTML; var sctr = aCtr.previousSibling.previousSibling; var lctr = aCtr.previousSibling; aCtr.blur();
    if (arguments.length > 1){
        sctr = $(shortText);
    }
    if (arguments.length > 2){
        lctr = $(longText);
    }
    if (val.toLowerCase() == "more" || val.toLowerCase() == "打开" || val.toLowerCase() == "更多"){
        sctr.style.display = "none"; lctr.style.display = ""; 
        if (val.toLowerCase() == "more"){aCtr.innerHTML = "Less";}
        else if (val.toLowerCase() == "打开"){aCtr.innerHTML = "收拢";}
        else if (val.toLowerCase() == "更多"){aCtr.innerHTML = "隐藏";}
    }else{
        sctr.style.display = ""; lctr.style.display = "none"; 
        if (val.toLowerCase() == "less"){aCtr.innerHTML = "More";}
        else if (val.toLowerCase() == "收拢"){aCtr.innerHTML = "打开";}
        else if (val.toLowerCase() == "隐藏"){aCtr.innerHTML = "更多";}        
    }
}
function clearElement(node){
	var element = $(node);
	for (var i in element) {
		try {
		
			element[i] = null;
		} catch (e) {
			continue;
		}
	}
}
function hasClass(node, _className){
	var element = $(node);
	var upperClass = _className.toUpperCase();
	if (element.className) {
		var classes = element.className.split(" ");
		for (var i = 0; i < classes.length; i++) {
			if (classes[i].toUpperCase() == upperClass) {
				return true;
			}
		}
	}
	return false;
}
function addClass(node, _class){
	var element = $(node);
	if (!hasClass(element, _class)) {
		element.className += element.className ? (" " + _class) : _class;
	}
}
function setClass(element, _class){
	var ctr = $(element);
	if (ctr) {
		ctr.className = _class;
	}
}
function removeClass(node, _class){
	var element = $(node);
	var upperClass = _class.toUpperCase();
	var remainingClasses = [];
	if (element.className) {
		var classes = element.className.split(' ');
		for (var i = 0; i < classes.length; i++) {
			if (classes[i].toUpperCase() != upperClass) {
				remainingClasses[remainingClasses.length] = classes[i];
			}
		}
		element.className = remainingClasses.join(' ');
	}
}
function setInnerHTML(div_id, value){
	var dstDiv = $(div_id);
	dstDiv.innerHTML = value;
}
function CurrentStyle(element){
	return element.currentStyle || document.defaultView.getComputedStyle(element, null);
}
function Contains(a, b){
	return a.contains ? a != b && a.contains(b) : !!(a.compareDocumentPosition(b) & 16);
}
function attachEvent(oTarget, sEventType, fnHandler){
	if (oTarget.addEventListener) {
		oTarget.addEventListener(sEventType, fnHandler, false);
	} else if (oTarget.attachEvent) {
		oTarget.attachEvent("on" + sEventType, fnHandler);
	} else {
		oTarget["on" + sEventType] = fnHandler;
	}
}
function detachEvent(oTarget, sEventType, fnHandler){
	if (oTarget.removeEventListener) {
		oTarget.removeEventListener(sEventType, fnHandler, false);
	} else if (oTarget.detachEvent) {
		oTarget.detachEvent("on" + sEventType, fnHandler);
	} else {
		oTarget["on" + sEventType] = null;
	}
}
function fireEvent(controlOrID, eventName){
	var ctr = $(controlOrID);
	if (document.all) {
		ctr.fireEvent(eventName.indexOf("on") == 0 ? eventName : "on" + eventName);
	} else {
		var e = document.createEvent('HTMLEvents');
		e.initEvent(eventName, false, false);
		document.getElementById(controlID).dispatchEvent(e);
	}
}
// 禁止默认行为;
function cancelDefault(e){
	if (e.preventDefault){ 
		e.preventDefault(); //2级DOM
	} else {
		e.returnValue = false; //IE
    }		    
}

// 阻止事件冒泡;
function cancelBubble(e){
	if (e.stopPropagation){
		e.stopPropagation(); //2 级DOM
	} else { 
		e.cancelBubble = true; //IE
    }
}
/*cookie functions*/
function readCookie(name){
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for (var i = 0; i < ca.length; i++) {
		var c = ca[i];
		while (c.charAt(0) == ' ') 
			c = c.substring(1, c.length);
		if (c.indexOf(nameEQ) == 0) 
			return c.substring(nameEQ.length, c.length);
	}
	return null;
}
function readIntCookie(name){
	var val = readCookie(name);
	if (val) {
		return parseInt(val, 10);
	} else {
		return 0;
	}
}
function addCookie(name, value, days){
	var cookie = "";
	var domain = "";
	var path = "/";
	cookie += name + "=" + value + ";";
	cookie += "path=" + path + ";";
	if (days) {
		var date = new Date();
		date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000));
		cookie += "expires=" + date.toGMTString() + ";";
	}
	document.cookie = cookie;
}
function removeCookie(name){
	addCookie(name, "", -1);
}
/*cookie functions*/
/*延时加载类*/
var LazyLoad = new Class({
	initialize:function(elems, options){
	    this.setOptions(options);
		this._elems = elems;//加载元素集合
		this._rect = {};//容器位置参数对象
		this._range = {};//加载范围参数对象
		this._loadData = Class.empty;//加载程序
		this._timer = null;//定时器
		this._lock = false;//延时锁定
		this._index = 0;//记录索引
		this._direction = 0;//记录方向
		this._lastScroll = {"left": 0,"top": 0};//记录滚动值
		this._setElems = Class.empty;//重置元素集合程序
		this.delay = this.options.delay;
		this.threshold = this.options.threshold;
		this.beforeLoad = this.options.beforeLoad;
		this._onLoadData = this.options.onLoadData;
		this.container = this.initContainer($(this.options.container));//容器
	},
	//设置默认属性
	setOptions: function(options){
		this.options = {
			container: window,//容器
			mode: "dynamic",//模式
			threshold: 20,//加载范围阈值
			delay: 100,//延时时间
			beforeLoad: function(){},//加载前执行
			onLoadData: function(){}//显示加载数据
		};
		$extend(this.options, options || {});
	},
	//初始化容器设置
	initContainer: function(container){
		var doc = document; this.isWindow = container == window || container == doc || !container.tagName || (/^(?:body|html)$/i).test(container.tagName);
		if (this.isWindow) { container = doc.compatMode == 'CSS1Compat' ? doc.documentElement : doc.body; }
		//定义执行方法
		var oThis = this, width = 0, height = 0;
		this.load = $b(this, this._load);
		this.resize = $b(this, this._resize);
		this.delayLoad = function(){
			oThis._delay(oThis.load);
		};
		this.delayResize = function(){//防止重复触发bug
			var clientWidth = container.clientWidth, clientHeight = container.clientHeight;
			if (clientWidth != width || clientHeight != height) {
				width = clientWidth; height = clientHeight; oThis._delay(oThis.resize);
			}
		};
		this._binder = this.isWindow ? window : container;//记录绑定元素方便移除
        if (this.isWindow){ window.onscroll = $be(this, this.delayLoad); window.onresize = $be(this, this.delayResize);} else { attachEvent(this._binder, "scroll", $be(this, this.delayLoad));}//绑定事件
		//获取容器位置参数函数
		this._getContainerRect = this.isWindow && ("innerHeight" in window) ? 
		    function(){ return { "left": 0, "right": window.innerWidth, "top": 0, "bottom": window.innerHeight } } : 
		    function(){ return oThis._getRect(container);};
		//设置获取scroll值函数
		this._getScroll = this.isWindow ? 
		    function(){ return { "left": document.documentElement.scrollLeft || document.body.scrollLeft, "top": document.documentElement.scrollTop || document.body.scrollTop } } : 
            function(){ return { "left": container.scrollLeft, "top": container.scrollTop } };
		return container;	
	},
	//初始化模式设置
	_initMode: function(){
		switch (this.options.mode.toLowerCase()) {
			case "vertical"://垂直方向
				this._initStatic("vertical", "vertical");
				break;
			case "horizontal"://水平方向
				this._initStatic("horizontal", "horizontal");
				break;
			case "cross":
			case "cross-vertical"://垂直正交方向
				this._initStatic("cross", "vertical");
				break;
			case "cross-horizontal"://水平正交方向
				this._initStatic("cross", "horizontal");
				break;
			case "dynamic"://动态加载
			default:
				this._loadData = this._loadDynamic;
		}
	},
	//初始化静态加载设置
	_initStatic: function(mode, direction){
		var isVertical = direction == "vertical";//设置模式
		if (mode == "cross") {
			this._crossDirection = $b(this, this._getCrossDirection, isVertical ? "_verticalDirection" : "_horizontalDirection", isVertical ? "_horizontalDirection" : "_verticalDirection");
		}
		var pos = isVertical ? "top" : "left", sortFunction = function(x, y){ return x._rect[pos] - y._rect[pos]; }; //设置元素
		var getRect = function(elem){ elem._rect = this._getRect(elem); return elem; };
		this._setElems = function(){ this._elems = this._elems.map(getRect, this).sort(sortFunction); };//转换数组并排序 
		this._loadData = $b(this, this._loadStatic, "_" + mode + "Direction", $b(this, this._outofRange, mode, "_" + direction + "BeforeRange"), $b(this, this._outofRange, mode, "_" + direction + "AfterRange"));
	},
	//延时程序
	_delay: function(run){
		clearTimeout(this._timer);
		if (this.isFinish()) {return;}
		var oThis = this, delay = this.delay;
		if (this._lock) {//防止连续触发
			this._timer = setTimeout(function(){ oThis._delay(run); }, delay);
		} else {
			this._lock = true; run(); setTimeout(function(){ oThis._lock = false; }, delay);
		}
	},
	//重置范围参数并加载数据
	_resize: function(change){
		if (this.isFinish()) { return; }
		this._rect = this._getContainerRect();
		//位置改变的话需要重置元素位置
		if (change) {
			this._setElems();
		}
		this._load(true);
	},
	//加载程序
	_load: function(force){
		if (this.isFinish()) { return; }
		var rect = this._rect, scroll = this._getScroll(), left = scroll.left, top = scroll.top, threshold = Math.max(0, this.threshold | 0);
		this._range = { top: rect.top + top - threshold, bottom: rect.bottom + top + threshold, left: rect.left + left - threshold, right: rect.right + left + threshold };//记录原始加载范围参数
		this.beforeLoad();//加载数据
		this._loadData(force);
	},
	//动态加载程序
	_loadDynamic: function(){
		this._elems = this._elems.filter(function(elem){ return !this._insideRange(elem); }, this);
	},
	//静态加载程序
	_loadStatic: function(direction, beforeRange, afterRange, force){
		direction = this[direction](force);//获取方向
		if (!direction) { return; }
		//根据方向历遍图片对象
		var elems = this._elems, i = this._index, begin = [], middle = [], end = [];
		if (direction > 0) {//向后滚动
			begin = elems.slice(0, i);
			for (var len = elems.length; i < len; i++) {
				if (afterRange(middle, elems[i])) {
					end = elems.slice(i + 1);
					break;
				}
			}
			i = begin.length + middle.length - 1;
		} else {//向前滚动
			end = elems.slice(i + 1);
			for (; i >= 0; i--) {
				if (beforeRange(middle, elems[i])) {
					begin = elems.slice(0, i);
					break;
				}
			}
			middle.reverse();
		}
		this._index = Math.max(0, i);
		this._elems = begin.concat(middle, end);
	},
	//垂直和水平滚动方向获取程序
	_verticalDirection: function(force){
		return this._getDirection(force, "top");
	},
	_horizontalDirection: function(force){
		return this._getDirection(force, "left");
	},
	//滚动方向获取程序
	_getDirection: function(force, scroll){
		var now = this._getScroll()[scroll], _scroll = this._lastScroll;
		if (force) {
			_scroll[scroll] = now;
			this._index = 0;
			return 1;
		}
		var old = _scroll[scroll];
		_scroll[scroll] = now;
		return now - old;
	},
	//cross滚动方向获取程序
	_getCrossDirection: function(primary, secondary, force){
		var direction;
		if (!force) {
			direction = this[primary]();
			secondary = this[secondary]();
			if (!direction && !secondary) {//无滚动
				return 0;
			} else if (!direction) {//次方向滚动
				if (this._direction) {
					direction = -this._direction;//用上一次的相反方向
				} else {
					force = true;//没有记录过方向
				}
			} else if (secondary && direction * this._direction >= 0) {
				force = true;//同时滚动并且方向跟上一次滚动相同
			}
		}
		if (force) {
			this._lastScroll = this._getScroll();
			this._index = 0;
			direction = 1;
		}
		return (this._direction = direction);
	},
	//判断是否加载范围内
	_insideRange: function(elem, mode){
		var range = this._range, rect = elem._rect || this._getRect(elem), insideH = rect.right >= range.left && rect.left <= range.right, insideV = rect.bottom >= range.top && rect.top <= range.bottom, 
		inside = { "horizontal": insideH, "vertical": insideV, "cross": insideH && insideV }[mode || "cross"];
		var dvds = inside && this._elementIsView(elem);
		if (dvds) { this._onLoadData(elem); }
		return dvds;
	},
	//判断是否超过加载范围
	_outofRange: function(mode, compare, middle, elem){
		if (!this._insideRange(elem, mode)) {
			middle.push(elem);
			return this[compare](elem._rect);
		}
	},
	_horizontalBeforeRange: function(rect){
		return rect.right < this._range.left;
	},
	_horizontalAfterRange: function(rect){
		return rect.left > this._range.right;
	},
	_verticalBeforeRange: function(rect){
		return rect.bottom < this._range.top;
	},
	_verticalAfterRange: function(rect){
		return rect.top > this._range.bottom;
	},
	//获取位置参数
	_getRect: function(node){
		var n = node, left = 0, top = 0, right = 0, bottom = 0;
		while (n) { left += n.offsetLeft; top += n.offsetTop; n = n.offsetParent; }; right = left + node.offsetWidth; bottom = top + node.offsetHeight;
		return { "left": left, "right": right, "top": top, "bottom": bottom };
	},
    _elementIsView: function(element){
        while(element && (element !== this.container && element !== window && element !== document && element !== document.body)){
            var dis, vis;
            if (element.currentStyle) {
                dis = element.currentStyle['display'];vis = element.currentStyle['visibility'];
            } else if (document.defaultView.getComputedStyle) {
                dis = document.defaultView.getComputedStyle(element, null).getPropertyValue("display");vis = document.defaultView.getComputedStyle(element, null).getPropertyValue("visibility");
            }
            if (dis && vis && (dis === "none" || vis === "hidden")) {
                return false;
            } else {
                element = element.parentNode;
            }
        }
        return true;
    },		
	//是否完成加载
	isFinish: function(){
		if (!this._elems || !this._elems.length) {
			this.dispose();
			return true;
		} else {
			return false;
		}
	},
	//销毁程序
	dispose: function(load){
		clearTimeout(this._timer);
		if (this._elems || this._binder) {
			if (load && this._elems) {//加载全部元素
				this._elems.forEach(this._onLoadData, this);
			}
		    if (this._binder && this.isWindow){ window.onscroll = Class.empty; window.onresize = Class.empty;} else { detachEvent(this._binder, "resize", $be(this, this.delayResize));}//绑定事件
			this._elems = this._binder = null;
		}
	}
});
/*end 延时加载类*/
/*图像延时加载类*/
var ImagesLazyLoad = LazyLoad.extend({
	//初始化程序
	initialize: function(options){
		options = options || {}; $extend(options, { onLoadData: this._onLoadData });
		LazyLoad.prototype.initialize.call(this, [], options);
		this.setOptions(options);//设置子类属性
		var opt = this.options;
		this.onLoad = opt.onLoad;
		var attribute = this._attribute = opt.attribute;
		var getSrc = opt.getSrc;//设置加载图片集合
		this._hasAttribute = Sys.ie ? function(img){ return attribute in img; } : function(img){ return img.hasAttribute(attribute); };//判断属性是否已经加载的方法
		var filter = $b(this, this._filter, opt["class"], getSrc ? function(img){ return getSrc(img); } : function(img){ return img.getAttribute(attribute) || img.src; }, opt.holder);
		this._elems = []; this._elems.extend(opt.images || this.container.getElementsByTagName("img")); this._elems = this._elems.filter(filter, this);
		if (this.isFinish()) { return; }
		this._initMode();
		this.resize(true);
	},
	//设置默认属性
	setOptions: function(options){
		this.options = {
			images: undefined,//图片集合
			attribute: "_lazysrc",//保存原图地址的自定义属性
			holder: "/images/pixel.gif",//占位图
			"class": "",//筛选样式
			getSrc: undefined,//获取原图地址程序
			onLoad: Class.empty
		};
		$extend(this.options, options || {});
		LazyLoad.prototype.setOptions.call(this, this.options);
	},
	//筛选整理图片对象
	_filter: function(cls, getSrc, holder, img){
		if (cls && img.className !== cls) { return false; } //排除样式不对应的
		if (!this._hasAttribute(img)){return false;}
		var src = getSrc(img); //获取原图地址
		if (!src) { return false; }//排除src不存在的
		if (src == img.src) {
			if (img.complete || Sys.chrome || Sys.safari) { return false; }//排除已经加载或不能停止加载的
			img.removeAttribute("src");//移除src
		}
		if (holder) {
			img.src = holder;
		}
		img.setAttribute(this._attribute, src);//用自定义属性记录原图地址
		return true;
	},
	//显示图片
	_onLoadData: function(img){
		var attribute = this._attribute;
		if (this._hasAttribute(img) && this._elementIsView(img)) {
			var ly = img.getAttribute(attribute); setTimeout(function(){img.src = ly;},Math.random() * 5);
			img.removeAttribute(attribute); if (img.onload){ img.onload(); }
			this.onLoad(img);
		}
	}
});
function initImagesLazy(){
    if (window["lazy_xylker_001"]){window["lazy_xylker_001"].dispose();}window["lazy_xylker_001"] = new ImagesLazyLoad();
}
/*end 图像延时加载类*/
/*Ajax类*/
var Ajax = new Class({
	initialize: function(url, options){
		this.url = url;
		this.headers = {};
		this.setTransport().setOptions(options);
		$extend(this.headers, this.options.headers || {});
		this.setHeader('X-Requested-With', 'XMLHttpRequest');
		this.setHeader('Accept', 'text/javascript, text/html, application/xml, text/xml, */*');
		if (this.options.urlEncoded && this.options.method == 'post') {
			var encoding = (this.options.encoding) ? '; charset=' + this.options.encoding : '';
			this.setHeader('Content-type', 'application/x-www-form-urlencoded' + encoding);
		}
	},
	setOptions: function(options){
		this.options = {
			data: null,
			method: 'post',
			async: true,
			onRequest: Class.empty,
			onSuccess: Class.empty,
			onFailure: Class.empty,
			isSuccess: this.isSuccess,
			urlEncoded: true,
			encoding: 'utf-8',
			autoCancel: false,
			evalScripts: false,
			evalResponse: false,
			update: null,
			headers: {}
		}
		$extend(this.options, options || {});
	},
	setTransport: function(){
		this.transport = (window.XMLHttpRequest) ? new XMLHttpRequest() : (Sys.ie ? new ActiveXObject('Microsoft.XMLHTTP') : false);
		return this;
	},
	onStateChange: function(){
		if (this.transport.readyState != 4 || !this.running) {
			return;
		}
		this.running = false;
		var status = 0;
		try {
			status = this.transport.status;
		} catch (e) {
		};
		if (this.options.isSuccess.call(this, status)) {
			this.onSuccess();
		} else {
			this.onFailure();
		}
		this.transport.onreadystatechange = Class.empty;
	},
	isSuccess: function(status){
		return ((status >= 200) && (status < 300));
	},
	onSuccess: function(){
	    window["request_userIsLogin"] = $time();
		this.response = {
			'text': this.transport.responseText,
			'xml': this.transport.responseXML
		};
		if (this.options.update) {
			setInnerHTML(this.options.update, this.response.text);
		}
		if (this.options.evalScripts || this.options.evalResponse) {
			this.evalScripts();
		}
		this.options.onSuccess(this, this.response);
	},
	onFailure: function(){
		this.options.onFailure(this, this.response);
	},
	setHeader: function(name, value){
		this.headers[name] = value;
		return this;
	},
	send: function(data){
		if (this.options.autoCancel) {
			this.cancel();
		} else {
			if (this.running) {
				return this;
			}
		}
		this.running = true;
		var url = this.url;
		if (data && this.options.method == 'get') {
			url = url + (url.indexOf('?') > 0 ? '&' : '?') + data;
			data = null;
		}
		this.transport.open(this.options.method.toUpperCase(), url, this.options.async);
		this.transport.onreadystatechange = $b(this, this.onStateChange);
		if ((this.options.method == 'post') && this.transport.overrideMimeType) {
			this.setHeader('Connection', 'close');
		}
		for (var type in this.headers) {
			try {
				this.transport.setRequestHeader(type, this.headers[type]);
			} catch (e) {
			};
					}
		this.options.onRequest(this, data);
		this.transport.send(data ? data : null);
		return this;
	},
	request: function(data){
		data = data || this.options.data;
		var queryString = "";
		switch ($type(data)) {
			case 'element':
				queryString = $(data).toQueryString();
				break;
			case 'object':
				if (!this.options.data) {
					this.options.data = {};
				}
				$extend(this.options.data, data);
				queryString = Object.toQueryString(this.options.data);
				break;
			case 'string':
				queryString = data;
				break;
		}
		if (this._method) {
			queryString = (queryString) ? [this._method, queryString].join('&') : this._method;
		}
		return this.send(queryString);
	},
	cancel: function(){
		if (!this.running) 
			return this;
		this.running = false;
		this.transport.abort();
		this.transport.onreadystatechange = Class.empty;
		this.setTransport();
		this.options.onCancel(this);
		return this;
	},
	evalScripts: function(){
		var script, scripts;
		if (this.options.evalResponse || (/(ecma|java)script/).test(this.getHeader('Content-type'))) 
			scripts = this.response.text;
		else {
			scripts = [];
			var regexp = /<script[^>]*>([\s\S]*?)<\/script>/gi;
			while ((script = regexp.exec(this.response.text))) 
				scripts.push(script[1]);
			scripts = scripts.join('\n');
		}
		if (scripts) 
			(window.execScript) ? window.execScript(scripts) : window.setTimeout(scripts, 0);
	},
	getHeader: function(name){
		try {
			return this.transport.getResponseHeader(name);
		} catch (e) {
		};
		return null;
	}
});
/*end Ajax类*/
/*  DateSelector */
var DateSelector = new Class({
	initialize: function(oYear, oMonth, oDay, options){
		this.SelYear = $(oYear);//年选择对象
		this.SelMonth = $(oMonth);//月选择对象
		this.SelDay = $(oDay);//日选择对象
		this.SetOptions(options);
		
		var dt = new Date(), iMonth = parseInt(this.options.Month), iDay = parseInt(this.options.Day), iMinYear = parseInt(this.options.MinYear), iMaxYear = parseInt(this.options.MaxYear);
		
		this.Year = parseInt(this.options.Year) || dt.getFullYear();
		this.Month = 1 <= iMonth && iMonth <= 12 ? iMonth : dt.getMonth() + 1;
		this.Day = iDay > 0 ? iDay : dt.getDate();
		this.MinYear = iMinYear && iMinYear < this.Year ? iMinYear : this.Year;
		this.MaxYear = iMaxYear && iMaxYear > this.Year ? iMaxYear : this.Year;
		this.onChange = this.options.onChange;
		
		//年设置
		this.SetSelect(this.SelYear, this.MinYear, this.MaxYear - this.MinYear + 1, this.Year - this.MinYear);
		//月设置
		this.SetSelect(this.SelMonth, 1, 12, this.Month - 1);
		//日设置
		this.SetDay();
		
		var oThis = this;
		//日期改变事件
		attachEvent(this.SelYear, "change", function(){
			oThis.Year = oThis.SelYear.value;
			oThis.SetDay();
			oThis.onChange();
		});
		attachEvent(this.SelMonth, "change", function(){
			oThis.Month = oThis.SelMonth.value;
			oThis.SetDay();
			oThis.onChange();
		});
		attachEvent(this.SelDay, "change", function(){
			oThis.Day = oThis.SelDay.value;
			oThis.onChange();
		});
	},
	//设置默认属性
	SetOptions: function(options){
		this.options = {//默认值
			Year: 0,//年
			Month: 0,//月
			Day: 0,//日
			MinYear: 0,//最小年份
			MaxYear: 0,//最大年份
			onChange: function(){
			}//日期改变时执行
		};
		$extend(this.options, options ||
		{});
	},
	//日设置
	SetDay: function(){
		//取得月份天数
		var daysInMonth = new Date(this.Year, this.Month, 0).getDate();
		if (this.Day > daysInMonth) {
			this.Day = daysInMonth;
		};
		this.SetSelect(this.SelDay, 1, daysInMonth, this.Day - 1);
	},
	//select设置
	SetSelect: function(oSelect, iStart, iLength, iIndex){
		//添加option
		oSelect.options.length = iLength;
		for (var i = 0; i < iLength; i++) {
			oSelect.options[i].text = oSelect.options[i].value = iStart + i;
		}
		//设置选中项
		oSelect.selectedIndex = iIndex;
	}
});
/* end DateSelector */
/*                                         OverLay                                   */
var OverLay = new Class({
	initialize: function(options){
	
		this.SetOptions(options);
		
		this.Lay = $(this.options.Lay) || document.body.insertBefore($create("div"), document.body.childNodes[0]);
		
		this.Color = this.options.Color;
		this.Opacity = parseInt(this.options.Opacity);
		this.zIndex = parseInt(this.options.zIndex);
		
		with (this.Lay.style) {
			display = "none";
			zIndex = this.zIndex;
			left = top = 0;
			position = "fixed";
			width = height = "100%";
		}
		
		if (Sys.ie6) {
			this.Lay.style.position = "absolute";
			//ie6设置覆盖层大小程序
			this._resize = $b(this, function(){
				this.Lay.style.width = Math.max(document.documentElement.scrollWidth, document.documentElement.clientWidth) + "px";
				this.Lay.style.height = Math.max(document.documentElement.scrollHeight, document.documentElement.clientHeight) + "px";
			});
			//遮盖select
			this.Lay.innerHTML = '<iframe style="position:absolute;top:0;left:0;width:100%;height:100%;filter:alpha(opacity=0);"></iframe>'
		}
	},
	//设置默认属性
	SetOptions: function(options){
		this.options = {//默认值
			Lay: null,//覆盖层对象
			Color: "#fff",//背景色
			Opacity: 50,//透明度(0-100)
			zIndex: 1000//层叠顺序
		};
		$extend(this.options, options ||
		{});
	},
	//显示
	Show: function(){
		//兼容ie6
		if (Sys.ie6) {
			this._resize();
			window.attachEvent("onresize", this._resize);
		}
		//设置样式
		with (this.Lay.style) {
			//设置透明度
			Sys.ie ? filter = "alpha(opacity:" + this.Opacity + ")" : opacity = this.Opacity / 100;
			backgroundColor = this.Color;
			display = "block";
		}
	},
	//关闭
	Close: function(){
		this.Lay.style.display = "none";
		if (Sys.ie6) {
			window.detachEvent("onresize", this._resize);
		}
	},
	//释放
	Dispose: function(){
		removeElement(this.Lay);
	}
});
/*                                         End  OverLay                                   */
/*                                         SlideTrans                                   */
var SlideTrans = new Class({
	initialize: function(container, slider, count, options){
		this._slider = $(slider);
		if (!this._slider) 
			return;
		this._container = $(container);//容器对象
		if (!this._container) 
			return;
		this._timer = null;//定时器
		this._count = Math.abs(count);//切换数量
		this._target = 0;//目标值
		this._t = this._b = this._c = 0;//tween参数
		this.Index = 0;//当前索引
		this.SetOptions(options);		
		this.Auto = !!this.options.Auto;
		this.Duration = Math.abs(this.options.Duration);
		this.Time = Math.abs(this.options.Time);
		this.Pause = Math.abs(this.options.Pause);
		this.Tween = this.options.Tween;
		this.onStart = this.options.onStart;
		this.onFinish = this.options.onFinish;
		
		var bVertical = !!this.options.Vertical;
		this._css = bVertical ? "top" : "left";//方向
		//样式设置
		var p = CurrentStyle(this._container).position;
		p == "relative" || p == "absolute" || (this._container.style.position = "absolute");
		//this._container.style.overflow = "hidden";
		//this._slider.style.position = "absolute";
		p = CurrentStyle(this._slider).position;
		if (p !== "relative" && p !== "absolute" && (this._slider.style.position !== "absolute")){this._slider.style.position = "absolute";}
		
		this.Change = this.options.Change ? this.options.Change : this._slider[bVertical ? "offsetHeight" : "offsetWidth"] / this._count;
	},
	//设置默认属性
	SetOptions: function(options){
		this.options = {//默认值
			Vertical: true,//是否垂直方向（方向不能改）
			Auto: true,//是否自动
			Change: 0,//改变量
			Duration: 50,//滑动持续时间
			Time: 10,//滑动延时
			Pause: 2000,//停顿时间(Auto为true时有效)
			onStart: function(){ },//开始转换时执行
			onFinish: function(){ },//完成转换时执行
			Tween: Tween.Quart.easeOut//tween算子
		};
		$extend(this.options, options || {});
	},
	//开始切换
	Run: function(index){
		//修正index
		index == undefined && (index = this.Index);
		index < 0 && (index = this._count - 1) || index >= this._count && (index = 0);
		//设置参数
		this._target = -Math.abs(this.Change) * (this.Index = index);
		this._t = 0;
		this._b = parseInt(CurrentStyle(this._slider)[this.options.Vertical ? "top" : "left"]);
		this._c = this._target - this._b;
		
		this.onStart();
		this.Move();
	},
	//移动
	Move: function(){
		clearTimeout(this._timer);
		//未到达目标继续移动否则进行下一次滑动
		if (this._c && this._t < this.Duration) {
			this.MoveTo(Math.round(this.Tween(this._t++, this._b, this._c, this.Duration)));
			this._timer = setTimeout($b(this, this.Move), this.Time);
		} else {
			this.MoveTo(this._target);
			this.Auto && (this._timer = setTimeout($b(this, this.Next), this.Pause));
		}
	},
	//移动到
	MoveTo: function(i){
		this._slider.style[this._css] = i + "px";
	},
	//下一个
	Next: function(){
		this.Run(++this.Index);	
	},
	//上一个
	Previous: function(){
		this.Run(--this.Index);
	},
	//停止
	Stop: function(){
		clearTimeout(this._timer);
		this.MoveTo(this._target);
	},
	//添加变换对象
	Add: function(sIimg, sText, sUrl){
		this.List.push({img: sIimg, text: sText, url: sUrl});
	}
});
var Tween = {
	Quart: {
		easeOut: function(t, b, c, d){
			return -c * ((t = t / d - 1) * t * t * t - 1) + b;
		}
	},
	Back: {
		easeOut: function(t, b, c, d, s){
			if (s == undefined) 
				s = 1.70158;
			return c * ((t = t / d - 1) * t * ((s + 1) * t + s) + 1) + b;
		}
	},
	Bounce: {
		easeOut: function(t, b, c, d){
			if ((t /= d) < (1 / 2.75)) {
				return c * (7.5625 * t * t) + b;
			} else if (t < (2 / 2.75)) {
				return c * (7.5625 * (t -= (1.5 / 2.75)) * t + .75) + b;
			} else if (t < (2.5 / 2.75)) {
				return c * (7.5625 * (t -= (2.25 / 2.75)) * t + .9375) + b;
			} else {
				return c * (7.5625 * (t -= (2.625 / 2.75)) * t + .984375) + b;
			}
		}
	}
}
/*                                        End SlideTrans                                   */
/*                                         LightBox                                       */
var LightBox = function(){}
LightBox.page=function(){
	return{
		top:function(){return document.body.scrollTop||document.documentElement.scrollTop},
		left:function(){return document.body.scrollLeft||document.documentElement.scrollLeft},
		width:function(){return self.innerWidth||document.documentElement.clientWidth},
		height:function(){return self.innerHeight||document.documentElement.clientHeight},
		theight:function(){
			var d=document, b=d.body, e=d.documentElement;
			return Math.max(Math.max(b.scrollHeight,e.scrollHeight),Math.max(b.clientHeight,e.clientHeight))
		},
		twidth:function(){
			var d=document, b=d.body, e=d.documentElement;
			return Math.max(Math.max(b.scrollWidth,e.scrollWidth),Math.max(b.clientWidth,e.clientWidth))
		}
	}
}();
//拖放程序
var Drag = new Class({
	//拖放对象
	initialize: function(drag, options){
		this.Drag = $(drag);//拖放对象
		this._x = this._y = 0;//记录鼠标相对拖放对象的位置
		this._marginLeft = this._marginTop = 0;//记录margin
		//事件对象(用于绑定移除事件)
		this._fM = $be(this, this.Move);
		this._fS = $b(this, this.Stop);
		
		this.SetOptions(options);
		
		this.Limit = !!this.options.Limit;
		this.mxLeft = parseInt(this.options.mxLeft);
		this.mxRight = parseInt(this.options.mxRight);
		this.mxTop = parseInt(this.options.mxTop);
		this.mxBottom = parseInt(this.options.mxBottom);
		
		this.LockX = !!this.options.LockX;
		this.LockY = !!this.options.LockY;
		this.Lock = !!this.options.Lock;
		
		this.onStart = this.options.onStart;
		this.onMove = this.options.onMove;
		this.onStop = this.options.onStop;
		
		this._Handle = $(this.options.Handle) || this.Drag;
		this._mxContainer = $(this.options.mxContainer) || null;
		
		this.Drag.style.position = "absolute";
		//透明
		if (Sys.ie && !!this.options.Transparent) {
			//填充拖放对象
			with (this._Handle.appendChild(document.createElement("div")).style) {
				width = height = "100%";
				backgroundColor = "#fff";
				filter = "alpha(opacity:0)";
				fontSize = 0;
			}
		}
		//修正范围
		this.Repair();
		attachEvent(this._Handle, "mousedown", $be(this, this.Start));
	},
	//设置默认属性
	SetOptions: function(options){
		this.options = {//默认值
			Handle: "",//设置触发对象（不设置则使用拖放对象）
			Limit: false,//是否设置范围限制(为true时下面参数有用,可以是负数)
			mxLeft: 0,//左边限制
			mxRight: 9999,//右边限制
			mxTop: 0,//上边限制
			mxBottom: 9999,//下边限制
			mxContainer: "",//指定限制在容器内
			LockX: false,//是否锁定水平方向拖放
			LockY: false,//是否锁定垂直方向拖放
			Lock: false,//是否锁定
			Transparent: false,//是否透明
			onStart: function(){
			},//开始移动时执行
			onMove: function(){
			},//移动时执行
			onStop: function(){
			}//结束移动时执行
		};
		$extend(this.options, options || {});
	},
	//准备拖动
	Start: function(oEvent){
		if (this.Lock) {
			return;
		}
		this.Repair();
		//记录鼠标相对拖放对象的位置
		this._x = oEvent.clientX - this.Drag.offsetLeft;
		this._y = oEvent.clientY - this.Drag.offsetTop;
		//记录margin
		this._marginLeft = parseInt(CurrentStyle(this.Drag).marginLeft) || 0;
		this._marginTop = parseInt(CurrentStyle(this.Drag).marginTop) || 0;
		//mousemove时移动 mouseup时停止
		attachEvent(document, "mousemove", this._fM);
		attachEvent(document, "mouseup", this._fS);
		if (Sys.ie) {
			//焦点丢失
			attachEvent(this._Handle, "losecapture", this._fS);
			//设置鼠标捕获
			this._Handle.setCapture();
		} else {
			//焦点丢失
			attachEvent(window, "blur", this._fS);
			//阻止默认动作
			oEvent.preventDefault();
		};
		this.Drag['style']['opacity'] = "0.7";
		//附加程序
		this.onStart();
	},
	//修正范围
	Repair: function(){
		if (this.Limit) {
			//修正错误范围参数
			this.mxRight = Math.max(this.mxRight, this.mxLeft + this.Drag.offsetWidth);
			this.mxBottom = Math.max(this.mxBottom, this.mxTop + this.Drag.offsetHeight);
			//如果有容器必须设置position为relative或absolute来相对或绝对定位，并在获取offset之前设置
			!this._mxContainer || CurrentStyle(this._mxContainer).position == "relative" || CurrentStyle(this._mxContainer).position == "absolute" || (this._mxContainer.style.position = "relative");
		}
	},
	//拖动
	Move: function(oEvent){
		//判断是否锁定
		if (this.Lock) {
			this.Stop();
			return;
		};
		//清除选择
		window.getSelection ? window.getSelection().removeAllRanges() : document.selection.empty();
		//设置移动参数
		var iLeft = oEvent.clientX - this._x, iTop = oEvent.clientY - this._y;
		//设置范围限制
		if (this.Limit) {
			//设置范围参数
			var mxLeft = this.mxLeft, mxRight = this.mxRight, mxTop = this.mxTop, mxBottom = this.mxBottom;
			//如果设置了容器，再修正范围参数
			if (!!this._mxContainer) {
				mxLeft = Math.max(mxLeft, 0);
				mxTop = Math.max(mxTop, 0);
				mxRight = Math.min(mxRight, this._mxContainer.clientWidth);
				mxBottom = Math.min(mxBottom, this._mxContainer.clientHeight);
			};
			//修正移动参数
			iLeft = Math.max(Math.min(iLeft, mxRight - this.Drag.offsetWidth), mxLeft);
			iTop = Math.max(Math.min(iTop, mxBottom - this.Drag.offsetHeight), mxTop);
		}
		//设置位置，并修正margin
		if (!this.LockX) {
			this.Drag.style.left = iLeft - this._marginLeft + "px";
		}
		if (!this.LockY) {
			this.Drag.style.top = iTop - this._marginTop + "px";
		}
		//附加程序
		this.onMove();
	},
	//停止拖动
	Stop: function(){
		//移除事件
		detachEvent(document, "mousemove", this._fM);
		detachEvent(document, "mouseup", this._fS);
		if (Sys.ie) {
			detachEvent(this._Handle, "losecapture", this._fS);
			this._Handle.releaseCapture();
		} else {
			detachEvent(window, "blur", this._fS);
		};
		this.Drag['style']['opacity'] = "1.0";
		//附加程序
		this.onStop();
	}
});
var FadeStruct = function(options){
	this.run = false;//是否渐变
	this.start = 0;//开始值
	this.end = 0;//结束值
	this.target = 0;//目标值
	$extend(this, options || {});
}

var Fade = new Class({
	initialize: function(obj, options){
	
		var obj = $(obj);
		obj.style.overflow = "hidden";
		this._obj = obj;
		this.currentStyle = CurrentStyle(obj);
		this._timer = null;//定时器
		this._finish = true;//是否执行完成
		this._fun = function(){
		};//渐变程序
		this._x = this._y = 0;//变换点位置
		//设置获取透明度程序
		this._setOpacity = Sys.ie ? function(opacity){
			obj.style.filter = "alpha(opacity:" + opacity + ")";
		}
 : function(opacity){
			obj.style.opacity = opacity / 100;
		};
		this._getOpacity = Sys.ie ? function(){
			return parseInt(obj.filters["alpha"].opacity);
		}
 : function(opacity){
			return 100 * parseFloat(this.currentStyle.opacity);
		};
		
		//获取边框宽度程序
		this._xBorder = function(){
			return (parseInt(this.currentStyle.borderLeftWidth) + parseInt(this.currentStyle.borderRightWidth));
		}
		this._yBorder = function(){
			return (parseInt(this.currentStyle.borderTopWidth) + parseInt(this.currentStyle.borderBottomWidth));
		}
		
		this.SetOptions(options);
		
		this.Mode = this.options.Mode;
		this.Time = Math.abs(this.options.Time);
		this.onFinish = this.options.onFinish;
		
		//先设置特殊默认值
		this.Opacity = new FadeStruct({
			end: 100
		});
		this.Top = new FadeStruct({
			start: this._obj.offsetTop,
			end: this._obj.offsetTop
		});
		this.Left = new FadeStruct({
			start: this._obj.offsetLeft,
			end: this._obj.offsetLeft
		});
		this.Height = new FadeStruct({
			end: this._obj.offsetHeight - this._yBorder()
		});
		this.Width = new FadeStruct({
			end: this._obj.offsetWidth - this._xBorder()
		});
		
		//再设置用户默认值
		$extend(this.Opacity, this.options.Opacity);
		$extend(this.Top, this.options.Top);
		$extend(this.Left, this.options.Left);
		$extend(this.Height, this.options.Height);
		$extend(this.Width, this.options.Width);
		
		//变换位置参数
		this.Height.pos = Number(this.options.Height.pos);
		this.Width.pos = Number(this.options.Width.pos);
		
		//设置成默认状态
		this.Show = !this.options.Show;
		this.Step = 1;
		this.Start();
		//重新设置Step
		this.Step = Math.abs(this.options.Step);
	},
	//设置默认属性
	SetOptions: function(options){
		this.options = {//默认值
			Opacity: {},//透明渐变参数
			Height: {},//高度渐变参数
			Width: {},//宽度渐变参数
			Top: {},//Top渐变参数
			Left: {},//Left渐变参数
			Step: 10,//变化率
			Time: 10,//变化间隔
			Mode: "both",//渐变顺序
			Show: false,//是否默认打开状态
			onFinish: function(){
			}//完成时执行
		};
		$extend(this.options, options || {});
	},
	//触发
	Start: function(){
		clearTimeout(this._timer);
		//取反表示要设置的状态
		this.Show = !this.Show;
		//为避免透明度为null值，需要先设置一次透明度
		if (this.Opacity.run) {
			this._setOpacity(this.Show ? this.Opacity.start : this.Opacity.end);
		}
		//根据状态设置目标值
		if (this.Show) {
			this.Opacity.target = this.Opacity.end;
			this.Top.target = this.Top.end;
			this.Left.target = this.Left.end;
			this.Height.target = this.Height.end;
			this.Width.target = this.Width.end;
		} else {
			this.Opacity.target = this.Opacity.start;
			this.Top.target = this.Top.start;
			this.Left.target = this.Left.start;
			this.Height.target = this.Height.start;
			this.Width.target = this.Width.start;
		}
		//设置渐变程序
		switch (this.Mode.toLowerCase()) {
			case "width":
				this._fun = function(){
					this.SetWidth() && this.SetHeight();
					//由于分了两步，下面的步长变成两倍
					this.Step = 2 * this.Step;
					this.SetOpacity();
					this.SetTop();
					this.SetLeft();
					this.Step = this.Step / 2;
				}
				break;
			case "height":
				this._fun = function(){
					this.SetHeight() && this.SetWidth();
					//由于分了两步，下面的步长变成两倍
					this.Step = 2 * this.Step;
					this.SetOpacity();
					this.SetTop();
					this.SetLeft();
					this.Step = this.Step / 2;
				}
				break;
			case "both":
			default:
				this._fun = function(){
					this.SetHeight();
					this.SetWidth();
					this.SetOpacity();
					this.SetTop();
					this.SetLeft();
				}
		}
		//获取变换点位置
		//由于设置变换点后与top和left变换有冲突只能执行其一
		if (this.Height.pos) {
			this._y = this._obj.offsetTop + this._obj.offsetHeight * this.Height.pos;
			this.Top.run = false;
		}
		if (this.Width.pos) {
			this._x = this._obj.offsetLeft + this._obj.offsetWidth * this.Width.pos;
			this.Left.run = false;
		}
		
		this.Run();
	},
	//执行
	Run: function(){
		clearTimeout(this._timer);
		this._finish = true;
		//执行渐变
		this._fun();
		//未完成继续执行
		if (this._finish) {
			this.onFinish();
		} else {
			var oThis = this;
			this._timer = setTimeout(function(){
				oThis.Run();
			}, this.Time);
		}
	},
	//设置高度渐变
	SetHeight: function(){
		var iGet = this.Get(this.Height, this._obj.offsetHeight - this._yBorder());
		if (isNaN(iGet)) 
			return true;
		
		
		this._obj.style.height = iGet + "px";
		//如果有变换点设置
		if (this.Height.pos) {
			this._obj.style.top = this._y - this._obj.offsetHeight * this.Height.pos + "px";
		}
		return false;
	},
	//设置宽度渐变
	SetWidth: function(){
		var iGet = this.Get(this.Width, this._obj.offsetWidth - this._xBorder());
		if (isNaN(iGet)) 
			return true;
		
		this._obj.style.width = iGet + "px";
		if (this.Width.pos) {
			this._obj.style.left = this._x - this._obj.offsetWidth * this.Width.pos + "px";
		}
		return false;
	},
	//设置top渐变
	SetTop: function(){
		var iGet = this.Get(this.Top, this._obj.offsetTop);
		if (isNaN(iGet)) 
			return true;
		
		this._obj.style.top = iGet + "px";
		return false;
	},
	//设置left渐变
	SetLeft: function(){
		var iGet = this.Get(this.Left, this._obj.offsetLeft);
		if (isNaN(iGet)) 
			return true;
		
		this._obj.style.left = iGet + "px";
		return false;
	},
	//设置透明渐变
	SetOpacity: function(){
		var iGet = this.Get(this.Opacity, this._getOpacity());
		if (isNaN(iGet)) 
			return true;
		
		this._setOpacity(iGet);
		return false;
	},
	//获取设置值
	Get: function(o, now){
		if (o.run) {
			var iStep = (o.target - now) / this.Step;
			if (iStep) {
				this._finish = false;
				if (Math.abs(iStep) < 1) {
					iStep = iStep > 0 ? 1 : -1;
				}
				return now + iStep;
			}
		}
	}
});
//judge information
function judgeUserName(userNameId, func, request){
	var userName = $(userNameId).value;
	if (userName.isNullOrEmpty()) {
		func(userName, {text:""});
		return;
	} else if (!userName.isUserName()) {
		func(userName, {text:"errorinput"});
		return;
	}
	if (request) {
		var opt = {
			method: 'get',
			onSuccess: func
		};
		var data = {
			t: 'j',
			n: 'username',
			v: userName,
			ts: $time()
		};
		new Ajax("/handler/commonhandler.ashx", opt).request(data);
	}
};
function judgeEmail(emailId, func, request){
	var email = $(emailId).value;
	if (email.isNullOrEmpty()) {
		func(email, {text:""});
		return;
	} else if (!email.isEmail()) {
		func(email, {text:"errorinput"});
		return;
	}
	if (request) {
		var opt = {
			method: 'get',
			onSuccess: func
		};
		var data = {
			t: 'j',
			n: 'email',
			v: email,
			ts: $time()
		};
		new Ajax("/handler/commonhandler.ashx", opt).request(data);
	}
};
//*****Popup类弹出窗口******
var Popup = new Class({
	iframeIdName: 'ifr_popup',
	initialize: function(config){
		this.config = {//---------------弹出对话框的配置信息------------------
			id: "",
			contentType: 1,//设置内容区域为什么类型：1为另外一个html文件 | 2为自定义html字符串 | 3为confirm对话框 | 4为alert警告对话框
			isHaveTitle: true,//是否显示标题栏
			isHaveHeader: true,//是否显示头
			scrollType: 'no',//设置或获取对话框中的框架是否可被滚动
			isBackgroundCanClick: false,//弹出对话框后，是否允许蒙布后的所有元素被点击。也就是如果为false的话，就会有全屏蒙布，如果为true的话，就会去掉全屏蒙布
			isSupportDraging: true,//是否支持拖拽
			isShowShadow: false,//是否现实阴影
			isReloadOnClose: true,//是否刷新页面，并关闭对话框
			width: 400,//宽度
			height: 300//高度
		};
		$extend(this.config, config || {});
		this.info = {//----------------对话框的参数值信息------------------------
			shadowWidth: 3,//阴影的宽度
			title: "",//
			contentUrl: "",//html链接页面
			contentHtml: "",//html内容
			callBack: Class.empty,//回调的函数名
			parameter: null,//回调的函数名中传的参数
			confirmCon: "",//对话框内容
			alertCon: "",//警告框内容
			someHiddenTag: "select,object,embed",//页面中需要隐藏的元素列表，以逗号分割
			someHiddenEle: "",//需要隐藏的元素的ID列表(和someToHidden的区别是：someHiddenEle是通过getElementById，而someToHidden是通过getElementByTagName，里面放的是对象)
			overlay: 0,
			coverOpacity: 50 //蒙布的透明值
		};
		this.color = {
			cColor: "#000000",//蒙布的背景
			bColor: "#FFFFFF",//内容区域的背景
			tColor: "#F3F3F3",//标题栏和边框的颜色
			wColor: "#000000"//字体的背景色
		};
		this.initVarible();
		this.dropClass = null;
		this.someToHidden = [];				
		if (!this.config.isHaveTitle) {
			this.config.isSupportDraging = false;
		}
		this.iniBuild();
		//this.fade = new Fade(this.dialogCase, {Opacity: {run: true}});
	},
	initVarible: function(){
		this.dialogCase = this.config.id + "dialogCase";
		this.dragDialogCase = this.config.id + "dragDialogCase";
		this.dialogBoxTitle = this.config.id + "dialogBoxTitle";
		this.dialogBoxClose = this.config.id + "dialogBoxClose";	
		this.dialogBoxBG = this.config.id + "dialogBoxBG";
		this.dialogBox = this.config.id + "dialogBox";		
		this.dialogClose = this.config.id + "dialogClose";	
		this.dialogBody = this.config.id + "dialogBody";
		this.dialogBoxShadow = this.config.id + "dialogBoxShadow";
		this.dialogOk = this.config.id + "dialogOk";
		this.dialogCancel = this.config.id + "dialogCancel";
		this.dialogYES = this.config.id + "dialogYES";	
		this.iframeBG = this.config.id + "iframeBG";	
		this.dialogContentDiv = this.config.id + "contentdiv";
	},
	iniBuild: function(){
		$(this.dialogCase) ? $(this.dialogCase).parentNode.removeChild($(this.dialogCase)) : function(){};
		var oDiv = $create('div');
		oDiv.id = this.dialogCase;
		if (document.forms && document.forms.length > 0){
		    document.forms[0].appendChild(oDiv);
		}else{
		    document.body.appendChild(oDiv);
		}
	},
	build: function(){
		var baseZIndex = 10001 + this.info.overlay * 10;
		var showZIndex = baseZIndex + 2;
		this.iframeIdName = this.iframeIdName + this.info.overlay;
		var path = "/images/close.png";
		var close = '<input type="image" id="'+this.dialogBoxClose+'" src="' + path + '" border="0" width="16" height="16" align="absmiddle" title="关闭"/>';
		var cB = 'filter:alpha(opacity=' + this.info.coverOpacity + ');opacity:' + this.info.coverOpacity / 100 + ';';
		var cover = '<div id="'+ this.dialogBoxBG + '" style="position:absolute;top:0px;left:0px;width:'+document.documentElement.scrollWidth+'px;height:'+document.documentElement.scrollHeight+'px;z-index:' + baseZIndex + ';' + cB + 'background-color:' + this.color.cColor + ';display:none;"></div>';
		var mainBox = '<div id="' + this.dragDialogCase +'" style="display:none;"><div id="'+this.dialogBox+'" style="border:solid ' + (this.config.isHaveHeader ? "3" : "0") + 'px #888381;display:none;z-index:' + showZIndex + ';position:relative;width:' + this.config.width + 'px;"><table width="100%" border="0" cellpadding="0" cellspacing="0" bgcolor="' + this.color.bColor + '">';
		if (this.config.isHaveTitle) {
			mainBox += '<tr height="24" bgcolor="' + this.color.tColor + '" style="' + (this.config.isHaveHeader ? "" : "display:none;") + '"><td style="border-bottom:solid 1px #CCCCCC;"><table style="height:24px;" width="100%" border="0" cellpadding="0" cellspacing="0" ><tr>' + '<td width="6" height="24"></td><td id="'+this.dialogBoxTitle+'" style="color:' + this.color.wColor + ';font-size:14px;padding:4px;font-weight:bold;">' + this.info.title + '&nbsp;</td>' + '<td id="' + this.dialogClose + '" width="20" align="right" valign="middle">' + close + '</td><td width="6"></td></tr></table></td></tr>';
		} else {
			mainBox += '<tr height="24" bgcolor="' + this.color.tColor + '" style="' + (this.config.isHaveHeader ? "" : "display:none;") + '"><td style="border-bottom:solid 1px #CCCCCC;"><table style="height:24px;" width="100%" border="0" cellpadding="0" cellspacing="0" ><tr>' + '<td width="6" height="24"></td><td id="'+this.dialogBoxTitle+'" style="color:' + this.color.wColor + ';font-size:14px;padding:4px;font-weight:bold;">' + this.info.title + '&nbsp;</td>' + '<td id="' + this.dialogClose + '" width="20" align="right" valign="middle">' + close + '</td><td width="6"></td></tr></table></td></tr>';
		};
		mainBox += '<tr style="height:' + this.config.height + 'px" valign="top"><td id="'+this.dialogBody+'" style="position:relative;"></td></tr></table></div>' + '<div id="'+this.dialogBoxShadow+'" style="display:none;z-index:' + baseZIndex + ';"></div></div>';
		if (!this.config.isBackgroundCanClick) {
			$(this.dialogCase).innerHTML = cover + mainBox;
		} else {
			$(this.dialogCase).innerHTML = mainBox;
		}
		attachEvent($(this.dialogBoxClose), "click", $b(this, this.close))
		//如果支持拖动,则设置拖动处理
		if (this.config.isSupportDraging) {
			this.Drag = new Drag(this.dragDialogCase, {Handle: this.dialogBoxTitle});
			$(this.dialogBoxTitle).style.cursor = "move"
		};
		this.p = $(this.dialogBox);
		this.lastBuild();
	},
	lastBuild: function(){
		var confirm = '<div style="text-align:center;"><div id="' + this.dialogContentDiv + '" style="margin:20px 20px 0 20px;font-size:14px;line-height:16px;color:#000000;text-align:left;">' + this.info.confirmCon + '</div><div style="margin:20px;"><input id="'+this.dialogOk+'" class="button" type="button" title="确定" value=" 确定 "/><input id="'+this.dialogCancel+'" class="button" type="button" value=" 取消 " title="取消" style="margin-left:20px;"/></div></div>';
		var alert = '<div style="text-align:center;"><div id="' + this.dialogContentDiv + '" style="margin:20px 20px 0 20px;font-size:14px;line-height:16px;color:#000000;text-align:left;">' + this.info.alertCon + '</div><div style="margin:20px;"><input id="'+this.dialogYES+'" class="button" type="button" title="确定" value=" 确定 "/></div></div>';
		var baseZIndex = 10001 + this.info.overlay * 10;
		var coverIfZIndex = baseZIndex + 4;
		//判断内容类型决定窗口的主内容区域应该显示什么
		if (this.config.contentType == 1) {
			var openIframe = "<iframe width='100%' style='height:" + this.config.height + "px' name='" + this.iframeIdName + "' id='" + this.iframeIdName + "' src='" + this.info.contentUrl + "' frameborder='0' scrolling='" + this.config.scrollType + "'></iframe>";
			var coverIframe = "<div id='"+this.iframeBG+"' style='position:absolute;top:0px;left:0px;width:1px;height:1px;z-index:" + coverIfZIndex + ";filter: alpha(opacity=00);opacity:0.00;background-color:#ffffff;'><div>";
			$(this.dialogBody).innerHTML = openIframe + coverIframe;
		} else if (this.config.contentType == 2) {
			$(this.dialogBody).innerHTML = this.info.contentHtml;
		} else if (this.config.contentType == 3) {
			$(this.dialogBody).innerHTML = confirm;
			attachEvent($(this.dialogOk), "click", $b(this, this.forCallback));
			attachEvent($(this.dialogCancel), "click", $b(this, this.close));
		} else if (this.config.contentType == 4) {
			$(this.dialogBody).innerHTML = alert;
			attachEvent($(this.dialogYES), "click", $b(this, this._closeAlter));
		}
		window.onresize = $be(this, this.middle);
		attachEvent(document, "keydown", $be(this, this.keyEvent));
	},
	_closeAlter: function(){
		if (this.info.callBack !== Class.empty){
			if (this.info.parameter) {
				this.info.callBack.apply(this, this.info.parameter);
			}else{
				this.info.callBack.apply(this);
			}
		}
		this.close();
	},
	reBuild: function(){
		$(this.dialogBody).height = $(this.dialogBody).clientHeight;
		this.lastBuild();
	},
	setContent: function(arrt, val){
		if ($defined(val)) {
			switch (arrt) {
				case 'id':
					this.config.id = val;
					break;			
				case 'contentType':
					this.config.contentType = val;
					break;
				case 'width':
					this.config.width = val;
					break;
				case 'height':
					this.config.height = val;
					break;
				case 'isSupportDraging':
					this.config.isSupportDraging = val;
					break;
				case 'isReloadOnClose':
					this.config.isReloadOnClose = val;
					break;
				case 'title':
					this.info.title = val;
					break;
				case 'contentUrl':
					this.info.contentUrl = val;
					break;
				case 'contentHtml':
					this.info.contentHtml = val;
					break;
				case 'callBack':
					this.info.callBack = val;
					break;
				case 'parameter':
					this.info.parameter = val;
					break;
				case 'confirmCon':
					this.info.confirmCon = val;
					break;
				case 'alertCon':
					this.info.alertCon = val;
					break;
				case 'someHiddenTag':
					this.info.someHiddenTag = val;
					break;
				case 'someHiddenEle':
					this.info.someHiddenEle = val;
					break;
				case 'overlay':
					this.info.overlay = val;
					break;
				case 'isHaveHeader':
					this.config.isHaveHeader = val;	
					break;
				case 'bColor':
					this.color.bColor = val;																
					break;
			};
		};
	},
	setContents: function(options){
		if (null == options || {} == options) 
			return;
		for (var key in options) {
			this.setContent(key, options[key]);
		}
		this.initVarible();
	},
	show: function(){
		this.hiddenSome();
		this.middle();
		if (this.config.isShowShadow) {
			this.shadow();
		}
	},
	forCallback: function(){
		if (this.info.callBack !== Class.empty) {
			if (this.info.parameter) {
				this.info.callBack.apply(this, this.info.parameter);
			} else {
				this.info.callBack.apply(this);
			}
		}
		this.close();
	},
	shadow: function(){
		var oShadow = $(this.dialogBoxShadow);
		var oDialog = $(this.dialogBox);
		oShadow['style']['position'] = "absolute";
		oShadow['style']['background'] = "#000";
		oShadow['style']['display'] = "";
		oShadow['style']['opacity'] = "0.2";
		oShadow['style']['filter'] = "alpha(opacity=20)";
		oShadow['style']['top'] = oDialog.offsetTop + this.info.shadowWidth + "px";
		oShadow['style']['left'] = oDialog.offsetLeft + this.info.shadowWidth + "px";
		oShadow['style']['width'] = oDialog.offsetWidth + "px";
		oShadow['style']['height'] = oDialog.offsetHeight + "px";
	},
	middle: function(){
        var oDialog = $(this.dialogBox); if (!oDialog)return; oDialog['style']['position'] = "absolute";
        var dDialog = $(this.dragDialogCase);
        oDialog['style']['display'] = dDialog['style']['display'] = '';
		var ow = oDialog.offsetWidth;
		var oh = oDialog.offsetHeight;	
        oDialog['style']['display'] = dDialog['style']['display'] =  'none';	
        var t = (LightBox.page.height() / 2) - (oh / 2);
        t = t < 10 ? 10 : t;
        dDialog['style']['left'] = ((LightBox.page.width() - ow) / 2) + 'px';
        dDialog['style']['top'] = (t + LightBox.page.top()) + 'px';
		oDialog['style']['display'] = dDialog['style']['display'] = '';
        if (!this.config.isBackgroundCanClick) {
		    var bg = $(this.dialogBoxBG);
            dDialog["style"]["zIndex"] = bg["style"]["zIndex"] + 2;
		    bg.style.height = LightBox.page.theight() + 'px';
            bg.style.width = LightBox.page.twidth() + 'px';		   
            bg.style.display = '';
        }
	},
	reset: function(){
		if (this.config.isReloadOnClose) {
			top.location.reload();
		};
		this.close();
	},
	close: function(){
		if ($(this.dialogBox)) {
			$(this.dialogBox)['style']['display'] = 'none';
			$(this.dialogBody).innerHTML = '';
		}
		if ($(this.dragDialogCase)) {
			$(this.dragDialogCase)['style']['display'] = 'none';
		}
		if (!this.config.isBackgroundCanClick && $(this.dialogBoxBG)) {
			$(this.dialogBoxBG).style.display = 'none';
		}
		if (this.config.isShowShadow && $(this.dialogBoxShadow)) {
			$(this.dialogBoxShadow).style.display = 'none';
		}
		this.showSome();
		this._removeElement(this.dialogCase);
	},
	_removeElement: function(ctrOrId){
		var ctr = $(ctrOrId);
		if (ctr) {
			if (ctr.childNodes && ctr.childNodes.length > 0) {
				for (var i = 0; i < ctr.childNodes.length; i++) {
					var elm = ctr.childNodes[0];
					this._removeElement(elm);
				}
			}
			ctr.parentNode.removeChild(ctr);
		}
	},
	keyEvent: function(evt){
		evt = $event(evt);
		if (evt.keyValue == 27) {
			cancelBubble(evt);
			cancelDefault(evt);
			this.close();
		}
	},
	hiddenSome: function(){
		var tag = this.info.someHiddenTag.split(",");
		if (tag.length == 1 && tag[0] == "") {
			tag.length = 0;
		}
		for (var j = 0; j < tag.length; j++) {
			this.hiddenTag(tag[j]);
		};
		var ids = this.info.someHiddenEle.split(",");
		if (ids.length == 1 && ids[0] == "") {
			ids.length = 0;
		}
		for (var j = 0; j < ids.length; j++) {
			this.hiddenEle(ids[j]);
		};
		//改变顶部和底部的div的id值为弹出状态的id值,祥见space的实现
		space("begin");
	},
	hiddenTag: function(tagName){
		var ele = document.getElementsByTagName(tagName);
		if (ele != null) {
			for (var j = 0; j < ele.length; j++) {
				if (ele[j].style.display != "none" && ele[j].style.visibility != 'hidden') {
					ele[j].style.visibility = 'hidden';
					this.someToHidden.push(ele[j]);
				};
							};
					};
			},
	hiddenEle: function(id){
		var ele = $(id);
		if (typeof(ele) != "undefined" && ele != null) {
			ele.style.visibility = 'hidden';
			this.someToHidden.push(ele);
		}
	},
	showSome: function(){
		for (var j = 0; j < this.someToHidden.length; j++) {
			this.someToHidden[j].style.visibility = 'visible';
		};
		space("end");
	},
	setHTML: function(msg){
		$(this.dialogContentDiv).innerHTML = msg;
	}
});
function space(flag){
	if (flag == "begin") {
		var ele = document.getElementById("ft");
		if (typeof(ele) != "undefined" && ele != null) 
			ele.id = "ft_popup";
		ele = document.getElementById("usrbar");
		if (typeof(ele) != "undefined" && ele != null) 
			ele.id = "usrbar_popup";
	} else if (flag == "end") {
		var ele = document.getElementById("ft_popup");
		if (typeof(ele) != "undefined" && ele != null) 
			ele.id = "ft";
		ele = document.getElementById("usrbar_popup");
		if (typeof(ele) != "undefined" && ele != null) 
			ele.id = "usrbar";
	};
	};
var message = new Class({
	initialize: function(){
		this.container = [];
	},
	push: function(msg){
		this.container.push(msg);
	},
	getMessages: function(){
		return this.container;
	},
	getHtmlMessages: function(){
		var builer = "";
		if (this.container && this.container.length > 0) {
			builer = "<ul>";
			for (var i = 0; i < this.container.length; i++) {
				builer += "<li>" + this.container[i] + "</li>";
			}
			builer += "</ul>"
		}
		return builer;
	},
	showMessage: function(className){
		$box(String.format("<div class=\"{0}\">{1}</div>", className.isNullOrEmpty() ? "" : className, this.getHtmlMessages()));
	},
	hasMessage: function(){
		if (this.container && this.container.length > 0) {
			return true;
		}
		return false;
	},
	clear: function(){
		this.container = [];
	}
});
var Message = new message();
function $box(){
	var options = {
		alertCon: "",
		width: 340,
		height: 80,
		title: "信息提示",
		isReloadOnClose: false,
		contentType: 4,
		overlay: 10,
		parameter: null
	};
	var args = [];
	for (var i = 0; i < arguments.length; i++) {
		if (i == 0) 
			options["alertCon"] = arguments[i];
		if (i == 1) 
			options["width"] = arguments[i].toInt();
		if (i == 2) 
			options["height"] = arguments[i].toInt();
		if (i == 3) 
			options["title"] = arguments[i];
		if (i == 4) 
			options["callBack"] = arguments[i];	
		if (i >= 5) 
		    args.push(arguments[i]);
	}
    if (arguments.length >= 5){
        options["parameter"] = args;
    }
	var p = new Popup({id: "sb"});
	p.setContents(options);
	p.build();
	p.show();
	return p;
};
function $confirm(){
	var options = {
		confirmCon: "",
		width: 340,
		height: 80,
		title: "确认？",
		isReloadOnClose: false,
		contentType: 3,
		overlay: 3,
		parameter: null
	};
	var args = [];
	for (var i = 0; i < arguments.length; i++) {
		if (i == 0) 
			options["confirmCon"] = arguments[i];
		if (i == 1) 
			options["callBack"] = arguments[i];
		if (i >= 2)
		    args.push(arguments[i]);
	}
	if (arguments.length > 2){
        options["parameter"] = args;
    }
	var p = new Popup({id: "cb"});
	p.setContents(options);
	p.build();
	p.show();
	return p;
};
function $rc(name, pt)
{
    ControlManager.getInstance().registerDynamicControl(name, pt);
}
//  匹配脚本的正则表达式
var gs_reScriptMatchAll = new RegExp('<script[^>]*>([\\S\\s]*?)<\/script>', 'img');
var gs_reScriptMatchOne = new RegExp('<script[^>]*>([\\S\\s]*?)<\/script>', 'im');
var gs_reScriptMatchSrc = new RegExp('<script[^>]*src=[\'\"]([^\'\"]*)[\'\"][^>]*>([\\S\\s]*?)<\/script>', 'im');
var ControlManager = new Class({
	initialize: function(){
		this.m_aDynamicControls = new Array();
		this.m_aRegisteredScriptSrc = new Array();
		this.m_aRegisteredPostback = new Array();
		ControlManager.gs_hInstance = this;
		if (typeof(theForm) == "undefined" || !theForm) {
			theForm = $("aspnetForm");
		}
		attachEvent(theForm, "submit", $be(this, this.onFormSubmit));
		if (typeof(window.__doPostBack) === "function") {
			this._originalDoPostBack = window.__doPostBack;
		} else {
			this._originalDoPostBack = ___doPostBack;
		}
		window.__doPostBack = $b(this, this.onDoPostBack);
		// 解析页面存在的脚本
		this._parseCurrentScript();
	},
	
	// 当表单被提交时，发生此事件
	onFormSubmit: function(evt){
		evt = $event(evt);
		var sControlId = evt.activeElement.id ? evt.activeElement.id.replace(/\_/g, "$") : evt.activeElement.name;
		if (sControlId) {
			var aAdditionnalInput = [{name: sControlId, value: ""}];
			var hDuc = this.findMatchingDuc(sControlId);
			if (hDuc) {
				if (evt) {
					cancelBubble(evt);
					cancelDefault(evt);
				}
				if (!this.validateForm()) {
					return false;
				}
				hDuc.doPostBack(sControlId, "", aAdditionnalInput);
				return false;
			}
		}
		this._dynamicControlCleanup();
	},
	
	// 重写 __doPostBack
	onDoPostBack: function(eventTarget, eventArgument, updateIds){
		if (!this.validateForm()) {
			return;
		}
		var hDuc = this.findMatchingDuc(eventTarget);
		if (hDuc) {
			hDuc.doPostBack(eventTarget, eventArgument, null, updateIds);
			return;
		}
		this._dynamicControlCleanup();
		return this._originalDoPostBack(eventTarget, eventArgument);
	},
	
	validateForm: function(){
		if ((theForm.onsubmit) && (theForm.onsubmit() == false)) {
			return false;
		}
		if (typeof(ValidatorOnSubmit) == "function" && ValidatorOnSubmit() == false) {
			return false;
		}
		return true;
	},
	
	// 查找DynamicUserControl，当uniqueId包含sControlId
	findMatchingDuc: function(sControlId){
		this.m_aDynamicControls.sort(ControlManager.LengthComparator);
		for (var i = 0; i < this.m_aDynamicControls.length; i++) {
			var uniqueId = this.m_aDynamicControls[i].get_uniqueId();
			if (uniqueId == sControlId.substring(0, uniqueId.length)) {
				return this.m_aDynamicControls[i];
			}
		}
		return null;
	},
	
	_parseCurrentScript: function(){
		var scripts = document.documentElement.innerHTML.match(gs_reScriptMatchAll);
		if (scripts) {
			for (var i = 0; i < scripts.length; i++) {
				var currentScriptSrc = scripts[i].match(gs_reScriptMatchSrc);
				if (currentScriptSrc) {
					if (!this.containsScriptSrc(currentScriptSrc[1])) {
						this.appendScriptSrc(currentScriptSrc[1]);
					}
				}
			}
		}
	},
	
	// 注册DynamicUserControl
	registerDynamicControl: function(uniqueId, controlpath){
		var hDuc = this.findMatchingDuc(uniqueId);
		if (hDuc){
		    var tmp = hDuc.get_uniqueId();
		    if (tmp.length === uniqueId.length){
			    this.m_aDynamicControls.remove(hDuc);
			}
		}		
		hDuc = new DynamicUserControl();
		hDuc.set_uniqueId(uniqueId);
		hDuc.set_controlPath(controlpath);
		this.m_aDynamicControls.push(hDuc);
	},
	
	// 卸载DynamicUserControl
	unregisterDynamicControlChilds: function(hDuc){
		var i = 0;
		var containerId = hDuc.get_uniqueId();
		this.m_aDynamicControls.sort(ControlManager.LengthComparator);
		while (i < this.m_aDynamicControls.length) {
			var childId = this.m_aDynamicControls[i].get_uniqueId();
			if ((containerId == childId.substring(0, containerId.length)) && (childId.length > containerId.length)) {
				var hElement = this.m_aDynamicControls.splice(i, 1);
			} else {
				i++;
			}
		}
	},
	
	containsScriptSrc: function(sScriptUrl){
		return this.m_aRegisteredScriptSrc[sScriptUrl]
	},
	
	appendScriptSrc: function(sScriptUrl){
		this.m_aRegisteredScriptSrc[sScriptUrl] = true;
	},
	
	// 处理iframe框架返回的数据
	updateFromIFrame: function(clientId, content){
		for (var i = 0; i < this.m_aDynamicControls.length; i++) {
			if (this.m_aDynamicControls[i].get_clientId() == clientId) {
				this.m_aDynamicControls[i]._updateContainer(content);
				return;
			}
		}
	},
	
	// 更新CSS样式
	updateCss: function(cssList){
		var header = document.getElementsByTagName('HEAD')[0];
		if (!header) 
			return;
		
		for (var i = 0; i < cssList.length; i++) {
			var linkElement = document.createElement('link');
			linkElement.type = 'text/css';
			linkElement.rel = 'stylesheet';
			linkElement.href = cssList[i];
			header.appendChild(linkElement);
		}
	},
	
	_redirectDocument: function(sUrl){
		location.href = sUrl;
	},
	
	registerPostback: function(hDUC, eventTarget, eventArgument, data){
		var hPostback = {
			handle: hDUC,
			eventTarget: eventTarget,
			eventArgument: eventArgument,
			data: data
		};
		return this.m_aRegisteredPostback.push(hPostback) - 1;
	},
	
	processRegisteredPostback: function(postbackId){
		var hPostback = this.m_aRegisteredPostback[postbackId];
		this.m_aRegisteredPostback[postbackId] = null;
		hPostback.handle._doPostBackXSS(hPostback.eventTarget, hPostback.eventArgument, hPostback.data);
	},
	
	// 在这里清理一些你不需要的数据
	_dynamicControlCleanup: function(){
		for (var i = 0; i < this.m_aDynamicControls.length; i++) {
			this.m_aDynamicControls[i].cleanup();
		}
	}
});
ControlManager.getInstance = function(){
	return ControlManager.gs_hInstance || new ControlManager();
}
ControlManager.LengthComparator = function(a, b){
	return b.get_uniqueId().length - a.get_uniqueId().length;
}
DynamicUserControl = new Class({
	initialize: function(){
		this.m_sUniqueId = null;
		this.m_sClientId = null;
		this.m_sControlPath = null;
		this.m_hProxy = null;
		this.m_nDisplayTimeoutDelay = 200;
		this.m_aDeferredScript = null;
	},
	get_uniqueId: function(){
		return this.m_sUniqueId;
	},
	set_uniqueId: function(value){
		this.m_sUniqueId = value;
		this.m_sClientId = value.replace(/\$/g, '_');
	},
	get_controlPath: function(){
		return this.m_sControlPath;
	},
	set_controlPath: function(value){
		this.m_sControlPath = value;
	},
	get_clientId: function(){
		return this.m_sClientId;
	},	
	get_customStateName: function(){
		return this.m_sUniqueId + "$__CUSTOMSTATE";
	},
	get_customStateId: function(){
		return this.m_sClientId + "___CUSTOMSTATE";
	},
	get_ducStateName: function(){
		return this.m_sUniqueId + "$__DUCSTATE";
	},
	get_ducStateId: function(){
		return this.m_sClientId + "___DUCSTATE";
	},	
	get_progressPanel: function(){
		if (typeof(this.m_hProgressPanel) == 'undefined') {
			this.m_hProgressPanel = document.getElementById(this.get_clientId() + "_progress");
		}
		return this.m_hProgressPanel;
	},
	get_contentPanel: function(){
		if (typeof(this.m_hContentPanel) == 'undefined') {
			this.m_hContentPanel = document.getElementById(this.get_clientId() + "_content");
		}
		return this.m_hContentPanel;
	},
	
	// 回传当前控件
	doPostBack: function(eventTarget, eventArgument, aAdditionnalInput, updateIds){
		// 显示进度条
		var progressPanel = this.get_progressPanel();
		if (progressPanel) {
            var rid = window[this.get_clientId()+"_pop"];
		    if (rid) {
			    progressPanel.style.display = "";
		    } else {
			    this.m_nDisplayTimerId = window.setTimeout(function(){
				    showLoading(progressPanel, null)
			    }, this.m_nDisplayTimeoutDelay);
			}
		}
		this.updateIds = null;
		if (typeof(updateIds) !== "undefined"){
			this.updateIds = updateIds;			
		}
		// 收集查询参数
		var data = new Array();
		data.push({name: "__EVENTTARGET", value: eventTarget});
		data.push({name: "__EVENTARGUMENT", value: eventArgument});
		data.push({name: "__DUCCONTAINER", value: this.m_sUniqueId});
		data.push({name: "__location", value: document.location.href});
		if ($(whisod__s)) {$(whisod__s).parentNode.removeChild($(whisod__s));}
		var wwh = getWindowVarible(whoids__s);
		if (typeof(wwh) != "undefined" && wwh) {
			this.get_contentPanel().appendChild(createHidden(whoids__s, wwh));
		}
		var wcus = getWindowVarible(this.get_customStateName());
		if (typeof(wcus) != "undefined" && wcus) {
			this.get_contentPanel().appendChild(createHidden(this.get_customStateName(), wcus));
		}
		var wduc = getWindowVarible(this.get_ducStateName());
		if (typeof(wduc) != "undefined" && wduc) {
			this.get_contentPanel().appendChild(createHidden(this.get_ducStateName(), wduc));
		}				
		if (aAdditionnalInput && aAdditionnalInput.length > 0) {
			data = data.extend(aAdditionnalInput);
		}
		data = data.extend($qa(this.get_contentPanel()));
		
		// 判断回传是否使用xmlhttprequest方式
		if (this.m_sControlPath.substr(0, 4) != "http") {
			this._doPostBackXHR(eventTarget, eventArgument, data);
		} else {
			// 使用跨域请求
			data.push({name: "xss", value: this.m_sClientId});
			this._doPostBackXSS(eventTarget, eventArgument, data);
		}
	},
	
	//使用xmlhttprequest框架实现请求
	_doPostBackXHR: function(eventTarget, eventArgument, data){
		var requestBody = "";
		for (var i = 0; i < data.length; i++) {
			if (data[i]) {
				requestBody += "&" + data[i].name + "=" + encodeURIComponent(data[i].value);
			}
		}
		var opt = { method: 'post', onSuccess: $b(this, this._onRequestCompleted) };
		requestBody = requestBody.substr(1); // remove first "&"	
		new Ajax(this.m_sControlPath, opt).request(requestBody);
	},
	
	// 使用iframe框架实现请求
	_doPostBackXSS: function(eventTarget, eventArgument, data){
		if (this.m_hProxy == null) {
			this.m_hProxy = document.createElement("iframe");
			var hpostbackId = ControlManager.getInstance().registerPostback(this, eventTarget, eventArgument, data);
			
			try {
				this.m_hProxy.style.border = "0";
				this.m_hProxy.style.width = "0";
				this.m_hProxy.style.height = "0";
			} catch (exception) {
				this.m_hProxy.setAttribute("style", "border:0;width:0;height:0;");
			}
			this.m_hProxy.setAttribute("id", this.m_sClientId + "_proxy");
			this.m_hProxy.name = this.m_sClientId + "_proxy";
			this.m_hProxy.src = this.m_sControlPath + "?__DUCMODE=proxy&pbid=" + hpostbackId;
			this.m_hProxy = document.body.appendChild(this.m_hProxy);
			return;
		}
		var hIframeDocument = this.m_hProxy.contentDocument ? this.m_hProxy.contentDocument : this.m_hProxy.contentWindow.document;
		var hForm = hIframeDocument.createElement("form");
		hForm.method = "post";
		hForm.action = this.m_sControlPath;
		hIframeDocument.body.appendChild(hForm);
		for (var i = 0; i < data.length; i++) {
			if (data[i]) {
				hForm.appendChild(this._buildInput(hIframeDocument, data[i].name, data[i].value));
			}
		}
		hForm.submit();
	},
	
	// 处理从xmlhttprequest返回的结果
	_onRequestCompleted: function(sender, response){
		if (response && (response.text || response.xml)) {
			// 判断是否是要跳转页面
			var urlRedir = sender.getHeader("X-DUCHANDLER-REDIR");
			if ((urlRedir != null) &&
			(urlRedir.length > 0)) {
				ControlManager.getInstance()._redirectDocument(urlRedir);
				return;
			}
			var content = response.text || response.xml;
			this._updateContainer(content);
		}
	},
	
	// 更新控件div
	_updateContainer: function(content){
		if ($(whoids__s)) {$(whoids__s).parentNode.removeChild($(whoids__s));}
	    if ($(whisod__s)) {$(whisod__s).parentNode.removeChild($(whisod__s));}	
	    if ($(this.get_customStateName())) {$(this.get_customStateName()).parentNode.removeChild($(this.get_customStateName()));}	
	    if ($(this.get_ducStateName())) {$(this.get_ducStateName()).parentNode.removeChild($(this.get_ducStateName()));}	
		var containerPanel = this.get_contentPanel();
		var progressPanel = this.get_progressPanel();
		//ControlManager.getInstance().unregisterDynamicControlChilds(this);
		var script = content.match(gs_reScriptMatchAll);
		script = script || []; script = script.extend(['<script type="text/javascript">//<![CDATA[\r\n initImagesLazy(); \r\n//]]></script>']);
		content = content.replace(gs_reScriptMatchAll, "");
		if ($type(this.updateIds) == "array") {
			if (this.updateIds.length > 0) {
				var exArr = [this.get_customStateId(), this.get_ducStateId()];
				this.updateIds.extend(exArr);
				var div = $create("div");
				div.innerHTML = content;
				var elemnents = this._parseDivContainer(div, this.updateIds);
				var len = 0;
				for (var i = 0; i < elemnents.length; i++) {
					if (exArr.contains(elemnents[i].original.id, 0)) {
						len += 1;
						if (len == 2) {
							break;
						}
					}
				}
				if (elemnents.length - len !== this.updateIds.length - 2) {
					try{containerPanel.innerHTML = content;}catch(ex){var dd1 = $create("div"); dd1.innerHTML = content; containerPanel.innerHTML = ""; containerPanel.appendChild(dd1);}
				} else {
					for (var i = 0; i < elemnents.length; i++) {
						var obj = elemnents[i];
						if (obj.original && obj.target) {
							obj.original.parentNode.replaceChild(obj.target, obj.original);
						}
					}
				}
				div.innerHTML = "";
				document.body.appendChild(div);
				div.parentNode.removeChild(div);
			}
		} else if ($type(this.updateIds) == "string" && this.updateIds.toLowerCase() == "all") {
			containerPanel.innerHTML = content;
		} else {
		    containerPanel.innerHTML = content;
		}
		this.updateIds = null;
		if (this.m_nDisplayTimerId) {
			window.clearTimeout(this.m_nDisplayTimerId);
		}
		//隐藏进度条
		if (progressPanel) {
			hideLoading(progressPanel);
		}
		//如果是对话框，则置中
		var rid = window[this.get_clientId()+"_pop"];
		if (rid) {
			rid.middle();
		}
		var hDUCInstance = ControlManager.getInstance();
		if (script) {
			var j = 0;
			this.m_aDeferredScript = new Array();
			for (var i = 0; i < script.length; i++) {
				var currentScriptSrc = script[i].match(gs_reScriptMatchSrc);
				if (currentScriptSrc) {
					if (!hDUCInstance.containsScriptSrc(currentScriptSrc[1])) {
						var js = document.createElement('script');
						js.setAttribute('type', 'text/javascript');
						js.setAttribute('src', currentScriptSrc[1]);
						document.body.appendChild(js);
						hDUCInstance.appendScriptSrc(currentScriptSrc[1]);
					}
				} else {
					var currentScript = script[i].match(gs_reScriptMatchOne)[1];
					currentScript = currentScript.replace('<!--', '');
					currentScript = currentScript.replace('// -->', '');
					this.m_aDeferredScript[j++] = currentScript;
				}
			}
			if (j > 0) {
				window.setTimeout($b(this, this._scriptExecutor), 10);
			}
		}
	},
	_parseDivContainer: function(hContainer, updateIds){
		var elemnents = new Array();
		for (var i = 0; i < hContainer.childNodes.length; i++) {
			var elm = hContainer.childNodes[i];
			if (elm.nodeType == 1) {
				if (elm.id && updateIds.contains(elm.id, 0)) {
					elemnents.push({original: $(elm.id), target: elm});
				}
				elemnents = elemnents.extend(this._parseDivContainer(hContainer.childNodes[i], updateIds));
			}
		}
		return elemnents;
	},	
	// 执行从XHR/XSS返回的客户端脚本
	_scriptExecutor: function(){
		if (this.m_aDeferredScript) {
			for (var i = 0; i < this.m_aDeferredScript.length; i++) {
				try {
					if (window.execScript) {
						window.execScript(this.m_aDeferredScript[i]);
					} else {
						window.eval(this.m_aDeferredScript[i]);
					}
				} catch (err) {
				}
			}
		}
		delete this.m_aDeferredScript;
	},
	//创建input元素
	_buildInput: function(hDocument, name, value){
		var hInput = hDocument.createElement("input");
		hInput.setAttribute("type", "hidden");
		hInput.setAttribute("name", name);
		hInput.setAttribute("value", value);
		return hInput;
	},
	
	cleanup: function(){
	}
});
function $luc(id, ph, data){
	loadUserControl(id, ph, data);
}
function loadUserControl(id, ph, data){
	var container = $(id);
	if (container && container.tagName.toLowerCase() == "div") {
		var progress = $(id + "_progress");
		if (!progress) {
			progress = createDiv(id + "_progress", "<img src='/images/loading.gif' alt='Loading'/>加载中...");
			container.appendChild(progress);
		}
		var div = $(id + "_content");
		if (!div) {
			div = createDiv(id + "_content", "");
			container.appendChild(div);
		}
		$rc(id, ph);
		$postback(id, data, [id + "_content"], null);
	}
}
function isLogin(){
	if (window["userIsLogin"] && window["userIsLogin"] === true) {
		return true;
	}
	return false;
}
function showUserLogin(){
    $suc("lusc", "03bb5d79238046e99aa59cee0034e711.xk", {lod:"true"}, {title: "登录到思酬之路", width:370, height:50});
}
function closeUserLogin() {
    closeDialog("lusc_content");
}
function $lsuc(id, ph, data, opts){
    if (!isLogin()){
        showUserLogin();
        return;
    }
	showUserControl(id, ph, data, opts);
}
function $suc(id, ph, data, opts){
	showUserControl(id, ph, data, opts);
}
function showUserControl(id, ph, data, opts){	
	var options = {
		width: 850,
		height: 440,
		title: "提示信息",
		isReloadOnClose: false,
		contentType: 2
	};
	$extend(options, opts || {});
	var p = new Popup();
	setWindowVarible(id + "_pop", p);
	p.setContents(options);
	p.build();
	var div = $(id);
	if (!div) {
		div = createDiv(id, "");
		$("dialogBody").appendChild(div);
	}
	p.show();
	loadUserControl(id, ph, data);
};
function midDialog(control){
	var ctr = $(control);
	if (ctr) {
		if (ctr.id) {
			var rid = ctr.id.replace(/_content/g, "_pop");
			if (window[rid] && $type(window[rid]) == "object") {
				window[rid].middle();
				return;
			}
		}
		midDialog(ctr.parentNode);
	}else{return;}
}
function closeDialog(control){
	var ctr = $(control);
	if (ctr) {
		if (ctr.id) {
			var rid = ctr.id.replace(/_content/g, "_pop");
			if (window[rid] && $type(window[rid]) == "object") {
				window[rid].close();
				return;
			}
		}
		closeDialog(ctr.parentNode);
	}else{return;}
    if (arguments.length === 2){
        $box(arguments[1]);
    }
	return;
};
var RowSelector = new Class({
	initialize: function(containerOrId, options){
		this.container = $(containerOrId);
		this.setOptions(options);
		this.elements = [];
		this.selectedRow = null;
		var elms = this.container.getElementsByTagName(this.options.tagName);
		for (var i = 0; i < elms.length; i++) {
			var elm = elms[i];
			if (this._isForElement(elm)) {
				this.elements.push(elm);
				attachEvent(elm, "click", $be(this, this.options.onClick));
				attachEvent(elm, "mouseover", $be(this, this.options.onMouseOver));
				attachEvent(elm, "mouseout", $be(this, this.options.onMouseOut));
			}
		}
		this.options.Filter(this.elements);
	},
	//设置默认属性
	setOptions: function(options){
		this.options = {//默认值
			tagName: "tr",
			forName:"",
			rollOverClass: "row-over",
			selectedClass: "row-select",
			unselectedClass: "",
			onClick: this.selectRow,
			onMouseOver: this.rollOverRow,
			onMouseOut: this.rollOutRow,			
			Filter: this.defaultFilter
		};
		$extend(this.options, options || {});
	},
	selectRow: function(evt){
		var target = this._getRow($event(evt).target);
		for (var i = 0; i < this.elements.length; i++) {
			var elm = this.elements[i];
			removeClass(elm, this.options.selectedClass);
			if (elm === target) {
			    this.selectedRow = elm;
				if (!hasClass(elm, this.options.selectedClass)) {
					addClass(elm, this.options.selectedClass);
				}
			}
		}
	},
	getSelectedRow: function(){
	    return this.selectedRow;
	},
	rollOverRow: function(evt){
		var target = this._getRow($event(evt).target);
		if (target.tagName.toLowerCase() == this.options.tagName) {
			addClass(target, this.options.rollOverClass);
		}
	},	
	rollOutRow: function(evt){
		var target = this._getRow($event(evt).target);
		if (target.tagName.toLowerCase() == this.options.tagName) {
			removeClass(target, this.options.rollOverClass);
		}		
	},	
	defaultFilter: function(elms){
		if (elms && elms.length > 0){
			var elm = elms[0];
			elms.remove(elm);
		}
	},
	_getRow: function(elm){
		if (elm) {	
			if (elm.tagName.toLowerCase() == this.options.tagName && this._isForElement(elm)) {
				return elm;
			} else {
				if (elm.tagName.toLowerCase() != "body") {
					return this._getRow(elm.parentNode);
				}
				return null;
			}
		} else {
			return null;
		}
	},
	_isForElement: function(elm){
		if (elm){
			var fn = elm.getAttribute("for");
			if (this.options.forName){
				if(fn && fn === this.options.forName){
					return true;
				}else{
					return false;
				}
			}else{
				return true;
			}
		}
		return false;
	}
});
var TabSelector = new Class({
	initialize: function(containerOrId, options){
		this.container = $(containerOrId);
		this.setOptions(options);
		this.elements = [];
		this.selectedTab = null;
		this.increment = 1;
		var elms = this.container.getElementsByTagName(this.options.tagName);
		for (var i = 0; i < elms.length; i++) {
			var elm = elms[i];
			if (elm.parentNode && elm.parentNode === this.container) {
				var control = null;
				if (elm.attributes["control"] && elm.attributes["control"].nodeValue) {
					control = $(elm.attributes["control"].nodeValue);
				}
				if (!control) {
					this._addTab(elm);
				}
				this.elements.push(elm);
				if (this.options.switchTabStyle == SwitchTabStyle.Click) {
					attachEvent(elm, "click", $be(this, this.options.onClick));
				} else if (this.options.switchTabStyle == SwitchTabStyle.MouseOver) {
					attachEvent(elm, "mouseover", $be(this, this.options.onMouseOver));
				}
				var aas = elm.getElementsByTagName("a");
				for (var j = 0; j < aas.length; j++){
				    attachEvent(aas[j], "focus", $be(aas[j], this._blurA));								    
				}
				if (elm.attributes["checked"] && elm.attributes["checked"].nodeValue == "true") {
					this.selectedTab = elm;
				}
			}
		}
		this.hiddenAll(this.selectedTab);
		this.options.Filter(this.elements);
	},
	//设置默认属性
	setOptions: function(options){
		this.options = {//默认值
			tagName: "li",
			selectedClass: "current",
			unselectedClass: "",
			switchTabStyle: SwitchTabStyle.Click,
			onClick: this.selectTab,
			onMouseOver: this.selectTab,
			Filter: Class.empty
		};
		$extend(this.options, options || {});
	},
	selectTab: function(evt){
		var target = this._getEvaluableTab($event(evt).target);
		if (target) {
			this.hiddenAll(target);
		}
		return false;
	},
	getSelectedTab: function(){
		return this.selectedTab;   
	},
	setSelectedTab: function(indexOrIdOrElement){
	    var elm = null;
	    if (!isNaN(indexOrIdOrElement)){
	        elm = this.elements[parseInt(indexOrIdOrElement) - 1];
	    } else if ($type(indexOrIdOrElement) === "string" || $type(indexOrIdOrElement) === "element") {
	        elm = $(indexOrIdOrElement);
	    } else {
	        return;
	    }
	    //elm.click();
	    if (elm) {
	        this.hiddenAll(elm);
	    }
	},
	hiddenAll: function(){
		var exceptElm = null;
		if (arguments.length > 0) {
			exceptElm = arguments[0]
		};
		for (var i = 0; i < this.elements.length; i++) {
			var elm = this.elements[i];
			var controlled = this._getControlled(elm);
			if (exceptElm && exceptElm === elm) {
				if (this.selectedTab && this.selectedTab !== elm) {
					this._getControlled(this.selectedTab).style.display = "none";
					this.selectedTab = null;
				}
				this.selectedTab = elm;
				elm.setAttribute("checked", "true");
				controlled.style.display = "";
				elm.className = this.options.selectedClass;
				continue;
			} else {
				elm.setAttribute("checked", "false");
				controlled.style.display = "none";
				elm.className = this.options.unselectedClass;
			}
		}
	},
	addTab: function(){
		var selected = false;
		if (arguments.length > 0) {
			selected = arguments[0]
		};
		var tab = _addTab();
		if (selected) {
			this.hiddenAll(tab);
		}
	},
	removeTab: function(elm){
		var tab = $(elm);
		var controlled = this._getControlled(tab);
		this.elements.remove(tab);
		if (tab.attributes["checked"] && tab.attributes["checked"].nodeValue == "true"){
			if (this.elements.length > 0) {
				this.hiddenAll(this.elements[0]);
			} else {
				this.hiddenAll();
			}
		}
		tab.parentNode.removeChild(tab);
		controlled.parentNode.removeChild(controlled);
	},
	_getEvaluableTab: function(elm){
		if (elm.nodeType == 1 && elm.tagName.toLowerCase() == this.options.tagName) {
			if (this.elements.contains(elm, 0)) {
				return elm;
			} else {
				return this._getEvaluableTab(elm.parentNode);
			}
		} else {
			return this._getEvaluableTab(elm.parentNode);
		}
	},
	_addTab: function(){
		var tab = null;
		if (arguments.length > 0) {
			tab = $(arguments[0]);
		};
		var control = createDiv("tab_" + this.increment, "");
		this.container.parentNode.appendChild(control);
		control.style.display = "none";
		if (!tab){
			tab = $create(this.options.tagName);
			this.container.appendChild(tab);
		}
		tab.setAttribute("control", control.id);
		tab.setAttribute("checked", "false");
		this.increment++;
		return tab;
	},
	_getControlled: function(arg){
		var elm = $(arg);
		var controlled = $(elm.attributes["control"].nodeValue);
		return controlled;
	},
	_blurA: function(){this.blur();}
});
var SwitchTabStyle = {
    Click: 0, MouseOver: 1, DoubleClick: 2
}
var DropDown = new Class({
	initialize: function(droppanel, options){
		this.droppanel = $(droppanel);
		for (var i = 0; i < this.droppanel.childNodes.length; i++){
			var elm = this.droppanel.childNodes[i];
			if (elm.nodeName && elm.nodeName.toLowerCase() == "input") {
				this.hiddeninput = elm;
			} else if (elm.nodeName && elm.nodeName.toLowerCase() == "big") {
				this.droptext = elm;
			} else if (elm.nodeName && elm.nodeName.toLowerCase() == "small") {
				this.drophandler = elm;
			} else if (elm.nodeName && elm.nodeName.toLowerCase() == "div") {
				this.dropdowndiv = elm;
			}						
		}
		this.setOptions(options);
		this.elements = [];
		var elms = this.dropdowndiv.getElementsByTagName(this.options.tagName);
		for (var i = 0; i < elms.length; i++) {
			var elm = elms[i];
			this.elements.push(elm);
			attachEvent(elm, "click", $be(this, this.options.onItemClick));
		}
		attachEvent(this.droptext, "click", $be(this, this.options.onClick));
		attachEvent(this.drophandler, "click", $be(this, this.options.onClick));	
	},
	//设置默认属性
	setOptions: function(options){
		this.options = {
			tagName: "a",
			onClick: this.toggle,	
			onItemClick: this.selectElement		
		};
		$extend(this.options, options || {});
	},
	selectElement: function(){
		var evt = $event(arguments[0]);var tar = evt.currentTarget || evt.srcElement; this._selectElement(tar);
	},
	setSelectElement: function(arg){
		if (typeof(arg) === "number") {
			var elm = this.elements[arg - 1];
			this._selectElement(elm);
		} else {
			this._selectElement(tar);
		}
		this.toggleClass();
	},
	_selectElement: function(target){
	    var tar = $(target);
		if (tar.tagName && tar.tagName.toLowerCase() == this.options.tagName.toLowerCase()) {
			var rel = tar.getAttribute("rel");
			if (this.droptext) {
				this.droptext.innerHTML = tar.innerHTML;
			}
			if (rel && this.hiddeninput) {
				this.hiddeninput.value = rel;
			}
			this.close();
		}
	},
	toggle: function(){
		showAndHideElement(this.dropdowndiv);
		this.toggleClass();
	},
	toggleClass: function(){
		if (!hasClass(this.droptext, "open")) {
			addClass(this.droptext, "open");
			addClass(this.drophandler, "open");
		}else{
			removeClass(this.droptext, "open");
			removeClass(this.drophandler, "open");			
		}
	},
	show: function(){
		openDiv(this.dropdowndiv);
		this.toggleClass();
	},
	close: function(){
		closeDiv(this.dropdowndiv);
		this.toggleClass();
	}
});
var ChksSelector = new Class({
	initialize: function(containerOrId, options){
		this.container = $(containerOrId);
		this.setOptions(options);
		this.elements = [];
		this.selectAllElement = null;
		var elms = this.container.getElementsByTagName(this.options.tagName);
		for (var i = 0; i < elms.length; i++) {
			var elm = elms[i];
			var sType = elm.getAttribute("type");			
			var sGroup = elm.getAttribute("group");			
			if (sType && sGroup && sType.toLowerCase() == this.options.type.toLowerCase() && sGroup == this.container.attributes["id"].nodeValue) {
				if (elm.value == this.options.allValue) {
					this.selectAllElement = elm;
					attachEvent(this.selectAllElement, "click", $be(this, this.options.onSelectAll))
				} else {
					this.elements.push(elm);
					attachEvent(elm, "click", $be(this, this.options.onClick))
				}
			}
		}
		this.options.Filter(this.elements);
	},
	//设置默认属性
	setOptions: function(options){
		this.options = {//默认值
			tagName: "input",
			type: "checkbox",
			allValue: "0",
			separator: ",",
			limited: 0,
			onClick: this.selectElement,
			onSelectAll: this.selectAll,
			Filter: Class.empty,
			selectedClass: null,
			unselectedClass: null
		};
		$extend(this.options, options || {});
	},
	selectElement: function(evt){
		evt = $event(evt);
	    if (this.options.limited > 0 && this.getSelectedElements().length > this.options.limited) {
	        evt.target.checked = false;
	        return false;
	    }
		if (this.options.type == "checkbox") {
			if (this.isSelectedAll()) {
				if(this.selectAllElement){
				    this.selectAllElement.checked = true
				};
				return;
			}
			if (this.selectAllElement) {
				this.selectAllElement.checked = false;
			}
		} else if (this.options.type == "radio") {
			for (var i = 0; i < this.elements.length; i++) {
				var elm = this.elements[i];
				if (evt.target != elm) {
					elm.checked = false;
				}
			//this._setClass(elm);			    
			}
		}
		return true;
	},
	selectAll: function(){
		this.selectAllElements(this.selectAllElement.checked);
	},
	selectAllElements: function(){
		var b = true;
		if (arguments.length > 0) {
			b = arguments[0]
		};
		for (var i = 0; i < this.elements.length; i++) {
			var elm = this.elements[i];
			elm.checked = b;
		    //this._setClass(elm);
		}
	},
	unselectAllElements: function(){
		this.selectAllElements(false);
	},
	getElements: function(){
		return this.elements;
	},
	getSelectedElements: function(){
		var selectedElements = [];
		for (var i = 0; i < this.elements.length; i++) {
			var elm = this.elements[i];
			if (elm.checked) {
				selectedElements.push(elm);
			}
		}
		return selectedElements;
	},
	removeElement: function(elm){
	    if (elm){
	        if (typeof(elm) == "string"){
		        for (var i = 0; i < this.elements.length; i++) {
			        var e = this.elements[i];
			        if (e.value == elm){
			            this.elements.remove(e);
			            break;
			        }
		        }                
            } else {
                this.elements.remove(elm);
            }
	    }
	},
	getValues: function(){
		var values = [];
		for (var i = 0; i < this.elements.length; i++) {
			var elm = this.elements[i];
			values.push(elm.value);
		}
		return values;
	},
	setValues: function(values){
		if (typeof (values).toLowerCase() == "array") {
			for (var i = 0; i < values.length; i++) {
				var val = values[i] + "";
				for (var j = 0; j < this.elements.length; i++) {
					var elm = this.elements[j];
					if (elm.value == val) {
						elm.checked = true;
					}
				}
			}
		}
	},
	getSelectedValues: function(){
		var selectedValues = [];
		for (var i = 0; i < this.elements.length; i++) {
			var elm = this.elements[i];
			if (elm.checked) {
				selectedValues.push(elm.value);
			}
		}
		return selectedValues;
	},
	setNextNodeClass: function(evt){
		this.selectElement(evt);
		var elms = this.getSelectedElements();
		for (var i = 0; i < this.elements.length; i++) {
	        var em = this.elements[i];
	        if (this.options.unselectedClass) {
				em.nextSibling.className = this.options.unselectedClass;
			}
	        if (elms[0] === em && this.options.selectedClass){
	            em.nextSibling.className = this.options.selectedClass;
	        }
		}
	},
	_setClass: function(elm){
	    if (elm){
	        if (elm.checked && this.options.selectedClass){
	            elm.className = this.options.selectedClass;
	        } else if (!elm.checked && this.options.unselectedClass) {
	            elm.className = this.options.unselectedClass;	            
	        }
	    }
	},
	isSelectedAll: function(){
		for (var i = 0; i < this.elements.length; i++) {
			var elm = this.elements[i];
			if (!elm.checked) {
				return false;
			}
		}
		return true;
	},
	clear: function(){
		var b = false;
		if (arguments.length > 0) {
			b = arguments[0]
		};
		if (this.selectAllElement) { this.selectAllElement.checked = b; }
		for (var i = 0; i < this.elements.length; i++) {
			var elm = this.elements[i];
			elm.checked = b;
		}
	},
	hasValues: function(){
		var ma = 10000;
		var mi = 1;		
		if (arguments.length > 0) {
			mi = arguments[0]
		};		
		if (arguments.length > 1) {
			ma = arguments[1]
		};			
		var len = this.getSelectedValues().length;
		return len >= mi && len <= ma;
	},
	toString: function(){
		var s = this.getSelectedValues();
		if (s.length > 0) {
			return s.join(this.options.separator)
		}
		return null;
	}
});
var TreeNavigator = new Class({
	initialize: function(containerOrId, options){
		this.tagName = "li";
		this.container = $(containerOrId);
		this.setOptions(options);
		this.elements = [];
		var elms = this.container.getElementsByTagName(this.tagName);
		for (var i = 0; i < elms.length; i++) {
			if (elms[i].parentNode === this.container) {
				this._parseElement(elms[i]);
			}
		}
		this.options.Filter(this.elements);
		this.initStatus();
	},
	//设置默认属性
	setOptions: function(options){
		this.options = {
			onClick: this.selectElement,
			Filter: Class.empty,
			selectedClass: "current",
			unselectedClass: "",
			hiddenOther:false
		};
		$extend(this.options, options || {});
	},
	initStatus: function(){
		var aLinks = this.container.getElementsByTagName("a");
		var url = location.href.toLowerCase();
		for (var i = 0; i < aLinks.length; i++){
			var a = aLinks[i];var href = a.href;
			if (url.substr(url.length - 1) === "#"){
				url = url.substr(0, url.length - 1);
			}
			if (href && href.toLowerCase() === url){
				this._openPreviousUl(a);
				if (this.options.selectedClass) {
					a.className = this.options.selectedClass;
				}
				break;
			}
		}
	},
	selectElement: function(){
		var evt = $event(arguments[0]);
		var target = evt.target;
		this.hiddenElements(target);
	},
	hiddenElements: function(){
		var target = null;
		if (arguments.length > 0) {
			target = arguments[0];
		};
		if (this.options.hiddenOther === true) {
			for (var i = 0; i < this.elements.length; i++) {
				var elm = this.elements[i];
				elm["style"]["display"] = "none";
			}
		}
		this.hiddenElement(target);		
	},
	hiddenElement: function(elm){
		if (elm) {
			var nelm = this._getNextUl(elm);
			if (nelm){
				var displayValue = nelm["style"]["display"];
				if (this.options.unselectedClass){elm.className == this.options.unselectedClass;}
				nelm["style"]["display"] = "none";
				if (displayValue == "none"){
					if (this.options.selectedClass){elm.className == this.options.selectedClass;}
					nelm["style"]["display"] = "block";
				}
			}
		}
	},
	_getNextUl: function(aelm){
		if (aelm) {
			if (aelm.nextSibling && aelm.nextSibling.nodeType === 1 && aelm.nextSibling.nodeName.toLowerCase() == "ul") {
				return aelm.nextSibling;
			} else {
				return this._getNextUl(aelm.nextSibling);
			}
		} else {
			return null;
		}
	},
	_openPreviousUl: function(aelm){
		if (aelm) {
			if (aelm.parentNode && aelm.parentNode.nodeType === 1 && aelm.parentNode.nodeName.toLowerCase() == "ul") {
				if (aelm.parentNode !== this.container) {
					aelm.parentNode["style"]["display"] = "block";
				}
				return;
			} else {
				this._openPreviousUl(aelm.parentNode);
			}
		}
	},	
	_parseElement: function(elm){
		var aElms = elm.getElementsByTagName("a");
		for (var i = 0; i < aElms.length; i++){
			var aElm = aElms[i];
			var uElms = aElm.parentNode.getElementsByTagName("li");
			if (uElms.length > 0){
				this.elements.push(aElm);
				attachEvent(aElm, "click", $be(this, this.options.onClick));
				attachEvent(aElm, "focus", $be(aElm, this._blurA));
				for (var j = 0; j < uElms.length; j++){
					this._parseElement(uElms[j]);
				}
			}
		}
	},
	_blurA: function(){this.blur();}
});
//var obj = {mediatype: 2, obje: {name: 'Borllor Lee', age: 23}, array: [1, 2, 4], fun: "$box('aa')", headerimage: '/images/all.png'};
function $so(obj){
	try {
		for (var o in obj) {
			var ctr = $(o);
			var val = $type(obj[o]) == "string" ? decodeURIComponent(obj[o]) : obj[o];
			if (ctr) {
				if (ctr.nodeType == 1) {
					switch (ctr.nodeName.toLowerCase()) {
						case "input":
							switch (ctr.attributes["type"].nodeValue.toLowerCase()) {
								case "button":
								case "reset":
								case "submit":
								case "text":
								case "password":
								case "hidden":
									$type(val) == "string" ? ctr.value = val : $extend(ctr, val);
									break;
								case "image":
									$type(val) == "string" ? ctr.src = val : $extend(ctr, val);
									break;
								case "checkbox":
								case "radio":
									$type(val) == "string" ? ctr.checked = val.toBoolean() : $extend(ctr, val);
									break;
							}
							break;
						case "textarea":
						case "select":
							$type(val) == "string" ? ctr.value = val : $extend(ctr, val);
							break;
						case "b":
						case "li":
						case "th":
						case "td":							
						case "span":
						case "div":
							$type(val) == "string" ? ctr.innerHTML = val : $extend(ctr, val);
							break;
						case "img":
							$type(val) == "string" ? ctr.src = val : $extend(ctr, val);
							break;						
						case "a":
							$type(val) == "string" ? ctr.href = val : $extend(ctr, val);
							break;						
						default:
							$type(val) == "string" ? ctr.value = val : $extend(ctr, val);
					}
				}
			} else {
			    if (o == "fun") {
			        (window.execScript) ? window.execScript(val) : window.setTimeout(val, 0);
			    } else if (o == "userIsLogin") {
					setWindowVarible(o, val);
				} else if (val) {
					setWindowVarible(o, val);
				}
			}
		}
	} catch (ex) {
	}
};
//show messsage before window unload
var UnloadConfirm = {};
UnloadConfirm.set = function(confirm_msg){
    window.onbeforeunload = function(event){
        event = event || window.event;
        event.returnValue = confirm_msg;
    }
}
UnloadConfirm.clear = function(){
    window.onbeforeunload = function(){};
}
function removeSoScript(){
    var scripts = document.getElementsByTagName("script");
    if (scripts && scripts.length > 0) {
        var scrpt = scripts[scripts.length - 1];
        if (scrpt.innerHTML.indexOf("$so") > 0){
            removeElement(scrpt);
        }
    }
}
function $sso(updatePanel, obj){
	try {
		var container = $(updatePanel);
		if (!container) {
			return;
		}
		for (var o in obj) {
			var ctr = findChildByFor(container, o);
			var val = $type(obj[o]) == "string" ? decodeURIComponent(obj[o]) : obj[o];
			if (ctr) {
				switch (ctr.nodeName.toLowerCase()) {
					case "input":
						switch (ctr.attributes["type"].nodeValue.toLowerCase()) {
							case "button":
							case "reset":
							case "submit":
							case "text":
							case "password":
							case "hidden":
								$type(val) == "string" ? ctr.value = val : $extend(ctr, val);
								break;
							case "image":
								$type(val) == "string" ? ctr.src = val : $extend(ctr, val);
								break;
							case "checkbox":
							case "radio":
								$type(val) == "string" ? ctr.checked = val.toBoolean() : $extend(ctr, val);
								break;
						}
						break;
					case "textarea":
					case "select":
						$type(val) == "string" ? ctr.value = val : $extend(ctr, val);
						break;
					case "th":
					case "td":
					case "span":
					case "div":
						$type(val) == "string" ? ctr.innerHTML = val : $extend(ctr, val);
						break;
					case "img":
						$type(val) == "string" ? ctr.src = val : $extend(ctr, val);
						break;
					case "a":
						$type(val) == "string" ? ctr.href = val : $extend(ctr, val);
						break;
					default:
						$type(val) == "string" ? ctr.value = val : $extend(ctr, val);
				}
			}
		}
	} catch (ex) {
	}
};
function findChildByFor(node, forName){
	if (node && node.nodeType === 1) {
		var forAttr = node.getAttribute("for");
		if (forAttr && forAttr === forName) {
			return node;
		} else {
			var elm = null;
			for (var i = 0; i < node.childNodes.length; i++) {
				elm = findChildByFor(node.childNodes[i], forName);
				if (elm) {break;}
			}
			return elm;
		}
	}
};
function isInTheXylker(element, xylker){
	var elm = $(element);
	if (elm && elm.nodeType && elm.nodeType == 1) {
		var attr = elm.getAttribute("xylker");
		if (attr && attr == xylker) {
			return true;
		} else if (elm.parentNode && elm.parentNode.tagName != "FORM") {
			return isInTheXylker(elm.parentNode, xylker);
		} else {
			return false;
		}
	} else {
		return false;
	}
};
function isInTheContainer(element, container){
	var elm = $(element);
	var parentElm = $(container);
	if (elm == parentElm) {
		return true;
	} else if (elm.parentNode && elm.parentNode.tagName != "FORM") {
		return isInTheContainer(elm.parentNode, parentElm);
	} else {
		return false;
	}
};
function BuildObjectFromElements(container){
	var cContainer = $(container);
	if (!cContainer) return {};
	var elements = [];
	var resultObject = {};
	var ins = cContainer.getElementsByTagName('input');
	var ses = cContainer.getElementsByTagName('select');
	var tes = cContainer.getElementsByTagName('textarea');
	elements = elements.extend(ins).extend(ses).extend(tes);
	for (var i = 0; i < elements.length; i++) {
		var elm = elements[i];
		var sName = elm.name; var sVal = elm.value;
		if (sName) {
			switch (elm.nodeName.toLowerCase()) {
				case "input":
					switch (elm.type.toLowerCase()) {
						case "text":
						case "password":
						case "hidden":
							resultObject[sName] = encodeURIComponent(sVal);
							break;
						case "checkbox":
						case "radio":
							if (elm.checked) {
								if (sVal && sVal == "on") {sVal = "true";}
								else if (sVal && sVal == "off") {sVal = "false";}
								resultObject[sName] = encodeURIComponent(sVal);
								break;
							}
					}
					break;
				case "textarea":
					resultObject[sName] = encodeURIComponent(sVal);
					break;
				case "select":
					resultObject[sName] = {text: elm.options[elm.selectedIndex].text, value: elm.options[elm.selectedIndex].value}
					break;
			}
		}
	}
	return resultObject;
};

function BuildArrayFromElements(container){
	var cContainer = $(container);
	if (!cContainer) return [];
	var elements = [];
	var resultArray = [];
	var ins = cContainer.getElementsByTagName('input');
	var ses = cContainer.getElementsByTagName('select');
	var tes = cContainer.getElementsByTagName('textarea');
	elements = elements.extend(ins).extend(ses).extend(tes);
	for (var i = 0; i < elements.length; i++) {
		var elm = elements[i];
		var sName = elm.name; var sVal = elm.value;
		if (sName) {
			switch (elm.nodeName.toLowerCase()) {
				case "input":
					switch (elm.type.toLowerCase()) {
						case "text":
						case "password":
						case "hidden":
							resultArray.push({name: sName, value: encodeURIComponent(sVal)});
							break;
						case "checkbox":
						case "radio":
							if (elm.checked) {
								if (sVal && sVal == "on") {sVal = "true";}
								else if (sVal && sVal == "off") {sVal = "false";}
								resultArray.push({name: sName, value: encodeURIComponent(sVal)});
							}
							break;
					}
					break;
				case "textarea":
				case "select":
					resultArray.push({name: sName, value: encodeURIComponent(sVal)});
					break;
			}
		}
	}
	return resultArray;
}

function BuildQueryStringFromElements(container){
	var resultArray = BuildArrayFromElements(container);
	var requestBody = "";
	for (var i = 0; i < resultArray.length; i++) {
		if (resultArray[i]) {
			requestBody += "&" + resultArray[i].name + "=" + resultArray[i].value;
		}
	}
	if (requestBody) {
		requestBody = requestBody.substr(1);
	}
	return requestBody;
}
function $qs(){
	var container = null;
	if (arguments.length > 0) {
		container = $(arguments[0]);
	} else {
		container = $("aspnetForm");
	}
	return BuildQueryStringFromElements(container);
}
function $qa(){
	var container = null;
	if (arguments.length > 0) {
		container = $(arguments[0]);
	} else {
		container = $("aspnetForm");
	}
	return BuildArrayFromElements(container);
}
function $qo(container){
	return BuildObjectFromElements(container);
}
function UpdateEditorClass(){
    this.UpdateEditorFormValue = function(val){       
        try{
        for (i = 0; i < parent.frames.length; ++i){
            if (parent.frames[i] && parent.frames[i].FCK){    
                parent.frames[i].FCK.UpdateLinkedField();
            }
        }
        }catch(e){}
    }
}
var MyFCKObject = new UpdateEditorClass();
function movepopdiv(evt, div){
	if (ns4 || ns6) {
		x = evt.pageX;
		y = evt.pageY;
	} else {
		x = event.x + document.documentElement.scrollLeft;
		y = event.y + document.documentElement.scrollTop;
	}
	//判断标签是否超出右边界
	var tooltipw = 345;
	var tooltiph = div.clientHeight;
	var iw = parseInt(window.document.body.clientWidth);
	var ih = parseInt(window.document.body.clientHeight);
	if (iw < x + tooltipw) {
		x = x - tooltipw + 24;
	}
	
	div.style.left = x - 20 + "px";
	div.style.top = y - 10 + "px";
	stopPropagation(evt);
	return true;
}
//tooltip
var ns4 = document.layers;
var ns6 = document.getElementById && !document.all;
var ie4 = document.all;
var tooltipdiv = null;
function initTooltipdiv(){
	if (ns4 || ns6 || ie4) {
		if (ns4) {
			tooltipdiv = document.tippopup;
		} else if (ns6) {
			tooltipdiv = getElement("tippopup");
		} else if (ie4) {
			tooltipdiv = document.all.tippopup;
		}
		if (ns4) {
			document.captureEvents(Event.MOUSEMOVE);
		} else {
			tooltipdiv.style.visibility = "visible";
			tooltipdiv.style.display = "none";
			tooltipdiv.innerHTML = "";
		}
	}
}
function on_mouse_over(el){
	if (tooltipdiv == null || el.title == "undefined" || el.title == "") {
		return;
	}
	el.onmousemove = moveToMouseLoc;
	tooltipdiv.innerHTML = el.title;
	el.title = "";
}
function on_mouse_out(el){
	if (tooltipdiv == null || tooltipdiv.innerHTML == "") {
		return;
	}
	tooltipdiv.style.display = "none";
	el.title = tooltipdiv.innerHTML;
}
function moveToMouseLoc(e){
	if (tooltipdiv == null) {
		inittooltipdiv();
	}
	if (ns4 || ns6) {
		x = e.pageX;
		y = e.pageY;
	} else {
		x = event.x + document.documentElement.scrollLeft;
		y = event.y + document.documentElement.scrollTop;
	}
	tooltipdiv.style.display = "block";
	//判断标签是否超出右边界
	var tooltipw = 345;
	var tooltiph = tooltipdiv.clientHeight;
	var iw = parseInt(window.document.body.clientWidth);
	var ih = parseInt(window.document.body.clientHeight);
	if (iw < x + tooltipw) {
		x = x - tooltipw + 24;
	}
	tooltipdiv.style.left = x + 0 + "px";
	tooltipdiv.style.top = y + 20 + "px";
	stopPropagation(e);
	return true;
}
//获得元素位置
function findPosition(objOrId){
	var obj = $(objOrId);
	var curleft = curtop = 0;
	curleft = obj.offsetLeft;
	curtop = obj.offsetTop;
	if (obj.offsetParent) {
		while (obj = obj.offsetParent) {
			curleft += obj.offsetLeft;
			curtop += obj.offsetTop;
		}
	}
	return [curleft, curtop];
};
function showLoading(img, mask){
	var imgdiv = $(img);
	if (!imgdiv) {
		return;
	}
	var sx = document.documentElement.scrollTop;
	var cwidth = document.documentElement.clientWidth;
	var cheight = document.documentElement.clientHeight;
	imgdiv.style.display = "";
	imgdiv.className = "loading";	
	imgdiv.style.top = (sx + cheight / 2 - 40) + "px";
	imgdiv.style.left = (cwidth / 2 - 100) + "px";
	imgdiv.style.zIndex = 20001;
	
	var imgbgdiv = $(mask);
	if (!imgbgdiv) {
		return;
	}
	imgbgdiv.style.width = document.documentElement.scrollWidth + "px";
	imgbgdiv.style.height = document.documentElement.scrollHeight + "px";
};
function hideLoading(img, mask){
	var imgdiv = $(img);
	if (imgdiv) {
		imgdiv.style.display = "none";
		imgdiv.className = "";
	}
	var imgbgdiv = $(mask);
	if (imgbgdiv) {
		imgbgdiv.style.display = "none";	
	}
};
function $etip(evt, pop){
	var target = $event(evt).target; var panl = $(pop);
	panl.setAttribute("xylker", "hsdhder");
	attachEvent(document.body, "click", $be(panl, elistenTipOutsideClick));
    var pos = findPosition(target);
    panl.style.left = pos[0] - 8 + "px";
    panl.style.top = pos[1] + target.offsetHeight + "px";
	panl.style.position = "absolute";	
	panl.style.display = "";
	cancelBubble(evt);
}
function elistenTipOutsideClick(evt){
    evt = $event(evt); var tar = evt.target; var bl = isInTheXylker(tar, "hsdhder");
    if(!bl){$ectip(this);};
}
function $ectip(tipid){
    var panl = $(tipid);
	if (panl.tagName.toLowerCase() == "div") {
		panl.style.display = "none";
	}
	detachEvent(document.body, "click", $be(panl, elistenTipOutsideClick));
}
function $tip(tar, msg, closed, tipid, twidth){
	var target = null; var evt = null;
	if ($type (tar) === "string" || $type (tar) === "element"){
		target = $(tar); 
	} else if (tar.target || tar.srcElement) {
		evt = $event(tar)
		target = evt.target; 
	}
    var col = ""; var tipname = "tipdialogbh"; msg = decodeURIComponent(msg);
    col = "<a class='closeButton' onclick='$ctip(\""+tipname+"\")'></a>"; var cls = "pplspe2";
    if (tipid){
        tipname = tipid;
    }
    if (typeof(closed) !== "undefined" && closed == false){
        col = ""; cls = "pplspe";
    }
	var panl = $(tipname);
	if (panl) {
		$ctip(tipname);
	}
	panl = $create("div");
	document.body.appendChild(panl);
	attachEvent(document.body, "click", $be(panl, listenTipOutsideClick));	
	panl.id = tipname;panl.style.position = "absolute";panl.setAttribute("xylker", "hsdhder");
    var body = "<table cellspacing='0' cellpadding='0' border='0'><tbody><tr><td class='pplml'><img class='pplwimg' alt='' src='/images/clear.gif' /></td>"
            + "<td class='"+ cls +"'>" + msg + col + "</td><td class='pplmr'><img class='pplwimg' alt='' src='/images/clear.gif' /></td></tr><tr><td class='pplbl'><img class='pplimg' alt='' src='/images/clear.gif' /></td><td class='pplb'><img class='pplhimg' alt='' src='/images/clear.gif' /></td><td class='pplbr'><img class='pplimg' alt='' src='/images/clear.gif' /></td></tr></tbody></table>";
	panl.innerHTML = body;
	if (panl.offsetWidth > 320){
		panl.style.width = (twidth ? twidth : 320) + "px";
	}
    var pos = findPosition(target);
    panl.style.left = pos[0] - 8 + "px";
    panl.style.top = pos[1] + target.offsetHeight + "px";
	if (evt) {
		cancelBubble(evt);
	}
};
function listenTipOutsideClick(evt){
    evt = $event(evt);var tar = evt.target; var bl = isInTheXylker(tar, "hsdhder");
    if(!bl){$ctip(this);}
}
function $ctip(tipid){
	var panl = $(tipid);
    if (arguments.length > 0){
        panl = $(arguments[0]);
    }
	if (panl.tagName.toLowerCase() == "div") {
		removeElement(panl);
	}
	detachEvent(document.body, "click", $be(panl, listenTipOutsideClick));
}
function fnTrapKD(btnID, event)
{
    var button = $(btnID); // only recent browsers
    if (document.all) // IE
    {
        if (event.keyCode == 13)
        {
            event.returnValue = false;
            event.cancel = true;
            button.click();
        }
    }
    else if (document.getElementById)
    {
        if (event.which == 13) 
        {
            event.returnValue = false;
            event.cancel = true;
            button.focus();
            button.click();
        }
    }
}
var ALittleHelp = new Class({
	initialize: function(displayDiv, configBtn, codes, show){
		this.displayPanel = $(displayDiv);
		this.configButton = $(configBtn);
		this.configPopupName = "popuphlp";
		this.configPopupButtonOk = this.configPopupName + "btn";
		this.configPopupNameer = this.configPopupName + "er";
		this.selectedCodes = codes || readIntCookie("ALittleHelp") || 12;
		this.Codes = [{
			id: 1,
			title: '新闻',
			code: "<iframe border=\"0\" name=\"sina_roll\" marginwidth=\"0\" marginheight=\"0\" src=\"http://news.sina.com.cn/o/allnews/input/index.html\" frameborder=\"no\" width=\"100%\" scrolling=\"no\" height=\"15\"></iframe>"
		}, {
			id: 2,
			title: '体育',
			code: "<iframe src=\"http://sports.sina.com.cn/iframe/run/index.htm\" frameBorder=\"0\" width=\"200\" scrolling=\"no\" height=\"26\"></iframe>"
		}, {
			id: 4,
			title: '历史上的今天',
			code: "<iframe src=\"http://www.TodayOnHistory.com/Today/1/gbk.html\" width=\"200px\" height=\"18px\" frameborder=\"no\" border=\"0\" marginheight=\"0\" scrolling=\"no\" hspace=\"0\" vspace=\"0\" name=\"history\"></iframe>"
		}, {
			id: 8,
			title: "天气",
			code: "<iframe src=\"http://m.weather.com.cn/m/pn4/weather.htm?id=101020100T\" width=\"160px\" height=\"20px\" marginwidth=\"0\" marginheight=\"0\" hspace=\"0\" vspace=\"0\" frameborder=\"0\" scrolling=\"no\"></iframe>"
		}, {
			id: 16,
			title: '梦幻时钟',
			code: "<embed style=\"margin:0 auto 0 auto; display:block;\"  wmode=\"transparent\" type=\"application/x-shockwave-flash\" src=\"/images/10087.swf\" quality=\"high\" pluginspage=\"http://www.macromedia.com/go/getflashplayer\" allownetworking=\"none\" />"
		}, {
			id: 32,
			title: '日历',
			code: "<embed style=\"margin:0 auto 0 auto; display:block;\"  wmode=\"transparent\" type=\"application/x-shockwave-flash\" src=\"/images/10014.swf\" quality=\"high\" pluginspage=\"http://www.macromedia.com/go/getflashplayer\" allownetworking=\"none\" />"
		}, {
			id: 64,
			title: '生活百科',
			code: "<iframe src=\"/better-life.html\" width=\"222px\" height=\"20px\" marginwidth=\"0\" marginheight=\"0\" hspace=\"0\" vspace=\"0\" frameborder=\"0\" scrolling=\"no\"></iframe>"
		}];
		attachEvent(this.configButton, "click", $be(this, this.selectItem));
		if (show){
		    this.showHtmlHelp();
		}
	},
	showHtmlHelp: function(){
		if (arguments.length > 0) {
			this.selectedCodes = arguments[0];
		}
		var code = this.selectedCodes;
		var sb = "";
		var tmp = "";
		if ((code & 1) === 1) {
			tmp = this._buildElement(1);
			sb = sb + tmp;
		}
		if ((code & 2) === 2) {
			tmp = this._buildElement(2);
			sb = sb + tmp;
		}
		if ((code & 4) === 4) {
			tmp = this._buildElement(4);
			sb = sb + tmp;
		}
		if ((code & 8) === 8) {
			tmp = this._buildElement(8);
			sb = sb + tmp;
		}
		if ((code & 16) === 16) {
			tmp = this._buildElement(16);
			sb = sb + tmp;
		}
		if ((code & 32) === 32) {
			tmp = this._buildElement(32);
			sb = sb + tmp;
		}
       if ((code & 64) === 64) {
			tmp = this._buildElement(64);
			sb = sb + tmp;
		}	
		this.displayPanel.innerHTML = sb;
	},
	_buildElement: function(code){
		var obj = null;
		for (var i = 0; i < this.Codes.length; i++) {
			if (this.Codes[i]["id"] == code) {
				obj = this.Codes[i];
				break;
			}
		}
		if (!obj) 
			return;
		var sb = "<fieldset><legend>";
		sb = sb + obj.title + "</legend><div class=\"code\">" + obj.code + "</div></fieldset>";
		return sb;
	},
	getCodes: function(){
		return this.Codes;
	},
	selectItem: function(evt){
	    this.configButton.blur();
		$tip(evt, this._getCodesHtml(), false);
		attachEvent($(this.configPopupButtonOk), "click", $be(this, this._saveHelpProfile));
		this.ahelpChk = new ChksSelector(this.configPopupNameer);
	},
	_getCodesHtml: function(){
		var idstr = " id = \"" + this.configPopupNameer + "\"";
		var sb = "<div" + idstr + " class=\"rbblk\" style=\"width:150px;\"><ul>";
		for (var i = 0; i < this.Codes.length; i++) {
			var seled = "";
			var obj = this.Codes[i];
			if (this.selectedCodes > 0 && (this.selectedCodes & obj.id) == obj.id) {
				seled = " checked=\"checked\"";
			}
			sb = sb + String.format("<li><label for=\"{0}\"><input type=\"checkbox\" id=\"{0}\" name=\"{3}\" group=\"{3}er\" value=\"{1}\"{4}>{2}</label></li>", String.format("{0}{1}", this.configPopupName, i), obj.id, obj.title, this.configPopupName, seled);
		}
		sb = sb + "</ul><div class='buttondiv'><input type=\"button\" id=\"" + this.configPopupButtonOk + "\" value=\"确定\"/><input type=\"button\" value=\"关闭\" onclick=\"$ctip('" + this.configPopupNameer + "')\"/></div></div>";
		
		return sb;
	},
	_saveHelpProfile: function(){
		if (!this.ahelpChk) 
			return;
		var cods = this.ahelpChk.getSelectedValues();
		if (cods.length === 0) {
			this.selectedCodes = 0;
			return;
		}
		var it = 0;
		for (var i = 0; i < cods.length; i++) {
			if (it === 0) {
				it = parseInt(cods[i]);
			} else {
				it = it | parseInt(cods[i]);
			}
		}
		this.selectedCodes = it;
		addCookie("ALittleHelp", it + "", 365);
		var opt = {
			method: 'get',
			onSuccess: Class.empty
		};
		var data = { t: 'profile', n: 'help', v: this.selectedCodes };
		new Ajax("/handler/commonhandler.ashx", opt).request(data);
		detachEvent($(this.configPopupButtonOk), "click", $be(this, this._saveHelpProfile));
		$ctip(this.configPopupNameer);
		this.showHtmlHelp();
	}
});
function $image(im, s){
    var MaxW=s; var MaxH=s; var o=new Image(); o.src=im.src;var w=o.width;var h=o.height;var t;if (w>MaxW){t=MaxW;}else{t=w;}
    if (im.src && im.src.indexOf("pixel.gif") < 0 && w < 2) { setTimeout(function(){$image(im, s);}, 50); }
    if ((h*t/w)>MaxH){im.height=MaxH;im.width=MaxH/h*w;}else{im.width=t;im.height=t/w*h;}
}
function $rimage(im, s){
    var MaxW=s; var MaxH=(MaxW*3)/4;var o=new Image(); o.src=im.src;var w=o.width;var h=o.height;var t;if (w>MaxW){t=MaxW;}else{t=w;}
    if (im.src && im.src.indexOf("pixel.gif") < 0 && w < 2) { o = null; setTimeout(function(){$rimage(im, s);}, 50); }
    if ((h*t/w)>MaxH){im.height=MaxH;im.width=MaxH/h*w;}else{im.width=t;im.height=t/w*h;}
}
function attachimg(obj, action){
    var msgwidth = 0;
    if (action == 'blog') { msgwidth = 650; } else if (action == 'product'){ msgwidth = 550; } else {msgwidth = 550;}
	if (obj.width > msgwidth) {
		obj.width = msgwidth;
	}
}
function downloadImagesFromInternet(container){
	var imgs = $(container).getElementsByTagName("img"); var dimgs = new Object(); var msg = "共{0}张图片, 正在下载{1}图片..."; var m_who = "";
	if (imgs && imgs.length == 0) {
		return;
	}
	if (window.location.href.lastIndexOf("new-blog") >= 0) {
		m_who = "blog";
	} else if (window.location.href.lastIndexOf("upload-productdesign") >= 0) {
		m_who = "design";
	} else if (window.location.href.lastIndexOf("new-article") >= 0) {
		m_who = "article";
	}
	var dialog = $box(String.format(msg, imgs.length, ""));
	downloadImageFromInternet(imgs, dimgs, 0, m_who, dialog, msg);
}
function downloadImageFromInternet(imgs, dimgs, index, wh, dialog, msg){
	var img = imgs[index]; var url = img.getAttribute("src");
	if (url.indexOf("http://") === 0 || url.indexOf("ftp://") === 0 || url.indexOf("https://") === 0) {
		if (url.indexOf(window.location.protocol + "//" + window.location.host) >= 0) {
			_downloadImageFromInternet(imgs, dimgs, index, wh, dialog, msg);
		} else {
			dialog.setHTML(String.format(msg, imgs.length, "第" + (index + 1) + "张"));
			if (dimgs[url]){
				if (img.getAttribute("_fcksavedurl")) {
					img.setAttribute("_fcksavedurl", dimgs[url]);
				}				
				img.setAttribute("src", dimgs[url]);
				_downloadImageFromInternet(imgs, dimgs, index, wh, dialog, msg);
			} else {
				new Ajax("/upld.aspx", {
					method: 'get',
					onSuccess: function(aj, rsp){
						if (rsp.text) {
							var backUrl = window.location.protocol + "//" + window.location.host + rsp.text;
							dimgs[url] = backUrl;
							if (img.getAttribute("_fcksavedurl")) {
								img.setAttribute("_fcksavedurl", backUrl);
							}
							img.setAttribute("src", backUrl);
						}
						_downloadImageFromInternet(imgs, dimgs, index, wh, dialog, msg);
					}
				}).request({path: url, who: wh, ts: $time()});
			}
		}
	}
}
function _downloadImageFromInternet(imgs, dimgs, index, wh, dialog, msg){
	if (index < imgs.length - 1) {
		setTimeout(function(){}, 100);
		downloadImageFromInternet(imgs, dimgs, index + 1, wh, dialog, msg);
	} else {
		dialog.setHTML("下载成功");
	}	
}

