// JavaScript Document
	//弹出窗口函数
	var $=function(objName)
	{
		if(document.getElementById)
		{
			return eval('document.getElementById("'+objName+'")')
		}
		else
		{
			return eval('document.all.'+objName)
		}
	}

	function makeScrollNews(arr_hr_news)
	{
		if(arr_hr_news==undefined || arr_hr_news.length==0)
		{
			jQuery('.subnav').css('display','none');
			return false;	
		}
		jQuery('.subnav').css('display','');
		var tmp='',html='';
		for(var i=0; i<arr_hr_news.length; i++)	
		{
			tmp = '<a href="'+arr_hr_news[i][0]+'" target="_blank">'+arr_hr_news[i][1]+'</a>';
			html += tmp;
		}
		window.document.getElementById('sinaMarquee').innerHTML = html;
	}

	var sinaScroll=function(obj,scrollLength,scrollTime){      //scrollLength:步长  ,scrollTime 间隔时间
		var obj=typeof(obj)=="string"?document.getElementById(obj):obj;
		obj.style.overflow="hidden";
		obj.style.height="29px";
		obj.style.lineHeight="29px";
		obj.style.width=obj.offsetWidth+"px";
		this.marqueeDiv=document.createElement("div");
		this.marqueeDiv.style.width="30000px";
		this.marqueeDiv.style.height=obj.offsetHeight+"px";
		this.marqueeDiv.style.overflow="hidden";
		this.marqueeDiv.style.zoom="1";
		this.marqueeData1=document.createElement("div");
		this.marqueeData2=document.createElement("div");
		this.marqueeData1.innerHTML=obj.innerHTML;
		this.marqueeData2.innerHTML=obj.innerHTML;
		obj.innerHTML="";
		this.marqueeData1.style.styleFloat="left";//ie
		this.marqueeData1.style.cssFloat="left";//ff
		this.marqueeData2.style.styleFloat="left";
		this.marqueeData2.style.cssFloat="left";
		this.marqueeData1.style.zoom="1";
		this.marqueeData2.style.zoom="1";
		this.marqueeData1.style.overflow="hidden";
		this.marqueeData2.style.overflow="hidden";
		obj.appendChild(this.marqueeDiv);
		this.marqueeDiv.appendChild(this.marqueeData1);
		this.marqueeDiv.appendChild(this.marqueeData2);
		var scroll=function(){
			
			if (obj.scrollLeft+scrollLength>=marqueeData1.scrollWidth)
			{
				obj.scrollLeft=obj.scrollLeft+scrollLength-marqueeData1.scrollWidth;
			}
			else
			{
				obj.scrollLeft+=scrollLength;
			}
		}
		var intervalId=setInterval(scroll,scrollTime);
		obj.onmouseover=function(){
			clearInterval(intervalId);
		}
		obj.onmouseout=function(){
			intervalId=setInterval(scroll,scrollTime);
		}
	}

	//判断是否是合法的Email
	function isEmail(s){
		var pattern = /^[a-z0-9]+[a-z0-9_-]*(\.[a-z0-9_-]+)*@[a-z0-9_-]+(\.[a-z0-9_-]+)*\.([a-z]+){2,}$/; 
		return pattern.test(s);
	}
	//判断是否为合法的身份证号
	function isIdentityCard(s)
	{
		var pattern1 = /^\d{15}$/;
		var pattern2 = /^\d{18}$/;
		return pattern1.test(s) || pattern2.test(s);
	}
	//判断是否为合法电话号码
	function isTelephone(s)
	{
		var pattern = /^\d{4,8}-?\d{1,8}$/;
		return pattern.test(s);
	}
	//判断是否是合法的邮政编码
	function isPostalCode(s)
	{
		var pattern = /^\d{6}$/;
		return pattern.test(s);
	}
	
	function getJobList(container_id, num)
	{
		jQuery.getJSON('http://career.sina.com.cn/iframe/job_list_json.php?type=new&num='+num,
			function(data)
			{
				if (data!='' && data!=null)
				{
					var html='';
					for (var i=0; i<data.length; i++)
					{
						//alert(data[i]['position_name']);
						li = '<li><a href="http://career.sina.com.cn/job_detail.php?id='+data[i]['id']+'" target="_blank">'+data[i]['position_name']+'</a> ('+data[i]['num']+'人)</li>';
						html += li;
					}
					jQuery(container_id).html(html);
				}
			}
		);
	}
	
function setHistoryCookie(id, name, dtype, area, num, jobtype, start)
{
	if (id==undefined || id=='' || name==undefined || name=='') {
		return false;	
	}
	var strCookies = getCookie('job_list');
	if (strCookies = makeCookie(strCookies, id, name, dtype, area, num, jobtype, start)){
		setCookie('job_list', strCookies, 30, '/');
	}
}

function makeCookie(strCookies, id, name, dtype, area, num, jobtype, start)
{
	var arrList = new Array();
	if (strCookies!=undefined && strCookies!='')
	{
		arrList = strCookies.split(',');
		for(var i=0; i<arrList.length; i++){
			cookie_id = arrList[i].split('|')[0];
			if (cookie_id==id){
				return false;
			}
		}
		if (arrList.length>=10) {
			arrList.shift();	
		}
	}
	arrList.push(id + '|' + name + '|' + dtype + '|' + area + '|' + num + '|' + jobtype + '|' + start);
	strCookies = arrList.join(',');
	return strCookies;
}

function getHistoryCookie()
{
	var strList = getCookie('job_list');
	if (strList != undefined && strList != '') {
		arrList = strList.split(',');
		var html = '';
		for(var i=0; i<arrList.length; i++){
			var color = i%2 ? '#f1f8ff' : '#FFFFFF';
			var one = arrList[i].split('|');
			var id = one[0];
			var name = one[1];
			var dtype = one[2];
			var area = one[3];
			var jobtype = one[4];
			var num = one[5];
			var start = one[6];
			html += '<tr bgcolor="'+color+'"><td><div class="t_job"><a href="job_detail.php?id='+id+'" target="_blank">'+name+'</a></div></td><td>'+dtype+'</td><td>'+area+'</td><td>'+jobtype+'</td><td>'+num+'</td><td>'+start+'</td><td><a href="job_detail.php?id='+id+'" target="_blank"><img src="http://www.sinaimg.cn/edu/images/career/recruit_hz_022.gif" width="55" height="17" alt=""/></a></td></tr>';
		}
	}
	jQuery('#jobHistory').html(html);
}

function getCookie(name) {
	var result = null;
	var myCookie = document.cookie + ";";
	var searchName = name + "=";
	var startOfCookie = myCookie.indexOf(searchName);
	var endOfCookie;
	if (startOfCookie != -1)
	{
		startOfCookie += searchName.length;
		endOfCookie = myCookie.indexOf(";",startOfCookie);
		result = unescape(myCookie.substring(startOfCookie, endOfCookie));
	}
	return result;
}

function setCookie(name,value,expires,path,domain,secure)
{
	var expDays = expires*24*60*60*1000;
	var expDate = new Date();
	expDate.setTime(expDate.getTime()+expDays);
	var expString = ((expires==null) ? "" : (";expires="+expDate.toGMTString()))
	var pathString = ((path==null) ? "" : (";path="+path))
	var domainString = ((domain==null) ? "" : (";domain="+domain))
	var secureString = ((secure==true) ? ";secure" : "" )
	document.cookie = name + "=" + escape(value) + expString + pathString + domainString + secureString;
}

function delCookie(sName)
{
	var ThreeDays=3*24*60*60*1000;
	var expDate = new Date();
	expDate.setTime(expDate.getTime()-ThreeDays);
	document.cookie=name+"=;expires="+expDate.toGMTString();
}

function login(container)
{
		jQuery.getJSON('http://career.sina.com.cn/login.php?action=validate&rnd=' + Math.round(Math.random()*10000),
			function(data)
			{
				if (data!='' && data!=null)
				{
					jQuery(container).prepend(data['username']+'，您好！<a href="logout.php">退出登录</a> | <a href="http://career.sina.com.cn/user_center.php">管理中心</a> | ');
				}
				else
				{
					jQuery(container).prepend('<a href="login.php">登陆</a> | <a href="http://login.sina.com.cn/cgi/register/reg_sso.php" target="_blank">注册</a> | <a href="http://login.sina.com.cn/getpass.html" target="_blank">密码找回</a> | ');
				}
			}
		);	
}