// shinhyosik(shs7718@congnamul.co.kr)

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) {
		if(id==null || width==null || height==null || x==null || y==null || scale==null) {
			alert("usage : showDefaultCongnamulMap(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_19.cab#version=2,0,0,19");
		//this.addInfo("classid","clsid:E0BF7A2B-2F7C-497A-B50F-292D3F318965");
		//this.addInfo("codebase","http://www.congnamul.com/ActiveX/CongnamulMap_V18.cab#version=1,0,0,18");
		this.addParam("ServerIPAddress","map.congnamul.com");
		this.addParam("ServerServletURL","Map/mapservice");
//		this.addParam("MapServerVersion", "1");
//		this.addParam("InputCoordinator", "0");
//		this.addParam("MapDatalevel", "15");

		this.showActiveXMap(id, width, height, x, y, scale, isMapLoadOnInit);
	}
	this.showDefaultSamsungMap = function(id, width, height, x, y, scale, isMapLoadOnInit) {
		if(id==null || width==null || height==null || x==null || y==null || scale==null) {
			alert("usage : showDefaultSamsungMap(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_19.cab#version=2,0,0,19");
//		this.addInfo("classid","clsid:DA76E8AE-2E7F-49A8-B5F2-D1C4FF70ECD5");
//		this.addInfo("codebase","http://mapsvc.samsung.co.kr/ActiveX/SamsungMap_V25.cab#version=1,0,0,25");
		this.addParam("ServerIPAddress","mapsvc.samsung.co.kr");
		this.addParam("ServerServletURL","Map/servlet/mapservice");
		this.addParam("UserImageLocation","http://mapsvc.samsung.co.kr/landmark/");
		this.addParam("DecoSymbolUrl","http://map.congnamul.com/images/decoimages");
		this.showActiveXMap(id, width, height, x, y, scale, isMapLoadOnInit);
	}
	this.showDefaultAspMap = function(id, width, height, x, y, scale, isMapLoadOnInit) {
		if(id==null || width==null || height==null || x==null || y==null || scale==null) {
			alert("usage : showDefaultAspMap(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_19.cab#version=2,0,0,19");
//		this.addInfo("classid","clsid:D96D2F74-0B74-47D2-964F-B67E9F69F1CD");		
//		this.addInfo("codebase","http://asp.congnamul.com/AspActiveX/CongnamulMap4Asp_V30.cab#version=1,0,0,30");
		this.addParam("ServerIPAddress","map.congnamul.com");
		this.addParam("ServerServletURL","Map/mapservice");
		this.addParam("DecoSymbolUrl", "http://image.congnamul.com/images/decoimages");
		//this.addParam("MapServerVersion", "1");
		//this.addParam("InputCoordinator", "0");
		//this.addParam("MapDatalevel", "15");

		this.showActiveXMap(id, width, height, x, y, scale, isMapLoadOnInit);
	}
}