 //图片预览
 $(function(){
	var x = 10;
	var y = 20;
	$("a.tooltip").mouseover(function(e){
		this.myTitle = this.title;
		this.title = "";	
		var imgTitle = this.myTitle? "<br/>" + this.myTitle : "";
		var imgUrl =  $(this).children().attr("src");
		var tooltip = "<div id='tooltip'><img src='"+ imgUrl +"' alt='模板预览图'/>"+imgTitle+"<\/div>"; //创建 div 元素
		$("body").append(tooltip);	//把它追加到文档中						 
		$("#tooltip")
			.css({
				"top": (e.pageY+y) + "px",
				"left":  (e.pageX+x)  + "px"
			}).show("fast");	  //设置x坐标和y坐标，并且显示
    }).mouseout(function(){
		this.title = this.myTitle;	
		$("#tooltip").remove();	 //移除 
    }).mousemove(function(e){
		$("#tooltip")
			.css({
				"top": (e.pageY+y) + "px",
				"left":  (e.pageX+x)  + "px"
			});
	});
})


function fadeShow(idObjSrc,idShowDivContainer,hotArea){
  this.strTimeOut = "";
  this.bleIsShow = false;
  this.idObjSrc = "";
  
  if(typeof(idObjSrc) == "object"){
    this.idObjSrc = idObjSrc;
  } else if(typeof(idObjSrc) == "string"){
    this.idObjSrc = "#" + idObjSrc;
  }
  
  this.hotArea = hotArea || this.idObjSrc;

  this.idShowDivContainer = "";
  if(typeof(idShowDivContainer) == "object"){
    this.idShowDivContainer = idShowDivContainer;
  } else if(typeof(idShowDivContainer) == "string"){
    this.idShowDivContainer = "#" + idShowDivContainer;
  }
  this.init();
}

fadeShow.prototype.init = function(){
  var thisObj =  this;
  var widthTemp = $(this.idShowDivContainer).outerWidth();
  var objTop = $(this.idObjSrc).offset().top;
  var objLeft = $(this.idObjSrc).offset().left;
  var objWidth = $(this.idObjSrc).width();
  var objHeight = $(this.idObjSrc).height();
  var leftTemp = parseInt(objLeft)+parseInt(objWidth)-parseInt(widthTemp);
  var topTemp = parseInt(objTop)+parseInt(objHeight);
  $(this.idShowDivContainer).css({position:"absolute",top:topTemp + "px",left:leftTemp+"px"}).mouseout(function(e){
    thisObj.hide(e);
  });
  $(this.hotArea).mouseout(function(e){
    thisObj.hide(e);
  });
}

fadeShow.prototype.hide = function(evt){
  evt = (evt)?evt:window.event;
  var toElementObj;
  if($.browser.msie){
    toElementObj = evt.toElement;
  } else if($.browser.mozilla){
    toElementObj = evt.relatedTarget;
  } else {
    toElementObj = evt.relatedTarget;
  }
  var thisObj = this;
  if ($(this.idShowDivContainer)[0].contains(toElementObj) || $(this.hotArea)[0].contains(toElementObj)) {
    this.bleIsShow = false;
  } else {
    this.bleIsShow = true;
    if(this.strTimeOut == ""){
      this.strTimeOut = setTimeout(function(){thisObj.doHide()},1000);
    }
  }
}

fadeShow.prototype.doHide = function(){
  if(this.strTimeOut != ""){
    clearInterval(this.strTimeOut);
    this.strTimeOut = "";
  }
  if(!this.bleIsShow){
    return ;
  }
  $(this.idShowDivContainer).fadeOut("slow");
}

fadeShow.prototype.show = function(){
  $(this.idShowDivContainer).fadeIn("slow");
}

var objLoginDiv = "";

var objAreaDiv = "";

function showLoginDiv(obj){
  var widthTemp = $("#loginDiv").outerWidth();
  var objTop = $(obj).offset().top;
  var objLeft = $(obj).offset().left;
  var objWidth = $(obj).width();
  var objHeight = $(obj).height();
  var leftTemp = parseInt(objLeft)+parseInt(objWidth)-parseInt(widthTemp);
  var topTemp = parseInt(objTop)+parseInt(objHeight);
  $("#loginDiv").css({"zIndex":2,position:"absolute",top:topTemp + "px",left:leftTemp+"px"}).show();
  $("#top_login_form_validate_tips").html("&nbsp;");
  $("#top_login_username").val("");
  $("#top_login_userpwd").val("");
  $("#top_login_username")[0].focus();
  $("#top_login_submit_btn")[0].disabled = false;
}
var myDomainMy = "";
function loginInSpeacial(para){
  myDomainMy = para.domain_my;
  var sucess = para.sucess;
  if(typeof sucess == "function"){
    $("#top_login_form").unbind("submit");
    $("#loginDiv").unbind("");
    $("#top_login_form")[0].onsubmit = "";
    $("#top_login_form").submit(function(){
      return loginIn(myDomainMy,sucess);
    });
  }
}

function showAreaDiv(obj,thisObj){
  if(objAreaDiv == ""){
    objAreaDiv = new fadeShow(obj,"all-channel",thisObj);
  }
  objAreaDiv.show();
}


function hideLoginDiv(){
  $("#loginDiv").fadeOut("slow");
}

if(typeof(HTMLElement) != "undefined"){
  HTMLElement.prototype.contains = function(obj) {
  while(obj != null &&  typeof(obj.tagName) != "undefind"){
    if(obj == this)
      return true;
      obj = obj.parentNode;
    }
    return false;
  };
}
//分区搜索
function type_search(districtVal){
 obj = document.forms.type_form;
 var districtVal12 = districtVal.substr( 0 , 2 );
 obj.district.value = districtVal;
 obj.jobarea.value = '99' == districtVal12 || '0302' == districtVal ? '0302' : districtVal12+'00';
 obj.submit();
}



var objOtherAreaDiv = "";
var objOtherCityDiv = "";
function onloadFun(){
  if(window.$){
    $(document).ready(function(){
      /*去除链接，button，image button的点击时虚线框*/
      $("a,input[type='button'],input[type='image'],input[type='submit'],area").bind("focus",function(){
        if(this.blur){
          this.blur();
        }
      })
      var obj = document.getElementById("51job|dev|all-channel1");
      if(obj != null){
        $(obj).mouseover(function(){
          if(objOtherAreaDiv == ""){
            objOtherAreaDiv = new fadeShow(this,"all-channel1");
          }
          objOtherAreaDiv.show();
        }).css({cursor:"pointer"});
      }
      
      var obj = document.getElementById("51job|dev|selectcity");
      if(obj != null){
        $(obj).mouseover(function(){
          if(objOtherCityDiv == ""){
            objOtherCityDiv = new fadeShow(this,"selectcity");
          }
          objOtherCityDiv.show();
        }).css({cursor:"pointer"});
      }
    })
  } else {
    setTimeout("onloadFun()",1000);
  }
}
onloadFun();

(function($){
$.fn.extend({
Scroll:function(opt,callback){
//参数初始化
if(!opt) var opt={};
var _btnUp = $("#"+ opt.up);//Shawphy:向上按钮
var _btnDown = $("#"+ opt.down);//Shawphy:向下按钮
var timerID;
var _this=this.eq(0).find("ul:first");
var lineH=_this.find("li:first").height()/2, //获取行高
line=opt.line?parseInt(opt.line,10):parseInt(this.height()/lineH,10), //每次滚动的行数，默认为一屏，即父容器高度
speed=opt.speed?parseInt(opt.speed,10):500; //卷动速度，数值越大，速度越慢（毫秒）
timer=opt.timer //?parseInt(opt.timer,10):3000; //滚动的时间间隔（毫秒）
if(line==0) line=1;
var upHeight=0-line*lineH;
//滚动函数
var scrollUp=function(){
_btnUp.unbind("click",scrollUp); //Shawphy:取消向上按钮的函数绑定
_this.animate({
marginTop:upHeight
},speed,function(){
for(i=1;i<=line;i++){
_this.find("li:first").appendTo(_this);
}
_this.css({marginTop:0});
_btnUp.bind("click",scrollUp); //Shawphy:绑定向上按钮的点击事件
});

}
//Shawphy:向下翻页函数
var scrollDown=function(){
_btnDown.unbind("click",scrollDown);
for(i=1;i<=line;i++){
_this.find("li:last").show().prependTo(_this);
}
_this.css({marginTop:upHeight});
_this.animate({
marginTop:0
},speed,function(){
_btnDown.bind("click",scrollDown);
});
}
//Shawphy:自动播放
var autoPlay = function(){
if(timer)timerID = window.setInterval(scrollUp,timer);
};
var autoStop = function(){
if(timer)window.clearInterval(timerID);
};
//鼠标事件绑定
_this.hover(autoStop,autoPlay).mouseout();
_btnUp.css("cursor","pointer").click( scrollUp ).hover(autoStop,autoPlay);//Shawphy:向上向下鼠标事件绑定
_btnDown.css("cursor","pointer").click( scrollDown ).hover(autoStop,autoPlay);

} 
})
})(jQuery);

$(document).ready(function(){
$("#scrollDiv").Scroll({line:2,speed:1000,timer:5000,up:"btn1",down:"btn2"});
});
try {document.execCommand("BackgroundImageCache", false, true);}catch(e) {};
