
document.write("<script language='javascript' src='/js/jquery.js'><\/script>");
document.write("<script language='javascript' src='/js/tex_pub.js'><\/script>");


function searchSubmit(id)
{
  var obj = $('#'+id);
  if (obj.val() != ''){
     return true;
  }
  return false;
}

function showApply(applyId)
{
  creatGreyBg('bgApply');
  $('#'+applyId).show();
  var itop  = ($(window).height() - $('#'+applyId).height())/2;
  var ileft = ($(window).width() - $('#'+applyId).width())/2;
  $('#'+applyId).css('top', itop);
  $('#'+applyId).css('left', ileft);
  
  //fly
  var apply_focus = applyId + '_focus';
  function fly(event){
    var mX = event.screenX - $('#'+applyId).offset().left;
    var mY = event.screenY - $('#'+applyId).offset().top;
    $(window).bind('mousemove', function(event) {
      $('#'+applyId).css('top', event.screenY-mY);
      $('#'+applyId).css('left', event.screenX-mX);
    });
  }
  $('#'+apply_focus).bind('mousedown', fly);
  $('#'+apply_focus).bind('mouseup', function() {
    $(window).unbind('mousemove')
  });
}

function hideApply(applyId)
{
  removeGreyBg('bgApply');
  $('#'+applyId).hide(); 
}

function doApply(applyId, apply_form)
{
  var flag = 0;
  if ($('#login').val() == '' || $('#passwd').val() == '') {   
    if ($('#contact').val() == '' || $('#title').val() == '' || $('#tel').val() == '' || $('#sex').val() == '' || $('#level').val() == '' || $('#school').val() == '' || $('#wyears').val() == ''){
      alert('请填写完整信息！');
    }
    else {
      flag = 1;
    }
  }
  else {
    flag = 1;
  }
  if (flag) {
  	if( confirm('确定提交?') ){
      var myurl   = getFormAction();
      var mydata  = getFormData(apply_form);
      //var mydata  = $(apply_form).serialize();
    	var callbak = function(data) {
    		alert(data);
    		$('#'+apply_form)[0].reset();
    		hideApply(applyId);
    	};
    	if (mydata != '')
        runAjax('POST', myurl, mydata, callbak);
    }
  }
}

function scrollHRsearch(barId, btnId, termsId)
{
  $(window).bind('scroll', function(event) {
    $('#'+barId).css('position', 'absolute');
    $('#'+barId).css('top', 200+$(window).scrollTop());
  });

  $('#'+btnId).bind('click', {'rng':document.body.createTextRange()}, function(event) {
    var rng  = event.data.rng;
    var text = $('#'+termsId).val();
    findInPage(rng, text)
  });
}

function findInPage(rng, text)
{
  //alert( text );
  rng.collapse(false);
  if (rng.findText(text, -1, 1)) {
    rng.select();
    rng.collapse(true);
  }
  else {
    alert('查找结束.');
    location.reload(); 
  }
}
