// JavaScript Document
//导入导航栏
var xmlHttp; 

function createXMLHttpRequest() { 
    if (window.ActiveXObject) { 
        xmlHttp = new ActiveXObject("Microsoft.XMLHTTP"); 
    }  
    else if (window.XMLHttpRequest) { 
        xmlHttp = new XMLHttpRequest(); 
    } 
} 
     
function startRequest() { 

    createXMLHttpRequest(); 
    xmlHttp.onreadystatechange = handleStateChange; 
	//取得导航数据
    var qurl = "navigator.html"; 
    xmlHttp.open("GET", qurl, true); 
    xmlHttp.send(null); 
    //setTimeout("startRequest()",2000); 
} 
     
function handleStateChange() { 
	var obj = document.getElementById("navigator");
    if(xmlHttp.readyState == 4) { 
        if(xmlHttp.status	== 200) {      	 
		    obj.innerHTML	=	xmlHttp.responseText;
        } else {obj.innerHTML	= "您所要访问的数据不存在！";}
    } else{
		obj.innerHTML	=	"稍后，数据加载中。。。";
		
	}
} 
//导航栏加载完毕！

//导航栏效果
//找到当前所按按钮，并设置其css
function switchTag(num)
{
	var temp = 0;
	// 查看子元素个数
	for(var i in  document.getElementById("titleul").childNodes)
	{
		if(i!="length"){
		i++;
		var tag = "tag"+i;
		var contentli	=	"contentli"+i;
			if(num==i){		
			//是点击的元素
				//设置当前的css,包括content1,hover,selectli1,selectspan1
				//设置title部分
				//设置当前元素（a标签）CSS
				document.getElementById(tag).getElementsByTagName("a")[0].className="selectli1";
				//设置当前元素（span标签）CSS			
				document.getElementById(tag).getElementsByTagName("a")[0].getElementsByTagName("span")[0].className="selectspan1";
				//设置content部分
				document.getElementById(contentli).className="";
							
			}else{
			//不是点击的元素
				document.getElementById(tag).getElementsByTagName("a")[0].className="";
				document.getElementById(tag).getElementsByTagName("a")[0].getElementsByTagName("span")[0].className="";
				document.getElementById(contentli).className="hideli";				
			}
		}
	}

}
//导航栏效果结束！


//取得index级列表  URL注意！
function send_url(url,searchtext) { 


	if(searchtext!=null){
		var search_name  =  document.getElementById(searchtext).value;
		//alert(search_name);
		url	=	url+"&sear="+search_name;
	}
   
    createXMLHttpRequest(); 
    xmlHttp.onreadystatechange = resu; 
	//取得导航数据
	//var qurl = url+"&sear="+search_name ;
    //var qurl = "news_list.php?page=1"; 
	
	url=encodeURI(url); 
    
	xmlHttp.open("GET",url,true); 
    xmlHttp.send(null); 
    //setTimeout("startRequest()",2000); 
} 
//列表插入指定位置    
function resu() { 
	var obj = document.getElementById("MainBody");
    if(xmlHttp.readyState == 4) { 
        if(xmlHttp.status	== 200) {  
		    obj.innerHTML	=	xmlHttp.responseText;
	
        } else {obj.innerHTML	= "您所要访问的数据不存在！";}
    } else{
		obj.innerHTML	=	"稍后，数据加载中。。。";
		
	}
} 
//取得INDEX级列表结束！




//取得列表页分页页面
var http_request;

 function topage(url){//初始化，指定处理函数，发送请求的函数
	  //开始初始化XMLHttpRequest对象
	 if(window.XMLHttpRequest){//Mozilla浏览器
	   http_request=new XMLHttpRequest();
	   if(http_request.overrideMimeType){//设置MIME类别
		http_request.overrideMimeType("text/xml");
	   }
	  }
	  else if(window.ActiveXObject){//IE浏览器
	   try{	
	   http_request=new ActiveXObject("Msxml2.XMLHttp");
	   }catch(e){
	   try{
	   http_request=new ActiveXobject("Microsoft.XMLHttp");
	   }catch(e){}
	   }
	  }
	  if(!http_request){//异常，创建对象实例失败
	   window.alert("创建XMLHttp对象失败！");
	   return false;
	  }
	  http_request.onreadystatechange=processrequest;
	  //确定发送请求方式，URL，及是否同步执行下段代码
	  url  = encodeURI(url);
	  http_request.open("GET",url,true);
	  http_request.send(null);
 }
 
  function processrequest(){
	  if(http_request.readyState==4){//判断对象状态
		   if(http_request.status==200){//信息已成功返回，开始处理信息
			 document.getElementById("MainBody").innerHTML=http_request.responseText;                 //
		   }
		   else{//页面不正常
		   alert("您所请求的页面不正常！");
		   }
	  }
 }

//取得招聘会页面
//var http_request;
 function zphxx_topage(url){//初始化，指定处理函数，发送请求的函数
 	
	  //开始初始化XMLHttpRequest对象
	  if(window.XMLHttpRequest){//Mozilla浏览器
	   http_request=new XMLHttpRequest();
	   if(http_request.overrideMimeType){//设置MIME类别
		http_request.overrideMimeType("text/xml");
	   }
	  }
	  else if(window.ActiveXObject){//IE浏览器
	   try{	
	   http_request=new ActiveXObject("Msxml2.XMLHttp");
	   }catch(e){
	   try{
	   http_request=new ActiveXobject("Microsoft.XMLHttp");
	   }catch(e){}
	   }
	  }
	  if(!http_request){//异常，创建对象实例失败
	   window.alert("创建XMLHttp对象失败！");
	   return false;
	  }
	  http_request.onreadystatechange=zphxx_processrequest;
	  url=encodeURI(url); 
	  //确定发送请求方式，URL，及是否同步执行下段代码
	  http_request.open("GET",url,true);
	  http_request.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded;charset=utf-8'); 
	  http_request.send(null);
 }
 
  function zphxx_processrequest(){
	  if(http_request.readyState==4){//判断对象状态
		   if(http_request.status==200){//信息已成功返回，开始处理信息
			 document.getElementById("MainBody").innerHTML=http_request.responseText;                 //
			 //load_login();
		   }
		   else{//页面不正常
		   alert("您所请求的页面不正常！");
		   }
	  }
 }
//取得招聘会页面结束

//登陆！
function login(){
  //login_http_request=null;
  //开始初始化XMLHttpRequest对象
  if(window.XMLHttpRequest){//Mozilla浏览器
   http_request=new XMLHttpRequest();
   if(http_request.overrideMimeType){//设置MIME类别
    http_request.overrideMimeType("text/xml");
   }
  }
  else if(window.ActiveXObject){//IE浏览器
   try{	
   http_request=new ActiveXObject("Msxml2.XMLHttp");
   }catch(e){
   try{
   http_request=new ActiveXobject("Microsoft.XMLHttp");
   }catch(e){}
   }
  }
  if(!http_request){//异常，创建对象实例失败
   window.alert("创建XMLHttp对象失败,请使用高于IE5.0以上的浏览器！");
   return false;
  }
  http_request.onreadystatechange=login_processrequest;

  var username		=	document.getElementById("username").value;
  var userpassword	=	document.getElementById("userpassword").value;
  var usertype	=false;
  if(document.getElementById("usertype_student").checked==true){
	  var usertype	=	"student";
  }else{
	if(document.getElementById("usertype_qiye").checked==true){
	  var usertype	=	"qiye";		
	}  
  }

  if(username==""){  alert("用户名不能为空！");return false;  }
  if(userpassword==""){alert("密码不能为空！");return false; } 
  if(usertype==false){ alert("用户类型不能为空！"); return false; }
  var url	= "login.php?username="+username+"&userpassword="+userpassword+"&usertype="+usertype+"&time="+new Date().getTime();
  url=encodeURI(url); 
  http_request.open("GET",url,true);
  http_request.send(null);
 }
 
  function login_processrequest(){
  if(http_request.readyState==4){//判断对象状态
   if(http_request.status==200){//信息已成功返回，开始处理信息
   		//alert("dd");
  	 document.getElementById("yhdl").innerHTML=http_request.responseText;                 
   }else{//页面不正常
  	 alert("您所请求的页面不正常！");
   }
  }else{
	document.getElementById("yhdl").innerHTML="正在尝试登陆...";  
  }	
	
}
//登陆结束！


//打开新窗口，防止浏览器拦截
/*
* 调用:Object.Window
* 作用:Window 引用类
* 参数:
*  Method   窗口打开方式
*  Href   窗口地址
*  Name   窗口标签
*  ToolBar   显示工具条 yes/no
*  MenuBar   显示菜单栏 yes/no
*  ScrollBar  显示滚动条 yes/no
*  UrlBar   显示地址栏 yes/no
*  Status   显示状态栏 yes/no
*  FullScreen  全屏窗口  yes/no
*  Resize   重设窗口大小 yes/no
*  Width   窗口宽度  yes/no
*  Height   窗口高度  yes/no
*  Place   窗口位置  center/top/openpop
*  ReturnValue  返回值
*  TextValue  文本显示
*  ConfirmTrue  确认返回
*  ConfirmFalse 取消返回
*  Params   参数
* 返回:
*/
function Window()
{
 var Method;
 var Params;
 var Splits;
 var Href;
 var Name;
 var ToolBar;
 var MenuBar;
 var ScrollBar;
 var UrlBar;
 var Status;
 var FullScreen;
 var Resize;
 var Width;
 var Height;
 var Place;
 var Top;
 var Left;
 var ReturnValue;
 var TextValue;
 var ConfirmTrue;
 var ConfirmFalse;

 this.Method = Method;
 this.Params = Params;
 this.Splits = Splits;
 this.Href = Href;
 this.Name = Name;
 this.ToolBar = ToolBar;
 this.MenuBar = MenuBar;
 this.ScrollBar = ScrollBar;
 this.UrlBar = UrlBar;
 this.Status = Status;
 this.FullScreen = FullScreen;
 this.Resize = Resize;
 this.Width = Width;
 this.Height = Height;
 this.Place = Place;
 this.Top = Top;
 this.left = Left;
 this.ReturnValue = ReturnValue;
 this.TextValue = TextValue;
 this.ConfirmTrue = ConfirmTrue;
 this.ConfirmFalse = ConfirmFalse;
}

Window.prototype.Init = function()
{
 this.Method = this.Method?this.Method:"open";
 this.Params = this.Params?this.Params:"";
 this.Splits = this.Splits?this.Splits:"|";
 this.Href = this.Href?this.Href:"about:blank";
 this.Name = this.Name?this.Name:Math.round(Math.random() * 100000);
 this.ToolBar = this.ToolBar?this.ToolBar:"no";
 this.MenuBar = this.MenuBar?this.MenuBar:"no";
 this.ScrollBar = this.ScrollBar?this.ScrollBar:"yes";
 this.UrlBar = this.UrlBar?this.UrlBar:"no";
 this.Status = this.Status?this.Status:"no";
 this.FullScreen = this.FullScreen?this.FullScreen:"no";
 this.Resize = this.Resize?this.Resize:"yes";
 this.Width = this.Width?this.Width:parseInt(screen.width/2);
 this.Height = this.Height?this.Height:parseInt(screen.height/2);
 this.Place = this.Place?this.Place:"";
 this.Top = this.Top?this.Top:"10";
 this.Left = this.Left?this.Left:"10";
 this.ReturnValue = this.ReturnValue?this.ReturnValue:"";
 this.TextValue = this.TextValue?this.TextValue:"";
 this.ConfirmTrue = this.ConfirmTrue?this.ConfirmTrue:true;
 this.ConfirmFalse = this.ConfirmFalse?this.ConfirmFalse:false;
}

Window.prototype.Open = function()
{
 // .toLowerCase()
 switch (this.Method)
 {
  /*
  * 类别:Open
  * 功能:Window.Open 弹出窗口 中所有功能;
  */
  case "open":
  if (this.Place == "center")
  {
   OpenWinTopXY = "top="+((screen.availHeight-this.Height)/2)+",left="+((screen.availWidth-this.Width)/2);
  }else if (this.Place == "top"){
   OpenWinTopXY = "top=0,left=0";
  }else{
   OpenWinTopXY = "top="+this.Top+",left="+this.Left+"";
  }

  window.open (this.Href,""+this.Name+"","location=no;toolbar="+this.ToolBar+",menubar="+this.MenuBar+",scrollbars="+this.ScrollBar+",resizable="+this.Resize+",directories="+this.UrlBar+",fullscreen="+this.FullScreen+",status="+this.Status+",titlebar=no,width="+this.Width+",height="+this.Height+","+OpenWinTopXY+"");
  break;

//  /*
//  * 类别:showModlDialog
//  * 功能:对话窗口
//  */
//  case "showModalDialog":
//  var DialogObj;
//  DialogObj = window.showModalDialog (this.Href,"","dialogWidth:'"+this.Width+"';dialogHeight:'"+this.Height+"';status:'"+this.Status+"';scroll='"+this.ScrollBar+"';help:no");
//  return (""+DialogObj+"");
//  break;
//
//  /*
//  * 类别:showHelp
//  * 功能:HELP帮助
//  */
//  case "showHelp":
//  window.showHelp(this.Href);
//  break;
//
//  /*
//  * 类别:Confirm
//  * 功能:确认对话框
//  */
//  case "confirm":
//  var msgbox = window.confirm(this.TextValue);
//  if (msgbox)
//  {
//   eval(this.ConfirmTrue);
//  }else{
//   eval(this.ConfirmFalse);
//  }
//  break;
//
//  case "popup":
//  if (this.ie)
//  {
//   this.PopTop=50;
//   this.oPopup = window.createPopup();
//   var html=this.TextValue;
//   this.oPopup.document.body.innerHTML = html;
//   popshow();
//  }
//  break;

  /*
  * 类别:缺省状态
  * 功能:当前页面转发
  */
  default:
  top.location=this.Href;
  break;
 }
}
//调用打开窗口类

var Window = new Window;
function OpenWin(url,width,height)
{

 Window.Method="open";
 Window.Href=url;
 Window.Width=width;
 Window.Height=height;
 Window.Init();
 Window.Open();
}

function display_calendar(){
	//alert(document.getElementById("calendar").id);
	document.getElementById("calendar").className='display';
}
function hide_calendar(){
	document.getElementById("calendar").className='hide';		
}