var dataurl='news/data/325/20';
var ajaxdata=null; 
getData = function(params) {
	var defaults = {
		page: 1,
		stockCode: "",
		title: "",
		ctime: 1,
		orgid: "",
		orders: "1",
		url: "",
		sid: "1",
		ps: 20
	}
	var url = $("#httphost").val();
	var params = $.extend(defaults, params);
	if(params.stockCode=="\u4ee3\u7801/\u540d\u79f0/\u7b80\u62fc")params.stockCode="";
	$("#stockCode").val(params.stockCode);
	$("#title").val(params.title);
	$("#title1").val(encodeURIComponent(params.title));
	$("#ctime").val(params.ctime);
	$("#orders").val(params.orders);
	$("#page").val(params.page);
	if(params.sid==""){alert("\u8bf7\u9009\u62e9\u680f\u76ee");return;}
 	$.ajax({
		type: "get",
		url: httphost+dataurl+"/"+params.page+"/"+params.ctime+"/"+params.orders+"/"+params.stockCode+"?title="+$("#title1").val(),
		dataType: "jsonp",
		success: function(json) {
			if (json.list.length > 0) {
				if (json.page.totalpage > 1) {
					var strFy=[];
			 		strFy[0] = "<input type=\"hidden\" id=\"tp\" value=\""+json.page.totalpage+"\"/><label>\u3010\u5f53\u524d\u7b2c" + json.page.page + "\u9875\u3011</label>";
					strFy[1]="<span onclick='return getData({page:1,stockCode:$(\"#stockCode\").val(),title:$(\"#title\").val(),sid:$(\"#sid\").val(),ctime:$(\"#ctime\").val(),orders:$(\"#orders\").val()})'>\u9996\u9875</span></span><span><span onclick='return getData({page:"+json.page.uppage + ",stockCode:$(\"#stockCode\").val(),title:$(\"#title\").val(),sid:$(\"#sid\").val(),ctime:$(\"#ctime\").val(),orders:$(\"#orders\").val()})'>\u4e0a\u4e00\u9875</span></span><span><span onclick='return getData({page:"+json.page.nextpage + ",stockCode:$(\"#stockCode\").val(),title:$(\"#title\").val(),sid:$(\"#sid\").val(),ctime:$(\"#ctime\").val(),orders:$(\"#orders\").val()})'>\u4e0b\u4e00\u9875</span></span><span><span onclick='return getData({page:"+json.page.totalpage + ",stockCode:$(\"#stockCode\").val(),title:$(\"#title\").val(),sid:$(\"#sid\").val(),ctime:$(\"#ctime\").val(),orders:$(\"#orders\").val()})'>\u672b\u9875</span></span>";
				$("#fenye").html(strFy.join("")).show();
				strFy=null;
				$("#fenye").find("span").bind("mouseover",function(){
					$(this).css("textDecoration","underline");
				});
				$("#fenye").find("span").bind("mouseout",function(){
					$(this).css("textDecoration","none");
				});
				}
				 else {
					$("#fenye").hide();
				}
				var str = "";
				for (var i = 0; i < json.list.length; i++) {
					var cl="odd";
						if(i%2==0){ cl="odd";}else cl="even";
						str += "<tr class=\""+cl+"\" style=\"cursor:pointer;\" tid=\"" + json.list[i].id +"|"+json.list[i].sid+ "\" id=\"t" + json.list[i].glid + "\">";
					str += "<td class=\"time\">" + json.list[i].createtime+ "</td>";
				 	str += "<td class=\"title\">"+json.list[i].title + "</td>";
					str += "</tr>";
					str += "<tr><td style=\"display:none;\" id=\"d" + json.list[i].glid + "\" colspan=\"2\"></td></tr>";
				}
				$("#commonTable").find("tbody").html(str).show();
				if(params.orders==0)$("#sortbytime").removeClass("sort_d").addClass("sort_a");
				else if(params.orders==1)$("#sortbytime").removeClass("sort_a").addClass("sort_d");

				$("#commonTable").find("tbody tr").each(function() { 
					$(this).mouseover(function(){
						$(this).toggleClass("over");
					}); 
					$(this).mouseout(function(){
						$(this).removeClass("over");
					});
				});
				$("#commonTable").find("tbody tr").bind("click",
				function() { 
					wkstock.openUrl(external.getModulePath()+'zgl/zixun/content1.html?tid='+$(this).attr("tid"));
				});
			} else
			 {
				$("#commonTable").find("tbody").html("<tr><td colspan=\"2\" >\u6ca1\u6709\u5173\u4e8e\u76f8\u5173\u4e2a\u80a1\u7684\u8d44\u8baf</td></tr>").show();
				$("#fenye").hide();
			}
		},
		error: function() {
		}
	});
	return false;
}; 
$(function(){  
	wkstock.opentype=1;
	getData();
});