//if (typeof(jQuery)=='undefined') document.write("<scr" + "ipt type=\"text/javascript\" src=/Js/JQuery22.js></scr" + "ipt>");


$(document).ready(function() {
    if (document.getElementById("search_html")) {
        $("#search_html > div.object").mouseover(function() {
            $(this).find("ul").show(200);
        }).bind("mouseleave", function() {
            $(this).find("ul").hide(200);
        });

        $("#search_html > div.object").find("ul li").click(function() {
            if (parseInt($(this).attr("val")) < 3) {
                if (parseInt($("#searchType").val()) == 0) {
                    $("#searchObject").val($(this).attr("val"));
                    $("div.object > span.type").html(this.innerHTML);
                } else {
                    $("#searchObject").val($(this).attr("val"));
                    $("div.object > span.type").html(this.innerHTML);
                    $("#search_type li:lt(2)").eq(0).click();
                }
            } else {
                $("#searchObject").val("3");
                $("div.object > span.type").html("求职内容");
                $("#search_type li:lt(2)").eq(1).click();
            }
            $("div.object > ul").hide();
        }).bind("mouseleave", function() {
            $(this).css("background-color", "#fff");
        }).bind("mouseover", function() {
            $(this).css("background-color", "#efefef");
        });

        var objMenu = $("#search_type li:lt(3)");
        objMenu.each(function() {
            $(this).click(function() {
                objMenu.siblings().removeClass("selected");
                $(this).addClass("selected");
                disSearchHtml(parseInt($(this).attr("val")));
            });
        });

        var standardControl = new StandardControl;
        standardControl.Load(document.location.href);
        $("div.btn").click(function() {
            var objType = parseInt($("#searchObject").val());
            var keyText = escape($("#keyword").val());
            var standardText = "";
            var Ind = standardControl.GetIndustry();
            if (Ind != null && Ind.length > 0)
                standardText += "&indIDList=" + Ind;
            var Cat = standardControl.GetCategory();
            if (Cat != null && Cat.length > 0)
                standardText += "&occIDList=" + Cat[0] + "&occParentIDList=" + Cat[1];
            var Loc = standardControl.GetLocation();
            if (Loc != null && Loc.length > 0)
                standardText += "&myLocIDList=" + Loc[0] + "&myLocParentIDList=" + Loc[1];
            if (parseInt($("#searchType").val()) == 0 || parseInt($("#searchType").val()) == 2) {
                switch (objType) {
                    case 0:
                        window.location.href = "http://www.hxhr.com.cn/Job.aspx?key=" + keyText + "&act=job" + standardText;
                        break;
                    case 1:
                        window.location.href = "http://www.hxhr.com.cn/DisClass.aspx?id=39&key=" + keyText;
                        break;
                    case 2:
                        window.location.href = "http://www.hxhr.com.cn/Job.aspx?key=" + keyText + "&act=name";
                        break;
                    case 4:
                        window.location.href = "http://www.hxhr.com.cn/ListArticle.aspx?key=" + keyText;
                        break;
                }
            }
            else window.location.href = "http://www.hxhr.com.cn/Resume.aspx?act=per&key=" + keyText;
        });
    }
	
//	alert()
	if ($(".area")[0]){
		$("#searchkey").focus(function(){
			var obj = $(this);
			if (obj.val() == "请输入关键字") obj.val("").removeClass("ccc");
		}).blur(function(){
			var obj = $(this);
			if (obj.val() == "") obj.val("请输入关键字").addClass("ccc");
		}).keydown(function(e){
			if (e.which == 13){
				$("#searchbtn").click();
				return false;
			}
		})
		$(".fod a").click(function(){
			if (this.className == "selected") return;
			$(this).addClass("selected").siblings().removeClass("selected");
			$("#searchtype").val($(this).index());
			$("#searchkey").focus();
		})
		
		$("#searchbtn").click(function(){
			var obj = $("#searchkey");
			if (obj.val() == "" || obj.val() == "请输入关键字"){
				alert("请输入关键字！");
				obj.focus();
				return;
			}
			switch($("#searchtype").val()){
				case "0":
					window.location.href = "http://www.hxhr.com.cn/Job.aspx?act=job&key=" + escape(obj.val());
					break;
				case "1":
					window.location.href = "http://www.hxhr.com.cn/Resume.aspx?act=per&key=" + escape(obj.val());
					break;
				case "2":
					window.location.href = "http://www.hxhr.com.cn/SearchNews.aspx?" + escape(obj.val());
					break;
			}
		})
	}
});

function disSearchHtml(n){
	$("#searchType").val(n);
	switch(n){
		case 0:
	  		$("#searchObject").val(0);
	  		$("div.object > span.type").html("招聘内容");
			break;
		case 1:
	  		$("#searchObject").val(3);
	  		$("div.object > span.type").html("求职内容");
	  		break;
	    case 2:
	        $("#searchObject").val(4);
	        $("div.object > span.type").html("资讯文章");
	        break;
	};
}

var StandardControl = function(){
	this.Init();
};
StandardControl.prototype = {
	iptLocation: null, iptCategory: null, iptIndustry:null
	,InitControl:function(){
		this.iptLocation = $("#txtLoc");
		this.iptCategory = $("#txtCat");
		this.iptIndustry = $("#txtInd");
	},InitEvent: function(){
	},Init: function(){
		this.InitControl();
		this.InitEvent();
	},Load:function(url){
		PopupSelector.loadSelected(url);
	},SetCategory: function(Cat){
		this.iptCategory.val(Cat != "" ? Cat : "请选择职业类别");
	},SetIndustry: function(Ind){
		this.iptIndustry.val(Ind != "" ? Ind : "请选择行业类别");
	},SetLocation: function(Loc){
		this.iptLocation.val(Loc != "" ? Loc : "请选择工作地点");
	},Clear: function(){
		this.SetCategory("");
		this.SetIndustry("");
		this.SetLocation("");
	},GetCategory: function(){
		var a = [], b = [],c = [];
		jQuery.each(PopupSelector._selItems.cat,function(){
		  	b.push(this.id);
			this.parObj != null ? c.push(this.parObj.id) : c.push(this.id);
		});
		if (b.length > 0){
			a.push(b.join(","));
			a.push(c.join(","));
		};
		return a;
	},GetIndustry: function(){
		var a = [];
		jQuery.each(PopupSelector._selItems.ind,function(){
			a.push(this.id);
		});
		return a.length > 0 ? a.join(",") : "";
	},GetLocation: function(){
		var a = [], b = [], c = [];
		jQuery.each(PopupSelector._selItems.loc, function(){
			b.push(this.id);
			this.parObj != null ? c.push(this.parObj.id) : c.push(this.id);
		});
		if (b.length > 0 ){
			a.push(b.join(","));
			a.push(c.join(","));
		}
		return a;
	}
}























