// JavaScript Document
var xpow = new Object;
xpow.m_cfg = new Array();
xpow.m_cfg["cm"]="";
xpow.m_cfg["m_r"]="m_r";
xpow.m_cfg["m_left"]="m_left";
xpow.m_cfg["dir"]="/admin/manage/";
xpow.m_cfg["app"]=".asp";
xpow.m_cfg["common_dir"]="/common/xpow/";
xpow.m_cfg["l_pre"]="mnu.";
xpow.m_cfg["r_pre"]="manage";
xpow.m_cfg["CHECK_FROM"]="listForm";
xpow.m_cfg["CHECK_INPUT"]="_chk_id";
xpow.m_cfg["menu"]="welcome,about,news,product,info,hr,connect,service";
xpow.m_cfg["ELEMT"]="iframe,table,div,span,a,h4,p,img,textarea,form,textbox";
xpow.m_cfg["client"]="xpow.captchImg"

xpow.URLencode=function (sStr) { return escape(sStr).replace(/\+/g,'%2B').replace(/\"/g,'%22').replace(/\'/g,'%27'); }
xpow.URLdecode=function (psEncodeString) { var lsRegExp = /\+/g; return unescape(String(psEncodeString).replace(lsRegExp,"   "));  }

function trim(value)
{
   var temp = value;
   var obj = /^(\s*)([\W\w]*)(\b\s*$)/;
   if (obj.test(temp)) { temp = temp.replace(obj, '$2'); }
   return temp;
}
 
//window.onerror = new Function("return false;");


//function trim(instr){return  instr.replace(/^[\s　\t]+|[\s　\t]+$/,"");}
function inSpace(instr){ return instr.replace(/ /g,"");}
function doFilter(instr,type){
	var sz = null;
	var pattern = null;
	var er=trim(instr)
	switch(type){
	case 0: //过滤脚本
		sz = er.replace(/<script(.|\n)*\/script>\s*/ig, '');
		sz = sz.replace( /\bon\w+\s*=\s*\"\w+\"/ig, '');
		break;
	case 1:	//只能输入英文和数字_
		pattern=/[^a-z0-9_]/ig;
		if (pattern.test(er))er = er.replace(pattern,'');
		sz=er;
//		sz = er.replace(/[\W]/g,'') 
//		sz = sz.replace(/[^\d]/g,'')
		break;
	case 2: //只能输入中文数字英文
		pattern=/[^\u4e00-\u9fa5\w,\.]/;
		if (pattern.test(er))er = er.replace(pattern,'');
		sz=er;
		break;
	}
	return sz;
}

function isInt(strer)
{
	pattern=/[^0-9]/ig;
	return pattern.test(strer);
}

function SpecChar(obj) { 
	if(event.type=="keyup") {
		if(/[^\u4e00-\u9fa5\w,\.]/.test(obj.value)) {
			obj.value=obj.value.substring(0,obj.value.length-1)
		}
		return false; 
	} 
}


function validPath(str)
{
	var _str = inSpace(str);
	var _part = /^[a-zA-Z0-9_]:(\\[a-zA-Z0-9_\u4e00-\u9fa5\w,\-\[\].]+)+$/i;
	if(!_part.test(_str) || _str==''){
		return false
	}else {
		return true
	}
}

function doCkeckFileSize(elemt,intRe)
{
	icount = 0
	var _fileAry=new Array();
	if (elemt.indexOf(',')>0){_fileAry=elemt.split(',')}
	if (_fileAry.length>0){
		for (i=0;i<_fileAry.length;i++){
			if ($(_fileAry[i]).value != ''){
				if(!validPath($(_fileAry[i]).value)){
					alert($(_fileAry[i]).value+' 不是有效文件!');
					return false;
				}else{
					icount += 1
					if (icount == _fileAry.length){return true}
				}
			}else{
				_tmpF = true;
			}
		}
		if (_tmpF && intRe){alert('请上传您的两副原创作品!');_tmpF=false}
	}else{
		var _fliesize = $(elemt)
		if (_fliesize){
			if(!validPath(_fliesize.value)){
				alert('您没有选择要上传的文件!\n\n或者上传的不是有效文件!');
				return false;
			}else{
				return true;
			}
		}
	}
}


function parseResponseHeader(key, header)
{ 
	var lines = header.split("\n"); 
	var re = new RegExp("^" + key + ":\\s");
	for (var i in lines) { 
		if (re.exec(lines[i])){ 
			var returnValue = trim(RegExp.rightContext); 
			return returnValue; 
		} 
	} 
	return ""; 
}

function put(strer) { document.write(strer); }
function isNull(strer) { return (strer==null) ? true : false; }
function isEmpty(strer) { return (strer==null || strer=="") ? true : false; }
function isObject(strer) { return (typeof(strer)=="object" && strer) ? true : false; }
function toReplace(str1,str2,str3) { return str1.replace(str2,str3); }
function toDisp(str1,str2,str3) { return str1.replace("{$"+str2+"}",str3); }
function toResysbom(strer,syb,tosyb){for (i = 0; i < strer.length;i++){if (strer.charAt(i)==syb)strer = strer.replace(syb,tosyb)};return strer;}


xpow.browser = new Object();
xpow.browser.userAgent	= navigator.userAgent.toLowerCase();
xpow.browser.appVersion	= navigator.appVersion;
xpow.browser.doInit=function()
{
	this.isIE=this.userAgent.indexOf("msie")!=-1;
	this.isIE5=false; this.isGecko=false; this.isNS=false; this.isMozilla=false; this.isFirefox=false; this.isOpera=false;
	if (this.isIE)
	{
		this.MajorVer=this.appVersion.match(/MSIE (.)/)[1];
		this.MinorVer=this.appVersion.match(/MSIE .\.(.)/)[1];
		this.isIE5=(this.MajorVer>5 || this.MinorVer>=5);
		if (this.isIE5) this.type="ie5";
		else this.type="ie";
		this.typeName="ie";
		//this.typeName=/msie/.test(navigator.userAgent.toLowerCase()) ? 'ie' : 'gecko';
	}
	else
	{
		this.isGecko=true;	
		this.type="gecko";
		this.typeName="gecko";
		this.MajorVer=0; this.MinorVer=0;
		this.isNS=this.userAgent.indexOf("netscape")!=-1;
		if(this.isNS) this.type="ns";
		this.isMozilla=(typeof document.implementation != 'undefined') && (typeof document.implementation.createDocument != 'undefined') && (typeof HTMLDocument!='undefined');
		this.isFirefox=(navigator.userAgent.toLowerCase().indexOf("firefox")!=-1);
		this.isOpera=(navigator.userAgent.toLowerCase().indexOf("opera")!=-1);
	}
}
xpow.browser.doInit();


xpow.browser.getObject=function(strname) { return this.getElementById(strname); }
xpow.browser.getElementById=function(strname)
{
	if (this.isIE5 || this.isMozilla || this.isFirefox) return document.getElementById(strname);
	if (this.isIE) return document.all(strname);
	if (this.isNS) return document.layers[strname];
}
xpow.browser.getElementsByName=function(strname)
{
	if (this.isIE5 || this.isMozilla || this.isFirefox) return document.getElementsByName(strname);
	if (this.isIE) return document.all(strname);
	if (this.isNS) return document.layers[strname];
}

xpow.browser.toAgent=function(strer,strHtml)
{
	var re,tmpstr,tmp1,tmp2;
	var tmpAry=strer.split(";");
	if (tmpAry.length<3) { re="未知的系统信息"; }
	else
	{
		tmpstr=tmpAry[2];
		tmp1=tmpstr.length-1;
		tmp2=tmpstr.substr(tmp1,1);
		if (tmp2==")") { tmpstr=tmpstr.substr(1,tmp1-1); }
		re="操作系统: "+tmpstr;
		re+=", 浏览器: "+tmpAry[1];
		re=re.replace("MSIE","Internet Explorer");
		re=re.replace("NT 5.0","2000");
		re=re.replace("NT 5.1","XP");
		re=re.replace("NT 5.2","2003");
	}
	if (strHtml!=null && strHtml!="") re=xpow.common.toDisp(strHtml,"agent",re);
	return re;
}


function $(strname) { return xpow.browser.getElementById(strname); }

xpow.browser.doRefresh=function() { return window.document.location.reload(); }
xpow.browser.goBack=function() { return history.back(); }
xpow.browser.getDomain=function() { return window.document.domain; }
xpow.browser.getURLs=function() { return window.document.URL; }
xpow.browser.getTitle=function() { return window.document.title; }
xpow.browser.getReferer=function() { return window.document.referrer; }
xpow.browser.getXMLHttpObject=function()
{
	if (this.xmlHttp==null)
	{
		if (window.ActiveXObject)						// IE
		{
			var tmpAry=new Array("Microsoft.XMLHTTP","Msxml2.XMLHTTP","Msxml.XMLHTTP");
			for (var i=0;i<tmpAry.length;i++) { try { this.xmlHttp=new ActiveXObject(tmpAry[i]); } catch(e) { this.xmlHttp=null; } if (this.xmlHttp!=null) break; }
		}
		else if(window.XMLHttpRequest) { this.xmlHttp=new XMLHttpRequest(); }	// Firefox, Opera, Safari, ...
	}
	return this.xmlHttp;
}

//function forbidRightMouse(evt)
//{
//	evt = evt || window.event;
//	if(evt.returnValue) evt.returnValue = false;//IE的事件模型
////	else evt.preventDefault();//dom2的事件模型，主要针对firefox/sofari
//}   
//document.onselectstart = forbidRightMouse;//防止用户选取文本
//document.oncontextmenu = forbidRightMouse;//防止用户使用右键

xpow.window=new Object();
xpow.window._QueuesOnLoad=new Array();
xpow.window.addOnLoad=function(strer) { this._QueuesOnLoad[this._QueuesOnLoad.length]=strer;}
xpow.window.doOnLoad=function(){ for (var i=0;i<this._QueuesOnLoad.length;i++){ eval(this._QueuesOnLoad[i]); }}
xpow.window.getClipBoardData=function(strType){ if (window.clipboardData){ if (isEmpty(strType)) strType='text'; return window.clipboardData.getData(strType); }}
xpow.window.setClipBoardData=function(strer) { if (window.clipboardData) window.clipboardData.setData(strer); }
xpow.window.doClipBoardClear=function() { if (window.clipboardData) window.clipboardData.clearData(); }
window.onload=function() { xpow.window.doOnLoad(); }

//########################################
//########################################
xpow.Cookie = {
	setCookie : function(name, value, hours){
		var expire = '';
		if(hours != null)
		{
			expire = new Date((new Date()).getTime() + hours * 3600000);
			expire = '; expires=' + expire.toGMTString();
		}
		document.cookie = name + '=' + escape(value) + expire;
	},
	getCookie : function(name){
		var cookieValue = '';
		var search = name + '=';
		if(document.cookie.length > 0){ 
			offset = document.cookie.indexOf(search);
			if (offset != -1){ 
				offset += search.length;
				end = document.cookie.indexOf(';', offset);
				if (end == -1) end = document.cookie.length;
				cookieValue = unescape(document.cookie.substring(offset, end))
			}
		}
		return cookieValue;
	}
}

xpow.doParseErr=function(errs)
{
	var _errs=errs;
	var _Ary=new Array();
	var _errMsg="";
	if (_errs.indexOf('$$$')>0){
		_Ary=_errs.split('$$$')
		_errMsg=_Ary[0]
	}else{
		_errMsg=_errs	
	}
	alert(_errMsg)
}

//======== menu parse ============//
xpow.doParseMenu=function(mnupage,mnurank)
{
	var mnuAry=this.m_cfg["menu"].split(",");
	var m_r=document.getElementById(this.m_cfg["m_r"]);
	var m_l=document.getElementById(this.m_cfg["m_left"]);
	var m_css=document.getElementById(mnupage);
	var _app="?module="+mnupage;
	for(var ii=0;ii<mnuAry.length;ii++){document.getElementById(mnuAry[ii]).className=''}
	if (mnurank==''){
		alert('当前Session为空，请刷新本页！')
	}else{
		if (mnupage=='welcome'){
			m_l.src=this.m_cfg["dir"]+this.m_cfg["l_pre"]+mnupage+this.m_cfg["app"];
			m_r.src=this.m_cfg["dir"]+mnupage+".in"+this.m_cfg["app"]+_app;
		}else{
			m_l.src=this.m_cfg["dir"]+this.m_cfg["l_pre"]+mnupage+this.m_cfg["app"];
			m_r.src=this.m_cfg["dir"]+this.m_cfg["r_pre"]+mnupage+this.m_cfg["app"]+_app;
		}
		m_css.className="abc";
	}
}

xpow.goMenu=function(mnupage,mnurank)
{
	var m_r=document.getElementById(this.m_cfg["m_r"])
	var _app="&module="+mnupage;
	var _apps="?module="+mnupage;
	if (mnurank==''){
		alert('当前Session为空，请刷新本页！')
	}else{
		if (mnupage=='welcome'){
			m_r.src=this.m_cfg["dir"]+mnupage+".in"+this.m_cfg["app"]
		}else{
			if (mnupage.indexOf('?')>0){ var _pageAry=mnupage.split('?')
				m_r.src=this.m_cfg["dir"]+this.m_cfg["r_pre"]+_pageAry[0]+this.m_cfg["app"]+'?'+_pageAry[1]+'&module='+_pageAry[0]
			}else{
				m_r.src=this.m_cfg["dir"]+this.m_cfg["r_pre"]+mnupage+this.m_cfg["app"]+_apps
			}
		}
	}
}

xpow.doSelectAll=function(theform)
{
	var _objForm=theform;
	var _nvalue=_objForm._chk_all.checked;
	var _ncheckbox;
	for(var i=0;i<_objForm.elements.length;i++)
	{
		var _ncheckbox=_objForm.elements[i];
		if(_ncheckbox.name==this.m_cfg["CHECK_INPUT"]) { _ncheckbox.checked=_nvalue; }
	}
}

xpow.goUrl=function(theurl){if(theurl!=''){location.href=theurl}}
xpow.dirUrl=function(theurl){if(theurl!=''){document.getElementById(this.m_cfg["m_r"]).src=theurl}}

xpow.doSelectHandle=function(theform)
{
	var _objform=theform;
	var _ncheckbox='';
	var _objHandle=_objform.opHandle;
	var isChecked=false;
	for(var i=0;i<_objform.elements.length;i++)
	{
		var _ncheckbox=_objform.elements[i];
		if(_ncheckbox.name==this.m_cfg["CHECK_INPUT"]&& _ncheckbox.checked) {isChecked=true; break;}
	}
	if (_objHandle){
		var __handle=_objHandle.value
		if (__handle!=''){
			if (confirm('您确定要执行此操作吗？此操作可能无法恢复！')){
				if (!isChecked){
					alert('没有选择任何记录！\n\n请选择要操作的记录！')
				}else{
					var _HandleUrl='';
					if (__handle.indexOf('?')>0){ var _pageAry=__handle.split('?')
						_HandleUrl=this.m_cfg["dir"]+this.m_cfg["r_pre"]+_pageAry[0]+this.m_cfg["app"]+'?'+_pageAry[1]
					}else{
						_HandleUrl=this.m_cfg["dir"]+this.m_cfg["r_pre"]+__handle+this.m_cfg["app"]
					}
					_objform.action=_HandleUrl;
					_objform.submit();
				}
			}
		}
	}
}


xpow.createHtmlPage = function(theform,type)
{
	var msg = (type==1)?'请选择要生成静态列表的项!':'请选择要生成静态页的项!'
	var __handle = (type==1)? $('listurl').value :$('pageurl').value;
	var isChecked = 0
	var _IDary = document.getElementsByName('_chk_id');
	for(var i=0;i<_IDary.length;i++){if (_IDary[i].checked){isChecked=true; break;}}
	if (!isChecked){
		alert(msg)
	}else{
		if (__handle.indexOf('?')>0){ var _pageAry=__handle.split('?')
			var _HandleUrl=this.m_cfg['dir']+this.m_cfg['r_pre']+_pageAry[0]+this.m_cfg['app']+'?'+_pageAry[1]
		}else{
			var _HandleUrl=this.m_cfg['dir']+this.m_cfg['r_pre']+__handle+this.m_cfg['app']
		}
		theform.action=_HandleUrl;
		theform.submit();
	}
}


xpow.doCheckNull=function(inFiled,inMsg,theForm)
{
	_objform=theForm;
	var isNull=false;
	var _br='\n';
	var _reMsg='';
	var _fArray = inFiled.split(",");
	var _mArray = inMsg.split(",");
	var tmpTree = new parent.XPOWS.shellTree();
	for(var i=0;i<_objform.elements.length;i++){
		var _nElemt=_objform.elements[i];
		tmpTree.addItem(_nElemt.name,_nElemt.value)
	}
	
	for(i=0;i<_fArray.length;i++){
		if (inSpace(tmpTree.getItem(_fArray[i])) == ''){
			if (_mArray[i]!=''){
				_reMsg+=_br+_mArray[i]+' 不能为空！\n';
				isNull=true;
			}
		}
	}
	if (isNull){alert(_reMsg);return false;}else{return true}
}

xpow.doHandleSucc=function(sucMsg)
{
	var _sucAry=sucMsg.split('$$$');
	var m_r=document.getElementById(this.m_cfg['m_r']);
	var _app='?module='+_sucAry[1];
	alert(_sucAry[0]);
	//m_r.src=this.m_cfg["dir"]+this.m_cfg["r_pre"]+_sucAry[1]+this.m_cfg["app"]+_app;
	this.goMenu(_sucAry[1],1)
}


//================= parse class ==================//
xpow.dolistSubClass=function(dataId,subid,msg,title)
{
	var dataAry=dataId.split(',');
	var unitAry=subid.split('|');
	var mainIdAry=unitAry[0].split(',');
	var subIdAry=unitAry[1].split(',');
	var subClsIds='';
	if (msg==''){
		msg="<font color=\"red\">没有查询到子分类......！<\/font><button onclick=document.getElementById('sub"+dataAry[1]+"').style.display='none';>确定<\/button>";
	}else{
		var subsImg="<img style=\"cursor:hand\;\" src=\"\/images\/status\/arrow_a.gif\">  ";
		var subImg="<img style=\"cursor:hand\;\" src=\"\/images\/status\/arrow_a.gif\">  ";
		for (i=0;i<msg.length;i++){
			if (msg.charAt(i)=="*"){ msg=msg.replace(msg.charAt(i),subsImg) }
			if (msg.charAt(i)=="`"){ msg=msg.replace(msg.charAt(i),subImg) }
		}
		var _msgAry=msg.split(",");
		var titImg="<img style=\"cursor:hand\;\" src=\"\/css\/admin\/sysclass\/i_ar01.gif\" >  ";
		msg="";
		for (i=1;i<_msgAry.length;i++){
			msg+="<div id=\""+mainIdAry[i]+"\" style=\"padding-left:10px\"> <img style=\"cursor:hand\;\" src=\"\/images\/status\/i_ar01.gif\" onclick=\"return xpow.showSubClass("+mainIdAry[i]+")\">"  +_msgAry[i]+"<\/div><div id=\"ff\">";
		}
	}
	document.getElementById('sub'+dataAry[1]).style.display='';
	document.getElementById('subClassList'+dataAry[1]).style.display='';
	document.getElementById("scsTitle").innerHTML=title;
	document.getElementById('subClassList'+dataAry[1]).innerHTML=msg;
	document.getElementById('showlistlink'+dataAry[1]).style.display='';
}

xpow.show2hide=function(tag)
{
	if ($(tag).style.display==''){
		$(tag).style.display='none';
	}else{
		$(tag).style.display='';
	}
}

xpow.show2hidevs=function(tag,elemt,vimg)
{
	var img = vimg;
	var spt = img.lastIndexOf('.');
	var start = img.substr(0, parseInt(spt));
	var end = img.substr(parseInt(spt), img.length - parseInt(spt));
	if ($(tag).style.display ==''){
		$(tag).style.display = 'none';
		$(elemt).src = img;
	}else{
		$(tag).style.display = '';
		$(elemt).src = start +'-'+ end;
	}
}

xpow.show2hides=function(tag,elemt)
{
	if ($(tag).style.display == '' && $(elemt).value == ''){
		$(tag).style.display = 'none';
	}else{
		$(tag).style.display = '';
	}
}


xpow.doConfirm=function(action)
{
	var _url=action;
	if(!confirm('确实要执行此操作吗?\n\n此操作可能无法恢复！')){return false;} else{location.href=_url}
}

redirect=function(toUrl) 
{
	var _url=toUrl;
	
	if (_url!=''){
		switch (_url){
			case "back":
				history.back();
				break;
			default:
				location.href=_url;
				break;
		}
	} 
}

xpow.paging=new Object();

xpow.paging.doGO=function(strtxt,strnum,strpage)
{
	if (isEmpty(strtxt)) strtxt="paging_url";
	if (isEmpty(strnum)) strnum="paging_num";
	if (isEmpty(strpage)) strpage="{$page}";
	var tmpurl=xpow.form.getValue(strtxt);
	var tmppage=xpow.form.getValue(strnum);
	tmpurl=toReplace(tmpurl,strpage,tmppage);
	try{document.location.href=tmpurl}catch(e){eval(tmpurl)}
}

xpow.paging.getQuickLinks=function(strURL,strCounter,strPageNum,strTpl)
{
	var re="";
	if (!xpow.common.isNumber(strPageNum)) strPageNum=10;
	var tmpPageTotal=strCounter/strPageNum;
	tmpPageTotal=Math.round(tmpPageTotal);
	if ((tmpPageTotal*strPageNum)<strCounter) tmpPageTotal++;
	var tmpURL;
	if (isEmpty(strTpl))
	{
		if (tmpPageTotal>1)
		{
			re='<img class="icon" src='+xpow.config.getURL('skin')+'images/common/ico_paging_quick.gif" title="快速分页">'
			for (var i=2;i<4;i++)
			{
				if (i>tmpPageTotal) break;
				tmpURL=xpow.common.toDisp(strURL,"page",i);
				re+=' <a href='+tmpURL+' alt="第 '+i+' 页">'+i+'</a>';
			}
			if (tmpPageTotal>3)
			{
				if (tmpPageTotal>4) re+=' ..';
				i=tmpPageTotal;
				tmpURL=xpow.common.toDisp(strURL,'page',i);
				re+=' <a href='+tmpURL+' alt="第 '+i+' 页">'+i+'</a>';
			}
		}
	}
	else
	{
		tmpURL=xpow.common.toDisp(strURL,"page",tmpPageTotal);
		re=xpow.common.toDisp(strTpl,"url",tmpURL);
	}
	return re;
}
xpow.form=new Object();
xpow.form.getValue=function(strName)
{
	var re="";
	var tmpElement=this.getElement(strName);
	if (isObject(tmpElement))
	{
		if (tmpElement.length)
		{
			var tmpType='';
			for(var i=0;i<tmpElement.length;i++)
			{
				if (isEmpty(tmpType)) tmpType=tmpElement[i].type;
				switch (tmpType)
				{
					case 'radio':
						if (tmpElement[i].checked) re=tmpElement[i].value;
						break;
					case 'checkbox':
						if (tmpElement[i].checked) re+=','+tmpElement[i].value;
						break;
				}
			}
			if (tmpType=='checkbox' && !isEmpty(re)) re=re.substring(2);
		}
		else { re=tmpElement.value; }
	}
	return re;
}

xpow.form.setValue=function(strName,strValue,strMode)
{
	var tmpElement=this.getElement(strName);
	if (isObject(tmpElement)){
		if (isEmpty(strValue)) strValue='';
		if (tmpElement.length){
			var tmpType='';
			for(var i=0;i<tmpElement.length;i++){
				if (isEmpty(tmpType)){tmpType=tmpElement[i].type;}
				switch (tmpType){
					case 'radio':
						if (strValue.inPart(tmpElement[i].value)>0 || strMode==('__no'+(i+1))) tmpElement[i].checked=true;
						break;
					case 'checkbox':
						if (strValue.inPart(tmpElement[i].value)>0 || strMode=='__all__') tmpElement[i].checked=true;
						break;
				}
			}
		}
		else{
			if (strMode=="append") tmpElement.value+=strValue;
			else tmpElement.value=strValue;
		}
	}
}

xpow.form.getElement=function(strName)
{
	var reElement=null;
	try{
		if (!isEmpty(strName)){
			var tmpTarget="";
			if (strName.indexOf(":")!=-1) { tmpTarget=strName.substring(0,strName.indexOf(":")); strName=strName.substring(strName.indexOf(":")+1); }
			var tmpForm;
			if (tmpTarget=="parent"){
				if (strName.indexOf(".")==-1) { reElement=window.parent.document.getElementById(strName); }
				else { if (isObject(tmpForm=window.parent.document.forms[strName.substring(0,strName.indexOf("."))])) reElement=tmpForm.elements[strName.substring(strName.indexOf(".")+1)]; }
			}
			else if (tmpTarget!="") { }
			else{
				if (strName.indexOf(".")==-1) { reElement=document.getElementById(strName); }
				else { if (isObject(tmpForm=document.forms[strName.substring(0,strName.indexOf("."))])) reElement=tmpForm.elements[strName.substring(strName.indexOf(".")+1)]; }
			}
		}
	}
	catch(e) { dbg.obj(e); }
	return reElement;
}

xpow.form.getObject=function(strName,strType)
{
	var reObject=null;
	switch (strType){
		case "parent":
			var tmpObject=this.getElement(strName);
			if (isObject(tmpObject)){reObject=xpow.browser.isIE ? tmpObject.parentElement : tmpObject.parentNode;}
			break;
	}
	return reObject;
}

xpow.doActionsFilterField=function(strForm,strFiledName,strSelectDefault)
{
	if (!isObject(strForm)){
		if (!isEmpty(strForm)) strForm=this.form.getObject(strForm,"parent");
		if (!isObject(strForm)) return false;
	}
	var _objForm=strForm;
	var _objSelect=eval("_objForm._actions_filter_"+strFiledName);
	if (!_objSelect) return false;
	var tmpValue="",s;
	if (isEmpty(strSelectDefault)){
		tmpValue=_objSelect.options[_objSelect.selectedIndex].value;
	}else{
		var tmpTrue=false;
		for(s=0;s<_objSelect.options.length;s++){
			if (_objSelect.options[s].value==strSelectDefault){
				_objSelect.options[s].selected=true;
				tmpTrue=true;
				break;
			}
		}
		if (tmpTrue) tmpValue=strSelectDefault;
	}
	if (tmpValue){
		var _AryFields=new Array();
		for(s=0;s<_objSelect.options.length;s++) { _AryFields[s]=_objSelect.options[s].value; }
		var _ncheckbox,_id,a;
		var _objSpan,_objSpanDefault,_objSpanSelect;
		for(var i=0;i<_objForm.elements.length;i++){
			var _ncheckbox=_objForm.elements[i];
			if(_ncheckbox.name=="_chk_id"){
				_id=_ncheckbox.value;
				_objSpan=$("row_"+_id+"_"+strFiledName);
				_objSpanDefault=$("row_"+_id+"_"+strFiledName+"__default");
				if (_objSpan && _objSpanDefault){
					if (tmpValue=="_default"){
						if (_objSpanDefault.innerHTML) _objSpan.innerHTML=_objSpanDefault.innerHTML;
					}else{
						if (!_objSpanDefault.innerHTML) _objSpanDefault.innerHTML=_objSpan.innerHTML;
						_objSpanSelect=$("row_"+_id+"_"+tmpValue);
						if (_objSpanSelect) _objSpan.innerHTML=_objSpanSelect.innerHTML;
					}
				}
			}
		}
	}
}

xpow.CreateElemt = function(objElemt,objPorperty)
{
	var vAry = xpow.m_cfg["ELEMT"].split(',');
	for (i = 0; i < vAry.length; i ++){
		if (objElemt == vAry[i]){
			var ELEMT = document.createElement(objElemt);
			this.m_cfg["cm"] = vAry[i] + '\n' + objPorperty;
			this.setProperty(ELEMT,objPorperty)
			break;
		}
	}
}

xpow.getProperty = function(){ return this.m_cfg["cm"] }
xpow.setProperty = function(theElemt,objPorperty)
{
	var proAry = new Array();
	var Propertys = new Array();
	proAry = objPorperty.split(',');
	for(i=0;i<proAry.length;i++){
		if (proAry[i].indexOf('name=')>=0){
			Propertys['name']=this.getProtParame(proAry[i],'name')
			theElemt.setAttribute('name',Propertys['name']);
		}else if(proAry[i].indexOf('id=')>=0){
			Propertys['id']=this.getProtParame(proAry[i],'id')
			theElemt.id=Propertys['id'];
		}else if(proAry[i].indexOf('display=')>=0){
			Propertys['display'] = this.getProtParame(proAry[i],'display')
		}else if(proAry[i].indexOf('width=')>=0){
			Propertys['width']= this.getProtParame(proAry[i],'width')
			if (Propertys['width']=="document.body.scrollWidth"){ Propertys['width']=document.body.scrollWidth + "px"};
			theElemt.style.width = Propertys['width'];
		}else if(proAry[i].indexOf('height=')>=0){
			Propertys['height'] = this.getProtParame(proAry[i],'height')
			if (Propertys['height']=="document.body.scrollHeight"){ Propertys['height']=document.body.scrollHeight + "px"};
			theElemt.style.height = Propertys['height'];
		}else if(proAry[i].indexOf('position=')>=0){
			Propertys['position']= this.getProtParame(proAry[i],'position')
			theElemt.style.position = Propertys['position'];
		}else if(proAry[i].indexOf('zIndex=')>=0){
			Propertys['zIndex']= this.getProtParame(proAry[i],'zIndex')
			theElemt.style.zIndex = Propertys['zIndex'];
		}else if(proAry[i].indexOf('border=')>=0){
			Propertys['border']= this.getProtParame(proAry[i],'border')
			theElemt.style.border = Propertys['border'];
		}else if(proAry[i].indexOf('padding=')>=0){
			Propertys['padding']= this.getProtParame(proAry[i],'padding')
			theElemt.style.padding =  Propertys['padding'];
		}else if(proAry[i].indexOf('top=')>=0){
			Propertys['top']= this.getProtParame(proAry[i],'top')
			if (Propertys['top']=='center'){Propertys['top']=(parseInt(document.body.scrollHeight) - Propertys['height']) / 2 + "px"; };
			theElemt.style.top = Propertys['top'];
		}else if(proAry[i].indexOf('left=')>=0){
			Propertys['left']= this.getProtParame(proAry[i],'left')
			if (Propertys['left']=='center'){Propertys['left']=(parseInt(document.body.scrollWidth) - Propertys['width']) / 2 + "px";}
			theElemt.style.left = Propertys['left'];
		}else if(proAry[i].indexOf('background=')>=0){
			Propertys['background']= this.getProtParame(proAry[i],'background')
			theElemt.style.background = Propertys['background'].toString();
		}else if(proAry[i].indexOf('filter=')>=0){
			Propertys['filter']= this.getProtParame(proAry[i],'filter')
			theElemt.style.filter = Propertys['filter'];
		}else if(proAry[i].indexOf('opacity=')>=0){
			Propertys['opacity']= this.getProtParame(proAry[i],'opacity')
			theElemt.style.background = Propertys['opacity'];
		}else if(proAry[i].indexOf('align=')>=0){
			Propertys['align']= this.getProtParame(proAry[i],'align')
			theElemt.style.background = Propertys['align'];
		}else if(proAry[i].indexOf('textAlign=')>=0){
			Propertys['textAlign']= this.getProtParame(proAry[i],'textAlign')
			theElemt.style.textAlign = Propertys['textAlign'];
		}else if(proAry[i].indexOf('lineHeight=')>=0){
			Propertys['lineHeight']= this.getProtParame(proAry[i],'lineHeight')
			theElemt.style.lineHeight = Propertys['lineHeight'];
		}else if(proAry[i].indexOf('align=')>=0){
			Propertys['align'] = this.getProtParame(proAry[i],'align')
			theElemt.setAttribute("align",Propertys['align']);
		}else if(proAry[i].indexOf('src=')>=0){
			Propertys['src'] = this.getProtParame(proAry[i],'src')
			theElemt.setAttribute("src",Propertys['src']);
		}else if(proAry[i].indexOf('frameBorder=')>=0){
			Propertys['frameBorder'] = this.getProtParame(proAry[i],'frameBorder')
			theElemt.setAttribute("frameBorder",Propertys['frameBorder']);
		}else if(proAry[i].indexOf('scrolling=')>=0){
			Propertys['scrolling'] = this.getProtParame(proAry[i],'scrolling')
			theElemt.setAttribute("scrolling",Propertys['scrolling']);
		}else if(proAry[i].indexOf('value=')>=0){
			Propertys['value'] = this.getProtParame(proAry[i],'value')
			theElemt.value=Propertys['value'];
		}
	}
	theElemt.style.display = ''
	if (Propertys['display']=="none")theElemt.style.display = 'none';
	document.body.appendChild(theElemt);
//	removeAttribute("href")
}

xpow.getProtParame=function (inParame,pars)
{
	var _index = parseInt(inParame.indexOf(pars)+pars.length+1);
	var _last = inParame.length-_index;
	var _parame = inParame.substr(parseInt(_index),parseInt(_last));
	return _parame;
}

xpow.removeElemts=function(type,intRe)
{
	var isMoved=false;
	var iElements = document.getElementsByTagName(type);
	for (i=0; i<iElements.length; i++) {
		var iElement = iElements[i];
		if (intRe){
			var msg = "Found an "+type+" element!";
			var atts = iElement.attributes;
			for (j=0; j<atts.length; j++) {
				var att = atts.item(j);
				msg = msg + "\n  " + att.nodeName + ": '" + att.nodeValue + "'";
			}
			alert(msg)
		}
		document.body.removeChild(iElement);
		isMoved=true;
	}
	if (isMoved && intRe) alert('remove '+i+' elements \"'+type+'\"')
}

xpow.removeElemt=function(eid,intRe)
{
	var isMoved=false;
	var iElement = document.getElementById(eid);
	try{
		if (iElement){ document.body.removeChild(iElement);isMoved=true; }
	}catch(e){
		//alert(iElement.parent)
	}
	if (isMoved && intRe==1){
		var msg = "Found an "+eid+" element!";
		var atts = iElement.attributes;
		for (j=0; j<atts.length; j++) {
			var att = atts.item(j);
			msg = msg + "\n  " + att.nodeName + ": '" + att.nodeValue + "'";
		}
		alert(msg);
	}
	if (isMoved && intRe==2) alert('remove '+eid+' element succesed!"')
}

xpow.setFromTarget=function (theform,action,targetName,theEnctype)
{
	theform.method = "post";
	theform.action = action;
	if (targetName!=''){theform.target = targetName;}
	if (theEnctype!=''){theform.encoding = theEnctype;}
	theform.submit();
}

xpow.editor = new Object()
xpow.editor.getEditor = function(eName,edH,edW,type)
{
	var _prop;
	var _e = xpow.m_cfg["ELEMT"].split(',');
	var src = (type == 0) ? '/common/Editor/HtmlEditor/doEdit.main.html?ID='+eName : '/common/xEditor/index/index.html?w='+edW+'&h='+edH;
	_prop = "id=Editor,name=Editor,src="+src+",frameBorder=0,scrolling=no,height="+edH+",width="+edW
	xpow.CreateElemt(_e[0],_prop);
	if ($("editors")){$("editors").appendChild($("Editor"));}
}

xpow.upload = function(){}
xpow.upload.prototype.doInit = function()
{
	this.VERSION = '1.2.0'
	this.objName = 'xUploader';
	this._dir = '/common/xpow/';
	this._path = 'xpow.upLoad.asp';
	this._form = 'upform';
	this._vElemt = 'velemt';
	this._vsElemt = 'vselemt';
	this._upPath = '';
	this._showElemt = 'showelemt';
	this.img_h = 'img_h';
	this.img_w = 'img_w';
	this._parent = 'edtParent';
	this._frameid = 'uploaderframe';
	this._framename = 'uploaderframe';
	this._isResize = 0;
	this._resizeMode = 0;
	this._maxsize = 0;
	this._re_maxw = 0;
	this._re_maxh = 0;
	this.width = 350;
	this.bodyWidth = 540;
	this.height = 22;
	this._cursorPos_start = 0;
	this._cursorPos_end = 0;
	this._editorObjname = '';
	this.isRecycle = 0;
	this.windowFrame = 'Editor';
	this.enterAction = 0;
	this.enterActionString = '';

}

xpow.upload.prototype.getUploader = function()
{
	var _prop;
	var _e = xpow.m_cfg["ELEMT"].split(',');
	_prop = "id="+this._frameid+",name="+this._framename+",frameBorder=0,scrolling=no,width="+this.width+",height="+this.height
	xpow.CreateElemt(_e[0],_prop);
	_prop = this._dir+this._path+'?filesize='+this._maxsize+'&vselemt='+this._vsElemt;
	_prop += '&velemt='+this._vElemt+'&filepath='+this._upPath+'&isresize='+this._isResize+'&maxh='+this._re_maxh;
	_prop += '&maxw='+this._re_maxw+'&showpic='+this._showElemt+'&remode='+this._resizeMode+'&formname='+this._form;
	_prop += '&v_reimg_h='+this.img_h+'&v_reimg_w='+this.img_w
	if ($(this._frameid)){$(this._frameid).src=_prop}
}

xpow.upload.prototype.Body = function()
{
	var reHt = "";
	reHt += "<table bgcolor=\"#F1F1F1\" width=\""+this.bodyWidth+"\" height=\"240\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\">"
	reHt += "<form id="+this._form+"><tr valign=\"top\"><td style=\"padding-left:10px\"><input type=hidden id="+this.img_h+"><input type=hidden id="+this.img_w+"><input type=hidden id="+this._vElemt+"><input type=hidden id="+this._vsElemt+">"
	reHt += "<div style=\"height:30px; padding-top:10px; font-weight:bold; color:#666666\">选择图片进行上传</div>"
	reHt += "<div style=\"width:312px; height:200px; background-color:#FFFFFF;color:#666666; padding:10px\">"
	reHt += "<div id="+this._parent+"></div>"
	reHt += "<div style=\"padding-top:10px; line-height:16px\">上传须知：图片 ≤ 300 K，JPG 或 GIF文件格式，RGB 色，72dpi / 英寸</div>"
	reHt += "<div style=\"color:#FF0000; line-height:16px\">*如果上传后无法看到预览图，请检查是否上传了 CMYK 色的图片，如果是请调整为 RGB 色重新上传</div>"
	reHt += "<div style=\"padding-top:10px; color:#666666\"><span style=\"width:160px\" id=file_size><B>图片大小：</B></span><span id=file_width><B>图片宽度：</B></span></div>"
	reHt += "<div style=\"padding-top:5px; color:#666666\"><span style=\"width:160px;\" id=file_ext><B>文件格式：</B></span><span id=file_height><B>图片高度：</B></span></div>"
	reHt += "<div style=\"padding-top:10px\"><img src=\"/images/common/okBtns.gif\" onclick=\"window.frames['"+this.windowFrame+"']."+this._editorObjname+"."+this.objName+".doSetAction()\" style=\"cursor:pointer\">&nbsp;&nbsp;&nbsp;&nbsp;<img src=\"/images/common/cancelBtns.gif\" style=\"cursor:pointer\" onclick=\"xpow.upload.doDel('"+this._vElemt+"','"+this._vsElemt+"')\"></div>"
	reHt += "</div></td><td width=\"10\">&nbsp;</td><td width=\"200\" style=\"padding-right:10px\">"
	reHt += "<div style=\"height:30px; padding-top:10px; font-weight:bold; color:#666666\">上传成功后预览图</div>"
	reHt += "<div style=\"width:200px; height:200px; background-color:#FFFFFF; padding:10px\" id=\"showpic\"></div>"
	reHt += "</td></tr></form></table>";
	return reHt;
}

xpow.upload.prototype.GetCursorPsn = function(txb) 
{ 
    var slct = document.selection;
    var rng = slct.createRange();
    txb.select();
    rng.setEndPoint("StartToStart", slct.createRange());
    var psn = rng.text.length;
    rng.collapse(false);
    rng.select();
    return psn;
}

xpow.upload.prototype.setUploader = function(){this.getUploader(); if ($(this._parent)){$(this._parent).appendChild($(this._frameid));}}
xpow.upload.doDel = function(vel,vsel)
{
	var imgpth=$(vel).value+'$$$'+$(vsel).value;
	if ($(vel).value != '' || $(vsel).value != ''){
		if (confirm('您确实要取消吗？\n\n取消将删除此次上传的图片')){
			window.frames['edtfrm'].doDeleteImg(imgpth,0);
			setTimeout("xpow.point.clear('alert')",500);
		}
	}else{
		xpow.point.clear('alert');
	}
}

xpow.upload.prototype.doSetAction = function()
{
	var eobj = this._editorObjname;
	var obj = this.objName;
	eval('window.frames["'+this.windowFrame+'"].'+eobj+'.'+obj+'.getContent()')
}

xpow.upload.prototype.test = function(inRe)
{
	var tbr = '\n'
	var str = this.objName + ' is here!' + tbr;
	str += 'version : ' + this.VERSION + tbr;
	str += 'frameid : ' + this._frameid + tbr;
	str += 'width : ' + this.width + tbr;
	str += 'height : ' + this.height + tbr;
	str += 'editorObjname : ' + this._editorObjname + ' # ' + $(this._editorObjname)+ ' # ' + tbr;
	str += 'parent : ' + this._parent + ' # ' + $(this._parent)+ ' #';
	if (inRe){alert(str)}
	return true;
}

xpow.upload.prototype.getContent = function()
{
	var imgurl = $(this._vElemt).value
	var imgsurl = $(this._vsElemt).value
	if (!this.enterAction){
		var w_e_h = window.frames[this.windowFrame].window.frames['HtmlEditor'];
		var w_e = window.frames[this.windowFrame];
		var tbr = '<br><br>';
		try{
			w_e_h.document.body.innerHTML += tbr+'<img width='+$(this.img_w).value+' height='+this.img_h.value+' src=\"'+this._vElemt.value+'\">';
		}catch (e){
			w_e.eval(this._editorObjname).insertImage(imgurl,$(this.img_w).value,$(this.img_h).value,0,'',0,0,10)
		}
	}else{
		var w_e = window.frames[this.windowFrame];
		w_e.eval(this.enterActionString)
	}
	
	xpow.point.clear('alert');
}

var dbg=new Object();
