window.onerror=reportError;
function reportError() {
     return true;
}
var sUserAgent = navigator.userAgent;
var isOpera = sUserAgent.indexOf("Opera") > -1;
var isIE = sUserAgent.indexOf("compatible") > -1 && sUserAgent.indexOf("MSIE") > -1 && !isOpera;
/* Êó±êÍÏ¶¯ */
var oDrag = "";
var ox,oy,nx,ny,dy,dx;
var obj_areaname,obj_areaid,obj_jobsname,obj_jobsid
obj_areaname='areaname';
obj_areaid='AreaId';
obj_jobsname='jobtypename';
obj_jobsid='JobClassId';
function drag(e,o){
	var e = e ? e : event;
	var mouseD = document.all ? 1 : 0;
	if(e.button == mouseD)
	{
		oDrag = o.parentNode;
		ox = e.clientX;
		oy = e.clientY;		
	}
}

function dragPro(e){
	if(oDrag != "")
	{	
		var e = e ? e : event;
		dx = parseInt($(oDrag).style.left);
		dy = parseInt($(oDrag).style.top);
		nx = e.clientX;
		ny = e.clientY;
		$(oDrag).style.left = (dx + ( nx - ox )) + "px";
		$(oDrag).style.top = (dy + ( ny - oy )) + "px";
		ox = nx;
		oy = ny;
	}
}
document.onmouseup = function(){oDrag = "";}
document.onmousemove = function(event){dragPro(event);}

var xmlHttp = false;
function createXMLHTTP(){ 
	if(window.XMLHttpRequest){ 
 		xmlHttp=new window.XMLHttpRequest(); 
		return xmlHttp; 
	} 
	else if(window.ActiveXObject){ 
		xmlHttp=new ActiveXObject("Microsoft.XMLHTTP"); 
		return xmlHttp; 
	} 
}
createXMLHTTP();

function $(o){
	if(typeof(o) == "string")
	return document.getElementById(o);
	return o;
}

function openBg(state){
	if(state == 1)
	{
		$("bg").style.display = "block";
		var h = document.body.offsetHeight > document.documentElement.offsetHeight ? document.body.offsetHeight : document.documentElement.offsetHeight;
		$("bg").style.height = h + "px";
	}
	else
	{
		$("bg").style.display = "none";
	}	
}

function getAbsoluteOffsetTop(obj) 
{
	var y = obj.offsetTop;
	while (obj = obj.offsetParent) y += obj.offsetTop;
	if(isIE)
	{
		return y+20;
	}
	else{
		return y+20+"px";
	}
}

function getAbsoluteOffsetLeft(obj,dwidth) 
{
	var x = obj.offsetLeft;
	while (obj = obj.offsetParent) x += obj.offsetLeft;
	var wwidth=document.body.clientWidth;
	if(wwidth<800)wwidth=800;
	dwidth=wwidth-dwidth;
	if(x>dwidth)x=dwidth
	if(x<200)x=200;
	
	if(isIE)
	{
		return x;
	}
	else{
		return x+"px";
	}
}

function getTop(obj,offset)
{
	var y = obj.offsetTop;
	while (obj = obj.offsetParent) y += obj.offsetTop;
	return y+offset;
}

function getLeft(obj,dwidth,offset) 
{
	var x = obj.offsetLeft;
	while (obj = obj.offsetParent) x += obj.offsetLeft;
	var wwidth=document.body.clientWidth;
	if(wwidth<800)wwidth=800;
	dwidth=wwidth-dwidth;
	if(x>dwidth)x=dwidth
	return x+offset;
}

function openAreaMsg(state,strlayer,obj,dwidth,objaname,objaid){
	if(objaname!=null)obj_areaname=objaname;
	if(objaid!=null)obj_areaid=objaid;
	var layer=$(strlayer);
	if(dwidth==null)dwidth=0;
	if(state == 1)	
	{
		openBg(1);
		var y=getAbsoluteOffsetTop(obj);
		var x=getAbsoluteOffsetLeft(obj,dwidth);
		layer.style.display = "block";
		layer.style.left = ($("bg").offsetWidth - layer.offsetWidth)/2 ;			
		layer.style.left = x ;		
		layer.style.top = y ;	
		layer.focus();
	}
	else
	{
		openBg(0);
		layer.style.display = "none";
	}
}

function openJobsMsg(state,strlayer,obj,dwidth,objjname,objjid){
	if(objjname!=null)obj_jobsname=objaname;
	if(objjid!=null)obj_jobsid=objaid;
	var layer=$(strlayer);
	if(dwidth==null)dwidth=0;
	if(state == 1)	
	{
		openBg(1);
		var y=getAbsoluteOffsetTop(obj);
		var x=getAbsoluteOffsetLeft(obj,dwidth);
		layer.style.display = "block";
		layer.style.left = ($("bg").offsetWidth - layer.offsetWidth)/2 ;			
		layer.style.left = x ;		
		layer.style.top = y ;	
		layer.focus();
	}
	else
	{
		openBg(0);
		layer.style.display = "none";
	}
}

function closeArea(){
	openAreaMsg(0,'AreaBox',null,null,null,null);
}

function closeJobs(){
	openJobsMsg(0,'JobnameClass',null,null,null,null);
}

function menu_show(strId,total)
{
	var obj="main_"+strId;
	var object='sort_'+strId;
	for(var i=1;i<=total;i++){
		$("sort_"+i).style.display="none";
	}
	$(object).style.display = "block";
	var y=getTop($(obj),5);
	var x=getLeft($(obj),10,40);
	x=x-$("bg").offsetTop;
	if(isIE){
		$(object).style.left =x;
		$(object).style.top =y;
	}else{
		$(object).style.left =x+"px";
		$(object).style.top =y+"px";
	}	
	$(object).focus();
}

function menu_color(id,zt){
	if(zt==1){
		$("l"+id).style.backgroundColor="#FF6600";
		$("l"+id).style.color="#FFFFFF";
		$("l"+id).style.fontWeight="bold";
	}else{
		$("l"+id).style.backgroundColor="#F8F9DF";
		$("l"+id).style.color="#000000";
		if(id>1)$("l"+id).style.fontWeight="";
	}
}

function menu_close(strId){
	var object='sort_'+strId;
	$(object).style.display="none";
}

function menu_sub(id,str,ly)
{
	$(obj_jobsname).value =str;
	$(obj_jobsid).value =id;
	var object='sort_'+ly;
	$(object).style.display="none";
	closeJobs();
}

function area_sub(id,str)
{
	$(obj_areaname).value =str;
	$(obj_areaid).value =id;
	$("selname").innerHTML =str;
	$("SelAreaId").value =id;
	closeArea();
}

function area_cfm_sub()
{
	$(obj_areaname).value =$("selname").innerHTML;
	$(obj_areaid).value =$("SelAreaId").value;
	closeArea();
}

function area_color(id,zt){
	if(zt==1){
		$("main_area_"+id).style.backgroundColor="#FF6600";
		$("main_area_"+id).style.color="#FFFFFF";
		//$("main_area_"+id).style.fontWeight="bold";
	}else{
		$("main_area_"+id).style.backgroundColor="#FFFFFF";
		$("main_area_"+id).style.color="#000000";
		//if(id>1)$("main_area_"+id).style.fontWeight="";
	}
}

function show_City(id,name,cls){
	$("chdcity").innerHTML = "";
	$("selname").innerHTML =name;
	$("SelAreaId").value =id;
	if(cls==0){
		var url = "/person_console/get_area.php?id=" + escape(id);
		xmlHttp.open("GET", url, true);
		xmlHttp.onreadystatechange = update_City;
		xmlHttp.send(null);
	}
}

function update_City() {
  	if (xmlHttp.readyState ==4) {
		$("chdcity").innerHTML = xmlHttp.responseText;
  	}
}

document.write("<div id=\"bg\"></div>");

function newJobsDate(){  
    today=new Date();   
    document.write("<font style='font-family:ËÎÌå'>",   
    today.getMonth()+1,".",   
    today.getDate(),   
    "</font>" );     
}  

function GetArgsFromHref(sArgName) 
{
	var sHref=window.location.href;
	var args=sHref.split("?"); 
	var retval=""; 
	
	if(args[0]==sHref)
	{ 
		return retval;
	} 
	var str=args[1];
	args=str.split("&");
	for(var i=0;i<args.length;i++)
	{ 
		str=args[i];
		var arg=str.split("="); 
		if(arg.length<=1) continue;
		if(arg[0]==sArgName)retval=arg[1]; 
	} 
	return retval; 
}
