var searchDomain = "http://s.job5156.com";
var personDomain = "http://my.job5156.com";
var companyDomain = "http://hr.job5156.com";

String.prototype.trim = function(){
    return this.replace(/(^\s*)|(\s*$)/g, "");
}

/**************************
 * 根据ID获取页面中的dom元素
 * date  : 2009-5-12
 */
function $(str){
	if (typeof str == 'string' && document.getElementById(str) != null ) 
		{return document.getElementById(str);}
	return false;
}

/**************************
 * 文件切换[v6]
 * date  : 2009-5-12
 */
function setTab(name,cursel,n,cname){
	for(i=1;i<=n;i++){
		var menu=document.getElementById(name+"_"+i);
		var con=document.getElementById("con_"+name+"_"+i);
		menu.className=(i==cursel?cname:"");
		con.style.display=(i==cursel?"block":"none");
	}
}

/**************************
 * 首页Ajax框架[v6]
 * date  : 2009-5-12
 */
var AjaxSC = new AjaxSupportChinese();
function AjaxSupportChinese() {
	var self = this;	
	self.send = function(url, options)
	{
		self.container = options.container || null;
		self.onComplete = options.onComplete || null;
		if (window.XMLHttpRequest) {
			   findreq = new XMLHttpRequest();
			   findreq.open("POST", url, true);
			   findreq.onreadystatechange = self.findreqFunction;
			   findreq.send(null);
		}else if (window.ActiveXObject) {
			   findreq = new ActiveXObject("Microsoft.XMLHTTP");
			   findreq.open("POST", url, false);
			   findreq.onreadystatechange = self.findreqFunction;
			   findreq.send();
		}
	}

	self.findreqFunction = function()
	{ 
		if (findreq.readyState == 4 && findreq.status == 200) {			
				if (self.onComplete) setTimeout(function(){self.onComplete(findreq);}, 10);
				if (self.container)  setTimeout(function(){document.getElementById(self.container).innerHTML=findreq.responseText.trim();}, 10);
		}
	}
}

/**************************
 * 首页加载静态文件
 * author: yanf
 * date  : 2009-5-20
 */
function loadStaticData(url, option){
	AjaxSC.send(url, option);
}

/**************************
 * 首页搜索变更类型[v6]
 * author: yanf
 * date  : 2009-5-12
 * changeSearchType: 公用函数[/js/city/index.js]
 */
function searchField(objName, cssName1, cssName2){
 	var m = document.queryForm;
 	if(objName == "key_all"){
 		m.indexField.value = "all";
 	}else if(objName == "key_com"){
 		m.indexField.value = "com";
 	}else if(objName == "key_pos"){
 		m.indexField.value = "pos";
 	}
 	var searchObj = new Array("key_all","key_com","key_pos");
 	changeSearchType(searchObj, objName, cssName1, cssName2);
}

/**************************
 * 首页搜索变更类型[v6]
 * author: yanf
 * date  : 2009-5-12
 */
function changeSearchType(option, objName, cssName1, cssName2){
 	if(cssName2 == null)cssName2 = "";
 	for(var i=0; i<option.length; i++){
 		var obj = document.getElementById(option[i]);
 		if(option[i] == objName){
 			obj.className = cssName1;
 		}else{
 			obj.className = cssName2;
 		}
 	}
}

/**************************
 * 改变对象样式和更换图片[v6]
 * 首页滑过城市站点变更样式和图片
 * author: yanf
 * date  : 2009-5-12
 */
function changeCssAndImg(obj, cssName, imgObjName, imgStr){
	if(cssName != "")obj.className = cssName;
	var imgObj = document.getElementById(imgObjName);
	imgObj.src = imgStr;
}

/**************************
 * 聚集焦点时,改变输入框样式
 * author: yanf
 * date  : 2009-5-12
 */
function keyTipOnFocus(obj, value, css){
	if(arguments.length == 2){
		if(obj.value == value){
			obj.value = "";
		}
	}
	if(arguments.length == 3){
		if(obj.value == value){
			obj.value = "";
			obj.className = css;
		}
	}
}

/**************************
 * 失去焦点时,改变输入框样式
 * author: yanf
 * date  : 2009-5-12
 */
function keyTipOnBlur(obj, value, css){
	if(arguments.length == 2){
		if(obj.value == ""){
			obj.value = value;		
		}
	}
	
	if(arguments.length == 3){
		if(obj.value == ""){
			obj.value = value;
			obj.className = css;
		}
	}
}

/**************************
 * 检查浏览器版本
 * date  : 2009-5-12
 */
function ie6check(){
	var verStr = navigator.appVersion;
    if (verStr.indexOf("MSIE") != -1) {
		if(verStr.indexOf("6")==-1 && verStr.indexOf("7")==-1){
	     	window.open ("/browser/ietip/01.htm","indexWin","width=267,height=178,left=100,top=0,resizable=no,scrollbars=no");
		}
	}
}

/**************************
 * 首页设置主页
 * author: yanf
 * date  : 2009-5-20
 */
function SetHome(obj,vrl){
	try{
		obj.style.behavior='url(#default#homepage)';
    	obj.setHomePage(vrl);
    }catch(e){
        if(window.netscape) {
        	try {
            	netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect"); 
            }catch (e){ 
                alert("此操作被浏览器拒绝！\n请在浏览器地址栏输入“about:config”并回车\n然后将[signed.applets.codebase_principal_support]设置为'true'"); 
            }
            var prefs = Components.classes['@mozilla.org/preferences-service;1'].getService(Components.interfaces.nsIPrefBranch);
            prefs.setCharPref('browser.startup.homepage',vrl);
        }
    }
}

function setFestivalBg()
{
	if(document.getElementById("chinaTop").className=="china09101"){
		document.getElementById("chinaTop").className = "china09101_2";
		document.getElementById("reSyleId").className="";
		document.getElementById("chinaback").className="";
		document.getElementById("indexBgId").display="none";
	}
}