function _FMapLib() {
	var isIE  = (navigator.appVersion.indexOf("MSIE") != -1) ? true : false;
	var isWin = (navigator.appVersion.toLowerCase().indexOf("win") != -1) ? true : false;
	var isOpera = (navigator.userAgent.indexOf("Opera") != -1) ? true : false;
	var isSafari = (navigator.userAgent.indexOf("Safari") != -1) ? true : false;
	var debug = false;
	window.fmap_cnt = 0;
	
	
	//alert(isIE + ',' + isWin + ',' + isOpera + ',' + isSafari);
	/* // FMap //*/
	function FMapObj(movieURL, container, flashID, mapname, LON, LAT, LEVEL, FMapSpec, PageConfig, CustomElements) {
		var srcStr = AC_FL_RunContent(
			'src', movieURL, 'id', flashID, 'name', flashID, 'movie', movieURL, 
			'flashvars', 'JsObjName=' + mapname + '&sLON='+LON+'&sLAT='+LAT+'&sLEVEL='+LEVEL+'&FMapSpec='+FMapSpec+'&PageConfig='+PageConfig+'&CustomElements='+CustomElements,
			'codebase', 'http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0',
			'width', '100%', 'height', '100%', 'quality', 'high', 'pluginspage', 'http://www.macromedia.com/go/getflashplayer',
			'align', 'middle', 'play', 'true', 'loop', 'true', 'scale', 'showall', 'wmode', 'opaque', 
			'devicefont', 'false', 'bgcolor', '#FFFFFF', 'menu', 'true', 'allowFullScreen', 'false', 
			'allowScriptAccess','always', 'salign', ''			
			); //end AC code
		document.getElementById(container).innerHTML = srcStr;

		if (isIE && isWin && !isOpera) {
			this.movie = document.getElementById(flashID);
			//this.movie = window[flashID];
		} else {
			this.movie = document[flashID];
		}
//		this.movie = document.getElementById(flashID);
	}

	var $A = Array.from = function(iterable) {
		if(!iterable) return [];
		if(iterable.toArray) {
			return iterable.toArray();
		} else {
			var results = [];
			for(var i=0, length=iterable.length; i<length; i++)
				results.push(iterable[i]);
			return results;
		}
	}
	Function.prototype.bindAsEventListener = function(object) {
		var __method = this, args=$A(arguments), object = args.shift();
		return function(event) {
			return __method.apply(object, 
				[(event || window.event)].concat(args).concat($A(arguments)));
		}
	}
	FMapObj.prototype.mousewheel = function(evt) {
		var delta=0;
		if(evt.wheelDelta) { //for IE
			delta = evt.wheelDelta/120;
		}
		else if(evt.detail) { //for Mozilla
		
			delta=-evt.detail/3;				
		}
//		alert(delta);
//		if (delta) 	this.mapZoom(delta);
	}
	FMapObj.prototype.mouseover = function() {
		if(debug) fmap_cnt++;
		if(debug) document.getElementById('consol').innerHTML = this.movie.name + ':'+ fmap_cnt;
		var coord = fmap.getCenter();
		if(debug) document.getElementById('centerLon').innerHTML = coord.Lon;
		if(debug) document.getElementById('centerLat').innerHTML = coord.Lat;
		this.movie.focus();
	};
	// ¸Þ¼Òµå Á¤ÀÇ
	FMapObj.prototype.setCenter = function(lon, lat) {
		var coord = new Object();
		coord.Lon = lon;
		coord.Lat = lat;
		//alert("aa" + this.movie);
		return this.movie.setCenter(coord);
	};
	FMapObj.prototype.setCenterAndZoom = function(lon, lat, level) {
		var coord = new Object();
		coord.Lon = lon;
		coord.Lat = lat;
		this.movie.setCenterAndZoom(coord, level);

	};
	FMapObj.prototype.getBound = function() {
		var boundary  = this.movie.getBound();
		return boundary;

	};
	FMapObj.prototype.getCenter = function() {
		return this.movie.getCenter();
		//alert(this.movie.test());
	};
	FMapObj.prototype.setMapLevel = function(level) {
		return this.movie.setMapLevel(level);

	};
	FMapObj.prototype.getMapLevel = function() {
	//alert(this.movie);
		return this.movie.getMapLevel();

	};
	FMapObj.prototype.zoomIn = function() {
		return this.movie.zoomIn();

	};
	FMapObj.prototype.zoomOut = function() {
		return this.movie.zoomOut();

	};
	FMapObj.prototype.getDpSize = function() {
		return this.movie.getDpSize();
	};
	FMapObj.prototype.infoboxShow = function(gid, pid) {
		//alert("FMap" +  gid+","+pid);
		return this.movie.infoboxShow(gid, pid);
	};
	FMapObj.prototype.infoboxHide = function() {
		//alert("aa");
		return this.movie.infoboxHide();
	};
	FMapObj.prototype.setTopIndex = function(gid, pid) {
//		alert("FMap setTopIndex" +  gid+","+pid);
		return this.movie.setTopIndex(gid, pid);
	};
	

	FMapObj.prototype.addPoi = function(pobj) {	//gid, pid, iconPath, text, lon,lat, positiontype, imgw, imgh, showtextS, showtextE) {
			return this.movie.addPoi(pobj);  
	};

	FMapObj.prototype.stickPoi = function() {
		this.movie.stickPoi();
	};
	FMapObj.prototype.removePoi = function(gid, pid) {
		this.movie.removePoi(gid, pid);
	};
	FMapObj.prototype.removeGroupPoi = function(gid) {
		this.movie.removeGroupPoi(gid);
	};
	
	//È­»ìÇ¥ ÀÌ¹ÌÁö °ü·Ã poi µî·Ï
	FMapObj.prototype.addArrow= function(pobj) {	//gid, pid, iconPath, text, lon,lat, positiontype, imgw, imgh, showtextS, showtextE) {
		return this.movie.addArrow(pobj);  
	};
	FMapObj.prototype.removeArrow = function(gid, pid) {
		this.movie.removeArrow(gid, pid);
	};
	FMapObj.prototype.removeGroupArrow = function(gid) {
		this.movie.removeGroupArrow(gid);
	};

	//ThemeBarÇÔ¼ö
	FMapObj.prototype.setOnOff = function(onoff) {
		this.movie.setOnOff(onoff);
	};
	FMapObj.prototype.themeOpen = function() {
		this.movie.themeOpen();
	};
	FMapObj.prototype.themeClose = function() {
		this.movie.themeClose();
	};

	//AroundInfo ÇÔ¼ö
	FMapObj.prototype.showAroundInfo = function(lon, lat) {
		//alert("FMapLib showAroundInfo");
		this.movie.showAroundInfo(lon, lat);
	};
	FMapObj.prototype.hideAroundInfo = function() {
//		alert('hide around info');
		this.movie.hideAroundInfo();
	};
	FMapObj.prototype.getDocumentURL = function() {
		var url = document.location.host;
		return url;
	};
	FMapObj.prototype.setCoordsArrange = function(coordList) {
		this.movie.setCoordsArrange(coordList); 
	};
	
	//TourGuide¿ë
	FMapObj.prototype.tourGuideLoadData = function(id) {
		this.movie.tourGuideLoadData(id, '');
	};
	FMapObj.prototype.carMovePause = function() {
		this.movie.carMovePause();
	};
	FMapObj.prototype.carMoveReplay = function() {
		this.movie.carMoveReplay();
	};
	FMapObj.prototype.carMoveStop = function() {
		this.movie.carMoveStop();
	};
	FMapObj.prototype.showVideo = function(gid, pid) {
		this.movie.showVideo(gid, pid);
	};

	//Ä¿¼­º¯°æ
	FMapObj.prototype.showImageCursor = function(obj) {
		this.movie.showImageCursor(obj);
	};
	FMapObj.prototype.hideImageCursor = function() {
		this.movie.hideImageCursor ();
	};

	//ÀüÃ¼È­¸é
	FMapObj.prototype.setFullScreen = function() {
		this.movie.setFullScreen ();
	};


	FMapObj.prototype.test2 = function(c) {
		return this.movie.test2(c);
	};



	
	/********************************************************/
	// ÀÌº¥Æ® Á¤ÀÇ  (ÇÃ·¡½Ã¿¡¼­ ÀÌ ÇÔ¼ö¸¦ È£ÃâÇÏ¸é ÀÌº¥Æ® ¹ß»ý)
	/********************************************************/
	FMapObj.prototype.onCreate = function() {
		FMapEvent.trigger(this, 'onCreate');
	};

	FMapObj.prototype.onMapMove = function(crd, lvl) {  //ÀÌº¥Æ® º¯¼ö ÀÌ·¸°Ô ÇÏ´Â°Å??
		var coord = new Object();
		coord.Lon = crd.Lon;
		coord.Lat = crd.Lat;
		FMapEvent.trigger(this, 'onMapMove', {coord:coord, level:lvl});
	};
	FMapObj.prototype.onChangeLevel = function(lvl) {
		FMapEvent.trigger(this, 'onChangeLevel', {level:lvl});
	};

	FMapObj.prototype.onMapClick = function(crd, pxpoint) {
		var coord = new Object();
		coord.Lon = crd.Lon;
		coord.Lat = crd.Lat;

		var point = new Object();
		point.x = pxpoint.x;
		point.y = pxpoint.y;


		FMapEvent.trigger(this, 'onMapClick', {coord:coord, point:point});
	};
	
	FMapObj.prototype.onMapDblClick = function(crd) {
		var coord = new Object();
		coord.Lon = crd.Lon;
		coord.Lat = crd.Lat;

		FMapEvent.trigger(this, 'onMapDblClick', {coord:coord});
	};

	FMapObj.prototype.onPoiClick = function(pobj) {
		//alert("FMapLib onPoiClick");// + pobj.gid +"," + pobj.pid);
		//alert( "ExternalÀÇ clickPoi" + pobj.gid +"," + pobj.pid + "," + pobj.iconPath +"," + unescape(pobj.text) +","+ pobj.Lon +","+ pobj.Lat +","+ pobj.posType +","+ pobj.imgw +","+ pobj.imgh +","+ pobj.textS +","+ pobj.textE +","+ pobj.infoKind +","+ pobj.ID);
		FMapEvent.trigger(this, 'onPoiClick', pobj);
	};
	FMapObj.prototype.onDetailClick = function(pobj) {
		FMapEvent.trigger(this, 'onDetailClick', pobj);
	};

	FMapObj.prototype.onRMapClick = function() {
		FMapEvent.trigger(this, 'onRMapClick');
	};
	FMapObj.prototype.onClickThemeBar = function(obj) {
		FMapEvent.trigger(this, 'onClickThemeBar', obj);
	};
	FMapObj.prototype.onClosedThemeBar = function() {
		FMapEvent.trigger(this, 'onClosedThemeBar');
	};
	FMapObj.prototype.onOpenedThemeBar = function() {
		FMapEvent.trigger(this, 'onOpenedThemeBar');
	};
	FMapObj.prototype.onCloseVideoPlayer = function() {
		FMapEvent.trigger(this, 'onCloseVideoPlayer');
	};
	
	window.FMap = FMapObj;
	


	
	/********************************************************/
	/* ÀÌº¥Æ® °´Ã¼ ¼±¾ð // FMapEvent //*/
	/********************************************************/
    var EventMan = {};
    EventMan.addListener =function (element,eventName,handler){
        var wEvent = EventMan.getWEventName(eventName);
        if (element[wEvent]) element[wEvent].push(handler);
        else element[wEvent] = new Array(handler);
    };
    EventMan.removeListener =function (element,eventName,handler){
        var evt = EventMan.getWEventName(eventName);
        var arrEvent = element[evt];
        if (arrEvent && arrEvent.length>0){
            var flag = false;
            for (var i = 0;i<arrEvent.length;i++){
                if (arrEvent[i] == handler){
                    flag = true;
                }
                if (flag && i!=(arrEvent.length-1)){
                    arrEvent[i] = arrEvent[i+1];
                }
            }
            if (flag){
                arrEvent.pop();
            }
        }
    };
    EventMan.trigger =function(element,eventName){
        var evt = EventMan.getWEventName(eventName);
        var arrEvent = element[evt];
        if(arrEvent&&arrEvent.length>0){
            var args = new Array();
            for(var i = 2;i<arguments.length;i++){
                args.push(arguments[i]);
            }
            args.push(element);
            for(var i = 0;i<arrEvent.length;i++){
                var evtCallBack = arrEvent[i];
                if(evtCallBack){
                    try{
                        evtCallBack.apply(element,args)}
                    catch (e){
                    }
                }
            }
        }
    };
    EventMan.getWEventName =function (eventName){
        return "_fmapEvent__"+eventName;
    };
    /* ÀÌº¥Æ® °ü¸® °´Ã¼ Á¤ÀÇ ³¡ */
    
	window.FMapEvent = EventMan;
};
_FMapLib();	