var MOTOROI = {
	__postLoginAction__: null,
	__postUploadAction__: null,
	__postCloseFrameAction__: null,
	__postZipcodeAction__: null,


	// ·Î±×ÀÎ µ¥ÀÌÅÍ..!
	memberData:{
		login: false,
		uid: "",
		uname: "",
		type: "",
		mania: false
	},


	layerFrame: null,
	pageLayer: null,
	disabledZone: null,
	downloadFrame: null,


	// ÆäÀÌÁö ·¹ÀÌ¾î ³»ºÎÀÇ ÇÁ·¹ÀÓ ¹ÝÈ¯
	getLayerFrame: function(){
		MOTOROI.layerFrame = $("__searchFrame__");

		if( !MOTOROI.layerFrame ){
			MOTOROI.layerFrame = new Element("iframe");
			MOTOROI.layerFrame.id = MOTOROI.layerFrame.name = "__layerFrame__";
			MOTOROI.layerFrame.frameBorder = 0;

			MOTOROI.getPageLayer().appendChild( MOTOROI.layerFrame );
		}

		return MOTOROI.layerFrame;
	},


	// ÆäÀÌÁö ·¹ÀÌ¾î ¹ÝÈ¯
	getPageLayer: function(){
		MOTOROI.pageLayer = $("__pageLayer__");

		if( !MOTOROI.pageLayer ){
			MOTOROI.pageLayer = new Element("div");

			MOTOROI.pageLayer.id = "__pageLayer__";
			MOTOROI.pageLayer.style.display = "none";
			MOTOROI.pageLayer.style.position = "absolute";
			MOTOROI.pageLayer.width = MOTOROI.pageLayer.height = 0;
			

			MOTOROI.pageLayer.page = MOTOROI.getLayerFrame();

			Event.observe(
				window,
				"resize",
				function(){
					MOTOROI.pageLayer.style.left = ( (document.body.scrollWidth / 2) - (MOTOROI.pageLayer.width / 2) ) + "px";
					MOTOROI.pageLayer.style.top = ( (document.body.scrollHeight / 2) - (MOTOROI.pageLayer.height / 2) ) + "px";
				}
			);


			document.body.appendChild( MOTOROI.pageLayer );
		}

		MOTOROI.pageLayer.style.zIndex = 9050;

		return MOTOROI.pageLayer;
	},
	

	// ¹ÝÅõ¸í ·¹ÀÌ¾î ¹ÝÈ¯
	getDisabledZone: function(){
		MOTOROI.disabledZone = $("__divDisabledZone__");

		if( !MOTOROI.disabledZone ){
			MOTOROI.disabledZone = new Element("div");
			MOTOROI.disabledZone.id = "__divDisabledZone__";
			MOTOROI.disabledZone.style.zIndex = 0;
			MOTOROI.disabledZone.style.width = document.body.scrollWidth;
			MOTOROI.disabledZone.style.height = document.body.scrollHeight;
			MOTOROI.disabledZone.style.left = 0;
			MOTOROI.disabledZone.style.top = 0;
			MOTOROI.disabledZone.style.position = "absolute";
			MOTOROI.disabledZone.style.backgroundColor = "black";
			MOTOROI.disabledZone.style.opacity = 0.25;
			MOTOROI.disabledZone.style.MozOpacity = 0.25;
			MOTOROI.disabledZone.style.KhtmlOpacity = 0.25;
			MOTOROI.disabledZone.style.filter = "alpha(opacity=25)";
			MOTOROI.disabledZone.style.zIndex = 9000;

			MOTOROI.disabledZone.hide();


			Event.observe(
				window,
				"resize",
				function(){
					MOTOROI.getDisabledZone().width = document.body.scrollWidth;
					MOTOROI.getDisabledZone().height = document.body.scrollHeight;
				}
			);


			document.body.appendChild( MOTOROI.disabledZone );
		}

		return MOTOROI.disabledZone;
	},



	// ·¹ÀÌ¾î ÆäÀÌÁö ·Îµå( °æ·Î, ³ÐÀÌ, ³ôÀÌ, °æ°è¼±Ç¥½Ã¿©ºÎ )
	loadPage: function( src, width, height, fnPostClose, gridBorder ){
		for(var i=0; i<document.getElementsByTagName("select").length; i++){
			document.getElementsByTagName("select")[i].style.display = "none";
		}


		MOTOROI.getPageLayer().width = MOTOROI.getLayerFrame().width = ((gridBorder) ? (width + 4) : width) + "px";
		MOTOROI.getPageLayer().height = MOTOROI.getLayerFrame().height = ((gridBorder) ? (height + 4) : height) + "px";
		MOTOROI.getPageLayer().style.left = ( (document.body.clientWidth / 2) - (width / 2) ) + "px";
		MOTOROI.getPageLayer().style.top = ( (document.body.clientHeight / 2) - (height / 2) ) + "px";



		MOTOROI.getLayerFrame().src = src;


		if( gridBorder ){
			MOTOROI.getPageLayer().style.border = "2px solid #CFCFCF";
		}


		MOTOROI.getDisabledZone().show();
		MOTOROI.getPageLayer().show();

		MOTOROI.getLayerFrame().focus();

		MOTOROI.__postCloseFrameAction__ = fnPostClose;
	},



	// ·¹ÀÌ¾î ÆäÀÌÁö ´Ý±â..
	closePage: function(){
		for(var i=0; i<document.getElementsByTagName("select").length; i++){
			document.getElementsByTagName("select")[i].style.display = "inline";
		}



		if( typeof(MOTOROI.__postCloseFrameAction__) == "function" ){
			try{
				MOTOROI.__postCloseFrameAction__(arguments[0]);
			} catch(e){};


			MOTOROI.__postCloseFrameAction__ = null;
		}


		MOTOROI.getLayerFrame().src = "about:blank";

		MOTOROI.getPageLayer().hide();
		MOTOROI.getDisabledZone().hide();
	},



	// ´Ù¿î·Îµå ÇÁ·¹ÀÓ ¹ÝÈ¯..
	getDownloadFrame: function(){
		if( !MOTOROI.downloadFrame ){
			MOTOROI.downloadFrame = document.createElement("IFRAME");
			MOTOROI.downloadFrame.id = MOTOROI.downloadFrame.name = "__ifrDownload__";
			MOTOROI.downloadFrame.frameBorder = "0px";
			MOTOROI.downloadFrame.style.width = MOTOROI.downloadFrame.style.height = "0px";
			MOTOROI.downloadFrame.style.display = "none";
			
			document.body.appendChild( MOTOROI.downloadFrame );
		}

		return MOTOROI.downloadFrame;
	},	

	
	
	// ·Î±×ÀÎ·¹ÀÌ¾î º¸ÀÌ±â..!
	showLoginLayer: function( evtCode ){
		//MOTOROI.__postLoginAction__ = fnPostLogin;



		for(var i=0; i<document.getElementsByTagName("select").length; i++){
			document.getElementsByTagName("select")[i].style.display = "none";
		}

		//MOTOROI.loadPage("/loginForm.aspx", 400, 250);
		MOTOROI.loadPage("/promotion/motoroi_login.asp", 400, 250);
	},



	// ·Î±×ÀÎ·¹ÀÌ¾î ´Ý±â..!
	closeLoginLayer: function(){
		for(var i=0; i<document.getElementsByTagName("select").length; i++){
			document.getElementsByTagName("select")[i].style.display = "inline";
		}


		if( typeof(MOTOROI.__postLoginAction__) == "function" ){
			try{
				MOTOROI.__postLoginAction__();
			} catch(e){};

		} 

		//MOTOROI.loadMemberInfo( new Function("MOTOROI.closePage();") );

		MOTOROI.closePage();
	},


	// ·Î±×¾Æ¿ô..
	logout: function(){
		new Ajax.Request(
			"/process/logout.asp",
			{
				parameters:("")
			}
		)
	},




	// »çÀÌÆ® Æ®·¡Å·..!
	setTrack: function( codeType, codeName ){		

		new Ajax.Request(
			"./process/tracking.asp",
			{
				parameters:("codeType=" + codeType + "&codeName=" + codeName)
			}
		);	
	},


	// ºí·Î±× Æ®·¡Å·..!
	blogtrace: function( codeType, codeName ){		

		new Ajax.Request(
			"./process/blog_tracking.asp",
			{
				parameters:("codeType=" + codeType + "&codeName=" + codeName)
			}
		);	
	}


};


