function filter() {};

filter.words = ['法轮功','李洪志','大纪元','真善忍','新唐人','肉棍','淫靡','淫水','六四事件','迷药','迷魂药','窃听器','六合彩','买卖枪支','退党','麻醉药','麻醉乙醚','短信群发器','帝国之梦','毛一鲜','黎阳评','色情服务','对日强硬','出售枪支','迷药','摇头丸','西藏天葬','鬼村','军长发威','PK黑社会','恶搞晚会','枪决女犯','投毒杀人','强硬发言','出售假币','监听王','昏药','侦探社北','麻醉钢枪','反华','官商勾结','升达毕业证','手机复制','戴海静','自杀手册','自杀指南','张小平','佳静安定片','蒙汗药粉','古方米香','强效失意药','东方迷魂','迷歼药','透视眼镜','远程偷拍','自制手枪','子女任职名单','激情小电影','黄色小电影','色情小电影','天鹅之旅','盘古乐队','高校暴乱','高校群体事件','大学骚乱','高校骚乱','催情药','扫肩神药','春药','窃听器材','身份证生成器','枪决现场','出售手枪','麻醉枪','办理证件','办理文凭','疆独','藏独','高干子弟','高干子女','枪支弹药','血腥图片','反政府','禁书','无界浏览器','无界','特码','自由门','反共','共产党','中共中央','成人片','成人电影','换妻','三级片'];

filter.filterWord = function(str)
{
	var len = filter.words.length;
	
	var beBreak = false;
	var word = "";
	
	for (var i = 0; i < len; i++)
	{
		if(str.indexOf(filter.words[i]) > -1)
		{
			word = filter.words[i];
			beBreak = true;
			break;
		}
	}
	
	if(beBreak)
	{
		alert("含有非法关键字“"+word+"”");
		
		return false;
	}
	
	return true;
}

//community

function community() {}

community.isLogin = false;

community.GPPLWin = null;
community.GPTJWin = null;
community.JRKPWin = null;
community.ZJZXWin = null;
community.currentStock = null;

community.showGPPL = function()
{
	if(!community.isLogin)
	{
		alert("游客您好，请您登陆或注册后操作。");
		return false;
	}
	
	var ZQDM = "";
	
	if(community.currentStock != null)
		ZQDM = community.currentStock.ZQDM;
	
	var msg = "<br><form METHOD=POST name='GPPLForm' onsubmit='return community.submitGPPL(this)'><INPUT TYPE='hidden' name='qzaction' value='publishComment'><INPUT TYPE='hidden' name='toJSON' value='true'><table width='100%'><tr ><td width='30%' align='right'>股票代码：</td><td width='70%'><input type='text' name='zqdm' value='"+ZQDM+"' id='zqdm' ></td></tr><tr><td width='30%' align='right'>股票评论：</td><td width='70%'><textarea name='content' ROWS=10 COLS=45></textarea></td></tr><tr><td  colspan='2' align='center'><input type='submit' name='submit' value='提交'>&nbsp;<input type='reset' name='reset' value='重置'></td></tr></table></form>";
	
	var obj = community.getDivShowPosition(window.event, 400,260,370,200);
	
	community.GPPLWin = new xWin(400,260,obj.l,obj.t,"股票评论",msg);
	
	return false;
}

community.showGPTJ = function()
{
	if(!community.isLogin)
	{
		alert("游客您好，请您登陆或注册后操作。");
		return false;
	}
	
	var ZQDM = "";
	
	if(community.currentStock != null)
		ZQDM = community.currentStock.ZQDM;
	
	var msg = "<br><form METHOD=POST  name='GPTJForm' onsubmit='return community.submitGPTJ(this)'><INPUT TYPE='hidden' name='qzaction' value='publishRecommend'><INPUT TYPE='hidden' name='toJSON' value='true'><table width='100%'><tr><td width='30%' align='right'>&nbsp;&nbsp; 股&nbsp;票&nbsp;代&nbsp;码：</td><td width='70%'><input type='text' name='zqdm' value='"+ZQDM+"' id='zqdm'></td></tr><td width='30%' align='right'>股票推荐级别：</td><td width='70%'><SELECT NAME='level'><OPTION VALUE='0' SELECTED>一般推荐<OPTION VALUE='1'>强烈推荐</SELECT></td></tr><tr><td width='30%' align='right'>股票推荐理由：</td><td width='70%'><textarea name='description' ROWS=10 COLS=45></textarea></td></tr><tr><td  colspan='2' align='center'><input type='submit' name='submit' value='提交'>&nbsp;<input type='reset' name='reset' value='重置'></td></tr></table></form>";
	
	var obj = community.getDivShowPosition(window.event, 400,260,370,200);
	
	community.GPTJWin = new xWin(400,260,obj.l,obj.t,"股票推荐",msg);
	
	return false;
}

community.showJRKP = function()
{
	if(!community.isLogin)
	{
		alert("游客您好，请您登陆或注册后操作。");
		return false;
	}
	
	var ZQDM = "";
	
	if(community.currentStock != null)
		ZQDM = community.currentStock.ZQDM;
	
	var msg = "<br><form METHOD=POST name='JRKPForm'  onSubmit='return community.submitJRKP(this)'><INPUT TYPE='hidden' name='qzaction' value='publishForecast'><INPUT TYPE='hidden' name='toJSON' value='true'><table><tr><td>股票代码：</td><td><input type='text' name='zqdm' value='"+ZQDM+"' id='zqdm'></td></tr><tr><td>预测趋势：</td><td><INPUT TYPE='radio' NAME='yclb' value='1' checked='checked'>看涨<INPUT TYPE='radio' NAME='yclb' value='2'>看跌</td></tr><tr><td>下注 ：</td><td><input type='text' name='money'> 金币</td></tr><tr><td  colspan='2' align='center'><input type='submit' name='submit' value='预测'>&nbsp;<input type='reset' name='reset' value='重置'></td></tr></table></form>";
	
	var obj = community.getDivShowPosition(window.event, 400,260,370,200);
	
	community.JRKPWin = new xWin(400,260,obj.l,obj.t,"今日看盘",msg);
	
	return false;
}

community.showZJZX = function()
{
	Ajax.sendGetRequest ("/community/communityAction.jsp?qzaction=getJSONForFXS", true, "community.callBackShowZJZX(ME.http_request.responseText)");
	return false;
}

community.callBackShowZJZX = function (responseText)
{
	var resObj = {};
	
	try{
		resObj = eval ("("+responseText+")");
	}catch(e) {}
	
	if(resObj.is_OK)
	{
		community.ZJZXWin = null;
		var fxslist = resObj.fxslist;
		
		if(!community.isLogin)
		{
			alert("游客您好，请您登陆或注册后操作。");
			return false;
		}
		
		var ZQDM = "";
		
		if(community.currentStock != null)
			ZQDM = community.currentStock.ZQDM;
		
		var arr = [];
		
		arr[arr.length] = "<br><form METHOD=POST  name='ZJZXForm' onSubmit='return community.submitZJZX(this)'>";
		arr[arr.length] = "<INPUT TYPE='hidden' name='qzaction' value='publishConsult'><INPUT TYPE='hidden' name='toJSON' value='true'>";
		arr[arr.length] = "<table width='100%'><tr><td align='right' width='30%'>股票代码：</td><td width='70%'><input type='text' name='zqdm' value='"+ZQDM+"' id='zqdm' maxlength=6></td></tr>";
		arr[arr.length] = "<tr><td align='right' width='30%'>分析师  ：</td><td width='70%'>";
		arr[arr.length] = "<select name='fxs_id'><option value=''>请选择分析师</option>";
		
		for(var i = 0; i < fxslist.length; i++)
		{
			arr[arr.length] = "<option value='"+fxslist[i].id+"'>"+fxslist[i].name+"</option>";
		}
		
		arr[arr.length] = "</select></td></tr>";
		arr[arr.length] = "<tr><td align='right' width='30%'>股民咨询：</td><td width='70%'><textarea name='ask' ROWS=10 COLS=45></textarea></td></tr>";
		arr[arr.length] = "<tr><td  colspan='2' align='center'><input type='submit' name='submit' value='提交'>&nbsp;<input type='reset' name='reset' value='重置'></td></tr></table></form>";
		
		var obj = community.getDivShowPosition(window.event, 400,260,200,230);
		
		community.ZJZXWin = new xWin(400,260,obj.l,obj.t,"股票咨询",arr.join(""));
		
		document.forms["ZJZXForm"].zqdm.focus();
	}
	else
	{
		if(resObj.message)
			alert(resObj.message);
	}
}

community.showZJReply = function(askID)
{
	var ZQDM = "";
	
	if(community.currentStock != null)
		ZQDM = community.currentStock.ZQDM;
	
	var msg = "<br><table width='100%'>"
					+ "<form METHOD=POST  name='ZJReplyForm' onSubmit='return community.submitZJReply(this)'>"
					+ "<INPUT TYPE='hidden' name='qzaction' value='publishConsultAnswer'>"
					+ "<INPUT TYPE='hidden' name='toJSON' value='true'>"
					+ "<INPUT TYPE='hidden' name='tebonconsult_seqno' value='"+askID+"'>"
					+ "<tr><td align='right' width='30%'>股民咨询：</td>"
					+ "<td width='70%'><textarea name='answer' ROWS=10 COLS=45></textarea></td>"
					+ "</tr><tr>"
					+ "<td colspan='2' align='center'><input type='submit' name='submit' value='提交'>&nbsp;<input type='reset' name='reset' value='重置'></td>"
					+ "</tr></form></table>";
	
	var obj = community.getDivShowPosition(window.event, 400,260,400,200);
	
	community.ZJReplyWin = new xWin(400,260,obj.l,obj.t,"专家答疑",msg);
	
	return false;
}

community.showSimTradeBuy = function(ZQDM)
{
	fileList = new Array();
	
	if(ZQDM == null)
		ZQDM = "";
	
	var msg =  "<br>";
			msg += "<table width='100%' cellpadding=0 cellspacing=0>";
			msg += "<form METHOD=POST name='SimTradeForm' onSubmit='return false;'>";
			msg += "<INPUT TYPE='hidden' name='qzaction' value='SimTradeBuy'>";
			msg += "<INPUT TYPE='hidden' name='toJSON' value='true'>";
			msg += "<INPUT TYPE='hidden' name='appendixURL' value=''>";
			msg += "<tr><td align='right' width='30%'>买卖方向：</td><td width='70%'>买入</td></tr>";
			msg += "<tr><td align='right' width='30%'>股票代码：</td><td width='70%'><input type='text' name='zqdm' value='"+ZQDM+"' id='zqdm'></td></tr>";
			msg += "<tr><td align='right' width='30%'>买入理由：</td><td width='70%'><textarea name='content' ROWS=10 COLS=45></textarea></td></tr>";
			msg += "</form><tr><td align='right' width='30%'>相关附件：</td><td width='70%'>";
			msg += "<iframe id='uploadFrame' name='uploadFrame' style='display:none;'></iframe>";
			msg += "<form method='post' name='uploadForm' action='do_upload.jsp' onsubmit='return uploadCheck()' enctype='multipart/form-data' target='uploadFrame'>";
			msg += "<div id='filesTD'><div id='file1Div'>附件1:<input type='file' id='file1' name='file1' size='40' onchange='autoAddFile()'></div></div>";
			msg += "<div align='right'><input type='submit' name='Submit' value='上传附件'>&nbsp;&nbsp;&nbsp;&nbsp;</div>";
			msg += "</form>";
			msg += "</td></tr>";
			msg += "<tr><td  colspan='2' align='center'><input type='button' name='submitButton' value='提交' onclick='submitSimTrade()'>&nbsp;<input type='reset' name='reset' value='重置'></td></tr>";
			msg += "</table>";
	
	var obj = community.getDivShowPosition(window.event, 500,320,240,180);
	
	community.SimTradeWin = new xWin(500,320,obj.l,obj.t,"模拟股票买入",msg);
	
	return false;
}

community.showSimTradeSell = function(seqno,ZQDM)
{
	fileList = new Array;
	
	if(ZQDM == null)
		ZQDM = "";
	
	var msg =  "<br>";
			msg += "<table width='100%' cellpadding=0 cellspacing=0>";
			msg += "<form METHOD=POST name='SimTradeForm' onSubmit='return false;'>";
			msg += "<INPUT TYPE='hidden' name='qzaction' value='SimTradeSell'>";
			msg += "<INPUT TYPE='hidden' name='toJSON' value='true'>";
			msg += "<INPUT TYPE='hidden' name='seqno' value='"+seqno+"'>";
			msg += "<INPUT TYPE='hidden' name='appendixURL' value=''>";
			msg += "<tr><td align='right' width='30%'>买卖方向：</td><td width='70%'>卖出</td></tr>";
			msg += "<tr><td align='right' width='30%'>股票代码：</td><td width='70%'><input type='text' name='zqdm' value='"+ZQDM+"' id='zqdm' readonly></td></tr>";
			msg += "<tr><td align='right' width='30%'>卖出理由：</td><td width='70%'><textarea name='content' ROWS=10 COLS=45></textarea></td></tr>";
			msg += "</form><tr><td align='right' width='30%'>相关附件：</td><td width='70%'>";
			msg += "<iframe id='uploadFrame' name='uploadFrame' style='display:none;'></iframe>";
			msg += "<form method='post' name='uploadForm' action='do_upload.jsp' onsubmit='return uploadCheck()' enctype='multipart/form-data' target='uploadFrame'>";
			msg += "<div id='filesTD'><div id='file1Div'>附件1:<input type='file' id='file1' name='file1' size='40' onchange='autoAddFile()'></div></div>";
			msg += "<div align='right'><input type='submit' name='Submit' value='上传附件'>&nbsp;&nbsp;&nbsp;&nbsp;</div>";
			msg += "</form>";
			msg += "</td></tr>";
			msg += "<tr><td colspan='2' align='center'><input type='button' name='submitButton' value='提交' onclick='submitSimTrade()'>&nbsp;<input type='reset' name='reset' value='重置'></td></tr>";
			msg += "</table>";
	
	var obj = community.getDivShowPosition(window.event, 500,320,240,180);
	
	community.SimTradeWin = new xWin(500,320,obj.l,obj.t,"模拟股票卖出",msg);
	
	return false;
}

community.showTJLY = function (ZQDM,msg)
{
	var obj = community.getDivShowPosition(window.event, 360,240,240,180);
	
	community.TJLYWin = new xWin(360,240,obj.l,obj.t,"推荐 "+ZQDM+" 的理由","<br><div style='vertical-align:text-top; text-align:left; color:blank;'>&nbsp;&nbsp;&nbsp;&nbsp;"+msg+"</div>");
	
	return false;
}

community.showGPPLInfo = function (ZQDM,msg)
{
	var obj = community.getDivShowPosition(window.event, 360,240,240,180);
	
	community.TJLYWin = new xWin(360,240,obj.l,obj.t,"评论 "+ZQDM+" 的全文","<br><div style='vertical-align:text-top; text-align:left; color:blank;'>&nbsp;&nbsp;&nbsp;&nbsp;"+msg+"</div>");
	
	return false;
}

community.getDivShowPosition = function (events,w,h,t,l)
{
	var obj = {'t':t,'l':l};
	
	if(events != null)
	{
		obj.l = (parseInt(document.body.clientWidth))/2+parseInt(document.body.scrollLeft)-w/2;
		obj.t = parseInt(document.body.scrollTop)+parseInt(events.clientY)-h/2;
		
		var pmbottom = Math.max(0, parseInt(document.body.scrollTop)+parseInt(document.body.clientHeight)-h);
		var pmtop = parseInt(document.body.scrollTop);
		
		if(obj.t > pmbottom)
			obj.t = pmbottom;
		
		if(obj.t < pmtop)
			obj.t = pmtop;
	}
	
	return obj;
}

community.submitGPPL = function (myform)
{
	if(myform.zqdm.value == "")
	{
		alert("请输入证券代码");
		return false;
	}
	
	if(myform.content.value == "")
	{
		alert("请输入评论内容");
		return false;
	}
	else if(!filter.filterWord(myform.content.value))
		return false;
	
	Ajax.sendPostRequest ("communityAction.jsp", myform, true, "community.callBackSubmitGPPL(ME.http_request.responseText)");
	
	return false;
}

community.callBackSubmitGPPL = function (responseText)
{
	var responseObj = null;
	
	try{
		responseObj = eval("("+responseText+")");
	}
	catch(e)
	{
		alert(e.getMessage());
		return false;	
	}
	
	if(responseObj.is_OK == true)
	{
		top.location.reload();
	}
	else
	{
		alert(responseObj.error_message);
	}
}

community.submitGPTJ = function (myform)
{
	if(myform.zqdm.value == "")
	{
		alert("请输入证券代码");
		return false;
	}
	
	if(myform.description.value == "")
	{
		alert("请输入推荐理由");
		return false;
	}
	else if(!filter.filterWord(myform.description.value))
		return false;
	
	Ajax.sendPostRequest ("communityAction.jsp", myform, true, "community.callBackSubmitGPPL(ME.http_request.responseText)");
	
	return false;
}

community.submitJRKP = function (myform)
{
	if(myform.zqdm.value == "")
	{
		alert("请输入证券代码");
		return false;
	}
	
	if(myform.money.value == "")
	{
		alert("请输入预测金额");
		return false;
	}
	else if(isNaN(myform.money.value))
	{
		alert("预测金额格式错误");
		return false;
	}
	
	Ajax.sendPostRequest ("communityAction.jsp", myform, true, "community.callBackSubmitGPPL(ME.http_request.responseText)");
	
	return false;
}

community.submitZJZX = function (myform)
{
	if(myform.zqdm.value == "")
	{
		alert("请输入证券代码");
		return false;
	}
	
	if(myform.fxs_id.value == "")
	{
		alert("请选择财富分析师。");
		return false;
	}
	
	if(myform.ask.value == "")
	{
		alert("请输入咨询内容");
		return false;
	}
	else if(!filter.filterWord(myform.ask.value))
		return false;
	
	Ajax.sendPostRequest ("communityAction.jsp", myform, true, "community.callBackSubmitGPPL(ME.http_request.responseText)");
	
	return false;
}

community.submitZJReply = function(myform)
{
	if(myform.answer.value == "")
	{
		alert("请输入回答内容");
		return false;
	}
	else if(!filter.filterWord(myform.answer.value))
		return false;
	
	Ajax.sendPostRequest ("communityAction.jsp", myform, true, "community.callBackSubmitGPPL(ME.http_request.responseText)");
	
	return false;
}