function externallinks() {
if (!document.getElementsByTagName) return;
var anchors = document.getElementsByTagName("a");
for (var i=0; i<anchors.length; i++) {
var anchor = anchors[i];
if (anchor.getAttribute("href") &&
anchor.getAttribute("rel") == "external")
anchor.target = "_blank";
}
}
window.onload = externallinks;

var http_request=false;

  function send_request(url){//初始化，指定处理函数，发送请求的函数
   // 
    http_request=false;
    //开始初始化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，及是否同步执行下段代码
    http_request.open("GET",url,true);
	//alert(url); 
    http_request.send(null);
  }
  
  function focus(){//打开首页时光标到登录框
    var inputuser=document.getElementById('inputuser');
	inputuser.focus(); 

  }


  function send_request_post(url,string){//初始化，指定处理函数，发送请求的函数
    http_request=false;
    //开始初始化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，及是否同步执行下段代码
    http_request.open("POST",url,true);
    http_request.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
    http_request.send(string);
    //alert(string);
  }
  //处理返回信息的函数
  function processrequest(){
   if(http_request.readyState==4){//判断对象状态
     if(http_request.status==200){//信息已成功返回，开始处理信息

	 // alert(http_request.responseText);
      document.getElementById(reobj).innerHTML = http_request.responseText;
	 // alert(document.getElementById(reobj).innerText);
     }
     else{//页面不正常
      alert("您所请求的页面不正常！");
     }
   }
  }
  function dopage(obj,url){
   document.getElementById(obj).innerHTML="读取数据...";
   reobj=obj;
   send_request(url);
   }
  


    function dopostpage(obj,url,string){
   document.getElementById(obj).innerHTML="读取数据...";
   reobj=obj;
   send_request_post(url,string);
  
   } 
  function confirm_del(){
	if(confirm('删除后将不能恢复，您确认执行删除操作么？')) return true;else return false;
  }

  function confirm_msg(msg){
	if(confirm(msg)) return true;else return false;
  }
   
  function winconfirm(msg,url){
    question = confirm(msg);
    if (question != "0"){
        window.location=url;
    }      
  }

  function confirm_del_C(){
	if(confirm('该班级还有成员，最好不要删除，您确认要执行删除操作么？')) return true;else return false;
  }
  function confirm_mima(){
	if(confirm('密码重置后将不能恢复，您确认执行密码重置操作么？')) return true;else return false;
  }
  function add_teacher(){
   	var str=document.getElementById('addselect').value;
	var str1=str.split("*")[0];
	var str2=str.split("*")[1];
	document.getElementById('selcheck').innerHTML+= "<label><input type=\"checkbox\" name=\"selteacher[]\" value=\""+str2+"\" checked=\"checked\"/>"+str1+"</label>";
  }
  function add_teacher_self(id,name,act){
	 if(act=='add') 
	document.getElementById('selcheck').innerHTML+= "<label><input type=\"checkbox\" name=\"selteacher[]\" value=\""+id+"\" checked=\"checked\"/>"+name+"</label>";
  }

 function del_teacher(){
 document.getElementById('selcheck').innerHTML="";
 }
 
 
  function add_area(){
   	var str=document.getElementById('addselect').value;
	
	document.getElementById('selcheck').innerHTML+= "<label><input type=\"checkbox\" name=\"area[]\" value=\""+str+"\" checked=\"checke\"/>"+str+"</label>";
	//alert("<label><input type=\"checkbox\" name=\"area[]\" value=\""+str+"\" checked=\"checke\"/>"+str+"</label>");
  }
    function add_rarea(){
   	var str=document.getElementById('addselect1').value;
	
	document.getElementById('selcheck1').innerHTML+= "<label><input type=\"checkbox\" name=\"rarea[]\" value=\""+str+"\" checked=\"checke\"/>"+str+"</label>";

  }
   function del_area(){
 	document.getElementById('selcheck').innerHTML="";
 }
 function del_rarea(){
 	document.getElementById('selcheck1').innerHTML="";
 }
  

    //使用google进行全站搜索
    function search(){
    	var x='http://www.google.cn/search?hl=zh-CN&complete=1&sitesearch=nubs.nju.edu.cn&domains=nubs.nju.edu.cn&q=' + encodeURL(document.getElementById('iptKeywords').value);
    //	alert(x);
    	window.location=x;
    	
        return false;
    } 


 function addclass(s1,s2,s3){
    var str=document.getElementById(s3).value;
	var str1=str.split("*")[0];
	var str2=str.split("*")[1];
	var str3=str.split("*")[2];
    document.getElementById(s1).innerHTML+= "<input type=\"checkbox\" name=\""+s2+"\" value=\""+str1+"\" checked=\"checked\"/>"+str2+"."+str3;  	
}
//MBA问卷调查
function t_wen_juan(show,wei,ques,cid,admin){
 // alert(ques);
  var x;
   for(i=1;i<=5;i++){
     x=document.getElementById("ques"+show+i);
     x.className="witem";
   }
    var q=document.getElementById("ques"+show+wei);
	var url="/admin_index.php?admin="+admin+"&act=ping&txt1="+ques+"&txt2="+wei+"&cid="+cid+"&time="+Date.parse(new Date());
   // alert(url);
  // q.innerHTML+=url;
	send_request(url);
    q.className="witemcur";
}

//问卷调查，sids SESSION,K点量表，wei选择的点数，iid题目id，show显示排序,qid问卷id
function q_wen_juan(sid,show,wei,iid,qid,k){
 // alert(ques);
  var x;
   for(i=1;i<=k;i++){
     x=document.getElementById("ques"+show+i);
     x.className="witem";
   }
    var q=document.getElementById("ques"+show+wei);
	var url="./ping.php?txt1="+wei+"&txt2="+iid+"&txt3="+qid+"&txt4="+sid+"&time="+Date.parse(new Date());;
   // alert(url);
  // q.innerHTML+=url;
	send_request(url);
//	alert(url);
    q.className="witemcur";
}

function check_ques(x){
	var cur;
	var k;
	for(i=1;i<=x;i++){
      cur=0; 	 
      for(j=1;j<=5;j++){
      	if(document.getElementById("ques"+i+j).className=='witemcur') cur=1;
	  }
	  if(cur==0) {
		  alert("第"+i+"项尚未选择！请选择后再提交！");
          return false;
	  }
	}
	if(document.getElementById("beizhu").value.length<=1){
	   alert("补充建议不能为空！");
	   return false;
	}
}

function select_local_file(url){
  var y1=document.getElementById('fileupload');
  var y2=document.getElementById('fileupload1');
  if(y2.type=="text"){
    y1.innerHTML="<input  type=\"file\"  name=\"file\"  id=\"fileupload1\"/>";   
  }
  else{
 
	 y1.innerHTML="<input  type=\"text\"  name=\"file\" value=\""+url+"\" id=\"fileupload1\"/>";   
  }
  var z=document.getElementById('fileuploadtext');
  if(z.innerHTML=="选择本机")
	  z.innerHTML="拷贝地址";
  else{
	 z.innerHTML="选择本机";	 
  }
}

function showroll(i,k){
  var y2; 
  for(j=1;j<=k;j++){
    y2=document.getElementById('roll'+j);
    y2.className="rollbox";
	y4=document.getElementById('tznews'+j);
	y4.style.display="none";
  }
  //alert(i+"&"+k);
  var y1=document.getElementById('roll'+i);
  y1.className="rollboxshow";

  var y3=document.getElementById('tznews'+i);
  y3.style.display="block";
}

