﻿//document.oncontextmenu = function(){return false;}
//图片切换代码--Begin
var isIE = (document.all) ? true : false;
var $ = function (id) {
	return "string" == typeof id ? document.getElementById(id) : id;
};

var Class = {
	create: function() {
		return function() { this.initialize.apply(this, arguments); }
	}
}

var Extend = function(destination, source) {
	for (var property in source) {
		destination[property] = source[property];
	}
}

var Bind = function(object, fun) {
	return function() {
		return fun.apply(object, arguments);
	}
}

var Each = function(list, fun){
	for (var i = 0, len = list.length; i < len; i++) { fun(list[i], i); }
};


//ie only
var RevealTrans = Class.create();
RevealTrans.prototype = {
  initialize: function(container, options) {
	this._img = document.createElement("img");
	this._a = document.createElement("a");
	
	this._timer = null;//计时器
	this.Index = 0;//显示索引
	this._onIndex = -1;//当前索引
	
	this.SetOptions(options);
	
	this.Auto = !!this.options.Auto;
	this.Pause = Math.abs(this.options.Pause);
	this.Duration = Math.abs(this.options.Duration);
	this.Transition = parseInt(this.options.Transition);
	this.List = this.options.List;
	this.onShow = this.options.onShow;
	
	//初始化显示区域
	//this._img.src = "javascript:void(0);";//第一次变换时不显示红x图
	this._img.style.width = this._img.style.height = "100%"; this._img.style.border = 0;
	this._img.onmouseover = Bind(this, this.Stop);
	this._img.onmouseout = Bind(this, this.Start);
	isIE && (this._img.style.filter = "revealTrans()");
	
	this._a.target = "_blank";
	
	$(container).appendChild(this._a).appendChild(this._img);
  },
  //设置默认属性
  SetOptions: function(options) {
	this.options = {//默认值
		Auto:		true,//是否自动切换
		Pause:		5000,//停顿时间(微妙)
		Duration:	1,//变换持续时间(秒)
		Transition:	12,//变换效果(23为随机)
		List:		[],//数据集合,如果这里不设置可以用Add方法添加
		onShow:		function(){}//变换时执行
	};
	Extend(this.options, options || {});
  },
  Start: function() {
	clearTimeout(this._timer);
	//如果没有数据就返回
	if(!this.List.length) return;
	//修正Index
	if(this.Index < 0 || this.Index >= this.List.length){ this.Index = 0; }
	//如果当前索引不是显示索引就设置显示
	if(this._onIndex != this.Index){ this._onIndex = this.Index; this.Show(this.List[this.Index]); }
	//如果要自动切换
	if(this.Auto){
		this._timer = setTimeout(Bind(this, function(){ this.Index++; this.Start(); }), this.Duration * 1000 + this.Pause);
	}
  },
  //显示
  Show: function(list) {
	if(isIE){
		//设置变换参数
		with(this._img.filters.revealTrans){
			Transition = this.Transition; Duration = this.Duration; apply(); play();
		}
	}
	//设置图片属性
	this._img.src = list.img; this._img.alt = list.text;
	//设置链接
	!!list["url"] ? (this._a.href = list["url"]) : this._a.removeAttribute("href");
	//附加函数
	this.onShow();
  },
  //添加变换对象
  Add: function(sIimg, sText, sUrl) {
	this.List.push({ img: sIimg, text: sText, url: sUrl });
  },
  //停止
  Stop: function() {
	clearTimeout(this._timer);
  }
}
//图片切换代码--End
function externallinks() {
	if (!document.getElementsByTagName) return;
	var anchors = document.getElementsByTagName("a");
	for (var i=0; i < anchors.length; i++) {
		var anchor = anchors[i];
		if (anchor.getAttribute("href") && anchor.getAttribute("rel") == "external") anchor.target = "_blank";
	}
}

window.onload = externallinks;

function LoadJsCssFile(filename, filetype){
	if (filetype == 0){
		var fileref = document.createElement('script');
		fileref.setAttribute("type","text/javascript");
		fileref.setAttribute("src",filename);
	}
	else if (filetype == 1){
		var fileref = document.createElement("link");
		fileref.setAttribute("rel", "stylesheet");
		fileref.setAttribute("type", "text/css");
		fileref.setAttribute("href",filename);
	}
	else if (filetype == 2){
		var fileref = document.createElement("link");
		fileref.setAttribute("rel", "shortcut icon");
		fileref.setAttribute("type", "image/ico");
		fileref.setAttribute("href",filename);
	}
	if (typeof fileref != "undefined") document.getElementsByTagName("head")[0].appendChild(fileref)
}

function getOs() {
	var sAgent = navigator.userAgent.toLowerCase();
	if (sAgent.indexOf("msie") >= 0) return 'IE';
	if (sAgent.indexOf("firefox") >= 0) return 'Firefox';
	if (sAgent.indexOf("safari") >= 0) return 'Safari';
	if (sAgent.indexOf("opera") >= 0) return 'Opera';
	if (sAgent.indexOf("netscape") >= 0) return 'NetScape';
	if (sAgent.indexOf("camino") >= 0) return 'Camino';
	if (sAgent.indexOf("gecko/") >= 0) return 'Gecko';
	return 'unknown';
}

function addFavorite(url,name){
	switch(getOs()){
		case 'IE' :
			window.external.addFavorite(url,name);
			break;
		default :
			window.sidebar.addPanel(name,url,"");
			break;
	}
}

function setHomepage(url){
	switch(getOs()){
		case 'IE' :
			document.body.style.behavior = 'url(#default#homepage)';
			document.body.setHomePage(url);
			break;
		default :
			if (window.sidebar){
				if(window.netscape){
					try {
						netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
					}
					catch (e) {
						alert('E-Dragon CMS 提醒：\n\n设置首页的操作被浏览器拒绝，如果想启用该功能，请在地址栏内输入 about:config\n然后将项 signed.applets.codebase_principal_support 值该为true');
					}
				}
				var prefs = Components.classes['@mozilla.org/preferences-service;1'].getService(Components. interfaces.nsIPrefBranch);
				prefs.setCharPref('browser.startup.homepage',url);
			}
			break;
	}
}

function SetCookie(name,value,days) {
	var exp = new Date(); //new Date("December 31, 9998");
	exp.setTime(exp.getTime() + days * 24 * 60 * 60 * 1000);
	document.cookie = name +'='+ escape(value) + ';expires='+ exp.toGMTString();
}

function getCookie(name) {
	var arr = document.cookie.match(new RegExp("(^| )"+name+"=([^;]*)(;|$)"));
	if(arr != null) return unescape(arr[2]); return null;
}

function ReturnMultipleValue(tag) {
	if (document.getElementById(tag)){
		var result = '';
		for (var i = 0; i < document.getElementById(tag).options.length; i ++) {
			if (document.getElementById(tag).options[i].selected) {
				if (result == '') result = document.getElementById(tag).options[i].value;
				else result = result +','+ document.getElementById(tag).options[i].value;
			}
		}
		return result;
	}
}

function selectAllCheckBox(objName,selfObjName){
	var coll = document.getElementsByTagName('input')
	if(!coll) return;
	if(coll.length){
		for(var i = 0;i < coll.length;i++){
			if (coll.item(i).name == objName) coll.item(i).checked = document.getElementById(selfObjName).checked;
		}
	}
	else coll.checked = document.getElementById(selfObjName).checked;
}

function getValueList(tagName,tagId){
	var result = "";
	var coll = document.getElementsByTagName(tagName)
	if(!coll) return result;
	if(coll.length){
		for(var i = 0;i<coll.length;i++){
			if(coll.item(i).checked) {
				if (coll.item(i).id == tagId) result += (result == "")?coll.item(i).value:("," + coll.item(i).value);
			}
		}
	}else{
		if(coll.checked) result = coll.value;
	}
	return result;
}

function getItemValue(tagName,val) {
	if (val == '***') document.getElementById(tagName).value = '';
	else {
		if (document.getElementById(tagName).value == '') document.getElementById(tagName).value = val;
		else document.getElementById(tagName).value = document.getElementById(tagName).value +','+ val;
	}
}

function checkDisabled(tagName,objNull) {
	var coll = document.getElementsByTagName('input')
	var temp = false;
	if (objNull == '') temp = true;
	if (!coll) return;
	if (coll.length){
		for(var i = 0;i < coll.length;i++){
			if (coll.item(i).name == tagName)  coll.item(i).disabled = temp;
		}
	}
	else coll.disabled = temp;
}

function createDiv(e,id,style) {
	if (!document.getElementById(id)) {
		var cDiv = document.createElement("div");
		cDiv.id = id;
		cDiv.className = style;
		cDiv.style.position = 'absolute';
		cDiv.style.zIndex = 9999;
		cDiv.style.left = returnXY(e,'x') +'px';
		cDiv.style.top = (returnXY(e,'y') + 6) +'px';
		document.body.appendChild(cDiv);
	}
}

function returnXY(e,sType) {
	e = e || window.event;
	if (sType == 'x') return e.pageX ||(e.clientX?e.clientX + document.documentElement.scrollLeft:0);
	if (sType == 'y') return e.pageY ||(e.clientY?e.clientY + document.documentElement.scrollTop:0);
}

function setWeather(e,virtualRoot,id) {
	var coll = document.getElementsByTagName('div')
	if(!coll) return;
	if(coll.length){
		for(var i = 0;i < coll.length;i++){
			if (coll.item(i).className == 'setWeather'){
				coll.item(i).style.display = 'none';
			}
		}
	}
	if (!document.getElementById(id)) {
		createDiv(e,id,'setWeather');
		xmlHttpPost(true,'',virtualRoot +'/Lib/XmlHttp.asp','action=setweather&result=show&id='+ id,0,0,id);
	}
	else {
		document.getElementById(id).style.display = '';
		document.getElementById(id).style.left = returnXY(e,'x') +'px';
		document.getElementById(id).style.top = (returnXY(e,'y') + 6) +'px';
	}
}

function selfLink(e,virtualRoot,id,text) {
	var coll = document.getElementsByTagName('div')
	if(!coll) return;
	if(coll.length){
		for(var i = 0;i < coll.length;i++){
			if (coll.item(i).className == 'selfLink'){
				coll.item(i).style.display = 'none';
			}
		}
	}
	if (!document.getElementById(id)) {
		createDiv(e,id,'selfLink');
		xmlHttpPost(true,'',virtualRoot +'/Lib/XmlHttp.asp','action=showSelfLink&title='+ text +'&id='+ id,0,0,id);
	}
	else {
		document.getElementById(id).style.display = '';
		document.getElementById(id).style.left = returnXY(e,'x') +'px';
		document.getElementById(id).style.top = (returnXY(e,'y') + 6) +'px';
	}
}

function windowOpen(url,item,val,target) {
	var a = item.split("|")
	var b = val.split("|")
	if (target == 'open') {
		if (item == '') window.open(url);
		else {
			for (var i = 0;i < a.length ;i ++ ){
				if (i == 0) url = url +'?'+ a[i] +'='+ escape(b[i]);
				else  url = url +'&'+ a[i] +'='+ escape(b[i]);
			}
			window.open(url);
		}
	}
	else {
		if (item == '') location.href = url;
		else {
			for (var i = 0;i < a.length ;i ++ ){
				if (i == 0) url = url +'?'+ a[i] +'='+ escape(b[i]);
				else  url = url +'&'+ a[i] +'='+ escape(b[i]);
			}
			location.href = url;
		}
	}
}

function menuStyle(objName,tag){
	var coll = document.getElementsByTagName('span')
	if(!coll) return;
	if(coll.length){
		for(var i = 0;i < coll.length;i++){
			if (coll.item(i).id == objName){
				if (tag == 'top') coll.item(i).className = 'clickedtop';
				else coll.item(i).className = 'clickedmenu';
			}
			else {
				if (tag == 'top') coll.item(i).className = '';
				else coll.item(i).className = 'menu';
			}
		}
	}
}

function randomChar(l,t){
	if (t == 1) var x = "0123456789poiuytrewqasdfghjklmnbvcxzQWERTYUIOPLKJHGFDSAZXCVBNM";
	else var x = "0123456789ABCDEF";
	var tmp = "";
	for(var i = 0;i < l;i ++) {
		tmp += x.charAt(Math.ceil(Math.random()*100000000)%x.length);
	}
	return tmp;
}

function changeClassName(stype,num,count,selfClass,tagClass) {
	if (document.getElementById(stype +'_'+ num)) document.getElementById(stype +'_'+ num).className = tagClass;
	for (var i = 0; i <= count; i ++) {
		if (i != num) {
			if (document.getElementById(stype +'_'+ i)) document.getElementById(stype +'_'+ i).className = selfClass;
		}
	}
}

function setIntervalchangeClassName(stype,count,step,showType) {
	var j = 0;
	for (var i = 0; i < count; i ++) {
		if (document.getElementById(stype +'_'+ i) && document.getElementById(stype +'_'+ i).style.display != 'none') {
			j = i;
			break;
		}
	}
	var k = j + 1;
	if (k >= count) k = 0;
	document.getElementById(stype +'_'+ j).style.display = 'none';
	if (showType) showBlock(stype +'_'+ k,step);
	else document.getElementById(stype +'_'+ k).style.display = 'block';
}

function showTr(id) {
	if (document.getElementById(id).style.display == 'none'){
		document.getElementById(id).style.display = ''
	}
	else document.getElementById(id).style.display = 'none'
}

function showBlocks(pre,num,count,step) {
	if (document.getElementById(pre +'_'+ num)) showBlock(pre +'_'+ num,step);
	for (var i = 0; i < count; i ++) {
		if (i != num) {
			if (document.getElementById(pre +'_'+ i)) hiddenBlock(pre +'_'+ i,step);
//			if (document.getElementById(pre +'_'+ i)) document.getElementById(pre +'_'+ i).style.display = 'none';
		}
	}
}

function showBlock(tag,step){
	if (document.getElementById(tag).style.display == 'none') {
		var h = 0;
		var anim = function(){
			document.getElementById(tag).style.display = 'block';
			document.getElementById(tag).style.overflow = 'hidden';
			var max_h = document.getElementById(tag).scrollHeight;
			h += step;
			if(h >= max_h){
				if (navigator.userAgent.toLowerCase().indexOf("msie 6.0") >= 0) {
					document.getElementById(tag).style.height = max_h +'px';
					document.getElementById(tag).style.overflow = 'auto';
				}
				else document.getElementById(tag).style.height = 'auto';
				if(tt) window.clearInterval(tt);
			}
			else{
				document.getElementById(tag).style.height = h +'px';
			}
		}
		var tt = window.setInterval(anim,2);
	}
}

function hiddenBlock(tag,step){
	if (document.getElementById(tag).style.display == 'block') {
		var h = document.getElementById(tag).scrollHeight;
		if (navigator.userAgent.toLowerCase().indexOf("msie 6.0") >= 0) document.getElementById(tag).style.overflow = 'hidden';
		var anim = function(){
			h -= step;
			if(h <= 10){
				document.getElementById(tag).style.display = 'none';
				if(tt) window.clearInterval(tt);
			}
			else{
				document.getElementById(tag).style.height = h +'px';
			}
		}
		var tt = window.setInterval(anim,10);
	}
}

function changePic(pic1,pic2,id) {
	if (document.getElementById(id).title == '点击展开') {
		document.getElementById(id).src = pic2;
		document.getElementById(id).title = '点击合起';
	}
	else {
		document.getElementById(id).src = pic1;
		document.getElementById(id).title = '点击展开';
	}
}

function openSelWin(url,winWidth,winHeight) {
	var regWin = window.open(url,'selWin_'+ randomChar(10,1),'modal=yes,toolbar=no,menubar=no,status=no,scrollbars=yes,resizable=no,width='+ winWidth +',height='+ winHeight);
	if (regWin) {
		regWin.moveTo((screen.availWidth - winWidth) / 2,(screen.availHeight - winHeight - 12) / 2);
		regWin.focus();
	}
	return true;
}

function getFieldVal(virtualRoot,act,oprateTable,key,PublicID,tagObj,updateTF) {
	xmlHttpPost(true,'',virtualRoot +'/Lib/XmlHttp.asp','action=getFieldVal&obj='+ act +'&table='+ oprateTable +'&key='+ key +'&id='+ PublicID +'&updateTF='+ updateTF,0,0,tagObj)
}

function getReNum(virtualRoot,PublicID,tagObj) {
	xmlHttpPost(true,'',virtualRoot +'/Lib/XmlHttp.asp','action=getReviewNum&id='+ PublicID,0,0,tagObj)
}

function CustomSqlList(virtualRoot,tempType,tempName,condition,topNum,picOrText,tagId) {
	xmlHttpPost(true,'',virtualRoot +'/Lib/XmlHttp.asp','action=CustomSqlList&tempType='+ tempType +'&tempName='+ unescape(tempName).replace(/ /g,'%20') +'&condition='+ unescape(condition).replace(/,/g,'%20').replace(/ /g,'%20') +'&pic='+ picOrText +'&topNum='+ topNum,0,0,'CustomList_'+ tagId)
}

function CheckReviewLength(virtualRoot,reviewType,PublicID,pageNo,maxLength) {
	var a = GetLength('reviewCont_'+ PublicID);
	var str = '';
	if (getOs() == 'Opera') str = document.getElementById('reviewCont_'+ PublicID).value;
	else str = escape(GetContents('reviewCont_'+ PublicID))
	if (a == 0) alert('1、帖子内容不能为空\n2、请不要使用纯表情或纯图片作为帖子内容');
	else if (a > maxLength) alert('帖子内容超出字数限制');
	else {
		if (document.getElementById('P_'+ PublicID) && document.getElementById('reviewTempId_'+ PublicID)) {
			xmlHttpPost(true,'<div style="text-align:center; clear:both; margin:10px;">正在提交您的帖子，请稍后...</div>',virtualRoot +'/Lib/xmlHttp.asp','action=getReviewList&id='+ PublicID +'&reviewType='+ reviewType +'&pageNo='+ pageNo +'&tempid='+ document.getElementById('reviewTempId_'+ PublicID).value +'&reviewcont='+ str,0,0,'P_'+ PublicID);
			SetContents('reviewCont_'+ PublicID,'');
			location.href = '#P_'+ PublicID;
		}
		else alert('出现意外错误，帖子无法提交');
	}
}

function getReview(virtualRoot,reviewType,PublicID,pageNo,tempId,reviewCont) {
	if (document.getElementById('P_'+ PublicID)) xmlHttpPost(true,'',virtualRoot +'/Lib/xmlHttp.asp','action=getReviewList&id='+ PublicID +'&reviewType='+ reviewType +'&pageNo='+ pageNo +'&tempid='+ tempId,0,0,'P_'+ PublicID);
}

function GetServerData(resultType,virtualRoot,act,val1,val2,val3,val4,tagObj) {
	xmlHttpPost(resultType,'',virtualRoot +'/Lib/xmlHttp.asp','action=getserverdata&obj='+ act +'&val1='+ val1 +'&val2='+ val2 +'&val3='+ val3 +'&val4='+ val4,0,0,tagObj);
}

function SearchSubmit(virtualRoot) {
	var key = document.getElementById('keyword').value;
	if (key == '') alert('请输入关键字');
	else location.href = virtualRoot +'/Search.shtml?page=1&key='+ escape(key);
}

function CheckReadGroup(virtualRoot,readscore,infoId,pageNo) {
	var userRead = xmlHttpPost(false,'',virtualRoot +'/Lib/XmlHttp.asp','action=getUserReadGroup&id='+ infoId +'&readscore='+ readscore,0,2,'');
	if (userRead == 'True') xmlHttpPost(true,'',virtualRoot +'/Lib/XmlHttp.asp','action=checkReadGroup&id='+ infoId +'&pageNo='+ pageNo,0,0,'Info_'+ infoId);
}

function userLogout(virtualRoot) {
	if (confirm('是否真的要退出？')){
		xmlHttpPost(false,'',virtualRoot +'/Lib/XmlHttp.asp','action=userLogout',0,0,'');
		location.reload();
	}
}

function GetUserLoginForm(virtualRoot,tempId,formId) {
	xmlHttpPost(false,'',virtualRoot +'/Lib/XmlHttp.asp','action=checkUser&tempid='+ tempId +'&id='+ formId,0,0,'LoginForm_'+ formId);
	xmlHttpPost(false,'',virtualRoot +'/Lib/XmlHttp.asp','action=onlineTime',0,0,'');
}

function ChkUserLogin(virtualRoot,action,formId) {
	var tempid = document.getElementById('tempId').value;
	var usn = document.getElementById('usn').value;
	var psw = document.getElementById('psw').value;
	var code = document.getElementById('code').value;
	var saveCookie = document.getElementById('savecookie').checked;
	if (saveCookie) saveCookie = 1;
	xmlHttpPost(true,'身份验证中，请稍后...',virtualRoot +'/Lib/XmlHttp.asp','action='+ action +'&tempid='+ tempid +'&usn='+ usn +'&psw='+ psw +'&code='+ code +'&savecookie='+ saveCookie +'&id='+ formId,0,0,'LoginForm_'+ formId);
}

function GetNextOrForwardInfoLink(virtualRoot,infoTable,classid,infoid,forwardOrBack,cutNum,endStr,linkStyle,isLink) {
	var a = 0;
	var b = 0;
	var c = true
	if (isLink == 1) {
		a = 1;
		b = 6;
		c = false;
	}
	xmlHttpPost(c,'请稍后...',virtualRoot +'/Lib/xmlHttp.asp','action=GetBackOrForwardInfoLink&showType='+ forwardOrBack +'&classid='+ classid +'&infoid='+ infoid +'&infotable='+ infoTable +'&cutnum='+ cutNum +'&endstr='+ escape(endStr) +'&linkstyle='+ linkStyle +'&islink='+ a,0,b,forwardOrBack +'Info_'+ infoid)
}

function GetActionFlagCont(virtualRoot,resultType,flagID,pageNo) {
	var ajaxType = true;
	if (resultType == 3) ajaxType = false;
	xmlHttpPost(ajaxType,'Loading...',virtualRoot +'/Lib/xmlHttp.asp','action=changePage&id='+ flagID +'&page='+ pageNo,0,0,'P_'+ flagID)
}

function changePage(virtualRoot,resultType,action,pCount,pButton,pPlace,pType,tagObj,condition) {
	var pNo = '';
	var ajaxType = true;
	if (resultType == 3) ajaxType = false;
	if (pButton == 'First') pNo = 1;
	else if (pButton == 'Previous'){
		if (document.getElementById('P_'+ tagObj +'_No0')) pNo = Number(document.getElementById('P_'+ tagObj +'_No0').innerHTML) - 1;
		if (document.getElementById('P_'+ tagObj +'_No1')) pNo = Number(document.getElementById('P_'+ tagObj +'_No1').innerHTML) - 1;
		if (pNo < 1) pNo = 1;
	}
	else if (pButton == 'Next'){
		if (document.getElementById('P_'+ tagObj +'_No0')) pNo = Number(document.getElementById('P_'+ tagObj +'_No0').innerHTML) + 1;
		if (document.getElementById('P_'+ tagObj +'_No1')) pNo = Number(document.getElementById('P_'+ tagObj +'_No1').innerHTML) + 1;
		if (pNo > pCount) pNo = pCount;
	}
	else if (pButton == 'Last') pNo = pCount;
	else pNo = Number(pButton);
	if (pType == 0){
		for (var i = 1;i <= pCount;i ++ ){
			if (i == pNo) {
				if (document.getElementById('P_'+ tagObj +'_'+ i)) document.getElementById('P_'+ tagObj +'_'+ i).style.display = 'block';
			}
			else {
				if (document.getElementById('P_'+ tagObj +'_'+ i)) document.getElementById('P_'+ tagObj +'_'+ i).style.display = 'none';
			}
		}
	}
	else {
		if (action == 'searchlist') location.href = '#';
		xmlHttpPost(ajaxType,'Loading...',virtualRoot +'/Lib/xmlHttp.asp','action='+ action +'&id='+ tagObj +'&page='+ pNo +'&condition='+ unescape(condition).replace(/ /g,"%20"),0,0,'P_'+ tagObj)
	}
	if (document.getElementById('P_'+ tagObj +'_No0')) document.getElementById('P_'+ tagObj +'_No0').innerHTML = pNo;
	if (document.getElementById('P_'+ tagObj +'_No1')) document.getElementById('P_'+ tagObj +'_No1').innerHTML = pNo;
}

function publicInfo(wid,aTag) {
	location.href = '#'+ aTag;
	if (parent.document.getElementById('progressNum')) parent.document.getElementById('progressNum').innerHTML = wid;
	if (parent.document.getElementById('progress')) parent.document.getElementById('progress').style.width = wid;
	if (document.getElementById('progressNum')) document.getElementById('progressNum').innerHTML = wid;
	if (document.getElementById('progress')) document.getElementById('progress').style.width = wid;
}

function xmlHttpPost(tf,loadImg,url,valueStr,postType,oprateType,id){
	loadImg = '<img style="border:0px;" src="'+ getAjaxFilePath(url) +'/Lib/Images/Loading.gif" alt="Loading..." /> <span style="color:#999999">'+ loadImg +'</span>';
	var postStr = 'POST';
	if (postType == 1) postStr = 'GET';
	var xmlhttp = creatAjaxObject();
	xmlhttp.open(postStr,url,tf);
	xmlhttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
	if (tf == false) {
		xmlhttp.send('now='+ new Date().getTime() +'&'+ valueStr);
		if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
			val = unescape(xmlhttp.responseText);
			returnAjaxResult(oprateType,id,val);
		}
	}
	else {
		xmlhttp.onreadystatechange = function() {
			var val = '';
			switch(xmlhttp.readyState){
				case 4 :
					if (xmlhttp.status == 200) val = unescape(xmlhttp.responseText);
					else val = '<span style="color:#FF0000">ErrNum:'+ xmlhttp.status + xmlhttp.status.description +'</span>';
					break;
				default :
					val = loadImg;
					break;
			}
			returnAjaxResult(oprateType,id,val);
		}
	}
	if (tf) xmlhttp.send(valueStr);
}

function creatAjaxObject() {
	var xmlhttp = false;
	if (window.XMLHttpRequest) {
		xmlhttp = new XMLHttpRequest();
		if (xmlhttp.overrideMimeType) xmlhttp.overrideMimeType('text/xml');
	}
	else if (window.ActiveXObject) {
		try {
			xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch (e) {
			try {
				xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
			}
			catch (e){
			}
		}
	}
	if (!xmlhttp) {
		alert('Can not init XMLHttpRequest!');
		return false;
	}
	return xmlhttp
}

function returnAjaxResult(oprateType,id,val) {
	switch(oprateType){
		case 0 :
			if (document.getElementById(id)) document.getElementById(id).innerHTML = val;
			break;
		case 1 :
			if (document.getElementById(id)) document.getElementById(id).value = val;
			break;
		case 2 :
			return val;
			break;
		case 3 :
			alert(val);
			break;
		case 4 :
			document.body.innerHTML = val;
			break;
		case 5 :
			document.write(val);
		case 6 :
			location.href = val;
			break;
		case 7 :
			eval(val);
			break;
		default :
			break;
	}
}

function getAjaxFilePath(url) {
	var temp = '';
	if (url.indexOf('/Lib/xmlHttp.asp') >= 0) temp = url.substring(0,url.indexOf('/Lib/xmlHttp.asp'));
	if (url.indexOf('../Inc/xmlHttp.asp') >= 0) temp = '../'
	return temp;
}

function setCaret(textObj){
	if (textObj.createTextRange) textObj.caretPos = document.selection.createRange().duplicate();
}

function insertAtCaret(textObj,textFeildValue) {
	if(document.all) {
		if (textObj.createTextRange && textObj.caretPos) {
			var caretPos = textObj.caretPos;
			caretPos.text = caretPos.text.charAt(caretPos.text.length - 1) == ''?textFeildValue + '' : textFeildValue;
		}
		else textObj.value = textFeildValue;
	}
	else{
		if(textObj.setSelectionRange){
			var rangeStart = textObj.selectionStart;
			var rangeEnd = textObj.selectionEnd;
			var tempStr1 = textObj.value.substring(0,rangeStart);
			var tempStr2 = textObj.value.substring(rangeEnd);
			textObj.value = tempStr1 + textFeildValue + tempStr2;
		}
		else alert("This version of Mozilla based browser does not support setSelectionRange");
	}
}

function GetLength(obj){
	var iLength ;
	if (getOs() == 'Opera') {
		iLength = document.getElementById(obj).value.replace(/[^\x00-\xff]/g,"**").length;
	}
	else {
		var oEditor = FCKeditorAPI.GetInstance(obj) ;
		var oDOM = oEditor.EditorDocument ;
		if ( document.all ) iLength = oDOM.body.innerText.length ;
		else{
			var r = oDOM.createRange() ;
			r.selectNodeContents( oDOM.body ) ;
			iLength = r.toString().length ;
		}
	}
	return iLength;
}

function createEditor(virtualRoot,toolBarSet,wid,hei,tagObj,showType) {
	var oFCKeditor = new FCKeditor('reviewCont_'+ tagObj) ;
	oFCKeditor.Config['CustomConfigurationsPath']	= virtualRoot +'/Lib/Editor/user_fckconfig.js' ;
	oFCKeditor.ToolbarSet							= toolBarSet;
	oFCKeditor.BasePath								= virtualRoot +'/Lib/Editor/' ;
	oFCKeditor.Width								= wid ;
	oFCKeditor.Height								= hei ;
	oFCKeditor.Value								= document.getElementById('reviewCont_'+ tagObj).value ;
	if (getOs() != 'Opera'){
		if (showType == 0) oFCKeditor.Create() ;
		else oFCKeditor.ReplaceTextarea() ;
	}
	if (document.getElementById('reviewSubmit_'+ tagObj)) document.getElementById('reviewSubmit_'+ tagObj).disabled = false;
	if (document.getElementById('reviewReset_'+ tagObj)) document.getElementById('reviewReset_'+ tagObj).disabled = false;
}

function InsertLocalFileToEditer(virtualRoot,filename,extname,filepath,filesize,tag) {
	if (typeof(FCKeditorAPI) == 'undefined') {
		alert('您尚未载入编辑器');
	}
	else {
		switch(extname){
		case 'jpg': case 'gif': case 'jpeg': case 'bmp': case 'png':
			InsertHTML(tag,'<img alt="'+ filename +'" title="'+ filename +'" src="'+ filepath +'" />');
			break;
		default :
			InsertHTML(tag,'<img src="'+ virtualRoot +'/Lib/Images/File/'+ extname +'.gif" style="border:0px; vertical-align:middle;" alt="" /> <a href="'+ unescape(filepath) +'" rel="external">'+ unescape(filename) +'.'+ extname +'</a> ['+ filesize +']');
			break;
		}
	}
}

function InsertHTML(obj,str){
	if (typeof(FCKeditorAPI) == 'undefined') {
		alert('请先将鼠标焦点定位于内容输入文本框以激活编辑器');
		 document.getElementById(obj).focus();
	}
	else {
		var oEditor = FCKeditorAPI.GetInstance(obj) ;
		if ( oEditor.EditMode == FCK_EDITMODE_WYSIWYG ) oEditor.InsertHtml(str) ;
		else alert( '必须在可视化编辑模式方能插入您选定的内容' ) ;
	}
}

function SetContents(obj,str){
	if (document.getElementById(obj)) {
		if (getOs() == 'Opera') {
			document.getElementById(obj).value = str;
		}
		else {
			var oEditor = FCKeditorAPI.GetInstance(obj) ;
			oEditor.SetHTML(str) ;
		}
	}
}

function GetContents(obj){
	var oEditor = FCKeditorAPI.GetInstance(obj) ;
	return oEditor.GetXHTML(true) ;		// "true" means you want it formatted.
}

function ExecuteCommand( obj,commandName ){
	var oEditor = FCKeditorAPI.GetInstance(obj) ;
	oEditor.Commands.GetCommand( commandName ).Execute() ;
}

function CreateFlash(obj,idad, swfurl, wad, had, vs){
	var FlashPic = '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" ';
	if (wad) FlashPic += 'width="' + wad + '" ';
	if (had) FlashPic += 'height="' + had + '" ';
	FlashPic += 'id="'+ idad +'" align="middle">';
	FlashPic += '<param name="allowScriptAccess" value="always" />';
	FlashPic += '<param name="quality" value="high" />';
	FlashPic += '<param name="menu" value="false" />';
	FlashPic += '<param name="movie" value="'+ swfurl +'" />';
	FlashPic += '<param name="wmode" value="transparent" />';
	FlashPic += '<param name="flashvars" value="'+ vs +'" />';
	FlashPic += '<embed src="'+ swfurl +'" flashvars="'+ vs +'" wmode="transparent" quality="high" ';
	if (wad) FlashPic += 'width="'+ wad +'" ';
	if (had) FlashPic += 'height="'+ had +'" ';
	FlashPic += 'name="'+ idad +'" align="middle" allowScriptAccess="always" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer">';
	FlashPic += "</object>";
	document.getElementById(obj).innerHTML = FlashPic;
}

Validator = {
	Require : /.+/,
	Email : /^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/,
	Phone : /^((\(\d{2,3}\))|(\d{3}\-))?(\(0\d{2,3}\)|0\d{2,3}-)?[1-9]\d{6,7}(\-\d{1,4})?$/,
	Mobile : /^((\(\d{2,3}\))|(\d{3}\-))?13\d{9}$/,
	Url : /^http:\/\/[A-Za-z0-9]+\.[A-Za-z0-9]+[\/=\?%\-&_~`@[\]\':+!]*([^<>\"\"])*$/,
	IdCard : "this.IsIdCard(value)",
	Currency : /^\d+(\.\d+)?$/,
	Number : /^\d+$/,
	Zip : /^[1-9]\d{5}$/,
	QQ : /^[1-9]\d{4,8}$/,
	Integer : /^[-\+]?\d+$/,
	Double : /^[-\+]?\d+(\.\d+)?$/,
	English : /^[A-Za-z]+$/,
	Chinese :  /^[\u0391-\uFFE5]+$/,
	Username : /^[a-z]\w{3,}$/i,
	UnSafe : /^(([A-Z]*|[a-z]*|\d*|[-_\~!@#\$%\^&\*\.\(\)\[\]\{\}<>\?\\\/\'\"]*)|.{0,5})$|\s/,
	IsSafe : function(str){return !this.UnSafe.test(str);},
	SafeString : "this.IsSafe(value)",
	Filter : "this.DoFilter(value, getAttribute('accept'))",
	Limit : "this.limit(value.length,getAttribute('min'),  getAttribute('max'))",
	LimitB : "this.limit(this.LenB(value), getAttribute('min'), getAttribute('max'))",
	Date : "this.IsDate(value, getAttribute('min'), getAttribute('format'))",
	Repeat : "value == document.getElementsByName(getAttribute('to'))[0].value",
	Range : "getAttribute('min') < (value|0) && (value|0) < getAttribute('max')",
	Compare : "this.compare(value,getAttribute('operator'),getAttribute('to'))",
	Custom : "this.Exec(value, getAttribute('regexp'))",
	Group : "this.MustChecked(getAttribute('name'), getAttribute('min'), getAttribute('max'))",
	ErrorItem : [document.forms[0]],
	ErrorMessage : ["错误提示：\n"],
	Validate : function(theForm, mode){
		var obj = theForm || event.srcElement;
		var count = obj.elements.length;
		this.ErrorMessage.length = 1;
		this.ErrorItem.length = 1;
		this.ErrorItem[0] = obj;
		for(var i=0;i<count;i++){
			with(obj.elements[i]){
				var _dataType = getAttribute("dataType");
				if(typeof(_dataType) == "object" || typeof(this[_dataType]) == "undefined")  continue;
				this.ClearState(obj.elements[i]);
				if(getAttribute("require") == "false" && value == "") continue;
				switch(_dataType){
					case "IdCard" :
					case "Date" :
					case "Repeat" :
					case "Range" :
					case "Compare" :
					case "Custom" :
					case "Group" :
					case "Limit" :
					case "LimitB" :
					case "SafeString" :
					case "Filter" :
						if(!eval(this[_dataType]))	{
							this.AddError(i, getAttribute("msg"));
						}
						break;
					default :
						if(!this[_dataType].test(value)){
							this.AddError(i, getAttribute("msg"));
						}
						break;
				}
			}
		}
		if(this.ErrorMessage.length > 1){
			mode = mode || 1;
			var errCount = this.ErrorItem.length;
			switch(mode){
			case 2 :
				for(var i=1;i<errCount;i++)
					this.ErrorItem[i].style.color = "red";
			case 1 :
				alert(this.ErrorMessage.join("\n"));
				this.ErrorItem[1].focus();
				break;
			case 3 :
				for(var i=1;i<errCount;i++){
				try{
					var span = document.createElement("SPAN");
					span.id = "__ErrorMessagePanel";
					span.style.color = "red";
					this.ErrorItem[i].parentNode.appendChild(span);
					span.innerHTML = this.ErrorMessage[i].replace(/\d+:/,"* ");
					}
					catch(e){alert(e.description);}
				}
				this.ErrorItem[1].focus();
				break;
			default :
				alert(this.ErrorMessage.join("\n"));
				break;
			}
			return false;
		}
		return true;
	},
	limit : function(len,min, max){
		min = min || 0;
		max = max || Number.MAX_VALUE;
		return min <= len && len <= max;
	},
	LenB : function(str){
		return str.replace(/[^\x00-\xff]/g,"**").length;
	},
	ClearState : function(elem){
		with(elem){
			if(style.color == "red")
				style.color = "";
			var lastNode = parentNode.childNodes[parentNode.childNodes.length-1];
			if(lastNode.id == "__ErrorMessagePanel")
				parentNode.removeChild(lastNode);
		}
	},
	AddError : function(index, str){
		this.ErrorItem[this.ErrorItem.length] = this.ErrorItem[0].elements[index];
		this.ErrorMessage[this.ErrorMessage.length] = this.ErrorMessage.length + ":" + str;
	},
	Exec : function(op, reg){
		return new RegExp(reg,"g").test(op);
	},
	compare : function(op1,operator,op2){
		switch (operator) {
			case "NotEqual":
				return (op1 != op2);
			case "GreaterThan":
				return (op1 > op2);
			case "GreaterThanEqual":
				return (op1 >= op2);
			case "LessThan":
				return (op1 < op2);
			case "LessThanEqual":
				return (op1 <= op2);
			default:
				return (op1 == op2);
		}
	},
	MustChecked : function(name, min, max){
		var groups = document.getElementsByName(name);
		var hasChecked = 0;
		min = min || 1;
		max = max || groups.length;
		for(var i=groups.length-1;i>=0;i--)
			if(groups[i].checked) hasChecked++;
		return min <= hasChecked && hasChecked <= max;
	},
	DoFilter : function(input, filter){
return new RegExp("^.+\.(?=EXT)(EXT)$".replace(/EXT/g, filter.split(/\s*,\s*/).join("|")), "gi").test(input);
	},
	IsIdCard : function(number){
		var date, Ai;
		var verify = "10x98765432";
		var Wi = [7, 9, 10, 5, 8, 4, 2, 1, 6, 3, 7, 9, 10, 5, 8, 4, 2];
		var area = ['','','','','','','','','','','','北京','天津','河北','山西','内蒙古','','','','','','辽宁','吉林','黑龙江','','','','','','','','上海','江苏','浙江','安微','福建','江西','山东','','','','河南','湖北','湖南','广东','广西','海南','','','','重庆','四川','贵州','云南','西藏','','','','','','','陕西','甘肃','青海','宁夏','新疆','','','','','','台湾','','','','','','','','','','香港','澳门','','','','','','','','','国外'];
		var re = number.match(/^(\d{2})\d{4}(((\d{2})(\d{2})(\d{2})(\d{3}))|((\d{4})(\d{2})(\d{2})(\d{3}[x\d])))$/i);
		if(re == null) return false;
		if(re[1] >= area.length || area[re[1]] == "") return false;
		if(re[2].length == 12){
			Ai = number.substr(0, 17);
			date = [re[9], re[10], re[11]].join("-");
		}
		else{
			Ai = number.substr(0, 6) + "19" + number.substr(6);
			date = ["19" + re[4], re[5], re[6]].join("-");
		}
		if(!this.IsDate(date, "ymd")) return false;
		var sum = 0;
		for(var i = 0;i<=16;i++){
			sum += Ai.charAt(i) * Wi[i];
		}
		Ai +=  verify.charAt(sum%11);
		return (number.length ==15 || number.length == 18 && number == Ai);
	},
	IsDate : function(op, formatString){
		formatString = formatString || "ymd";
		var m, year, month, day;
		switch(formatString){
			case "ymd" :
				m = op.match(new RegExp("^((\\d{4})|(\\d{2}))([-./])(\\d{1,2})\\4(\\d{1,2})$"));
				if(m == null ) return false;
				day = m[6];
				month = m[5]*1;
				year =  (m[2].length == 4) ? m[2] : GetFullYear(parseInt(m[3], 10));
				break;
			case "dmy" :
				m = op.match(new RegExp("^(\\d{1,2})([-./])(\\d{1,2})\\2((\\d{4})|(\\d{2}))$"));
				if(m == null ) return false;
				day = m[1];
				month = m[3]*1;
				year = (m[5].length == 4) ? m[5] : GetFullYear(parseInt(m[6], 10));
				break;
			default :
				break;
		}
		if(!parseInt(month)) return false;
		month = month==0 ?12:month;
		var date = new Date(year, month-1, day);
        return (typeof(date) == "object" && year == date.getFullYear() && month == (date.getMonth()+1) && day == date.getDate());
		function GetFullYear(y){return ((y<30 ? "20" : "19") + y)|0;}
	}
 }
function copyToClipBoard(){
	var clipBoardContent="";//初始清空
	var titleStr = window.document.title.split("-")[0];
	clipBoardContent+=titleStr;//写入Title
    clipBoardContent+='\r\n'+window.location.href;//换行，写入URL
	window.clipboardData.setData("Text",clipBoardContent);//写入ClipBoard
	alert("成功复制本文标题及链接,现在可与您的好友分享了!");//弹出提示，如不需要可删除或屏蔽此行
}


function AddFavorite(sURL, sTitle)
{
   try
   {
       window.external.addFavorite(sURL, sTitle);
   }
   catch (e)
   {
       try
       {
           window.sidebar.addPanel(sTitle, sURL, "");
       }
       catch (e)
       {
           alert("加入收藏失败，请使用Ctrl+D进行添加");
       }
   }
}