function postRss(cid){
var strHour = "",strInterval="";
for(var i=0;i<24;i++){
	if(i==3){
		strHour += "<option value='"+i+"' selected>"+i+"</option>";
	}else{
		strHour += "<option value='"+i+"'>"+i+"</option>";
	}
}
for(var i=1;i<=6;i++){
	if(i==6){
		strInterval += "<option value='"+i*4+"' selected>"+i*4+"</option>";
	}else{
		strInterval += "<option value='"+i*4+"'>"+i*4+"</option>";
	}
}
var rssForm = "<div id='homePopCnt'><form id='rssform' target='postReply'  method='post' action='/actions/addNewRss.jsp' enctype='multipart/form-data'>\
		<input type='hidden' name='cid_2' id='cid' value='"+cid+"'/>\
			<table>\
				<tr>\
					<td width='140px' >您站点/公会的名称：</td>\
					<td align='left'><input type='text' name='rssname' id='rssname'></td>\
				</tr>\
				<tr>\
					<td >您的RSS地址：</td>\
					<td align='left'><input name='rssaddress' id='rssaddress' type='text'></td>\
				</tr>\
				<tr>\
					<td ><input type='radio' id='fillEmail' name='email'>&nbsp;<span class='needEmail'>需要邮件反馈</span></td><td align='left'><input type='text' id='rssemail' name='rssemail' style='display:none;'></td>\
				</tr>\
				<tr>\
					<td >抓取时间设置：</td><td class='capTime' align='left'>每天<select id='catchtime' name='catchtime'>"+strHour+"</select>时，每隔<select id='intervaltime' name='intervaltime'>"+strInterval+"</select>小时。</td>\
				</tr>\
				<tr>\
					<td ><span  id='upLogo'>上传您的LOGO</span></td><td align='left'><input id='rsslogo' type='file' name='rsslogo' style='display:none;'><input name='photoname' type='hidden' id='photoname' value=''></td>\
				</tr>\
				<tr>\
					<td  valign='bottom'>输入验证码：</td>\
					<td align='left'><input type='text' name='ckcode' id='ckcode' size='6' maxlength='6' onfocus='clearMesg(\"ckcodeMsg\")'>&nbsp;<img id='ckimg'  style='visibility:hidden;vertical-align: bottom;'>&nbsp;<a id='chimgA' href='javascript:chimg()' style='visibility:hidden;'>看不清</a>&nbsp;&nbsp;<br><span id='ckcodeMsg' style='color: red;font-weight: bold'></span></td>\
				</tr>\
			</table>\
		</form></div>";
	g_pop=new Popup({ contentType:3, isReloadOnClose:false, width:480, height:300 });
	g_pop.setContent("confirmCon",rssForm);
	g_pop.setContent("callBack",checkRssForm);
	g_pop.setContent("title","提交");
	g_pop.build();
	g_pop.show();
	G("catchtime").style.visibility ="";
	G("intervaltime").style.visibility ="";
	addLogoEmail();
}
function postRssOver(result,flag){
	var info ="";
	switch (result){
		case 0:info="提交成功!";break;
		case -100:info="提交失败!";break;
		case -201:info="验证码错误!";break;
		case -202:info="公会名称不能为空!";break;
		case -203:info="RSS地址不能为空!";break;
		case -204:info="图片大小超过500k!";break;
		case -300:info="网络繁忙，请稍后再提交！";break;
	}
	if(!document.getElementById("homePopCnt") || (result==0 || result==-300)){		
		g_pop=new Popup({ contentType:2, isReloadOnClose:false, width:250, height:80 });
		g_pop.setContent("contentHtml",info);
		g_pop.setContent("title","提示！");
		g_pop.build();
		g_pop.show();
		window.setTimeout("g_pop.close()",1500);
	}else{
		alert(info);
	}
	if(result==0 && flag==0){
		var loc=window.location.href;
		var p=loc.indexOf("#");
		if(p!=-1){
			loc=loc.substring(0,p);
		}
		window.setTimeout("document.location.replace('"+loc+"')",800);
		
	}
}

function addLogoEmail(){
	var fillEmail = G("fillEmail");
	var popEmail = G("rssemail");
	fillEmail.onclick = function(){
		popEmail.style.display = "inline";
	} 
	var upLogo = G("upLogo");
	var logoUpload = G("rsslogo");
	upLogo.onclick = function(){
		logoUpload.style.display = "inline";
		return false;
	} 
}
function checkRssForm(){
	var errorInfo="";
	if (!checkInput(G("ckcode"))) {
		errorInfo ="请输入验证码";
	}
	if (!checkInput(G("rssaddress"))) {
		errorInfo ="请输入RSS地址";
	}
	if (!checkInput(G("rssname"))) {
			errorInfo ="请输入公会名称";
	}
	
	
	if (G("rsslogo").value!=null&&G("rsslogo").value!=""
			&&!(endWith(G("rsslogo").value,".jpg")
				||endWith(G("rsslogo").value,".gif")
				||endWith(G("rsslogo").value,".png")
				||endWith(G("rsslogo").value,".bmp"))) {
			errorInfo ="图片格式不正确";
	}
	if (G("rsslogo").value!=null&&G("rsslogo").value!="") {
			G("photoname").value=G("rsslogo").value;
	}
	if(errorInfo!=""){
		if(document.getElementById("homePopCnt") != null){
			alert(errorInfo);
		}else{
			str="<font color=#e60000>"+errorInfo+"</font>";
			g_pop=new Popup({ contentType:2, isReloadOnClose:false, width:250, height:80 });
			g_pop.setContent("contentHtml",str);
			g_pop.setContent("title","提示！");
			g_pop.build();
			g_pop.show();
		}
		return false;
	}
	if(confirm("提交后不可撤销，信息不可更改，确定要提交吗？")) {
			G("rssform").submit();
		}
}

function checkInput(str,name){
	if(str.value==null || trim(str.value)==""){
		return false;
	}else{
		return true;
	}
}
	//必须为汉字
	
function trim(str){
	  var strl = trimL(str);
	  var strRet = trimR(strl);
	  return strRet;
}
function trimL(str){
	  var nLoop = 0;
	  var strReturn = str;
	  while (nLoop < str.length){
	    if (strReturn.substring(0, 1) == " "){
	      strReturn = str.substring(nLoop + 1, str.length);
	    } else {
	      break;
	    }
	    nLoop++;
	  }
	  return strReturn;
}
	//去掉右侧空格
function trimR(str) {
	  var nLoop = 0;
	  var strReturn = str;
	  while (nLoop < str.length) {
	    if (strReturn.substring(strReturn.length - 1, strReturn.length) == " ") {
	      strReturn = str.substring(0, str.length - (nLoop + 1));
	    } else {
	      break;
	    }
	    nLoop++;
	  }
	  return strReturn;
}
	
function endWith (str1,str2) {
	var reg = "/\."+str2+"$/gi";
	var reg1 = eval(reg);
	return (reg1.test(trim(str1)));
}