﻿// JScript 文件
//绘制隐藏IFRAME和隐藏表单。用于模拟AJAX后台提交数据

var $ = function(id) { var o = document.getElementById(id); if (o == null) o = document.getElementById("ctl00_ContentPlaceHolder2_" + id); return o; };
var $all = function(id) { var o = document.all(id); if (!o) o = $(id); return o; };
var $s=function(id){return $(id).style;};
var $v=function(id){return $(id).value;};

//获取控件在网页中绝对定位
function ObjLocation(e){
var left=0,top=0;
this.w=e.offsetWidth;
this.h=e.offsetHeight;

	while (e.offsetParent){
		left += e.offsetLeft;
		top  += e.offsetTop;
		e     = e.offsetParent;
	}
this.x=left;
this.y=top;

return this;
}
var $p=ObjLocation;


with(document){
  //自动提示层
  write("<iframe id=\"MessageFrame\" name=\"MessageFrame\" src=\"\" style=\"position: absolute;	z-index: 100;border-style:solid; border-color:Gray; border-width:1px;visibility:hidden \" frameborder=\"0\" marginwidth=\"1\" marginheight=\"1\" ></iframe>");

  ///用于后台提交数据的隐藏AjaxFrame
  write("<iframe id=\"AjaxFrame\" name=\"AjaxFrame\" src=\"about:blank\" style=\"display:none;width:98%;height:500px\"></iframe>");

  ///用于提交数据的隐藏表单AjaxForm
  write("<form id='AjaxForm' name='AjaxForm' target='AjaxFrame' method='post'><input type='hidden' id='EventArgs' name='EventArgs' /></form>");

  ///用于全屏背景层，挡住对话框后面的控件使用
  write("<iframe  src=\"about:blank\" name=\"MessageBG\" id=\"MessageBoxBG\"  style=\"position: absolute;visibility:hidden;left: -1px;	width: 100%;top: -2px;height:100%;	z-index: 99;filter: Alpha(Opacity=80);\"></iframe>");
  ///用于弹出的对话框层
  write("<table id=\"pup-Box\" class=\"pup-box\" style=\"position: absolute;visibility: hidden;width: 500px;z-index: 1000;\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\">");
  write("<tr class=bg onselectstart=\"return false\" style=\"CURSOR: move; HEIGHT: 14px\">");
 write("<td class=bg onselectstart=\"return false\" ><span id=\"pup-MyTitle\" class=\"window\" >JOBHA.COM网站对话框</span></td> ");
 write("<td class=bg style=\"width: 4%\"><img class=\"close\" onclick=CancelMessage() src=\"../images/spacer.gif\"></td></tr> ");
  write("<tr> <td colspan=\"2\" class=pub_text2 id=\"pup-MyMessage\" >信息内容</td></tr>");
 write("<tr> <td colspan=\"2\" class=input2><INPUT class=pup-button id=\"pup-OK\" style=\"DISPLAY: none\" onclick=OkMessage() type=button value=确定> ");
write("<INPUT class=pup-button id=\"pup-Cancel\" style=\"DISPLAY: none\" onclick=CancelMessage() type=button value=取消> ");
write("<iframe id=\"pup-bg\" class=\"iframe_bg\" frameborder=\"0\" marginwidth=\"1\" marginheight=\"1\"></iframe></td></tr></table>");
}


function GoHiddenUrl(url){
$("AjaxFrame").src=url;
}

var AjaxForm=$('AjaxForm');
var OkCommand="";
var CancelCommand="";
var Body=document.body;
var MessageBoxBG=$("MessageBoxBG");
var MyBox=$("pup-Box");
var MyTitle=$("pup-MyTitle");
var MyMessage=$("pup-MyMessage");
var MyBtOk=$("pup-OK");
var MyBtCancel=$("pup-Cancel");
var point=new Array(0,0);
var IsMoving;




///显示随鼠标定位的小消息
function TipMessage(mobj,msg,titile,left,top){
var L=new ObjLocation(mobj);
L.x=(left!=undefined)?L.x+left:L.x+mobj.offsetWidth;
L.y=(top!=undefined)?L.y+top:L.y+mobj.offsetHeight;

SetMoveEvent();
MyMessage.innerHTML=msg;
if(titile!=undefined)MyTitle.innerText=titile;
else MyTitle.innerText="JOBHA.COM网站对话框";

MyBox.style.left=L.x;
MyBox.style.top=L.y;
MyBtOk.style.display=MyBtCancel.style.display="none";
ShowBox();
MyBox.onblur=CloseMessage;
}

///显示对话框和背景拦截IFRAME
function ShowBox(){
MyBox.style.visibility="visible";
$s("pup-bg").left=1;
$s("pup-bg").top=1;
$s("pup-bg").height=MyBox.offsetHeight-3;
$s("pup-bg").width=MyBox.offsetWidth-3;
//$s("pup-bg").display="none";
if(MyBtOk.style.display!="none")MyBtOk.focus();
}


///显示随指定对象定位的小消息
function TipMessage2(msg,titile,left,top){
SetMoveEvent();
MyMessage.innerHTML=msg;
if(titile!=undefined)MyTitle.innerText=titile;
else MyTitle.innerText="JOBHA.COM网站对话框";

MyBox.style.left=left;
MyBox.style.top=top+20;
MyBtOk.style.display=MyBtCancel.style.display="none";
ShowBox();
}

///显示对话框
function ShowMessage(msg,titile,dialog,OkCom,CancelCom){
MyTitle.innerText=(titile!=undefined)?titile:" JOBHA.COM网站对话框";
SetMoveEvent();
MyMessage.innerHTML=msg;


//设置满屏屏蔽底层
MessageBoxBG.style.left=0;
MessageBoxBG.style.top=0;
MessageBoxBG.style.height=Body.scrollHeight; 
//MessageBoxBG.style.height="100%";
MessageBoxBG.style.width=Body.scrollWidth;



MyBox.style.visibility="visible";
MessageBoxBG.style.visibility="visible";
var left=Body.scrollLeft+Body.clientWidth/2-MyBox.style.posWidth/2;
var top=Body.scrollTop+Body.clientHeight/2-MyBox.clientHeight/2;
if(left<1) left=1;
if(top<1) top=1;

MyBox.style.left=left;
MyBox.style.top=top;



if(dialog==undefined||dialog==1)
{
MyBtOk.style.display="";
MyBtCancel.style.display="none";
}
else if(dialog==2){
MyBtOk.style.display="none";
MyBtCancel.style.display="";
}
else if(dialog==0){
MyBtOk.style.display="";
MyBtCancel.style.display="";
}
else{
MyBtOk.style.display="none";
MyBtCancel.style.display="none";
}

if(OkCommand==undefined)OkCommand='';
else OkCommand=OkCom;

if(CancelCom==undefined)CancelCommand='';
else CancelCommand=CancelCom;

ShowBox();
MyBox.onblur=null;
}

///关闭消息框
function CloseMessage(){
MessageBoxBG.style.visibility=MyBox.style.visibility="hidden";
}

///对话框按取消后的事件
function CancelMessage(){
CloseMessage();eval(CancelCommand);

}

///对话框按确定后的事件
function OkMessage(){
CloseMessage();
eval(OkCommand);
}


///初始化移动对话框。记录初始位置
function InitMoveMessage(){
var p=$p(MyBox);
point[0]=document.documentElement.scrollLeft+event.x-p.x;
point[1]=document.documentElement.scrollTop+event.y-p.y;
IsMoving=true;
//IsMoving=setInterval("MoveMessage()",500);

}



///移动对话框(如果有背景层，也需要处理鼠标移动事件，否则在鼠标移到背景层将失效)
function MoveMessage(myevent){
if(!IsMoving)return;
if(myevent.button==1){
MyBox.style.left=document.documentElement.scrollLeft+myevent.clientX-point[0];
if(event==undefined)
MyBox.style.top=myevent.offsetY;//-document.documentElement.scrollTop-point[1];
else
MyBox.style.top=document.documentElement.scrollTop+myevent.clientY-point[1];
}
}


///停止移动
function StopMoveMessage(){
IsMoving=false;
}

///设置鼠标移动标题框事件
function SetMoveEvent(){
MyTitle.onmousedown=InitMoveMessage;
document.onmouseup=MessageBG.document.onmouseup=StopMoveMessage;
MessageBG.document.onmousemove=function(){MoveMessage(MessageBG.event);}
document.onmousemove=function(){MoveMessage(event);}
//document.onmousemove=function(){if(IsMoving){MyBox.style.left=document.documentElement.scrollLeft+event.x-point[0];}}
window.onresize =function(){MessageBoxBG.style.height=Body.scrollHeight;MessageBoxBG.style.width=Body.scrollWidth;}

}



///设置按OK按钮跳转URL
function SetOkUrl(url){
OkCommand="document.location.href='"+url+"';";
}

///设置按取消按钮跳转URL
function SetCancelUrl(url){
CancelCommand="document.location.href='"+url+"';";
}

//===========================================ASP.NET表单处理===========

var FormData=function(){
this.target="";
this;action="";
this.method="";
return this;
}
var NeedBack=true;
var IsChangForm=false;



var theForm;
Body.onload=SaveTheForm;

function SaveTheForm(){
if (!theForm) theForm = document.forms['aspnetForm'];
if (!theForm) theForm = document.aspnetForm;
if (!theForm) theForm = aspnetForm;
if (theForm){
FormData.action=theForm.action;
FormData.target=theForm.target;
FormData.method=theForm.method;
theForm.onsubmit=ReadForm;

}


}

//读取FORM方式
function ReadForm(){
if(!IsChangForm)ResetForm();
else IsChangForm=false;
}

//改变FORM方式
function ChangeForm(target,action,method){
IsChangForm=true;
if(target!=undefined)theForm.target=target;
if(action!=undefined)theForm.action=action;
if(method!=undefined)theForm.method=method;
}

///恢复默认Form
function ResetForm(){
theForm.action=FormData.action;
theForm.target=FormData.target;
theForm.method=FormData.method;
}
//=========================================================================


//====================================以下用于全选功能=================================================================
//全选按钮事件
//me:全选按钮本身
//CBox:绑定的列表ID名称
function CheckAll(me, Cbox) {
    theForm = document.forms['aspnetForm'];
Cbox=theForm.all[Cbox];
if(Cbox== undefined)return;
var Checked=me.checked;
if(Cbox.length== undefined){
Cbox.checked=Checked;
}
else{ 
for(i=0;i<Cbox.length;i++) Cbox[i].checked=Checked;  
}}

///获取选中项的ID项集合
function GetCheckedID(Cbox) {
    theForm = document.forms['aspnetForm'];
var IDS="";
Cbox=theForm.all[Cbox];
if(Cbox== undefined)return '';
if(Cbox.length== undefined)return Cbox.value;
else{ 
for(i=0;i<Cbox.length;i++){if(Cbox[i].checked)IDS+=Cbox[i].value+",";} 
}
if(IDS!="")IDS=IDS.substr(0,IDS.length-1);
return IDS;
}
//========================================================================================================


///============================以下操作列表鼠标移入行效果=================================================
var GridView1;
var ShowTrInfo=true;//是否显示行内隐藏的浮动消息

function ShowHiddenInfo(img,title){
if(title==undefined||title=="")title="网站浮动消息框";
var r=img.parentNode.parentNode.all["HiddenInfo"];
if(r==undefined||!ShowTrInfo)return;
TipMessage(img,r.innerHTML,title);
}

function TrOnMouseOver(me){
me.className="bg";
}

function TrOnMouseLeave(me){
me.className="";
//MessageBoxBG.style.display=MyBox.style.display="none";
}
///对表中的行（标题行除外）设置移入移出效果函数名。
function TableMouse(id){

GridView1=document.all[id];

if(GridView1!=undefined){

if(GridView1.rows.length<2)return;
var i=0;
for(i=1;i<GridView1.rows.length ;i++){
eval("GridView1.rows["+i+"].onmouseover=function(){TrOnMouseOver(GridView1.rows["+i+"]);}");
eval("GridView1.rows["+i+"].onmouseleave=function(){TrOnMouseLeave(GridView1.rows["+i+"]);}");
}
}
}
//==============================================================================


//======================================以下用于输入框输入检测=============================
function OnlyNumber(the) 
   {
     var startkey=48;
     if(the.value=="")startkey=48;//若希望第一位不为0  这里可改为49
     if(event.keyCode<startkey||event.keyCode>57)event.returnValue=false;
	 else event.returnValue=true;
   }
   
   
//======================================以上是输入框输入检测代码=========================================
var InputObj;
//获取元素的纵坐标
function getTop(e){
var offset=e.offsetTop;
if(e.offsetParent!=null) offset+=getTop(e.offsetParent);
return offset;
}
//获取元素的横坐标
function getLeft(e){
var offset=e.offsetLeft;
if(e.offsetParent!=null) offset+=getLeft(e.offsetParent);
return offset;
}

//赋值
function setInputValue(value){
if(InputObj){
InputObj.value=value;InputObj.focus();
if(mFrame)mFrame.style.display="none";
InputObj.form.submit();
}
}

///关键字智能感知
function keypress(me){
InputObj=me;
if(event.keyCode==38)upKeyword();
else if(event.keyCode==40)downKeyword();
setTimeout("keyshow('"+me.value+"')",200);
}

///上移选中的关键字
function upKeyword(){
if(mFrame==null||mFrame.style.display=="none")return;
if(!t)return;
var i=0;
for(i=0;i<t.rows.count;i++)
{
    if(t.rows[i].style.backgroundColor=="gray"){
    if(i>0){t.rows[i].style.backgroundColor="";t.rows[i-1].style.backgroundColor="gray";}
    return;
    }
}
}

///下移选中的关键字
function downKeyword(){
if(mFrame==null||mFrame.style.display=="none")return;
if(!t)return;
var i=0;
for(i=0;i<t.rows.count;i++)
{
    if(t.rows[i].style.backgroundColor=="gray"){
    if(i<t.rows.count-1){t.rows[i].style.backgroundColor="";t.rows[i+1].style.backgroundColor="gray";}
    return;
    }
}
}

function keyfocusout(me){
//setTimeout("mFrame.style.display='none'",400);
}

var mFrame=null;
var t=null;
///显示智能感知相关关键字列表
function keyshow(oldvalue){
if(InputObj.value=="")
{
if(mFrame!=null)mFrame.style.display="none";
return;
}
KeyList.GetKeywordList(InputObj.value,ShowKeyList); 
}

function ShowKeyList(response){
MessageFrame.document.body.innerHTML=response.value;
t=MessageFrame.document.getElementById("ListTable");
if(!t||t.rows.length<1)
{
if(mFrame!=null)mFrame.style.display="none";
return;
}
if(mFrame==null)
{
mFrame=$("MessageFrame");
}

mFrame.style.left=getLeft(InputObj);
mFrame.style.top=getTop(InputObj)+22;
mFrame.style.width=InputObj.style.width;
mFrame.style.height=t.rows.length*17+20;
mFrame.style.display="block";
}


///在文本框指定光标处插入文本
function insertText(textEl, text)
{
   textEl.focus();document.selection.createRange().text = text; return;
  
         if (textEl.selectionStart || textEl.selectionStart == '0') {
             var startPos = textEl.selectionStart;
             var endPos = textEl.selectionEnd;
             textEl.value = textEl.value.substring(0, startPos)
             + text 
             + textEl.value.substring(endPos, textEl.value.length);
         }
         else {
             textEl.value += text;
         }

}

//====================================短信息=============================
function WriteMsg(Addresser){
var url="../Message/MessageWrite.aspx";
if(Addresser!=undefined)url=url+"?LogAccNo="+Addresser;
window.open(url,"Message","width=550px,height=400px,top=100px,left=220px");
}

function ReadMsg(ID){
var url="../Message/MessageRead.aspx?ID="+ID;
if(location.href.toLowerCase().indexOf("company")>-0)url=url+"&reffer=company";
else url=url+"&reffer=seeker";
window.open(url,"Message","width=550px,height=400px,top=100px,left=220px");
}

//======================================以下Cookie操作==================
///读取Cookie
function getCookie(Key){
var search = Key + "=";
begin = document.cookie.indexOf(search);
if (begin != -1) {
  begin += search.length;
  end = document.cookie.indexOf(";",begin);
  if (end == -1) end = document.cookie.length;
  return unescape(document.cookie.substring(begin,end));
}
 return '';
} 
///写入cookie
function setCookie(name, value,hours)

{

  var expire = "";

  if(hours != null)

  {

    expire = new Date((new Date()).getTime() + hours * 3600000);

    expire = "; expires=" + expire.toGMTString();

  }

  document.cookie = name + "=" + escape(value) + expire+";path=/;domin=.jobha.com;";

}


//======================================以下是CSS样式切换==================

function change_style(CssName,CssNo){
var today = new Date();
var expireDay = new Date();
var msPerMonth = 24*60*60*1000*31;
expireDay.setTime( today.getTime() + msPerMonth );
document.cookie=CssName+"="+CssNo+";" + expireDay.toGMTString();
var href=$(CssName).href;
var i=href.lastIndexOf("/");
$(CssName).href=href.substr(0,i+1)+CssNo+".css";
}

function GetDefaultStyle(CssName,CssNo){
var css=getCookie(CssName);
if(css!="")CssNo=css;
var href=$(CssName).href;
var i=href.lastIndexOf("/");
$(CssName).href=href.substr(0,i+1)+CssNo+".css";
}


///后台访问页面
function GetAjaxUrl(url,msg){
if(msg==undefined||confirm(msg))
$("AjaxFrame").src=url;
}



//=================WebClient.js===========================

var WebClient=function(){
this.version="1.0";
this.Ajax=function(){};

}


//====================选择框===============
///显示地区选择框
function ShowSelectBox(obj) 
{
if(obj.BoxType=="0"){
var iframe="<iframe src='../Company/AreaList.aspx?Source="+obj.id+"&AreaNames="+encodeURIComponent(obj.value)+"' frameborder='0' allowTransparency='true' scrolling='no' width=500px height=400px border='0' align='center' ></iframe>";
ShowMessage(iframe,'选择地区',-1);
}
else if(obj.BoxType=="1"){
var iframe="<iframe src='../Company/StationList.aspx?Source="+obj.id+"&StationNos="+obj.nextSibling.nextSibling.value+"' frameborder='0' allowTransparency='true' scrolling='no' width=500px height=450px border='0' align='center' ></iframe>";
ShowMessage(iframe,'选择岗位',-1);
}
else if(obj.BoxType=="2"){
var iframe="<iframe src='../Company/IndustryList.aspx?Source="+obj.id+"&Nos="+obj.nextSibling.nextSibling.value+"&Type=Industry&BoxLang="+obj.BoxLang+"' frameborder='0' allowTransparency='true' scrolling='no' width=580px height=450px border='0' align='center' ></iframe>";
ShowMessage(iframe,'选择行业',-1);
}

}

///显示岗位选择框
function SelectStation(Station)
{


}