function StringBuffer() {
	this.buff = '';
	
	this.append = function(str) {
		this.buff = this.buff + str;
	}
	
	this.toString = function() {
		return this.buff;
	}
}

function XObject(type) {
	this.ie = (navigator&&navigator.appName=="Microsoft Internet Explorer") ? true : false;
	this.type = type;
	this.infoKeyArray = new Array();
	this.infoValueArray = new Array();
	this.paramKeyArray = new Array();
	this.paramValueArray = new Array();
	this.embedKeyArray = new Array();
	this.embedValueArray = new Array();
	this.addInfo = function(name, value) {
		if(name==null || value==null) {
			alert("usage : addInfo(name, value)");
		}
		this.infoKeyArray.push(name);
		this.infoValueArray.push(value);
	}
	this.addParam = function(name, value) {
		if(name==null || value==null) {
			alert("usage : addParam(name, value)");
		}
		this.paramKeyArray.push(name);
		this.paramValueArray.push(value);
	}
	this.addEmbedInfo = function(name, value) {
		if(name==null || value==null) {
			alert("usage : addEmbedInfo(name, value)");
		}
		this.embedKeyArray.push(name);
		this.embedValueArray.push(value);	
	}
	this.show = function() {
		if(this.type==null) {
			alert("usage : new Map(type) - type={'object','applet'..}");
		}
		var sb = new StringBuffer();
		sb.append("<");
		sb.append(this.type);
		sb.append(" ");
		for(var i=0; i<this.infoKeyArray.length; i++) {
			sb.append(this.infoKeyArray[i]);
			sb.append("='");
			sb.append(this.infoValueArray[i]);
			sb.append("' ");
		}
		sb.append(">")
		
		for(var i=0; i<this.paramKeyArray.length; i++) {
			sb.append("<param name='");
			sb.append(this.paramKeyArray[i]);
			sb.append("' value='");
			sb.append(this.paramValueArray[i]);
			sb.append("'>");
		}
		
		if(this.embedKeyArray.length > 0) {
			sb.append("<embed ");
			for(var i=0; i<this.embedKeyArray.length; i++) {
				sb.append(this.embedKeyArray[i]);
				sb.append("='");
				sb.append(this.embedValueArray[i]);
				sb.append("' ");
			}
			sb.append(">");
		}
		
		sb.append("</");
		sb.append(this.type);
		sb.append(">");
		document.write(sb.toString());
	}
	this.showActiveXMap = function(id, width, height, x, y, scale, isMapLoadOnInit) {
		this.addInfo("id",id);
		this.addInfo("width",width);
		this.addInfo("height",height);
		this.addParam("CenterX",x);
		this.addParam("CenterY",y);
		this.addParam("DrawScale",scale);
		this.addParam("IsMapLoadOnInit",isMapLoadOnInit);
		this.show();
	}
	this.showAppletMap = function(id, width, height, x, y, scale, isMapLoadOnInit) {
		
	}
	this.showDefaultFlash = function(id, src, width, height, wmode) {
		if(id==null || src==null || width==null || height==null || wmode==null) {
			alert("usage : showDefaultFlash(id, src, width, height, wmode)");
		}
		if(this.ie) {
			this.addInfo("id",id);
		}
		this.addInfo("width",width);
		this.addInfo("height",height);
		this.addInfo("classid","clsid:D27CDB6E-AE6D-11cf-96B8-444553540000");
		this.addInfo("codebase","http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0");
		this.addParam("movie",src);
		this.addParam("quality","high");
		this.addParam("wmode",wmode);
		if(!this.ie) {
			this.addEmbedInfo("id",id);
		}
		this.addEmbedInfo("src",src);
		this.addEmbedInfo("quality","high");
		this.addEmbedInfo("bgcolor","#FFFFFF");
		this.addEmbedInfo("width",width);
		this.addEmbedInfo("height",height);
		this.addEmbedInfo("type","application/x-shockwave-flash");
		this.addEmbedInfo("pluginspace","http://www.macromedia.com/go/getflashplayer");
		this.show();
	}
	
	this.showDefaultCongnamulMap = function(id, width, height, x, y, scale, isMapLoadOnInit) {
		this.showMap(id, width, height, x, y, scale, isMapLoadOnInit);
	}
	this.showDefaultSamsungMap = function(id, width, height, x, y, scale, isMapLoadOnInit) {
		this.showMap(id, width, height, x, y, scale, isMapLoadOnInit);
	}
	this.showDefaultAspMap = function(id, width, height, x, y, scale, isMapLoadOnInit) {
		this.showMap(id, width, height, x, y, scale, isMapLoadOnInit);
	}
	
	this.showMap = function(id, width, height, x, y, scale, isMapLoadOnInit) {
		if(id==null || width==null || height==null || x==null || y==null || scale==null) {
			alert("usage : showMap(id, width, height, x, y, scale, isMapLoadOnInit)");
		}
		this.addInfo("classid", "clsid:D96D2F74-0B74-47D2-964F-B67E9F69F1CD");
		this.addInfo("codebase","http://www.congnamul.com/ActiveX/Release/CongnamulMap4Asp_V2_0_0_18.cab#version=2,0,0,18");
		this.addParam("ServerIPAddress","nmap.congnamul.com");
		this.addParam("ServerServletURL","Map/mapservice");
		this.addParam("DecoSymbolUrl", "http://image.congnamul.com/images/decoimages");
		this.showActiveXMap(id, width, height, x, y, scale, isMapLoadOnInit);
	}
}

function SetTooltipMode()
{
	CongnamulMap.TooltipMode = !CongnamulMap.TooltipMode;
}

//È®´ë
function  zoomIn() {
    CongnamulMap.FixedZoomInMap();
}

//Ãà¼Ò
function zoomOut() {
    CongnamulMap.FixedZoomOutMap();
}

//ÀÌµ¿
function panning() {
    if (CongnamulMap.CmdType == 1) {
        CongnamulMap.CmdType = 0;
    } else if (CongnamulMap.CmdType == 0) {
        CongnamulMap.CmdType = 1;
    } else {
        CongnamulMap.CmdType = 1;
    }

/*
    if (CongnamulMap.CmdType == 1) {
        CongnamulMap.CmdType = 0;
    } else if (CongnamulMap.CmdType == 0) {
        CongnamulMap.CmdType = 1;
    } else {
        alert("´Ù¸¥ ÀÛ¾÷ÀÌ ÁøÇàÁßÀÔ´Ï´Ù");
    }
*/
}

//ÀÌÀü
function preview() {
    CongnamulMap.PreviewMap();
}

//ÀÌÈÄ
function nextview() {
    CongnamulMap.NextMap();
}

//Áöµµ Å¬¸®¾î
function resetMap() {
    CongnamulMap.CmdType = 0;
    CongnamulMap.ResetMap();
}

//Ãâ·Â
function printMap() {
	CongnamulMap.SetPrintMode();
    print();
}

//2, 3Â÷¿ø
function setShadowMap() {
    if (CongnamulMap.DrawMode != 0) {
        CongnamulMap.DrawMode = 0; // 2D Mode
		document.getElementById("btn_07").value = 0;
    } else {
        CongnamulMap.DrawMode = 1; // 3D Mode
		document.getElementById("btn_07").value = 1;
    }
}

//°Å¸®ÃøÁ¤
function setDistanceFlag() {
    if (CongnamulMap.CmdType == 2) 
	{
        CongnamulMap.CmdType = 0;
    } 
	else
	{
        CongnamulMap.CmdType = 2;
    }
}

//¸éÀûÃøÁ¤
function setAreaFlag() {
    if (CongnamulMap.CmdType == 3) 
	{
        CongnamulMap.CmdType = 0;
		
    } 
	{
        CongnamulMap.CmdType = 3;
    }
}

// ¾àµµ°ü·Ã  -- ½ÃÀÛ --
//Æ÷ÀÎÆ® Âï±â
function setMapLineFlag() {
    if (CongnamulMap.CmdType == 5) 
	{
        CongnamulMap.CmdType = 0;
    } 
	else
	{
        CongnamulMap.CmdType = 5;
    }
}

function setMapALineFlag() {
    if (CongnamulMap.CmdType == 6) 
	{
        CongnamulMap.CmdType = 0;
    } 
	else
	{
        CongnamulMap.CmdType = 6;
    }
}

function setMapCircleFlag() {
    if (CongnamulMap.CmdType == 7) 
	{
        CongnamulMap.CmdType = 0;
    } 
	else
	{
        CongnamulMap.CmdType = 7;
    }
}

function setMapRectFlag() {
    if (CongnamulMap.CmdType == 8) 
	{
        CongnamulMap.CmdType = 0;
    } 
	else
	{
        CongnamulMap.CmdType = 8;
    }
}

function setMapClickFlag() {
    if (CongnamulMap.CmdType == 9) 
	{
        CongnamulMap.CmdType = 0;
    } 
	else
	{
        CongnamulMap.CmdType = 9;
    }
}

function removeSimpleMap(nCount) {
    CongnamulMap.RemoveSimpleMap(nCount);
}

// ¾àµµ°ü·Ã -- ³¡ --

//ÇöÀç Áöµµ¿µ¿ª X
function getX() {
    alert("Áöµµ¿µ¿ª X " +CongnamulMap.MapX);
}

//ÇöÀç Áöµµ¿µ¿ª Y
function getY() {
    alert("Áöµµ¿µ¿ª Y " +CongnamulMap.MapY);
}

//ÇöÀç Áöµµ¿µ¿ª Width
function getW() {
   alert(" Æø "+CongnamulMap.MapWidth);
}

//ÇöÀç Áöµµ¿µ¿ª Height
function getH() {
   alert("³ôÀÌ " + CongnamulMap.MapHeight);
}

function removeUserSymbol(id)
{
	CongnamulMap.RemoveUserSymbol(id);
}

function setIndexFlag() {
    if (CongnamulMap.IndexMode == 2) {
	CongnamulMap.IndexMode = 1;
    } else {
	CongnamulMap.IndexMode = 2;
    }
   // document.Form1.indexmode.value = CongnamulMap.IndexMode;
}

function setPoint1() {
    if (CongnamulMap.CmdType == 4) {
        CongnamulMap.CmdType = 0;
    } else {
        CongnamulMap.CmdType = 4;
        CongnamulMap.ClickPointX = -1;
        CongnamulMap.ClickPointY = -1;
	modifyID = setInterval("mapModify()", 500);        
    }
}

function mapModify() {
   if (CongnamulMap.ClickPointX > 0) {
      clearInterval(modifyID);
      Form1.xcoor.value = (CongnamulMap.ClickPointX / 2.5);
      Form1.ycoor.value = (CongnamulMap.ClickPointY / 2.5);   
      resetMap()
      CongnamulMap.AddUserSymbol(0, 1, 1,CongnamulMap.ClickPointX, CongnamulMap.ClickPointY, "", "", "");
      CongnamulMap.ReDraw();
   }
}

function setPoint() {
    if (CongnamulMap.CmdType == 4) 
	{
        CongnamulMap.CmdType = 0;
    } 
	else
	{
        CongnamulMap.CmdType = 4;
        CongnamulMap.ClickPointX = -1;
        CongnamulMap.ClickPointY = -1;
    } 
}

function getPoint() {
    document.Form1.xcoor.value = CongnamulMap.ClickPointX;
    document.Form1.ycoor.value = CongnamulMap.ClickPointY;
}

function getUrl(theURL,winName,features) {
    strUrl = theURL+"?LU="+escape(CongnamulMap.GetQuickURLString());
    window.open(strUrl,winName,features);
}

function SaveBitMap() {
    CongnamulMap.SaveBitmap();
}

function SendMapMail() {
    var level, x, y, w, h, s, cx, cy, cindex;

    var drawScale;

    drawScale = CongnamulMap.DrawScale;

    if (drawScale < 4.0) {
        level = 0;
    }
    else if (drawScale < 6.0) {
        level = 1;
    }
    else if (drawScale < 9.0) {
        level = 2;
    }
    else if (drawScale < 13.5) {
        level = 3;
    }
    else if (drawScale < 21.0) {
        level = 4;
    }
    else {
        level = 5;
    }

    cx = CongnamulMap.CenterX;
    cy = CongnamulMap.CenterY;

    w = 421 * drawScale;
    h = 332 * drawScale;
//    w = 421 * drawScale * 2.5;
//    h = 332 * drawScale * 2.5;

    x = cx - w / 2;
    y = cy - h / 2;

    s = 0;
    cindex = 0;

    strUrl = "http://www.congnamul.com/mapmail/mailmap.jsp?X="+parseInt(x);
    strUrl = strUrl + "&Y="+parseInt(y);
    strUrl = strUrl + "&W="+parseInt(w);
    strUrl = strUrl + "&H="+parseInt(h);
    strUrl = strUrl + "&S=0";
    strUrl = strUrl + "&CX="+parseInt(cx);
    strUrl = strUrl + "&CY="+parseInt(cy);
    strUrl = strUrl + "&LEVEL="+level;
    strUrl = strUrl + "&CINDEX="+cindex;

    window.open(strUrl,"mailMap", "toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=700,height==460,top=10,left=10");
}
