var map = function(varId, objId, x, y, zoom, pinImg, pinW, pinH, bigMapFunc)
{
	// 2008.04.25 ¼öÁ¤ bigMapFunc ¸Å°³º¯¼ö¸¦ this.bigMapFunc·Î ³Ñ°Ü ¹ÞÀº ÈÄ map.prototype.setDefaultMap¿¡µµ µ¿ÀÏÇÏ°Ô Àû¿ë
	this.bigMapFunc = bigMapFunc;
	this.varId = varId;
	this.baseObj = document.getElementById(objId);
	this.x = (typeof(x) != "undefined") ? x : 0;
	this.y = (typeof(y) != "undefined") ? y : 0;
	this.zoom = (typeof(zoom) != "undefined") ? zoom : 3;
	this.pinUrl = ((typeof(pinImg) != "undefined") && (pinImg != "")) ? pinImg : "http://www.all.or.kr/common/images/map_pin.gif";
	this.pinW = ((typeof(pinW) != "undefined") && (pinW != 0)) ? pinW : 30;
	this.pinH = ((typeof(pinH) != "undefined") && (pinH != 0)) ? pinH : 30;
	this.marker = null;
	this.isMarkerDrag = false;

	this.layer = null;
	this.bigMap = null;
	this.bigMarker = null;

	if (this.baseObj == null)
		return false;
	
	if ((document.domain.indexOf("all.or.kr") == -1))
	{	

	}

//	function bdhj7(_obj,xnu2){ try {_obj.style.cursor=xnu2;} catch(e) {}; if (xnu2=="point"){_obj.style.cursor="hand";}}
	this.setDefaultMap();
};

map.prototype.setDefaultMap = function()
{
	try
	{
		this.map = new NMap(this.baseObj);
	}
	catch(e) 	// ³×ÀÌ¹ö Áöµµ ·Îµù Áö¿¬¿¡ ÀÇÇÑ NMap ¹ÌÁ¤ÀÇ¿¡ ´ëÇÑ Ã³¸®
	{
		var now = new Date();
		var exitTime = now.getTime() + 100;

		while (true) 
		{
			now = new Date();
			if (now.getTime() > exitTime)
				break;
		}

		this.map = new NMap(this.baseObj);
		return false;
	}

	if ((this.x > 0) && (this.y > 0))
	{
		this.map.setCenterAndZoom(new NPoint(this.x,this.y),this.zoom);
		this.marker = new NMark((new NPoint(this.x,this.y)), new NIcon(this.pinUrl, new NSize(this.pinW,this.pinH)));
		this.map.addOverlay(this.marker);
	}

	if (typeof(this.bigMapFunc) != "undefined")
	{
		this.map.disableDrag();
		NEvent.addListener(this.map, "click", eval(this.bigMapFunc));
//		try { this.baseObj.style.cursor = "pointer"; } catch(e) { this.baseObj.style.cursor = "hand"; };
	}
	
	return true;
};

map.prototype.openBigMap = function(baseObjId, bwidth, bheight, mapObjId, width, height, msg)
{
	if (this.layer == null)
	{
		this.layer = new lightbox({ id : this.objId + "_big" });
		this.bigMap = new NMap(document.getElementById(mapObjId), width, height);
	}

	this.bigMap.setCenterAndZoom(this.map.getCenter(),this.map.getZoom());
	this.bigMarker = new NMark(new NPoint(this.x,this.y), new NIcon(this.pinUrl, new NSize(this.pinW,this.pinH)));
	this.bigMap.clearOverlays();
	this.bigMap.addControl(new NZoomControl());
	this.bigMap.addOverlay(this.bigMarker);

	if ((typeof(msg) != "undefined") && (msg != "") && (typeof(this.bigMarker) != "undefined"))
		this.bigMarker.setText(msg);

	this.layer.open("object", baseObjId, bwidth, bheight);
};

map.prototype.closeBigMap = function()
{
	this.layer.close();
};

map.prototype.markerMoveCenter = function()
{
	var point = this.map.getCenter();
	this.marker.setPoint(point);
};

map.prototype.enableMarkerDrag = function()
{
	this.map.icrossVarId = this.varId;	// ÀÎ¼ö¸¦ ³Ñ°ÜÁÖ±â À§ÇÔ
	this.marker.icrossVarId = this.varId;	// ÀÎ¼ö¸¦ ³Ñ°ÜÁÖ±â À§ÇÔ
	NEvent.addListener(this.marker, "mousedown", eval(this.varId + ".markerDown"));
	NEvent.addListener(this.marker, "mouseup", eval(this.varId + ".markerUp"));
	NEvent.addListener(this.map, "mousemove", eval(this.varId + ".markerDrag"));
};

map.prototype.markerDown = function()
{
	var id = (typeof(this.varId) == "undefined") ? this.icrossVarId : this.varId;
	eval(id).isMarkerDrag = true;
};

map.prototype.markerUp = function()
{
	var id = (typeof(this.varId) == "undefined") ? this.icrossVarId : this.varId;
	eval(id).isMarkerDrag = false;
};

map.prototype.markerDrag = function(point)
{
	var id = (typeof(this.varId) == "undefined") ? this.icrossVarId : this.varId;
	var obj = eval(id);

	if (obj.isMarkerDrag)
	{
		obj.marker.setPoint(point);
	}
};

