/*
+-----------------------------------------------
+	WeSpace Base Javascript
+-----------------------------------------------
+	Update: 2010/05/03
*/
var isEnglish = false, categorys = new Array(), category = {
	Init : {
		Lang : {
			year				: isEnglish ? ' [Year] '	: '年',
			month				: isEnglish ? ' [Month] '	: '月',
			day					: isEnglish ? ' [Day] '		: '日',
			week_py				: '', 
			week_pm				: '', 
			week_nm				: '', 
			week_ny				: '', 
			week_n1				: '日',
			week_n2				: '一',
			week_n3				: '二',
			week_n4				: '三',
			week_n5				: '四',
			week_n6				: '五',
			week_n7				: '六',
			do_unchoose			: isEnglish ? '=NULL='					: '=不选=',
			do_submit			: isEnglish ? 'SUBMIT'					: '确定',
			do_empty			: isEnglish ? 'EMPTY'					: '清空', 
			do_empty_confirm	: isEnglish ? 'Empty Item?'				: '确定要清空吗?',
			newfolder			: '建立文件夹',
			chosedchosen		: isEnglish ? 'Chosen List'				: '已选中', 
			maxiumoptions		: isEnglish ? 'Maxium(!x!) is Allowed.'	: '您最多可添加!x!个选项'
		},
		MULS : 5,
		UNIX : new Date(),
		CATER : function(cid){
			if (typeof(inEnglishCategory) != 'undefined' && !isEnglish){
				isEnglish = true;
			} var results = ''; if (typeof categorys[cid] != 'undefined'){
				results = categorys[cid];
			} return results;
		}, 
		NAMES : function(cid){
			var results = isEnglish ? ['==CHOOSE==', '==CHOOSE=='] : ['==请选择==', '==请选择==']; switch (cid){
				case 'year' : results = isEnglish ? ['YY', 'MM'] : ['年份', '月份']; break;
				case 'month' : results = isEnglish ? ['YY', 'MM'] : ['年份', '月份']; break;
			} return results;
		}, 
		Poper : {
			simple : true, 
			double : true, 
			mulity : true, 
			mulityusedisabled : false, 
			compact : ' + ', 
			select : function(obj, txt, script, hide){
				if (typeof script == 'undefined'){
					script = '';
				} if (typeof hide == 'undefined'){
					hide = '';
				} obj.innerHTML = '<div id="' + obj.id + '_prompter"' + script + ' class="wsbase_select"><a href="#" onclick="return false">' + txt + '</a></div>' + hide + '&nbsp;';
			}
		}
	},
	/*
	+-------------------------------------------
	+	年份选择
	+-------------------------------------------
	*/
	year : function(id, num, type, slider, popid){
		var obj = WSBase._func.is_object(id), year = parseInt(this.Init.UNIX.getFullYear()), config = [], loopi = loops = begine = finish = 0, txtipt = txtpop = txtslide = clicks = inputs = '', ispoper = true; if (obj){
			/*
			+-----------------------------------
			+	读取年限
			+-----------------------------------
			*/
			switch (type){
				case 'prev'	: begine = year - 14;	finish = year - 80;						break;
				case 'next'	: begine = year;		finish = year + 5;	ispoper = false;	break;
				default		: begine = year + 5;	finish = year - 80;						break;
			} if (begine > finish){
				for (var i = begine; i > finish; i--){
					config.push(i);
				}
			} else {
				for (var i = begine; i < finish; i++){
					config.push(i);
				}
			} if (this.Init.Poper.simple){
				var V_VAL = 0; if (ispoper){
					/*
					+---------------------------
					+	初始化
					+---------------------------
					*/
					txtpop += '<div class="p1">';
						txtpop += '<div class="p">';
							txtpop += '<input class="i" type="button" value="' + this.Init.Lang.do_submit + '" onclick="WSBase._displayer.categoff()" />';
						txtpop += '</div>';
					txtpop += '</div>';
					/*
					+---------------------------
					+	组织年限列表
					+---------------------------
					*/
					txtpop += '<div class="p2">'; for (var i = 0; i < config.length; i++){ loopi++;
						if (config[i] == num){ V_VAL = txtipt = config[i];
							var classid = 't', clicker = 'category.year(\'' + id + '\', 0, \'' + type + '\', true)';
						} else {
							var classid = 'f', clicker = 'category.year(\'' + id + '\', \'' + config[i] + '\', \'' + type + '\', true)';
						}
						txtpop += '<ol class="b"><li class="' + classid + '">';
						txtpop += '<a href="#" onclick="' + clicker + ';return false">' + config[i] + '</a>';
						txtpop += '</li></ol>';
					} if (loopi % 3 > 0){
						loops = 3 - loopi % 3;
						for (var li = 0; li < loops; li++){
							txtpop += '<ol class="b"><li></li></ol>';
						}
					} txtpop += '</div>';
					/*
					+---------------------------
					+	编译表单
					+---------------------------
					*/
					clicks = 'onclick="category.year(\'' + id + '\', \'' + V_VAL + '\', \'' + type + '\', true);return false"'; 
					inputs = '<input type="hidden" name="year" value="' + V_VAL + '" />'; if (txtipt == ''){ var names = this.Init.NAMES('year');
					txtipt = names[0]; }
					this.Init.Poper.select(obj, txtipt, clicks, inputs);
					/*
					+---------------------------
					+	弹出窗口选项
					+---------------------------
					*/
					if (slider){
						WSBase._displayer.category(txtpop);
					}
				} else {
					txtslide += '<li class="n"><a href="#" onclick="category.year(\'' + id + '\', 0, \'' + type + '\'); WSBase._displayer.slidoff(); return false">' + this.Init.Lang.do_unchoose + '</a></li>';
					for (var i = 0; i < config.length; i++){
						if (config[i] == num){ V_VAL = txtipt = config[i];
							var classid = 't';
						} else {
							var classid = 'f';
						} var clicker = 'category.year(\'' + id + '\', \'' + config[i] + '\', \'' + type + '\')';
						txtslide += '<li class="' + classid + '"><a href="#" onclick="' + clicker + '; WSBase._displayer.slidoff(); return false">' + config[i] + '</a></li>';
					}
					/*
					+---------------------------
					+	编译表单
					+---------------------------
					*/
					clicks = 'onclick="category.year(\'' + id + '\', \'' + V_VAL + '\', \'' + type + '\', true, this.id); return false"'; 
					inputs = '<input type="hidden" name="year" value="' + V_VAL + '" />'; if (txtipt == ''){ var names = this.Init.NAMES('year');
					txtipt = names[0]; }
					this.Init.Poper.select(obj, txtipt, clicks, inputs);
					/*
					+---------------------------
					+	表出下拉选项
					+---------------------------
					*/
					if (typeof popid != 'undefined'){
						var sObj = WSBase._func.is_object(popid); if (sObj){
							WSBase._displayer.slider(sObj, '<ol>' + txtslide + '</ol>');
						}
					}
				}
			} else {
				/*
				+-------------------------------
				+	4.x模式
				+-------------------------------
				*/
				this.year_base(obj, config, num);
			}
		}
	},
	year_base : function(obj, config, num){
		var names = this.Init.NAMES('year'), results = '<select id="' + obj.id + '_prompter" name="year"><option value="0">' + names[0] + '</option>'; 
		for (var i = 0; i < config.length; i++){
			results += '<option value="' + config[i] + '"' + (config[i] == num ? ' selected="selected"' : '') + '>' + config[i] + '</option>';
		} results += '</select> '; obj.innerHTML = results;
	},
	/*
	+-------------------------------------------
	+	月份选择
	+-------------------------------------------
	*/
	month : function(id, key, val, poper, type){
		var obj = WSBase._func.is_object(id), config = [], year = parseInt(this.Init.UNIX.getFullYear()), loopi = loops = begine = finish = 0, txtipt = txtpop = ''; if (obj){
			/*
			+-----------------------------------
			+	读取年限
			+-----------------------------------
			*/
			switch (type){
				case 'next'	: begine = year;		finish = year + 5;	ispoper = false;	break;
				default		: begine = year + 6;	finish = year - 50;	type = 'common';	break;
			} if (begine > finish){
				for (var i = begine; i > finish; i--){
					config.push(i);
				}
			} else {
				for (var i = begine; i < finish; i++){
					config.push(i);
				}
			} if (this.Init.Poper.double){
				var vid1 = vid2 = 0, V_SUB = V_SEL = '', keys = key.split('|'), vals = val.split('|'), yearid = br = 0;
				txtpop += '<div class="p1">';
					txtpop += '<div class="p">';
						txtpop += '<input class="i" type="button" value="' + this.Init.Lang.do_submit + '" onclick="WSBase._displayer.categoff()" />';
					txtpop += '</div>';
				txtpop += '{sel}';
				txtpop += '</div>';
				txtpop += '<div class="p2">';
				for (var i = 0 ; i < config.length; i++){ loopi++;
					var checker = false, classid = 'f', clicker = 'category.month(\'' + id + '\', \'' + key + '\' ,\'' + config[i] + '|0\', true, \'' + type + '\')'; if (config[i] == vals[0]){
						checker = true; classid = 't'; yearid = config[i]; br = 1;
						clicker = 'category.month(\'' + id + '\', \'' + key + '\' ,\'0|0\', true, \'' + type + '\')';
					}
					txtpop += '<ol class="' + (checker ? 'm' : 'b') + '"><li class="' + classid + '">';
					txtpop += '<a href="#" onclick="' + clicker + ';return false">' + config[i] + '</a>';
					txtpop += '</li></ol>';
					if (br == 1 && loopi % 3 == 0){ br = 0;
						txtpop += '{sub}';
					}
				} if (loopi % 3 > 0){
					loops = 3 - loopi % 3; for (var li = 0; li < loops; li++){
						txtpop += '<ol class="b"><li></li></ol>';
					}
				} if (br == 1){ br = 0;
					txtpop += '{sub}';
				} txtpop += '</div>'; if (yearid > 0){
					for (var j = 1; j <= 12; j++){
						var classid = 'f', clicker = 'category.month(\'' + id + '\', \'' + key + '\' ,\'' + yearid +'|' + j + '\', true, \'' + type + '\')'; if (j == vals[1]){ vid1 = yearid; vid2 = j;
							classid = 't'; txtipt = yearid + this.Init.Lang.year + j + this.Init.Lang.month;
							clicker = 'category.month(\'' + id + '\', \'' + key + '\' ,\'' + yearid +'|0\', true, \'' + type + '\')';
							V_SEL = '<a href="#" onclick="category.month(\'' + id + '\', \'' + key + '\' ,\'0|0\', true, \'' + type + '\');return false">' + txtipt + '</a>';
						}
						V_SUB += '<ul><li class="' + classid + '">';
						V_SUB += '<a href="#" onclick="' + clicker + ';return false">' + j + '</a>';
						V_SUB += '</li></ul>';
					}
				}
				/*
				+-------------------------------
				+	编译表单
				+-------------------------------
				*/
				if (txtipt == ''){ var names = this.Init.NAMES();
					txtipt = names[0];
				} 
				clicks = 'onclick="category.month(\'' + id + '\', \'' + key + '\', \'' + vid1 + '|' + vid2 + '\', true, \'' + type + '\');return false"'; 
				inputs = '<input type="hidden" name="' + keys[0] + '" value="' + vid1 + '" /><input type="hidden" name="' + keys[1] + '" value="' + vid2 + '" />';
				this.Init.Poper.select(obj, txtipt, clicks, inputs);
				/*
				+-------------------------------
				+	弹出窗口选项
				+-------------------------------
				*/
				if (poper){
					if (V_SEL != ''){
						V_SEL = '<div class="s">' + V_SEL + '<div class="clear"></div></div>';
					} txtpop = txtpop.replace(/\{sel\}/g, V_SEL); if (V_SUB != ''){
						V_SUB = '<div class="s">' + V_SUB + '<div class="clear"></div></div>';
					} txtpop = txtpop.replace(/\{sub\}/g, V_SUB); WSBase._displayer.category(txtpop);
				}
			} else {
				this.month_base(obj, config, key, val, id, type);
			}
		}
	},
	month_base : function(obj, config, key, val, id, type){
		var txtyear = txtmonth = '', yearid = 0, keys = key.split('|'), vals = val.split('|'), names = this.Init.NAMES('month'); if (typeof keys[0] == 'undefined' || keys[0] == ''){
			keys[0] = 'year'; keys[1] = 'month';
		} else if (typeof keys[1] == 'undefined' || keys[1] == ''){
			keys[1] = 'month';
		} if (typeof vals[0] == 'undefined'){
			vals[0] = vals[1] = 0;
		} else if (typeof vals[1] == 'undefined'){
			vals[1] = 0;
		}
		txtyear 	+= '<select name="' + keys[0] + '" onchange="category.month(\'' + id +'\', \'' + key + '\', this.value + \'|0\', false, \'' + type + '\')"><option value="0">' + names[0] + '</option>';
		txtmonth	+= '<select name="' + keys[1] + '"><option value="0">' + names[1] + '</option>';
		for (var i = 0; i < config.length; i++){
			var checked = ''; if (config[i] == parseInt(vals[0])){
				yearid = config[i];
				checked = ' selected="selected"';
			} txtyear	+= '<option value="' + config[i] + '"' + checked + '>' + config[i] + '</option>';
		} txtyear += '</select> '; if (yearid > 0){
			for (var j = 1; j <= 12; j++){
				var checked = ''; if (j == vals[1]){
					checked = ' selected="selected"';
				} txtmonth	+= '<option value="' + j + '"' + checked + '>' + j + '</option>';
			}
		} txtmonth += '</select> '; obj.innerHTML = txtyear + txtmonth;
	},
	/*
	+-------------------------------------------
	+	单选
	+-------------------------------------------
	*/
	folder : function(id, val, folders, popid, inew){
		var obj = WSBase._func.is_object(id), config = [], folderid = 0, newtype = 'hidden'; txtipt = txtpop = inputs = clicks = ''; if (obj){ config = folders.split('^');
			txtpop += '<li class="n"><a href="#" onclick="WSBase._displayer.slidoff(); category.folder(\'' + id + '\', 0, \'' + folders + '\', false, ' + (inew ? 'true' : 'false') + '); return false">' + this.Init.Lang.do_unchoose + '</a></li>'; for (var i = 0; i < config.length; i++){
				var tmps = config[i].split(','), cls = 'f'; if (tmps.length == 2){
					if (tmps[0] == val){
						cls = 't';
						folderid = tmps[0];
						txtipt = tmps[1];
					} txtpop += '<li class="' + cls + '"><a href="#" onclick="WSBase._displayer.slidoff(); category.folder(\'' + id + '\', \'' + tmps[0] + '\', \'' + folders + '\', false, ' + (inew ? 'true' : 'false') + '); return false">' + tmps[1] + '</a></li>';
				}
			} if (inew){ var cls = 'f';
				if (val == -1){
					cls = 't';
					newtype = 'text'; 
					folderid = -1;
					txtipt = this.Init.Lang.newfolder;
				} txtpop += '<li class="' + cls + '"><a href="#" onclick="WSBase._displayer.slidoff(); category.folder(\'' + id + '\', -1, \'' + folders + '\', false, ' + (inew ? 'true' : 'false') + '); return false">' + this.Init.Lang.newfolder + '</a></li>';
			} if (txtipt == ''){
				var names = this.Init.NAMES(); 
				txtipt = names[0];
			}
			inputs = '<input type="hidden" name="folderid" value="' + folderid + '" />&nbsp;<input id="foldername_prompter" type="' + newtype + '" name="foldername" value="" />';
			clicks = 'onclick="category.folder(\'' + id + '\', \'' + folderid + '\', \'' + folders + '\', this.id, ' + (inew ? 'true' : 'false') + '); return false"';
			this.Init.Poper.select(obj, txtipt, clicks, inputs);
			if (typeof popid != 'undefined'){
				var sObj = WSBase._func.is_object(popid); if (sObj){
					WSBase._displayer.slider(sObj, '<ol>' + txtpop + '</ol>');
				}
			}
		}
	},
	simple : function(id, cid, key, val, popid){
		var obj = WSBase._func.is_object(id), config = [], names = this.Init.NAMES(), valipt = 0, txtipt = txtpop = inputs = clicks = ''; if (obj){ config = this.Init.CATER(cid).split('^');
			if (this.Init.Poper.simple){
				/*
				+-------------------------------
				+	初始化
				+-------------------------------
				*/
				txtipt  = names[0];
				txtpop += '<li class="n"><a href="#" onclick="WSBase._displayer.slidoff(); category.simple(\'' + id + '\', \'' + cid + '\', \'' + key + '\', \'0\'); return false">' + this.Init.Lang.do_unchoose + '</a></li>';
				/*
				+-------------------------------
				+	建立选项
				+-------------------------------
				*/
				for (var i = 0; i < config.length; i++){
					var tmp = config[i].split(','), cls = 'f';
					if (tmp.length == 2){
						if (tmp[0] == val) { cls = 't';
							txtipt = tmp[1];
							valipt = tmp[0];
						} txtpop += '<li class="' + cls + '"><a href="#" onclick="WSBase._displayer.slidoff(); category.simple(\'' + id + '\', \'' + cid + '\', \'' + key + '\', \'' + tmp[0] + '\');return false">' + tmp[1] + '</a></li>';
					}
				}
				/*
				+-------------------------------
				+	编译表单
				+-------------------------------
				*/
				inputs = '<input type="hidden" name="' + key + '" value="' + valipt + '" />';
				clicks = 'onclick="category.simple(\'' + id + '\', \'' + cid + '\', \'' + key + '\', \'' + valipt + '\', this.id); return false"';
				this.Init.Poper.select(obj, txtipt, clicks, inputs);
				/*
				+-------------------------------
				+	表出下拉选项
				+-------------------------------
				*/
				if (typeof popid != 'undefined'){
					var sObj = WSBase._func.is_object(popid); if (sObj){
						WSBase._displayer.slider(sObj, '<ol>' + txtpop + '</ol>');
					}
				}
			} else {
				/*
				+-------------------------------
				+	使用4.x模式
				+-------------------------------
				*/
				this.simple_base(obj, names[0], key, val, config);
			}
		}
	},
	simple_base : function(obj, chosen, key, val, config){
		var results = '<select id="' + obj.id + '_prompter" name="' + key + '"><option value="0">' + chosen + '</option>'; for (var i = 0; i < config.length; i++){
			var tmp = config[i].split(','), selected = ''; if (tmp.length == 2){
				if (tmp[0] == val){
					selected = ' selected="selected"';
				} results += '<option value="' + tmp[0] + '"' + selected + '>' + tmp[1] + '</option>';
			}
		} results += '</select> '; obj.innerHTML = results;
	},
	single : function(id, key, val, txt, popid){
		var obj = WSBase._func.is_object(id), config = [], names = this.Init.NAMES(), valipt = 0, txtipt = txtpop = inputs = clicks = ''; if (obj){
			if (this.Init.Poper.simple){
				/*
				+-------------------------------
				+	初始化
				+-------------------------------
				*/
				txtipt  = names[0];
				txtpop += '<li class="n"><a href="#" onclick="WSBase._displayer.slidoff(); category.single(\'' + id + '\', \'' + key + '\', 0, \'' + txt + '\'); return false">' + this.Init.Lang.do_unchoose + '</a></li>';
				config  = txt.split('^');
				/*
				+-------------------------------
				+	建立选项
				+-------------------------------
				*/
				for (var i = 0; i < config.length; i++){
					var tmp = config[i].split(','), cls = 'f';
					if (tmp.length == 2){
						if (tmp[0] == val) { cls = 't';
							txtipt = tmp[1];
							valipt = tmp[0];
						} txtpop += '<li class="' + cls + '"><a href="#" onclick="WSBase._displayer.slidoff(); category.single(\'' + id + '\', \'' + key + '\', \'' + tmp[0]+ '\', \'' + txt+ '\');return false">' + tmp[1] + '</a></li>';
					}
				}
				/*
				+-------------------------------
				+	编译表单
				+-------------------------------
				*/
				inputs = '<input type="hidden" name="' + key + '" value="' + valipt + '" />';
				clicks = 'onclick="category.single(\'' + id + '\', \'' + key + '\', \'' + val + '\', \'' + txt + '\', this.id); return false"';
				this.Init.Poper.select(obj, txtipt, clicks, inputs);
				/*
				+-------------------------------
				+	表出下拉选项
				+-------------------------------
				*/
				if (typeof popid != 'undefined'){
					var sObj = WSBase._func.is_object(popid); if (sObj){
						WSBase._displayer.slider(sObj, '<ol>' + txtpop + '</ol>');
					}
				}
			} else {
				/*
				+-------------------------------
				+	使用4.x模式
				+-------------------------------
				*/
				this.single_base(obj, names[0], key, val, txt);
			}
		}
	},
	single_base : function(obj, chosen, key, val, txt){
		var config = txt.split('^'), results = '<select id="' + obj.id + '_prompter" name="' + key + '"><option value="0">' + chosen + '</option>'; for (var i = 0; i < config.length; i++){
			var tmp = config[i].split(','), selected = ''; if (tmp.length == 2){
				if (tmp[0] == val){
					selected = ' selected="selected"';
				} results += '<option value="' + tmp[0] + '"' + selected + '>' + tmp[1] + '</option>';
			}
		} results += '</select> '; obj.innerHTML = results;
	},
	/*
	+-------------------------------------------
	+	双选
	+-------------------------------------------
	*/
	double : function(id, cid, key, val, poper, handle){
		var obj = WSBase._func.is_object(id), config = [], loopi = loops = br = 0, vid1 = vid2 = 0, commt = txtipt = txtpop = clicks = ''; if (obj){ config = this.Init.CATER(cid).split('^');
			if (this.Init.Poper.double){
				/*
				+-------------------------------
				+	初始化
				+-------------------------------
				*/
				var V_SEL = V_SUB = '', keys = key.split('|'), vals = val.split('|'); if (typeof keys[0] == 'undefined' || keys[0] == ''){
					keys[0] = cid + '_a';
				} if (typeof keys[1] == 'undefined' || keys[1] == ''){
					keys[1] = cid + '_b';
				} if (typeof vals[0] == 'undefined' || isNaN(vals[0])){
					vals[0] = vals[1] = 0;
				} else if (typeof vals[1] == 'undefined' || isNaN(vals[1])){
					vals[1] = 0;
				} if (typeof handle == 'undefined' && !isNaN(vals[0]) && vals[0] > 0){
					handle = vals[0];
				}
				/*
				+-------------------------------
				+	确定框
				+-------------------------------
				*/
				txtpop += '<div class="p1">';
					txtpop += '<div class="p">';
						txtpop += '<input class="i" type="button" value="' + this.Init.Lang.do_submit + '" onclick="WSBase._displayer.categoff()" />';
					txtpop += '</div>';
				txtpop += '{sel}';
				txtpop += '</div>';
				/*
				+-------------------------------
				+	读取列表
				+-------------------------------
				*/
				txtpop += '<div class="p2">';
				for (var i = 0; i < config.length; i++){
					var tmps = config[i].split(','), checker = false, classid = 'f'; if (tmps.length == 3){
						if (tmps[0] == 0){ loopi++;
							if (tmps[1] == vals[0]){ vid1 = tmps[1]; txtipt += commt + tmps[2]; commt = this.Init.Poper.compact;
								checker = true;
							} if (tmps[1] == handle){ br = 1;
								hander = 'category.double(\'' + id + '\', \'' + cid + '\', \'' + key + '\', \'' + val + '\', true)';
							} else {
								hander = 'category.double(\'' + id + '\', \'' + cid + '\', \'' + key + '\', \'' + val + '\', true, \'' + tmps[1] + '\')';
							} if (checker){
								classid = 't';
								clicker = 'category.double(\'' + id + '\', \'' + cid + '\', \'' + key + '\', \'0|0\', true)';
								V_SEL += tmps[2];
							} else {
								clicker = 'category.double(\'' + id + '\', \'' + cid + '\', \'' + key + '\', \'' + tmps[1] + '|0\', true)';
							}
							/*
							+------------------
							+	附加选项
							+------------------
							*/
							txtpop += '<ol class="' + (tmps[1] == handle ? 'm' : 'b') + '"><li class="' + classid + '">';
							txtpop += '<a href="#" onclick="' + clicker + ';return false">' + tmps[2] + '</a>';
							txtpop += '<i onclick="' + hander + '"></i>';
							txtpop += '</li></ol>';
							if (br == 1 && loopi % 3 == 0){ br = 0;
								txtpop += '{sub}';
							}
						} else {
							if (tmps[1] == vals[1]){
								checker = true; vid2 = tmps[1]; txtipt += commt + tmps[2]; commt = this.Init.Poper.compact;
								classid = 't';
								V_SEL += '(' + tmps[2] + ')';
							} if (tmps[0] == handle){
								if (checker){
									clicker = 'category.double(\'' + id + '\', \'' + cid + '\', \'' + key + '\', \'' + tmps[0] + '|0\', true)';
								} else {
									clicker = 'category.double(\'' + id + '\', \'' + cid + '\', \'' + key + '\', \'' + tmps[0] + '|' + tmps[1] + '\', true)';
								}
								V_SUB += '<ul><li class="' + classid + '">';
								V_SUB += '<a href="#" onclick="' + clicker + ';return false">' + tmps[2] + '</a>';
								V_SUB += '</li></ul>';
							}
						}
					}
				}
				/*
				+-------------------------------
				+	补余
				+-------------------------------
				*/
				if (loopi % 3 > 0){ loops = 3 - loopi % 3;
					for (var li = 0; li < loops; li++){
						txtpop += '<ol class="b"><li></li></ol>';
					}
				} if (br == 1){
					txtpop += '{sub}';
				} txtpop += '</div>';
				/*
				+-------------------------------
				+	编译表单
				+-------------------------------
				*/
				if (txtipt == ''){ var names = this.Init.NAMES();
					txtipt = names[0];
				} 
				clicks = 'onclick="category.double(\'' + id + '\', \'' + cid + '\', \'' + key + '\', \'' + vid1 + '|' + vid2 + '\', true);return false"'; 
				inputs = '<input type="hidden" name="' + keys[0] + '" value="' + vid1 + '" /><input type="hidden" name="' + keys[1] + '" value="' + vid2 + '" />';
				this.Init.Poper.select(obj, txtipt, clicks, inputs);
				/*
				+-------------------------------
				+	弹出窗口选项
				+-------------------------------
				*/
				if (poper){
					if (V_SEL != ''){
						V_SEL = '<div class="s"><a href="#" onclick="category.double(\'' + id + '\', \'' + cid + '\', \'' + key + '\', \'0|0\', true);return false" title="' + V_SEL + '">' + V_SEL + '</a><div class="clear"></div></div>';
					} txtpop = txtpop.replace(/\{sel\}/g, V_SEL); if (V_SUB != ''){
						V_SUB = '<div class="s">' + V_SUB + '<div class="clear"></div></div>';
					} txtpop = txtpop.replace(/\{sub\}/g, V_SUB); WSBase._displayer.category(txtpop);
				}
			} else {
				/*
				+-------------------------------
				+	4.x模式
				+-------------------------------
				*/
				this.double_base(obj, config, key, val, id, cid);
			}
		}
	},
	double_base : function(obj, config, key, val, id, cid){
		var keys = key.split('|'), vals = val.split('|'), results = [], names = this.Init.NAMES(cid); for (var i = 0; i < config.length; i++){
			results['f'] = '<select name="' + keys[0] + '" onchange="category.double(\'' + id + '\', \'' + cid + '\', \'' + key + '\', this.value + \'|0\')"><option value="0">' + names[0] + '</option>';
			results['s'] = '<select name="' + keys[1] + '"><option value="0">' + names[1] + '</option>';
			for (var i = 0; i < config.length; i++){
				var tmps = config[i].split(','); if (tmps.length == 3){
					if (tmps[0] == 0){
						results['f'] += '<option value="' + tmps[1] + '"' + (tmps[1] == vals[0] ? ' selected="selected"' : '') + '>' + tmps[2] + '</option>';
					} else {
						if (tmps[0] == vals[0]){
							results['s'] += '<option value="' + tmps[1] + '"' + (tmps[1] == vals[1] ? ' selected="selected"' : '') + '>' + tmps[2] + '</option>';
						}
					}
				}
			} obj.innerHTML = results['f'] + '</select> ' + results['s'] + '</select>';
		}
	},
	/*
	+-------------------------------------------
	+	多选
	+-------------------------------------------
	*/
	mulity : function(id, cid, key, val, single, adder, deler, poper){
		var obj = WSBase._func.is_object(id), config = [], loopi = loops = br = 0; txtipt = txtpop = '', inputs = clicks = ''; if (obj){ config = this.Init.CATER(cid).split('^');
			if (this.Init.Poper.mulity){
				/*
				+-------------------------------
				+	添加 | 添加
				+-------------------------------
				+	valed : 已添加的分类组数
				+	addid : 要添加的分类编号
				+	delid : 要删除的分类编号
				*/
				var valed = val.split(',');
				var addid = !isNaN(adder) && adder > 0 ? parseInt(adder) : 0;
				var delid = !isNaN(deler) && deler > 0 ? parseInt(deler) : 0;
				var handle = 0;
				/*
				+-------------------------------
				+	确定框
				+-------------------------------
				*/
				txtpop += '<div class="p1">';
					txtpop += '<div class="p">';
						txtpop += '<input class="e" type="button" value="' + this.Init.Lang.do_empty + '" onclick="category.mulity(\'' + id + '\', \'' + cid + '\', \'' + key + '\', \'\', ' + (single ? 'true' : 'false') + ', 0, 0, true)" />';
						txtpop += '<input class="i" type="button" value="' + this.Init.Lang.do_submit + '" onclick="WSBase._displayer.categoff()" />';
					txtpop += '</div>';
				txtpop += '{sel}';
				txtpop += '</div>';
				/*
				+-------------------------------
				+	初始化
				+-------------------------------
				*/
				var V_SUB = V_VAL = V_SEL = '', P_SUB = false, commv = commt = '', checki = 0; if (single){
					/*
					+---------------------------
					+	一级
					---------------------------
					*/
					txtpop += '<div class="p2">';
					for (var i = 0; i < config.length; i++){
						var tmps = config[i].split(','), checker = false, clicker = ''; if (tmps.length == 2){ loopi++;
							if (tmps[0] == addid || WSBase._func.in_array(tmps[0], valed)){
								if (tmps[0] != delid){ checki++;
									/*
									+----------
									+	最大值
									+----------
									*/
									if (addid && this.Init.MULS > 0 && checki > this.Init.MULS){
										alert(this.Init.Lang.maxiumoptions.replace(/!x!/ig, this.Init.MULS));
										return false;
									}
									/*
									+----------
									+	赋值
									+----------
									*/
									checker = true; txtipt += commt + tmps[1]; commt = this.Init.Poper.compact;
									inputs += '<input type="hidden" name="' + key + '[]" value="' + tmps[0] + '" />';
									V_VAL += commv + tmps[0]; commv = ',';
									V_SEL += '<a href="#" title="' + tmps[1] + '" onclick="category.mulity(\'' + id + '\', \'' + cid + '\', \'' + key + '\', \'{val}\', true, 0, \'' + tmps[0] + '\', true);return false">' + tmps[1] + '</a>';
								}
							}
							/*
							+------------------
							+	附加选项
							+------------------
							*/
							if (checker){
								clicker = 'category.mulity(\''+id+'\', \''+cid+'\', \''+key+'\', \'{val}\', ' + single + ', 0, \''+tmps[0]+'\', true)';
								/*
								+--------------
								+	已选中
								+--------------
								*/
								txtpop += '<ol class="b"><li class="t">';
								txtpop += '<a href="#" onclick="' + clicker + ';return false">' + tmps[1] + '</a>';
								txtpop += '</li></ol>';
							} else {
								clicker = 'category.mulity(\''+id+'\', \''+cid+'\', \''+key+'\', \'{val}\', ' + single + ', \''+tmps[0]+'\', 0, true)';
								/*
								+--------------
								+	未选中
								+--------------
								*/
								txtpop += '<ol class="b"><li class="f">';
								txtpop += '<a href="#" onclick="' + clicker + ';return false">' + tmps[1] + '</a>';
								txtpop += '</li></ol>';
							}
						}
					}
					/*
					+---------------------------
					+	补余
					---------------------------
					*/
					if (loopi % 3 > 0){ loops = 3 - loopi % 3;
						for (var li = 0; li < loops; li++){
							txtpop += '<ol class="b"><li></li></ol>';
						}
					} txtpop += '</div>';
				} else {
					if (addid > 0){
						handle = addid; if (addid > 1000){
							handle = Math.round(addid / 100);
						}
					} else if (delid > 0){
						handle = delid; if (delid > 10000){
							handle = delid - 10000; delid = 0;
						} else if (delid > 1000 && delid < 10000) {
							handle = Math.round(delid / 100);
						}
					}
					/*
					+---------------------------
					+	二级
					---------------------------
					*/
					txtpop += '<div class="p2">';
					for (var i = 0; i < config.length; i++){
						var tmps = config[i].split(','), checker = false, classid = 'f'; clicker = handler = ''; if (tmps.length == 3){
							if (tmps[0] == 0){ loopi++;
								/*
								+--------------
								+	状态过滤
								+--------------
								*/
								if ((tmps[1] == addid || WSBase._func.in_array(tmps[1], valed)) && tmps[1] != delid){ checki++;
									checker = true; classid = 't';
									clicker = 'category.mulity(\'' + id + '\', \'' + cid + '\', \'' + key + '\', \'{val}\', false, 0, \'' + tmps[1] + '\', true)';
								} else {
									clicker = 'category.mulity(\'' + id + '\', \'' + cid + '\', \'' + key + '\', \'{val}\', false, \'' + tmps[1] + '\', 0, true)';
								} if (tmps[1] == handle){
									hander = 'category.mulity(\'' + id + '\', \'' + cid + '\', \'' + key + '\', \'{val}\', false, 0, 0, true)';
								} else {
									hander = 'category.mulity(\'' + id + '\', \'' + cid + '\', \'' + key + '\', \'{val}\', false, 0, \'' + (parseInt(tmps[1]) + 10000) + '\', true)';
								}
								/*
								+--------------
								+	附加选项
								+--------------
								*/
								txtpop += '<ol class="' + (tmps[1] == handle ? 'm' : 'b') + '"><li class="' + classid + '">';
								txtpop += '<a href="#" onclick="' + clicker + ';return false">' + tmps[2] + '</a>';
								txtpop += '<i onclick="' + hander + '"></i>';
								txtpop += '</li></ol>';
								/*
								+--------------
								+	下级容器
								+--------------
								*/
								if (tmps[1] == handle){
									br = 1;
								} if (br == 1 && loopi % 3 == 0){ br = 0;
									txtpop += '{sub}';
								}
							} else {
								/*
								+--------------
								+	状态过滤
								+--------------
								*/
								if (tmps[0] != addid && tmps[1] != delid && (tmps[1] == addid || WSBase._func.in_array(tmps[1], valed))){ checki++;
									checker = true; classid = 't';
									clicker = 'category.mulity(\'' + id + '\', \'' + cid + '\', \'' + key + '\', \'{val}\', false, 0, \'' + tmps[1] + '\', true)';
								} else {
									clicker = 'category.mulity(\'' + id + '\', \'' + cid + '\', \'' + key + '\', \'{val}\', false, \'' + tmps[1] + '\', \'' + tmps[0] + '\', true)';
								}
								/*
								+--------------
								+	附加选项
								+--------------
								*/
								if (tmps[0] == handle){
									V_SUB += '<ul><li class="' + classid + '">';
									V_SUB += '<a href="#" onclick="' + clicker + ';return false">' + tmps[2] + '</a>';
									V_SUB += '</li></ul>';
								}
							} if (checker){
								/*
								+--------------
								+	最大值
								+--------------
								*/
								if (addid && this.Init.MULS > 0 && checki > this.Init.MULS){
									alert(this.Init.Lang.maxiumoptions.replace(/!x!/ig, this.Init.MULS));
									return false;
								}
								/*
								+--------------
								+	赋值
								+--------------
								*/
								txtipt += commt + tmps[2]; commt = this.Init.Poper.compact;
								inputs += '<input type="hidden" name="' + key + '[]" value="' + tmps[1] + '" />';
								V_VAL += commv + tmps[1]; commv = ',';
								V_SEL += '<a href="#" title="' + tmps[2] + '" onclick="category.mulity(\'' + id + '\', \'' + cid + '\', \'' + key + '\', \'{val}\', false, 0, \'' + tmps[1] + '\', true);return false">' + tmps[2] + '</a>';
							}
						}
					}
					/*
					+---------------------------
					+	补余
					---------------------------
					*/
					if (loopi % 3 > 0){ loops = 3 - loopi % 3;
						for (var li = 0; li < loops; li++){
							txtpop += '<ol class="b"><li></li></ol>';
						}
					} if (br == 1){
						txtpop += '{sub}';
					} txtpop += '</div>';
					/*
					+---------------------------
					+	定义编译处理范围
					---------------------------
					*/
					P_SUB = true;
				}
				/*
				+-------------------------------
				+	编译表单
				+-------------------------------
				*/
				if (txtipt == ''){ var names = this.Init.NAMES();
					txtipt = names[0];
				} clicks = 'onclick="category.mulity(\'' + id + '\', \'' + cid + '\', \'' + key + '\', \'' + V_VAL + '\', ' + single + ', \'0\', \'0\', true);return false"'; this.Init.Poper.select(obj, txtipt, clicks, inputs);
				/*
				+-------------------------------
				+	弹出窗口选项
				+-------------------------------
				*/
				if (poper){
					if (V_SEL != ''){
						V_SEL = '<div class="s">' + V_SEL + '<div class="clear"></div></div>';
					} txtpop = txtpop.replace(/\{sel\}/g, V_SEL); if (P_SUB){
						if (V_SUB != ''){
							V_SUB = '<div class="s">' + V_SUB + '<div class="clear"></div></div>';
						} txtpop = txtpop.replace(/\{sub\}/g, V_SUB);
					} txtpop = txtpop.replace(/\{val\}/g, V_VAL);
					WSBase._displayer.category(txtpop);
				}
			} else {
				/*
				+-------------------------------
				+	4.x模式
				+-------------------------------
				*/
				this.mulity_base();
			}
		}
	}, 
	mulity_base : function(){},
	/*
	+-------------------------------------------
	+	日历
	+-------------------------------------------
	*/
	calformat : function(y, n, j){
		var finish = 31; if (n == 0){
			/*
			+-----------------------------------
			+	前一年的12月份
			+-----------------------------------
			*/
			y -= 1;
			n = 12;
		} else if (n == 13){
			/*
			+-----------------------------------
			+	后一年的1月份
			+-----------------------------------
			*/
			y += 1;
			n = 1;
		} if (n == 2){ finish = 28;
			/*
			+-----------------------------------
			+	润年过滤
			+-----------------------------------
			*/
			if (y%4 == 0 && y % 100 != 0){
				finish = 29;
			}
		} else if (n == 4 || n == 6 || n == 9 || n == 11){
			/*
			+-----------------------------------
			+	月(小)
			+-----------------------------------
			*/
			finish = 30;
		} if (j > finish){
			/*
			+-----------------------------------
			+	日期最大值过滤
			+-----------------------------------
			*/
			j = finish;
		}  return y + '' + (n < 10 ? ('0' + n) : n) + (j < 10 ? ('0' + j) : j);
	},
	calandar : function(id, key, val, popid){
		var obj = WSBase._func.is_object(id), names = this.Init.NAMES(), txtpop = '', txtipt = '', inputs = '', dateid = begine = y = n = j = 0, finish = 31; if (obj){
			/*
			+-----------------------------------
			+	读取默认日期(年、月、日)
			+-----------------------------------
			*/
			var txtipter = false; if (val.length == 8){ txtipter = true;
				y = val.substr(0, 4); y *= 1;
				n = val.substr(4, 2); n *= 1;
				j = val.substr(6, 2); j *= 1;
				if (y < 1900 || y > 2100 || n < 1 || n > 12 || j < 1 || j > 31){
					y = n = j = 0; val = 0;
				} 
			} if (y == 0 || n == 0 || j == 0){
				y = parseInt(this.Init.UNIX.getFullYear());
				n = parseInt(this.Init.UNIX.getMonth()) + 1;
				j = parseInt(this.Init.UNIX.getDate());
			} if (n == 2){
				finish = 28; if (y % 4 == 0 && y % 100 != 0){
					finish = 29;
				}
			} else if (n == 4 || n == 6 || n == 9 || n == 11){
				finish = 30;
			} if (j > finish){
				j = finish;
			}

			/*
			+-----------------------------------
			+	编译表单
			+-----------------------------------
			*/
			if (txtipter){
				txtipt = y + this.Init.Lang.year + n + this.Init.Lang.month + j + this.Init.Lang.day;
				inputs = '<input type="hidden" name="' + key + '" value="' + this.calformat(y, n, j) + '" />';		
			} else {
				txtipt = names[0];
				inputs = '<input type="hidden" name="' + key + '" value="0" />';
			} this.Init.Poper.select(obj, txtipt, 'onclick="category.calandar(\'' + id + '\', \'' + key + '\', \'' + val + '\', this.id); return false"', inputs);
			/*
			+-----------------------------------
			+	加载日历
			+-----------------------------------
			*/
			if (typeof popid != 'undefined'){

				var sObj = WSBase._func.is_object(popid); if (!sObj){
					return true;
				}

				var timestamp = Date.UTC(y, parseInt(n-1), 1, 0, 0, 0);
				var begine = new Date(timestamp).getDay();
				/*
				+-----------------------------------------------------------
				+	选项
				+-----------------------------------------------------------
				*/
				txtpop += '<div class="h">';
				txtpop += '<dl><a href="#" onclick="category.calandar(\'' + id + '\', \'' + key + '\', \'' + this.calformat(y-1, n, j) + '\', \'' + popid + '\');return false" title="' + (this.calformat(y-1, n, j).substr(0, 4) + this.Init.Lang.year + this.calformat(y-1, n, j).substr(4, 2) + this.Init.Lang.month + this.calformat(y-1, n, j).substr(6, 2) + this.Init.Lang.day) + '">' + this.Init.Lang.week_py + '</a></dl>';
				txtpop += '<dt><a href="#" onclick="category.calandar(\'' + id + '\', \'' + key + '\', \'' + this.calformat(y, n-1, j) + '\', \'' + popid + '\');return false" title="' + (this.calformat(y, n-1, j).substr(0, 4) + this.Init.Lang.year + this.calformat(y, n-1, j).substr(4, 2) + this.Init.Lang.month + this.calformat(y, n-1, j).substr(6, 2) + this.Init.Lang.day) + '">' + this.Init.Lang.week_pm + '</a></dt>';
				txtpop += '<dd>' + y + this.Init.Lang.year + n + this.Init.Lang.month + '</dd>';
				txtpop += '<dt><a href="#" onclick="category.calandar(\'' + id + '\', \'' + key + '\', \'' + this.calformat(y, n+1, j) + '\', \'' + popid + '\');return false" title="' + (this.calformat(y, n+1, j).substr(0, 4) + this.Init.Lang.year + this.calformat(y, n+1, j).substr(4, 2) + this.Init.Lang.month + this.calformat(y, n+1, j).substr(6, 2) + this.Init.Lang.day) + '">' + this.Init.Lang.week_nm + '</a></dt>';
				txtpop += '<dl><a href="#" onclick="category.calandar(\'' + id + '\', \'' + key + '\', \'' + this.calformat(y+1, n, j) + '\', \'' + popid + '\');return false" title="' + (this.calformat(y+1, n, j).substr(0, 4) + this.Init.Lang.year + this.calformat(y+1, n, j).substr(4, 2) + this.Init.Lang.month + this.calformat(y+1, n, j).substr(6, 2) + this.Init.Lang.day) + '">' + this.Init.Lang.week_ny + '</a></dl>';
				txtpop += '<h2><a href="#" onclick="category.calandar(\'' + id + '\', \'' + key + '\', 0, \'' + popid + '\');return false" title="' + this.Init.Lang.do_empty + '"></a></h2>';
				txtpop += '</div>';
				/*
				+-----------------------------------------------------------
				+	星期
				+-----------------------------------------------------------
				*/
				txtpop += '<div class="w"><ol>';
				txtpop += '<li>' + this.Init.Lang.week_n1 + '</li>';
				txtpop += '<li>' + this.Init.Lang.week_n2 + '</li>';
				txtpop += '<li>' + this.Init.Lang.week_n3 + '</li>';
				txtpop += '<li>' + this.Init.Lang.week_n4 + '</li>';
				txtpop += '<li>' + this.Init.Lang.week_n5 + '</li>';
				txtpop += '<li>' + this.Init.Lang.week_n6 + '</li>';
				txtpop += '<li>' + this.Init.Lang.week_n7 + '</li>';
				txtpop += '</ol></div>';
				/*
				+-----------------------------------------------------------
				+	日期
				+-----------------------------------------------------------
				*/
				txtpop += '<div class="c"><ol>'; 
				for (var a = 0; a < begine; a++){
					txtpop += '<li class="s"></li>';
				} for (var b = 1; b <= finish; b++){ var cls = b == j ? 't' : 'f';
					var dateid = y + '' + (n < 10 ? ('0' + n) : n) + '' + (b < 10 ? ('0' + b) : b);
					txtpop += '<li class="' + cls + '"><a href="#" title="'+ (y + this.Init.Lang.year + n + this.Init.Lang.month + b + this.Init.Lang.day) +'" onclick="category.calandar(\'' + id + '\', \'' + key + '\', \'' + dateid + '\');WSBase._displayer.calandoff();return false">' + b + '</a></li>';
				} var totals = 0, total = begine + finish; if (total % 7 > 0){ totals = 7 - total % 7;
					for (c = 0; c < totals; c++){
						txtpop += '<li class="s"></li>';
					}
				} txtpop += '</ol><div class="clear"></div></div>'; WSBase._displayer.calandar(sObj, txtpop);
			}
		}
	}
}
