var n = 500;
var dragok = false;
var y,x,d,dy,dx;
if  (document.getElementById)
{
		if (window.opera)
		{
			document.write("<input type='hidden' id='QEFSGBFGHTU%#$%$' value=' '>");
		}
		n = 500;
		dragok = false;
		y,x,d,dy,dx;
		
}//End.

document.onmousedown = down;
document.onmouseup = up;

function down(e)
{
	if (!e) e = window.event;
	var temp = (typeof e.target != "undefined")?e.target:e.srcElement;
	if (temp.tagName != "HTML"|"BODY" && temp.className != "dragclass")
	{
		temp = (typeof temp.parentNode != "undefined")?temp.parentNode:temp.parentElement;
	}
	if (temp.className == "dragclass")
	{
		if (window.opera)
		{
			document.getElementById("QEFSGBFGHTU%#$%$").focus();
		}
		dragok = true;
		temp.style.zIndex = n++;
		d = temp;
		dx = parseInt(temp.style.left+0);
		dy = parseInt(temp.style.top+0);
		x = e.clientX;
		y = e.clientY;
		document.onmousemove = move;
		return false;
	}
}

function up()
{
	dragok = false;
	document.onmousemove = null;
}
function move(e)
{
	if (!e)
	{
		e = window.event;
	}
	if (dragok)
	{
		var l=dx + e.clientX - x;
		var t=dy + e.clientY - y;
		//if(l>=5)
		//{
			d.style.left = dx + e.clientX - x + "px";
//		}
		//if(t>=5)
		//{
			d.style.top  = dy + e.clientY - y + "px";
		//}
		return false;
	}
}

var div_windows=Array();
function GetXmlHttpObject()
{
	if (window.XMLHttpRequest)
	{
		return new XMLHttpRequest();
	}
	if (window.ActiveXObject)
	{
		return new ActiveXObject("Microsoft.XMLHTTP");
	}
	return null;
}
function spawn_map_popup(npc_id,title)
{
	xmlhttp=GetXmlHttpObject();
	if (xmlhttp==null)
	{
		alert ("Browser does not support HTTP Request");
		return;
	}
	var url = "show_spawn.php?src=ajax_ext2&npc_id="+npc_id;
	xmlhttp.open("GET", url, false);
	xmlhttp.send(null);
	var content = xmlhttp.responseText;
	xmlhttp=GetXmlHttpObject();
	xmlhttp.open("GET","./template/popup_div.tpl", false);
	xmlhttp.send(null);
	var popup = xmlhttp.responseText;
	div_id=div_windows.length;
	div_windows.push(npc_id,url,title);
	popup=popup.replace(/%%div_id%%/g,div_id);
	popup=popup.replace(/%%content%%/g,content);
	popup=popup.replace(/%%title_bar%%/g,title);
	document.getElementById("div_pool").innerHTML+=popup;
	return div_id;
}

function hide_popup(id)
{
	document.getElementById(id).style.visibility="hidden";
}


function findDOM(objectId)
{
	if (document.getElementById)
	{
		return (document.getElementById(objectId));
	}
	if (document.all)
	{
		return (document.all[objectId]);
	}
}
function zoom(type,imgx,sz)
{
	imgd = findDOM(imgx);
	if (type=="+" && imgd.width < 3000)
	{
		imgd.width += 100;
	}
	if (type=="-" && imgd.width > 300)
	{
		imgd.width -= 100;
	}
}
