/**************** ÀÏ¹ÝÀûÀ¸·Î ¾²ÀÌ´Â JS ÇÔ¼ö ÆÄÀÏ ********************
**************************************************************************/

/********* ¸¶¿ì½º ·Ñ¿À¹ö ½º¿ÒÀÌ¹ÌÁö **********/ 
function MM_reloadPage(init) {  //reloads the window if Nav4 resized
	if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
		document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
	else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);

function MM_swapImgRestore() { //v3.0
	var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
	var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
	var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
	if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
	var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
		d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
	if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
	for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
	if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
	var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
	if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

/********* ÀÌ¹ÌÁö ¹öÆ° Å¬¸¯½Ã Á¡¼± ¾Èº¸ÀÌ±â **********/ 
function bluring(){ 
	if(event.srcElement.tagName=="A"||event.srcElement.tagName=="IMG") document.body.focus(); 
} 
// document.onfocusin=bluring;

/********************* ÆË¾÷ *********************/ 
function winPopup(URL,Name,features) {
	window.open(URL,Name,features);
}

/********************* flash Include *********************/
function EmbedObject() {
// Object
	var objectTAG		= new String;
	//SWF
	var classIDSWF		= 'CLSID:D27CDB6E-AE6D-11cf-96B8-444553540000';
	var codeBaseSWF		= 'http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab';

	//WMP
	var classIDWMP		= 'CLSID:22D6F312-B0F6-11D0-94AB-0080C74C7E95';
	var codeBaseWMP		= 'http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab';

// Param
	var parameterTAG	= new String;

// Embed
	var embedTAG		= new String;

	// SWF
	var typeSWF			= 'application/x-shockwave-flash';
	var pluginsPageSWF	= 'http://www.macromedia.com/go/getflashplayer';

	// WMP
	var typeWMP			= 'application/x-mplayer2';
	var pluginsPageWMP	= 'http://www.microsoft.com/Windows/MediaPlayer/';	

	this.embedSWF		= embedSWF;
	this.embedWMP		= embedWMP;
	this.editObject		= editObject;
	this.editParam		= editParam;
	this.editEmbed		= editEmbed;
	this.displayHTML	= displayHTML;
	this.showembedTAG	= showembedTAG;

	// Flash ³Ö´Â ÇÔ¼ö
	function embedSWF(srcSWF, widthSWF, heightSWF, objectID, alignSWF, verSWF) {

		//Script init
		objectTAG += "<OBJECT ";
		embedTAG += "<EMBED ";

		//Class ID
		objectTAG += "classid='"+ classIDSWF +"' ";
	
		//CodeBase, Version
		(verSWF) ? codeBaseSWF += "#version="+ verSWF : codeBaseSWF += "#version=9,0,0,0"
		this.editObject('codebase',codeBaseSWF);


		// Align
		if (alignSWF)	{
			this.editObject('align',alignSWF);
		}

		// ID
		if (objectID)	{
			this.editObject('id',objectID);
			this.editEmbed('name',objectID);
		}
		
		//Parameter
		this.editParam('quality','high');
		this.editParam('movie',srcSWF,'Param');

		//Embed tag
		this.editEmbed('src',srcSWF);
		this.editEmbed('pluginspage',pluginsPageSWF);
		this.editEmbed('type',typeSWF);


		if (widthSWF)	{
			this.editObject('width',widthSWF);
			this.editEmbed('width',widthSWF);
		}

		if (heightSWF)	{
			this.editObject('height',heightSWF);
			this.editEmbed('height',heightSWF);
		}
	}

	// Media Player ³Ö´Â ÇÔ¼ö
	function embedWMP(srcWMP, widthWMP, heightWMP, objectID, alignWMP, verWMP) {

		//Script init
		objectTAG += "<OBJECT ";
		embedTAG += "<EMBED ";

		//Class ID
		objectTAG += "classid='"+ classIDWMP +"' ";
	
		//CodeBase, Version
		codeBaseWMP += (verWMP) ? "#version="+ verWMP : "#version=5,1,52,701";
		this.editObject('codebase',codeBaseWMP);

		//Type
		this.editObject('type','application/x-oleobject');

		// ID
		if (objectID)	{
			this.editObject('id',objectID);
			this.editEmbed('name',objectID);
		}

		// Align
		if (alignWMP)	{
			this.editObject('align',alignWMP);
		}
		
		//Parameter
		this.editParam('FileName',srcWMP,'Param');

		//Embed tag
		this.editEmbed('src',srcWMP);
		this.editEmbed('pluginspage',pluginsPageWMP);
		this.editEmbed('type',typeWMP);


		if (widthWMP)	{
			this.editObject('width',widthWMP);
			this.editEmbed('width',widthWMP);
		}

		if (heightWMP)	{
			this.editObject('height',heightWMP);
			this.editEmbed('height',heightWMP);
		}
	}
	
	//Object Tag
	function editObject(name, value) {
		objectTAG += " " + name + "='" + value + "' ";
	}

	//Parameter Tag
	function editParam(name, value, target) {

		parameterTAG += "<PARAM NAME='"+name+"' VALUE='"+value+"'>\n";
		
		// editParamÇÔ¼ö¿¡¼­ Object ¹× Embed¿¡ ÇÑ²¨¹ø¿¡ Áý¾î³ÖÀ½. 
		if (!target) {
			editEmbed(name, value);
		}
	}
	//Embed Tag
	function editEmbed(name, value) {
		embedTAG += " " + name + "='" + value + "' ";
	}

	//HTML¿¡ »Ñ·ÁÁÖ´Â ÇÔ¼ö
	function displayHTML(DivID) {
		objectTAG	+= ">\n"; 
		embedTAG	+= "></EMBED>\n"; // ¸¶°¨ÅÂ±× ºÙ¿©ÁÖ±â
		totalHTML		= objectTAG + parameterTAG + embedTAG + "</OBJECT>";

		(DivID) ? document.getElementById(DivID).innerHTML = totalHTML : document.write(totalHTML);
	}

	function showembedTAG() {
		alert(objectTAG + parameterTAG + embedTAG+"></EMBED>\n</OBJECT>");
	}
}

/********* XML Handling **********/ 
function initXML(xmlFile) {
	try {
		if (window.ActiveXObject) {
			try {
				xmlDoc = new ActiveXObject('Microsoft.XMLDOM');
			} catch (cantRead) {
				try {
					xmlDoc = new ActiveXObject('Msxml2.Domdocument');
				} catch (cantRead) {
					alert('¸øÀÐ¾úÀ½ \nF5 ¿¬Å¸ ÀÐÀ» ¼ö ÀÖÀ» ¶§ ±îÁö');
				}
			}
		}
		else if (document.implementation && document.implementation.createDocument) {
			xmlDoc = document.implementation.createDocument('','doc',null);
		}
		else alert('Sorry, this browser is not XML-compliant and cannot render the XML data.');

		xmlDoc.async=false;
		xmlDoc.load(xmlFile);

	} catch(cantRead) {
		alert ('There was an error (' + cantRead + ') attempting to load the XML document');
	}
}

//ÄíÅ°±Á´ÂÇÔ¼ö.
function getCookie( name ){ 
	var nameOfCookie = name + "="; 
	var x = 0; 
	while ( x <= document.cookie.length ) { 
		var y = (x+nameOfCookie.length); 
		if ( document.cookie.substring( x, y ) == nameOfCookie ) { 
			if ( (endOfCookie=document.cookie.indexOf( ";", y )) == -1 ) 
			endOfCookie = document.cookie.length; 
			return unescape( document.cookie.substring( y, endOfCookie ) ); 
		} 
		x = document.cookie.indexOf( " ", x ) + 1; 
		if ( x == 0 ) break; 
	}  
	return ""; 
} 

// ¹®ÀÚ Ä¡È¯ ÇÔ¼ö
	String.prototype.trim = function() {
		return this.replace(/(^\s*)|(\s*$)/gi, "");
	}

	String.prototype.replaceAll = function(str1, str2) {
		var temp_str = "";
		if (this.trim() != "" && str1 != str2) {
		temp_str = this.trim();
			while (temp_str.indexOf(str1) > -1) {
				temp_str = temp_str.replace(str1, str2);
			}
		}
		return temp_str;
	}
