﻿
function check_img()
{var o_img=document.getElementById('imgCheck');o_img.src=uc_appPath+"ValidateCode.aspx?&t="+Math.random();}
function CloseUserContributeDlg()
{document.getElementById('UserContributeDlg_Station').style.display='none';document.getElementById('UserContributeDlg_BK').style.display='none';}
function ShowUserContributeDlgInerPage()
{var doc=window.document;$("anchorCloseUserContribute").style.display="none";$("btCloseUserContribute").style.display="none";var bar=doc.getElementById("UserContributeDlg_Station");var divAllBody=doc.getElementById("UserContributeDlg_BK");var barHolder=document.getElementById("UserContributeDlg_Holder");divAllBody.style.display="none";barHolder.style.display="none";bar.style.display="";bar.style.width="503px";bar.style.position="";bar.style.top="0px";bar.style.left="0px";bar.style.backgroundColor="#4583ec";check_img();}
function ShowUserContributeDlg()
{var doc=window.document;var scr=window.screen;var bar=doc.getElementById("UserContributeDlg_Station");var divAllBody=doc.getElementById("UserContributeDlg_BK");var barHolder=document.getElementById("UserContributeDlg_Holder");var isMSIE=(navigator.appName=="Microsoft Internet Explorer");bar.style.position="absolute";bar.style.backgroundColor="#0054E3";bar.style.display="";bar.style.top=((document.documentElement.clientHeight-bar.scrollHeight)/2).toString()+"px";bar.style.left=((scr.width-bar.scrollWidth)/2).toString()+"px";barHolder.style.top=bar.style.top;barHolder.style.left=bar.style.left;barHolder.style.width=bar.scrollWidth;barHolder.style.height=bar.scrollHeight;divAllBody.style.display="";divAllBody.style.top="0px";divAllBody.style.left="0px";if(isMSIE)
{try{divAllBody.style.filter="alpha(opacity=40);"}catch(e){}
try{barHolder.style.filter="alpha(opacity=40);"}catch(e){}}
else
{try{divAllBody.style.MozOpacity=0.5;}catch(e){}
try{barHolder.style.MozOpacity=0;}catch(e){}}
divAllBody.style.width=doc.body.scrollWidth.toString()+"px";if(doc.documentElement.clientHeight>doc.body.scrollHeight)
{divAllBody.style.height=doc.documentElement.clientHeight.toString()+"px";}
else
{divAllBody.style.height=doc.body.scrollHeight.toString()+"px";}
check_img();}
var PARAM_CATV="CatV";var PARAM_CATT="CatT";var PARAM_WORDS="Words";var PARAM_COMM="Comm";var PARAM_CHECK="CheckNum";var MAX_WORDS_LEN=50;var MAX_COMM_LEN=200;var CHECK_NUM_LEN=4;function SubmitClick()
{try
{var titlePrompt=uc_titlePrompt;var bodyPrompt=uc_bodyPrompt;var cat=document.getElementById(uc_ddlCategories);var words=document.getElementById("tbWords");var comm=document.getElementById("tbComments");var check=document.getElementById("tbCheckNum");var lbMsg=document.getElementById("lbMsg");if(cat.selectedIndex==0)
{alert("请选择一个类别。");cat.focus();return;}
if(words.value.trim()=="")
{alert("请输入"+titlePrompt+"。");words.focus();return;}
if(words.value.trim().length>MAX_WORDS_LEN)
{alert(titlePrompt+"的长度请控制在"+MAX_WORDS_LEN+"以内。");words.focus();words.select();return;}
if(comm.value.trim()=="")
{alert("请输入"+bodyPrompt+"。");comm.focus();return;}
if(comm.value.trim().length>MAX_COMM_LEN)
{alert(bodyPrompt+"的长度请控制在"+MAX_COMM_LEN+"以内。");comm.focus();comm.select();return;}
if(check.value.trim()=="")
{alert("请输入验证码。");check.focus();return;}
if(check.value.trim().length!=CHECK_NUM_LEN)
{alert("验证码的长度应该为"+CHECK_NUM_LEN+"个字符。");check.focus();check.select();return;}
if(CheckWhetherOrNotAdded(words.value.trim()))
{alert("该项您已经提交过了，请不要重复提交。");words.value="";return;}
var url=uc_appPath+"AJAXService/AddUserContribution.aspx?";url+=PARAM_CATV+"="+escape(cat.options[cat.selectedIndex].value);url+="&"+PARAM_CATT+"="+escape(cat.options[cat.selectedIndex].text);url+="&"+PARAM_WORDS+"="+escape(words.value.trim());url+="&"+PARAM_COMM+"="+escape(comm.value.trim());url+="&"+PARAM_CHECK+"="+escape(check.value.trim());var xmlHttp=GetXmlHttpObject();lbMsg.innerHTML="提交中，请稍后...";var result=SynSendXmlHttpRequest(xmlHttp,url);switch(result)
{case"-1":alert("参数输入不全，请重新输入。");break;case"0":alert("验证码错误，请重新输入。");check_img();break;case"1":alert("提交成功，我们一定会认真阅读并持续改进，谢谢。\r\n如果您还想继续添加，直接输入提交即可。");lbMsg.innerHTML="提交成功，谢谢。";LogToCookie(words.value.trim());words.value="";comm.value="";check.value="";words.focus();check_img();break;default:alert("有错误发生，请稍后再试。\r\n注意：不要提交任何带有HTML标记的文字。");break;}
lbMsg.innerHTML="";}
catch(e)
{alert("有错误发生，请稍后再试。");lbMsg.innerHTML="";}}
function LogToCookie(words)
{try
{var old=GetCookie(PARAM_WORDS);var newOne="";if(old!=null&&old.trim()!="")
{newOne=old+words+"|"}
else
{newOne="|"+old+"|";}
SetCookie(PARAM_WORDS,newOne);}
catch(e)
{}}
function CheckWhetherOrNotAdded(words)
{try
{var old=GetCookie(PARAM_WORDS);if(old==null||old.trim()==""||old.indexOf("|"+words+"|")==-1)
{return false;}
else
{return true;}}
catch(e)
{}}
