var cu_page = 1;
var final_page;

$(function(){
		$('#show_jg').html('正在加载......');
		$.ajax({
		timeout:'10000',
		dataType:'html',
		url:'http://www.fxgtj.gov.cn/publish/tddj_result_zs_trouch.php',
		error:function(){
			$('#show_jg').html('连接数据库超时，请重试。');
		},
		success:function(result){
			$('#show_jg').html(result);
		}
		});
		
		$('#showall_bt').click(function(){
		showsimwin("系统信息","加载中，请稍后!","800","600");
		$.ajax({
		timeout:'10000',
		dataType:'html',
		url:'http://www.fxgtj.gov.cn/publish/tddj_result_zs_1.php?page='+cu_page,
		error:function(){
			showsimwin("","连接数据库超时，请重试。","800","600");
		},
		success:function(result){
			showsimwin(title,result,"800","600");
			shownav(cu_page,final_page);
		}
		});										
		});
		$('#djjg_submit').click(function(){
		showsimwin("系统信息","加载中，请稍后!","800","600");
		$.ajax({
		timeout:'10000',
		type:'POST',
		dataType:'html',
		url:'http://www.fxgtj.gov.cn/publish/tddj_result_zs_2.php',
		data:{slbh:$('#slbh_jg').val()},
		error:function(){
			showsimwin("系统信息","连接数据库超时，请重试。","800","600");
		},
		success:function(result){
			showsimwin('查询结果',result,"800","600");
		}
		});									
										
		})
		
})

function showsimwin(title,content,width,height){
	var simwin_html = new String;
	simwin_html = "<div id=\"simwinbg\"></div>";
	simwin_html += "<div id=\"simwin\">";
	simwin_html += "<div id=\"simwin-title\"><h2></h2><span id=\"simwin-close\">关闭</span></div>";
	simwin_html += "<div id=\"simwin-content\"></div>";
	simwin_html += "<div id=\"simwin-control\"></div>";
	simwin_html += "</div>";
	$("body").append(simwin_html);
	$("#simwinbg").css({height:$(document).height(),filter:"alpha(opacity=50)","z-index":"99901"});
	$("#simwin").css({width:width+"px",height:height+"px",filter:"alpha(opacity=90)"});
	$("#simwin-content").css({width:(parseInt(width)-0)+"px",height:(parseInt(height)-60)+"px"});
	$("#simwin-content").html(content);
	$("#simwin-title h2").html(title);
	$("#simwinbg").fadeIn("slow",function(){$(this).show();});
	$("#simwin").fadeIn("slow",function(){$(this).show();});
	var	cw = document.documentElement.clientWidth,ch = document.documentElement.clientHeight,est = document.documentElement.scrollTop; 
	var _version = $.browser.version;
	if ( _version == 6.0 ) {
		$("#simwin").css({left:"50%",top:(parseInt((ch)/2)+est)+"px",marginTop: -((parseInt(height)+53)/2)+"px",marginLeft:-((parseInt(width)+32)/2)+"px",zIndex: "999999"});
	}else {
		$("#simwin").css({left:"50%",top:"50%",marginTop:-((parseInt(height)+53)/2)+"px",marginLeft:-((parseInt(width)+32)/2)+"px",zIndex: "999999"});
	};
	var closeWindown = function() {
		$("#simwinbg").remove();
		$("#simwin").fadeOut("slow",function(){$(this).remove();});
	}
	$("#simwin-close").click(closeWindown);
}

function shownav(cu_page,final_page){
	var navlist = new String;
	navlist = "<div id=\"back\" onclick=\"gotoback(cu_page);\">上一页</div>";
	navlist += "<div id=\"next\" onclick=\"gotonext(cu_page);\">下一页</div>";
	navlist += "<div>跳转到:";
	navlist += "<select id=\"jump\">";
	for(i=1;i<=final_page;i++)
	navlist += "<option value=\""+i+"\">"+i+"</option>";
	navlist += "</select>";
	navlist += "</div>";
	$("#simwin-control").html(navlist);
	if(cu_page==1)	$("#back").hide();
	else $("#back").show();
	if(cu_page == final_page) $("#next").hide();
	else $("#next").show;
	$("#jump").change(function(){
			gotojump($("#jump option:selected").val());
	  })

};
function gotoback(page){
	showsimwin("系统信息","加载中，请稍后!","800","600");
	$.ajax({
		timeout:'10000',
		dataType:'html',
		url:'http://www.fxgtj.gov.cn/publish/tddj_result_zs_1.php?page='+(cu_page=parseInt(page)-1),
		error:function(){
			showsimwin("","连接数据库超时，请重试。","800","600");
		},
		success:function(result){
			showsimwin(title,result,"800","600");
			shownav(cu_page,final_page);
		}
		});	
}
function gotonext(page){
	showsimwin("系统信息","加载中，请稍后!","800","600");
	$.ajax({
		timeout:'10000',
		dataType:'html',
		url:'http://www.fxgtj.gov.cn/publish/tddj_result_zs_1.php?page='+(cu_page=parseInt(page)+1),
		error:function(){
			showsimwin("系统信息","连接数据库超时，请重试。","800","600");
		},
		success:function(result){
			showsimwin(title,result,"800","600");
			shownav(cu_page,final_page);
		}
		});		
}
function gotojump(page){
	showsimwin("系统信息","加载中，请稍后!","800","600");
	$.ajax({
		timeout:'10000',
		dataType:'html',
		url:'http://www.fxgtj.gov.cn/publish/tddj_result_zs_1.php?page='+(cu_page=parseInt(page)),
		error:function(){
			showsimwin("系统信息","连接数据库超时，请重试。","800","600");
		},
		success:function(result){
			showsimwin(title,result,"800","600");
			shownav(cu_page,final_page);
		}
		});		
}
var title = function(){
			$("#simwin-title h2").html("当前显示为2006年至今的登记结果，共计"+$('#sql_count').val()+"条，每页显示"+$('#list_no').val()+"条，当前第"+cu_page+"页，共"+$('#final_page').val()+"页");
			final_page = $('#final_page').val();
}

