

// 修改信息_类型检测
function CheckRevInfoType(){
	for (var i=0; i<$name("revType").length; i++){
		if ($name("revType")[i].checked==true){
			$id($name("revType")[i].value +"Box").style.display="";
		}else{
			$id($name("revType")[i].value +"Box").style.display="none";
		}
	}
}

// 修改信息_检测表单
function CheckRevForm(){
	var selValue = "";
	for (var i=0; i<$name("revType").length; i++){
		if ($name("revType")[i].checked==true){
			selValue = $name("revType")[i].value;
		}
	}
	if (selValue==""){
		alert("请先选择修改类型.");$name("revType")[0].focus();return false;
	}

	if (selValue=="info"){
		try {
			if ($id("realname").value==""){alert("称呼不能为空！");$id("realname").focus();return false;}
		}catch (e) {}

	}
	else if (selValue=="password"){
		try {
			if ($id("userpwdOld").value==""){alert("原密码不能为空！");$id("userpwdOld").focus();return false;}
		}catch (e) {}
		if ($id("userpwd").value==""){alert("新密码不能为空！");$id("userpwd").focus();return false;}
		if ($id("userpwd").value.length<6){alert("新密码长度不能少于6位！");$id("userpwd").focus();return false;}
		if ($id("userpwd").value!=$id("userpwd2").value){alert("两次密码不一致！");$id("userpwd2").focus();return false;}

	}
	else if (selValue=="mail"){
		if ($id("mail").value==""){alert("新邮箱不能为空！");$id("mail").focus();return false;}
		if (! IsMail($id("mail").value)){alert("新邮箱格式错误！");$id("mail").focus();return false;}
		if ($id("mailPwd").value==""){alert("登录密码不能为空！");$id("mailPwd").focus();return false;}

	}
	else if (selValue=="question"){
		if ($id("question").value==""){alert("密保问题不能为空！");$id("question").focus();return false;}
		if ($id("answer").value==""){alert("密保答案不能为空！");$id("answer").focus();return false;}

	}

//	if (webPathPart=="../"){ $id('revForm').action = webPathPart + $id('revForm').action; }
//	if ($id("verCode").value==""){alert("验证码不能为空！");$id("verCode").focus();return false;}
	if (selValue=="face"){
		$id("revForm").target = "DataDeal";
	}else{
		AjaxPostDeal("revForm");
		return false;
	}
}



// 检测发表文章
var wNewsWaitTime = 0;
var wNewsCutWaitFunc = null;
function CheckNewsForm(){
	if ($id("theme").value==""){alert("标题不能为空！");$id("theme").focus();return false;}
	if ($id("typeStr").value==""){alert("请选择栏目！");$id("typeStr").focus();return false;}
	try {
		KE.sync('content');
	}catch (e) {}
	contentStr = setContent($id("content").value);
	if (contentStr.length<10){alert("内容不能小于10字符！");return false;}
	try {
		jsPageNum = parseInt($id("pageNum").value);
		if (isNaN(jsPageNum)){ jsPageNum=0; }
		if (jsPageNum>0 && jsPageNum<500){
			alert("自动分页字数最少500设置起");$id("pageNum").focus();return false;
		}
	}catch (e) {}
	if ($id('contentKey').value.length > 180){alert("内容摘要不能超过180个字符，当前有"+ $id('contentKey').value.length +"个字符");$id('contentKey').focus();return false}
	if ($id('imgBox').style.display=="" && $id("img").value==""){
		alert("缩略图/图片不能为空！");$id("img").focus();return false;
	}
	if (wNewsWaitTime>0){
		alert("已提交，请稍等一会儿...("+ wNewsWaitTime +")");return false;
	}
		wNewsWaitTime = 10;
		wNewsCutWaitFunc = window.setInterval("CutWnewsWaitTime()",1000);

//	if (webPathPart=="../"){ $id('dealForm').action = webPathPart + $id('dealForm').action; }
	AjaxPostDeal("dealForm");
	return false;
}

function CutWnewsWaitTime(){
	if (wNewsWaitTime<=0){
		window.clearInterval(wNewsCutWaitFunc);
		return false;
	}else{
		wNewsWaitTime --;
	}
}


// 清空文章表单内容
function NewsClearBtn(){
	if (confirm('确定要清空？')){
		$id('theme').value = "";
		$id('source').value = "";
		$id('writer').value = "";
		$id('typeStr').value = "";
		$id('content').value = "";
		$id('themeKey').value = "";
		$id('contentKey').value = "";
	}
}

// 删除文章
function DelNews(dataID,isAudit){
	auditStr = "";
	if (isAudit==1){
		auditStr = "\n\n删除该文章将扣除";
		if (parseInt($id('delScore1').value)>0){
			auditStr += "\n\n"+ $id('score1Name').value +"："+ $id('delScore1').value;
		}
		if (parseInt($id('delScore2').value)>0){
			auditStr += "\n\n"+ $id('score2Name').value +"："+ $id('delScore2').value;
		}
		if (parseInt($id('delScore3').value)>0){
			auditStr += "\n\n"+ $id('score3Name').value +"："+ $id('delScore3').value;
		}
		if (parseInt($id('delScore4').value)>0){
			auditStr += "\n\n"+ $id('score4Name').value +"："+ $id('delScore4').value;
		}
		if (parseInt($id('delScore5').value)>0){
			auditStr += "\n\n"+ $id('score5Name').value +"："+ $id('delScore5').value;
		}
	}else{
		auditStr = "";
	}
	if (confirm('你确定要删除该文章？'+ auditStr)){
		AjaxGetDeal(webPathPart +'usersNews_deal.asp?mudi=del&dataID='+ dataID);
	}
	
}


// 检测重复标题
function CheckRepeatTheme(){
	themeStr = $id('theme').value;

	if (themeStr==""){
		alert("标题不能为空.");return false;
	}

	$.ajaxSetup({cache:false});
	$.get(webPathPart +"readDeal2.asp?mudi=checkInfoRepeatTheme&dataID="+ $id('dataID').value +"&theme="+ escape(themeStr) +"", function(result){
		alert(result);
	});
	return false;

}


// 载入关键词(标签)
function GetDzKeyWord(){
	themeStr = $id('theme').value;
	try {
		KE.sync('content');
	}catch (e) {}
	contentStr = setContent($id('content').value);

	if (themeStr==""){
		alert("获取关键词(标签)，标题不能为空.");return false;
	}

	$id('onloadThemeKey').innerHTML = "<img src='"+ webPathPart +"inc_img/onload.gif' style='margin-right:5px;' />请稍等，关键词获取中...</center>";
	$.ajaxSetup({cache:false});
	$.get(webPathPart +"read.asp?mudi=getDzKeyWord&theme="+ escape(themeStr) +"&content="+ escape(contentStr).substr(0,1750), function(result){
		$id('onloadThemeKey').innerHTML = "";
		if (result=="0"){ alert("获取不到关键词(标签)，请手动添加。");return false; }
		$id('themeKey').value = result;
	});

	return false;

}


// 从本地库获取关键词(标签)
function GetKeyWord(){
	themeStr = $id('theme').value;

	if (themeStr==""){
		alert("获取关键词(标签)，标题不能为空.");return false;
	}

	$id('onloadThemeKey').innerHTML = "<img src='"+ webPathPart +"inc_img/onload.gif' style='margin-right:5px;' />请稍等，关键词获取中...</center>";
	$.ajaxSetup({cache:false});
	$.get(webPathPart +"read.asp?mudi=getKeyWord&theme="+ escape(themeStr) +"", function(result){
		$id('onloadThemeKey').innerHTML = "";
		if (result=="0"){ alert("获取不到关键词(标签)，请手动添加。");return false; }
		$id('themeKey').value = result;
	});
	return false;

}


// 载入内容摘要
function ToContentKey(){
	try {
		KE.sync('content');
	}catch (e) {}
	str = setContent($id('content').value);
	try {
		str = LTrim(str);
	}catch (e) {}
	if (str==""){
		alert('请先填写内容');return false;
	}
	$id('contentKey').value = str.substring(0,140).replace(/\r\n/g,"") +"...";
}

function CheckRefNewsForm(){
	OpenPopup('newsManage','&refTypeStr='+ escape($id("refTypeStr").value) +'&refTheme='+ escape($id("refTheme").value) +'&refSource='+ escape($id("refSource").value) +'&refWriter='+ escape($id("refWriter").value) +'');
}

function setContent(str) {
	str = str.replace(/<\/?[^>]*>/g,''); //去除HTML tag
	str = str.replace(/[ | ]*\n/g,'\n'); //去除行尾空白
	str = str.replace(/\n[\s| | ]*\r/g,'\n'); //去除多余空行
	return str;
}




function OT_OpenUpImg(fileMode,fileFormName,fileDir,otherPara){
	var arr = window.open(jsPathPart +"usersNewsUpImg.asp?fileMode="+ fileMode +"&fileFormName="+ fileFormName +"&upPath="+ fileDir +"&upFileType=images"+ otherPara,"","top=250,left=340,width=600,height=300,menubar=no,scrollbars=yes,status=no,resizable=yes");
}

function OT_OpenUpFile(fileMode,fileFormName,fileDir,otherPara){
	var arr = window.open(jsPathPart +"usersNewsUpFile.asp?fileMode="+ fileMode +"&fileFormName="+ fileFormName +"&upPath="+ fileDir + otherPara,"","top=250,left=340,width=600,height=300,menubar=no,scrollbars=yes,status=no,resizable=yes");
}


// 检测属性
function CheckAddition(){
	isImgBox = false;
	try {
		if ($id('isHomeThumb').checked){ isImgBox = true; }
	}catch (e) {}
	try {
		if ($id('isThumb').checked){ isImgBox = true; }
	}catch (e) {}
	try {
		if ($id('isImg').checked){ isImgBox = true; }
	}catch (e) {}
	try {
		if ($id('isFlash').checked){ isImgBox = true; }
	}catch (e) {}

	try {
		if (isImgBox==true){
			$id('imgBox').style.display="";
		}else{
			$id('imgBox').style.display="none";
		}
	}catch (e) {}
}

// 载入缩略图/图片框
function ToImg(str){
	$id('img').value = str;
	$id('editorImgBox').innerHTML = "";
}

// 获取编辑器图片
function GetEditorImg(){
	selImgStr = "";
	imgPath = $id('infoFileDir').value;
	imgStr = $id('upImgStr').value;
	imgArr = imgStr.split('|');
	for (var i=0; i<imgArr.length; i++){
		if (imgArr[i]!=""){
			if (imgArr[i].substr(0,6)!="thumb_"){
				selImgStr += "<div id='edImg"+ i +"' style='width:80px; height:80px; border:1px #707070 solid; overflow:hidden; margin:3px; float:left;'><img src='"+ imgPath + imgArr[i] +"' width='80' class='pointer' onclick=\"ToImg('"+ imgArr[i] +"');\" alt='原图' onerror=\"$id('edImg"+ i +"').style.display='none';\" /></div>";
				selImgStr += "<div id='edSmallImg"+ i +"' style='width:50px; height:50px; border:1px #707070 solid; overflow:hidden; margin:3px; float:left;'><img src='"+ imgPath +"thumb_"+ imgArr[i] +"' width='50' class='pointer' onclick=\"ToImg('thumb_"+ imgArr[i] +"');\" alt='缩略图' onerror=\"$id('edSmallImg"+ i +"').style.display='none';\" /></div>";
			}else{
				selImgStr += "<div id='edSmallImg"+ i +"' style='width:50px; height:50px; border:1px #707070 solid; overflow:hidden; margin:3px; float:left;'><img src='"+ imgPath + imgArr[i] +"' width='80' class='pointer' onclick=\"ToImg('"+ imgArr[i] +"');\" alt='缩略图' onerror=\"$id('edSmallImg"+ i +"').style.display='none';\" /></div>";
			}
		}
	}
	if (selImgStr==""){ selImgStr="<span class='font2_2'>编辑器中无图片</span>"; }
	$id('editorImgBox').innerHTML = selImgStr;
}



// 账号绑定-API解除绑定
function CheckApiCancel(str,strCN){
	if (confirm('确定要解除【'+ strCN +'】绑定？')){
		AjaxGetDeal(jsPathPart +"api.asp?mudi=cancel&apiType="+ str);
//		var a=window.open('api.asp?mudi=cancel&apiType='+ str);
	}
}

// 账号绑定-增加绑定
function AddApiUser(str){
	var a=window.open(jsPathPart +"api.asp?mudi=login&dataID=-1&apiType="+ str);
}