var catelogDailog = null;
addEventHandler(window, 'load', addCatelogDailog);
function addCatelogDailog(){		
	var catelogConfig = {
		className:"pop_dailog",						
		width:"600px",			
		top: "100px",		
		title:"请选择您想搜索的岗位 ",			
		searchLabel: "请输入您要查询的关键字  ",			
		promptFlag:	true,
		promptLabel:"当前选择的岗位：",
		promptNull:	"[未选]",			
		data: catelogs,			
		allValue: 0,			
		allLabel: '岗位不限',				
		model: true,
		drag:  false,			
		colunms: 3,			
		oddBgColor: "#F9F9F9", //"#FFFBF6"
		eveBgColor: "#F9F9F9", //"#FFFFFF"
		
		submit: function(value,label){
			var form = document.getElementsByName("form1")[0];
			var jobMainCatalogry = document.getElementsByName("jobMainCatalogry")[0];
			var jobfunction = document.getElementsByName("jobfunction_1")[0];				
			jobMainCatalogry.value = value.toString().substring(0,2) + "00"; 
			jobfunction.value = value;		
			var btn_jobMainCatalogry =document.getElementsByName('btn_jobMainCatalogry')[0];
			var btn_jobfunction =document.getElementsByName('btn_jobfunction')[0];
					
			
			btn_jobMainCatalogry.value = catelogDailog.supCheckLabel;
			
			
			btn_jobfunction.value = catelogDailog.subCheckLabel;
		}
	};

	var button1 = document.getElementById('btn_jobMainCatalogry');
	var button2 = document.getElementById('btn_jobfunction');
	var supCatelog = document.getElementById('jobMainCatalogry');
	
	if(button1 && button2){
		catelogDailog = new CatelogDailog(catelogConfig);
		button1.onclick = function() { catelogDailog.listSupCatelog() ;catelogDailog.show(); };
		button2.onclick = function() { catelogDailog.listSubCatelog(supCatelog.value, button1.title); catelogDailog.show() };	
	}
}


addEventHandler(window, 'load', addMoreOptionToggle);
function addMoreOptionToggle(){

	var toggle = document.getElementById("button_more_option");	
	if(!toggle) return;
	
	toggle.onclick = function(){		
		var height = parseInt(moreOptionCollapse.divObj.style.height);		
		if(height>0) {
			toggle.innerHTML = '[ 展开岗位分类  <img src="/images/open.gif" /> ]';
		}else {
			toggle.innerHTML = '[ 收起岗位分类  <img src="/images/close.gif" /> ]';
		}
				
		if(height==0){
			
		} else {
			
		}
		moreOptionCollapse.slideit();
	}
}


//add area selector -- by zhangping
var areaselector = null;
addEventHandler(window, 'load', addAreaSelector);
function addAreaSelector(){
	var areaConfig = {
	id:"id_selector_area", 
	className:"area_selector",			
	width:"500px", 
		
	top: "50px",
	//left: "400px",
	values: provinceValue,
	labels: provinceLabel,
	subValues: cityValue,
	subLabels: cityLabel,
	usableValues:	mainCitiesValue,	
	usableLabels: mainCitiesLabel ,
	colunms: 6,
	
	title:	"请选择您想搜索的地区 ",			
	mainCityLabel:	"主要城市及地区快速选择：",
	provinceLabel:	"选择省区：" ,//"省区范围：",	
	cityLabel: 			"选择城市：",//"城市范围：",
	
	superAllValue:	"0",
	superAllLabel:	"全国",				
	subAllLabel:	"[不限]",
	
	modelDialog: true,
	singleChoose: true,			

	oddBgColor: "#F9F9F9", //"#FFFBF6"
	eveBgColor: "#F9F9F9", //"#FFFFFF"

	submit: function(value, label){
		if(value == '其他,其他') label = '其他省区';
		else if(label == '其他')  label = value.replace(',','');
		else if(value=='')  label = '全国';	
		document.getElementById('zone').value = label;
		document.getElementById('location').value =City_show_NametoInt(label);
	}
};
	
	var zone = document.getElementById('zone');
	if(zone){
		areaselector = new AreaSelector(areaConfig);
		areaselector.init();
		zone.onclick = function() { areaselector.show( new String(zone.value )) };	
	}
}
function City_show_NametoInt(cityname)
{
	var cityint=0;
    items = citys;
	for(var i=0; i<citys.length; i++) 
	{
	    if(citys[i][5].length==2){
	    
	        if(items[i][1]==cityname)
		    {
			    cityint=items[i][5];
			     break;
		    }		
	    }else {
		     if(items[i][2]==cityname)
		    {
			    cityint=items[i][5];
			     break;
		    }
	    }
		
	}
	return cityint;
}
function pointMoreOptionDiv() {
	if(!document.getElementById('div_more_option')) return;
	var div_main_menu = document.getElementById('main_menu');
	var div_more_option = document.getElementById('div_more_option');
	div_more_option.style.left = findPos(div_main_menu)[0] - 11 + "px";
	div_more_option.style.top = findPos(div_main_menu)[1] + 57 + "px";			
}

function addEventHandler (oTarget, sEventType, fnHandler) {
    if (oTarget.addEventListener) {
        oTarget.addEventListener(sEventType, fnHandler, false);
    } else if (oTarget.attachEvent) {
        oTarget.attachEvent("on" + sEventType, fnHandler);
    } else {
        oTarget["on" + sEventType] = fnHandler;
    }
}
 
function findPos(obj) {
	var curleft = curtop = 0;
	if (obj.offsetParent) {
		curleft = obj.offsetLeft
		curtop = obj.offsetTop
		while (obj = obj.offsetParent) {
			curleft += obj.offsetLeft
			curtop += obj.offsetTop
		}
	}
	return [curleft,curtop];
}
function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}



