var List_url='Ajax_List.asp';

function PageList(CurrentPage,CountNum,MaxRows,Act,n){
	CountNum=parseInt(CountNum);
	CurrentPage=parseInt(CurrentPage);
	if (CountNum%MaxRows==0){var Pagecount= parseInt(CountNum / MaxRows);}else{var Pagecount = parseInt(CountNum / MaxRows)+1}
	if (Pagecount>CurrentPage+n){var EndPage=parseInt(CurrentPage+n);}else{var EndPage=parseInt(Pagecount);}
	var ShowPage="";
	if (CurrentPage>n+1){ShowPage+='<a href=\"#page=1\" OnClick=\"Javascript:GetContent(1,\''+Act+'\');\" >[1]</a>...';}
	for (var i=CurrentPage-n;i<=EndPage;i++)
		{
			if (i>0)
			{
				if (i==CurrentPage)
				{
					ShowPage+='<font color=Red>['+i+']</font>';
				}else{
					ShowPage+='<a href=\"#page='+i+'\"  OnClick=\"Javascript:GetContent('+i+',\''+Act+'\');\">['+i+']</a>';
				}
			}
		}
	if (Pagecount>CurrentPage+n){ShowPage+='...<a href=\"#page='+Pagecount+'\"  OnClick=\"Javascript:GetContent('+Pagecount+',\''+Act+'\');\">['+Pagecount+']</a>';}
	$('Page').innerHTML=ShowPage;
	//alert(location.hash);
}

function GetPage(){
    var strHref = window.document.location.href;
	var intPos = strHref.indexOf("#");
	var Page;
	if(intPos != -1)
	{
	  var strRight = strHref.substr(intPos + 1);
	  var arrTmp = strRight.split("#");
	  var strName = "page";
	  var strUrl = strHref.substr(0,intPos+1);
	  for(var i = 0; i < arrTmp.length; i++)
	  {
	     var arrTemp = arrTmp[i].split("=");
	     if(arrTemp[0].toUpperCase() == strName.toUpperCase())
		 {
		   Page=arrTemp[1];
		 }
	  }
	}
	else
	{
		Page="1";
	}
	return Page;
}

function Reload(Act){
	var page=GetPage();
	GetContent(page,Act);
}

function GetContent(Page,Act){
	$('Page').innerHTML='&nbsp;';
	var pars='Action='+Act+'&Page='+Page;
	var myAjax = new Ajax.Updater('Content',List_url,{method:"post",evalScripts:true,parameters:pars,onFailure:AjaxFailed});
}

function AjaxComplete(request){
	var response = request.responseText;
	alert(response);
}

function AjaxFailed(){
	alert('出现错误，请联系管理员解决！');
}

function Vote(){
	var pars='Action=poll&'+Form.serialize('vote')
	//alert(pars);
	var myAjax = new Ajax.Request('vote.asp', {method:'post', postBody:pars, onSuccess:AjaxComplete,onFailure:AjaxFailed});
}

function GetVote(){
	var WinWidth=595;
	var WinHeight=355;
	var WinLeft = (screen.width-WinWidth)/2;
	var WinTop = (screen.height-WinHeight)/2;
	var newWindow = window.open('vote.asp?Action=view&VoteID='+$F('VoteID'),'vote','resizable=0,scrollbars=0, status=0, toolbar=0, menubar=0,width='+WinWidth+',height='+WinHeight+',left='+WinLeft+',top='+WinTop);
	newWindow.focus();
}

function OpenJob(JobID){
	var WinWidth=screen.width;
	var WinHeight=screen.height;
	var JobWin = window.open('resume.asp?JobID='+JobID,'Job','resizable=1,scrollbars=1, status=0, toolbar=0, menubar=0,width='+WinWidth+',height='+WinHeight+',left=0,top=0');
	JobWin.focus();
}

function PostJob(JobID){
	var pars='Action=submit&JobID='+JobID+'&name='+encodeURIComponent(encodeurl($F('name')))+'&sex='+encodeURIComponent(encodeurl($F('sex')))+'&birthday='+$F('birthday')+'&idcard='+$F('idcard')+'&province='+encodeURIComponent(encodeurl($F('province')))+'&marriage='+encodeURIComponent(encodeurl($F('marriage')))+'&email='+$F('email')+'&tel='+$F('tel')+'&address='+encodeURIComponent(encodeurl($F('address')))+'&xueli='+encodeURIComponent(encodeurl($F('xueli')))+'&school='+encodeURIComponent(encodeurl($F('school')))+'&profession='+encodeURIComponent(encodeurl($F('profession')))+'&paynow='+encodeURIComponent(encodeurl($F('paynow')))+'&payhope='+encodeURIComponent(encodeurl($F('payhope')))+'&jobdate='+$F('jobdate')+'&zhichen='+encodeURIComponent(encodeurl($F('zhichen')))+'&resumes='+encodeURIComponent(encodeurl($F('resume')))+'&content='+encodeURIComponent(encodeurl($F('content')))
	//alert($F('province'));
	var myAjax = new Ajax.Request('resume.asp', {method:'post', postBody:pars, onSuccess:JobComplete,onFailure:AjaxFailed});
}

function JobComplete(request){
	var response = request.responseText;
	alert(response);
	this.close();
	//Form.Element.setValue('content',response);
}

function encodeurl(text){
	text = text.toString();
	var matches = text.match(/[\x90-\xFF]/g);
	if (matches)
	{
		for (var matchid = 0; matchid < matches.length; matchid++)
		{
			var char_code = matches[matchid].charCodeAt(0);
			text = text.replace(matches[matchid], '%u00' + (char_code & 0xFF).toString(16).toUpperCase());
		}
	}
	return escape(text).replace(/\+/g, "%2B");
}

function ajaxcheck(){
	var pars='U_Name='+encodeURIComponent(encodeurl($F('U_Name')));
	var myAjax = new Ajax.Updater('username','check.asp',{method:"post",parameters:pars});
}

function Show(url){
	var memberwin = window.open(url,'memberwin','resizable=1,scrollbars=1, status=0, toolbar=0, menubar=0,width=500,height=400,left=0,top=0');
	memberwin.focus();
}

function PostDataText(url,data){
	var xmlhttp = new ActiveXObject("Msxml2.XMLHTTP"); //创建XMLHTTP对象
	xmlhttp.Open("POST",url, false); 
	xmlhttp.Send(data); //发出指令
	return xmlhttp.responseText;
}

function LogOff(){
	PostDataText("Logoff.asp","");
	document.location.href="index.asp";
}

function resizepic(picname,width_v,height_v,url){
	if(isFirefox=navigator.userAgent.indexOf("Firefox")>0){
		var backw=width_v;
		var backh=height_v;
	}else{
		var backw=width_v+8;
		var backh=height_v+8;
	}
	var i = String(Math.floor(Math.random()*10000)+1);  
	document.writeln("<div style='width:"+backw+"px;height:"+backh+"px;padding:3px;border:1px solid #a1a1a1;backgournd:#fff;'>");
	document.writeln("<div style='width:"+width_v+"px;height:"+height_v+"px;overflow:hidden;'>");
	if (url=="")
	{
		document.writeln("<img src='"+picname+"' id='img"+i+"' border=0/></div></div>");
	}else{
		document.writeln("<a href="+url+" target=\"_blank\"><img src='"+picname+"' id='img"+i+"' border=0/></a></div></div>");
	}
	var pic=document.getElementById("img"+i);
	if((width_v/height_v)>(pic.offsetWidth/pic.offsetHeight)){
		pic.width=width_v;
	}else{
		pic.height=height_v;
	}
}