loadingPane = null;
var titleObj = null;
var flag = true;
var rangeDeltaX = -18;
var rangeDeltaY = 0;

var rangeDeltaXArray = new Array();
var rangeDeltaYArray = new Array();

//rangeDeltaXArray["changjrb"] = -15;
//rangeDeltaYArray["changjrb"] = 0;
if(document.all){
    if (window.XMLHttpRequest) {
		 rangeDeltaX = -9;
         rangeDeltaY = 0;
    }
}

function CreatTitlePane() 
{
		loadingPaneSub = $("mp_loadingSub");
			var elFar = document.createElement('DIV');
			elFar.style.cssText="background-color:#BFBFBF; padding:2px; display:none;font-family:黑体;font-size:20px;font-weight:150%; color:#000; position:absolute; border: 2px solid #3D3D3D; right:1px; top:1px; bottom:1px; left:1px;width:30%; height:6%; z-index:10000;filter:alpha(opacity=70); line-height: 180%;";
			
			elFar.setAttribute("id","mp_loading");
			elFar.setAttribute("align","center");

			var el = document.createElement('DIV');
			el.setAttribute("id","mp_loadingSub");
			el.style.cssText="layer-background-color:#C71915;width:100%; height:90%; margin-top:5;margin-bottom:3;margin-left:3;margin-right:3;";
			
			elFar.appendChild(el);
			document.body.appendChild(elFar);
			loadingPane = elFar;
			loadingPaneSub = el;
			
			loadingPane.onmouseout=function(){
                  MouseOutMap();}

}

function showTitlePane(state,txt,iLeft,iTop) 
{

		var divElm = $("leveldiv");
		loadingPane = $("mp_loading");
        if (loadingPane == null) {
		CreatTitlePane();
	   }
		if(typeof txt == "string")
		{

			loadingPaneSub.innerHTML=txt;
			if(typeof iLeft == "number")
				loadingPane.style.left = iLeft;
			if(typeof iTop == "number")
				loadingPane.style.top = iTop;
		}
		else
			loadingPaneSub.innerHTML="";
		if (state) {
			
			loadingPane.style.display="block";
			divElm.style.display="block";
			if(titleObj.parentElement != null)
			{
			titleObj.parentElement.parentElement.className = "hover";
			}

		} else {
			loadingPane.style.display="none";
			divElm.style.display="none";
			if(typeof titleObj != "undefined")
			{
			   titleObj.parentElement.parentElement.className = "out";
			}
		}
}
	
	 
	function getPaperDir(url)
	{
		var paperdirRe = /[\\\/]([^\\\/]+?)[\\\/]html[\\\/]\d{4}-\d{2}[\\\/]\d{2}/i;
		var r = url.match(paperdirRe);
		if(r)
		{
			return r[1];
		}
		else
			return "";
	}


/* 坐标模式 */
function drawLine(obj)
{
	var divElm = $("leveldiv");
	var nowurl = location.href;
	var paperDir = getPaperDir(nowurl);
	var myRangeDeltaX = rangeDeltaXArray[paperDir];
	var myRangeDeltaY = rangeDeltaYArray[paperDir];
	 var str = obj.coords;

	 var arr = str.split(",");
	 var xArr = new Array(arr.length/2);
	 var yArr = new Array(arr.length/2);
	 var x=0,y=0;
	 var max =1,min =2;
	 for (var t =0 ;t<arr.length ;t=t+2 )
	 {
		
	 xArr[x++] = parseInt(arr[t]);
	 }
	 for (var t =1 ;t<arr.length ;t=t+2 )
	 {
		
	 yArr[y++] = parseInt(arr[t]);
	 }
	var x1 = find(xArr,min);
	
	var x2 = find(xArr,max);
	
	var y1 = find(yArr,min);
	
	var y2 = find(yArr,max);
	
	 var mapObj = obj.parentElement;
	 //alert(mapObj.tagName);
	
	 if(typeof mapObj == "object")
	 {
		
			var imgs = document.all.tags("img");
			
			if(imgs != null)
			{
				   for(var i=0;i<imgs.length;i++)
					{
						var imgobj = imgs.item(i);
						
						var mapname = imgobj.useMap;
						
						if(typeof mapname == "string" && mapname.toLowerCase() == ("#" + mapObj.name).toLowerCase())
						{
							
							var imgleft = 0;
							var imgtop = 0;
							var imgparent = imgobj.parentElement;
							while(typeof imgparent == "object" && imgparent.tagName.toUpperCase() != "BODY")
							{
								
								imgleft += getWidthNumber(imgparent.offsetLeft) - getWidthNumber(imgparent.style.borderLeftWidth);
								imgtop += getWidthNumber(imgparent.offsetTop) - getWidthNumber(imgparent.style.borderTopWidth);
								imgparent = imgparent.parentElement;
							}
							
							if(typeof myRangeDeltaX == "number")
								imgleft = imgleft + myRangeDeltaX;
							else
								imgleft = imgleft + rangeDeltaX;
							
							if(typeof myRangeDeltaY == "number")
								imgtop = imgtop + myRangeDeltaY;
							else
								imgtop = imgtop + rangeDeltaY;
							 var articleRe = /content_(\d+)\.htm/i;
							 
							 if(typeof obj.href == "string")
							 {
								var r = obj.href.match(articleRe);
								if(r)
								{
									titleObj = $("mp" + r[1]);
									
									
									
									var xposition = event.clientX + document.body.scrollLeft - document.body.clientLeft + 3;
									var yposition = event.clientY + document.body.scrollTop  - document.body.clientTop;
									
									if(typeof titleObj == "object" && typeof titleObj.innerHTML == "string")
									{
										divElm.onclick=function(){
										var conlink = titleObj.parentElement.href;
                                        window.open(conlink,"_self"); 
                                        };
										showTitlePane(true, titleObj.innerHTML, xposition, yposition);
										MouseOverMap(x1,y1,x2,y2,imgleft,imgtop);
									}
								
									else
									{
										showTitlePane(false);
									}
								 }
							}
							
						 }
				    }
			}
	 }

}

function getWidthNumber(sWidth)
{
	if(typeof sWidth == "number")
		return sWidth;
	var re = /\d+/i;
	var r = sWidth.match(re);
	if(r)
	{
		return parseInt(r);
	}
	else
		return 0;
}

function find(arr,type)
{
	var tmp=arr[0]; 
	if (type==1)
	{
	 for (var loop=0;loop<arr.length ;loop++ )
	 if (arr[loop]>tmp)
		 tmp = arr[loop];
	 return tmp;
	}
	else if (type == 2)
		{

	 for (var loop=0;loop<arr.length ;loop++ )
	 if (arr[loop]<tmp)
	 		 tmp = arr[loop];
	 return tmp;
	}

}

function MouseOverMap(x1,y1,x2,y2,imgleft,imgtop) {
	
var divElm = $("leveldiv");
var Left = x1;
var Top = y1;
var Right = parseInt(x2 - x1);
var bottom = parseInt(y2 - y1);
divElm.style.border = "0px solid ff0000"; 
divElm.style.backgroundColor = "#4A4949"; 
divElm.style.filter = "alpha(opacity=30)";
divElm.style.zIndex = "20"; 
divElm.style.left = Left+imgleft;
divElm.style.top = Top+imgtop;
divElm.style.width = Right+10;
divElm.style.height = bottom+12;
divElm.style.cursor = "pointer";
divElm.style.display = "block"; 
}

function MouseOutMap() {

	showTitlePane(false);
}
 