var DEBUG = false;

function debug(str){
	if(DEBUG)
		dbg.innerText += "\nDEBUG> "+str
}

//	¿ÀºêÁ§Æ® »ý¼ºÀÌ ¿Ï·áµÈÈÄ ½ÇÇàÇÒ ³»¿ëÀ» Æ÷ÇÔÇÑ´Ù.
//
//

function oncompleted(){
	try{

		//	 **1. ´ëºÎºÐÀÇ ¾ÖÇÃ¸®ÄÉÀÌ¼Ç¿¡¼­´Â ¾Æ·¡ ³»¿ëÀÌ ÇÊ¿ä¾ø½À´Ï´Ù.
		//		emarket ÀÇ °æ¿ìÃ³·³ ´ëºÎºÐÀÇ È­¸é¿¡¼­ document ready »óÅÂ¿¡¼­ ÀÏ°üµÇ°Ô
		//		window_onload ¸¦ ½ÇÇàÇÏ´Â °æ¿ì ¾Æ·¡ Ã³·³ ±â¼ú ÇÒ ¼ö ÀÖ°í, body ¿¡¼­ onload ¸¦
		//		Á¤ÀÇÇÏ´Â °æ¿ì´Â Æ÷ÇÔ½ÃÅ³ ÇÊ¿ä°¡ ¾ø½À´Ï´Ù.
		//

		//window_onload1();

	}
	catch(e){
		debug("issued.oncompleted()'"+e.description+"'");
	}
}

//	¹®¼­°¡ ·ÎµåµÈÈÄ Áï½Ã ½ÇÇàÇÒ ÇÔ¼ö¸¦ ¼¼Æ®ÇÑ´Ù.
//
//

function orsc1(){
	try{
		if(document.readyState == "complete"){
			launch();
			try{eval(document.body.onload);}catch(e){}	//	ignored
		}
	}
	catch(e){
		debug("issued.orsc1() '"+e.description+"'");
	}
}

//	¿ÀºêÁ§Æ®µéÀÌ ·ÎµåµÈÈÄ ½ÇÇàÇÒ ÇÔ¼ö¸¦ ¼¼Æ®ÇÑ´Ù.
//
//

function orsc2(){
	try{
		var src=event.srcElement;
		if(src.readyState == "4" || scr.readyState == "complete"){
			oncompleted();
		}
	}
	catch(e){
		debug("issued.orsc2()'"+e.description+"'");
	}
}

// °øÅë ½ÇÇà ÇÔ¼ö
//
//

function launch(){

	try{

		var lst, e1;

		if(DEBUG){
			try{
				lst = document.getElementsByTagName("BODY");
				if(lst != null && lst.length >0){
					for(i=0; i<lst.length; i++){
						el = lst.item(i);
						dl = document.createElement(
								"<Div id='dbg' "+
									"style='width:640;height:280;overflow:scroll;font-size:10pt;"+
									"font-family:Verdana;text-align:left;'></Div>");
						el.insertBefore(dl, el.firstChild);
					}
				}
			}
			catch(e){}	//	ignored
		}

		//	**2. ÇÃ·¡½¬ ¶Ç´Â À©µµ¿ìÁî ¹Ìµð¾îÀÇ °æ¿ì Embed ÅÂ±×¸¸ ±â¼úÇÏ´Â °æ¿ì°¡ ÀÖ´Âµ¥ ÀÌ¶§¿¡´Â
		//		¾Æ·¡¿¡¼­ OBJECT ÅÂ±×¿Í EMBED ÅÂ±× ¸ðµÎ¿¡ ´ëÇØ Ã³¸®ÇÕ´Ï´Ù. APPLET ÀÇ °æ¿ìµµ °°Àº
		//		¹æ¹ýÀ¸·Î Ã³¸®ÇÕ´Ï´Ù.

		lst = document.getElementsByTagName("OBJECT");
		if(lst != null && lst.length >0){

			for(i=lst.length-1; i>=0; i--){

				el = lst.item(i);
				debug(el.tagName+" id="+el.id);

				//	retrieves the parent node for this element

				var pe = el.parentNode;

				//	removes current node of the document

				var te = pe.removeChild(el);

				//	creates a new element for grid control

				e1 = document.createElement("<OBJECT classid=\""+el.classid+"\" id=\""+el.id+"\"></OBJECT>");
				debug("-> new '"+e1.id+"'");

				//	 **3. ¾ÖÆ®¸®ºäÆ®¸¦ °³º° ¼³Á¤ÇÏ´Â °æ¿ì
				//

				e1.width = el.width;
				e1.height = el.height;
				e1.codebase = el.codebase;
				e1.viewAsText = el.viewAsText;

				//	 **3. ¾ÖÆ®¸®ºäÆ®¸¦ ÀÚµ¿ ¼³Á¤ÇÏ´Â°æ¿ì
				//		ºÒÇÊ¿äÇÑ ¼öÇàÀÌ ¸¹À» ¼ö ÀÖÀ¸¹Ç·Î µÇµµ·Ï °³º° ¼³Á¤ÇÏ´Â ¹æ¹ýÀ¸·Î Àû¿ëÇÕ´Ï´Ù.

				//for(a=0; a<e1.attributes.length; a++){
				//	itm = el.attributes.item(a);
				//	ni = document.createAttribute(itm.name);
				//	ni.value = itm.value;
				//
				//	//if(ni.value == null || ni.value == "" ||
				//	//	ni.name == "classid" || ni.name == "codebase" ||
				//	//	ni.name == "implementation" || ni.name == "style" ||
				//	//	new String(ni.name).substring(0,2) == "on")
				//	//	continue;	//	skipped
				//
				//	debug("  ATTR:"+ni.name+"="+ni.value)
				//	//e1.attributes.setNamedItem(ni);
				//}

				//	embeds the element

				pe.appendChild(e1);

				//	retrieves and sets the settings of the ctrl

				colxn = el.childNodes;
				len = colxn.length;
				for(g=0; g<len; g++){
					debug("  PARAM:"+colxn.item(g).getAttribute("NAME")+"="+colxn.item(g).getAttribute("VALUE"))
					e2 = document.createElement("PARAM");
					e2.name = colxn.item(g).getAttribute("NAME");
					e2.value = colxn.item(g).getAttribute("VALUE");
					e1.appendChild(e2);
				}

				debug(pe.innerHTML)

			}

			if(e1 != null){

				//	sets the event handler for initialization

				e1.onreadystatechange = orsc2;

			}
			else
				oncompleted();

		}

	}
	catch(e){
		debug("issued.launch() '"+e.description+"'");
	}

}

// hooks the ready state change event of the document

document.onreadystatechange = orsc1;

;