function fn_CheckMainFrame()
{
	if (window == top)
	{
		document.write ('<form name="frame_top" action="/" method=post>');
		document.write ('<input type=hidden name=indexUrl value="'+location.href+'">');
		document.write ('</form>');
		document.frame_top.submit();
	}
}
//String ÀÇ °ø¹éÀ» ¸ðµÎ Á¦°ÅÇÑ´Ù.
function fn_Trim(sourceString)
{
	var strResult ;
	try
	{
		strResult = sourceString.replace(/\s/g,"");
		return strResult;
	}
	catch(exception){}
}

//String ÀÇ ¾çÂÊ°ø¹éÀ» ¸ðµÎ Á¦°ÅÇÑ´Ù.
function fn_RLTrim(strSource)
{
	try
	{
		return strSource.replace(/(^\s*)|(\s*$)/g, "");
	}
	catch(exception){}
}

//¹®ÀÚ¿­ ¹Ù²Þ
function fn_ReplaceAll(oldStr,findStr,repStr)
{
	try
	{
		var srchNdx = 0;
		var newStr = ""; 
		while (oldStr.indexOf(findStr,srchNdx) != -1)  
		{
			newStr += oldStr.substring(srchNdx,oldStr.indexOf(findStr,srchNdx));
			newStr += repStr;
			srchNdx = (oldStr.indexOf(findStr,srchNdx) + findStr.length);
		}
		newStr += oldStr.substring(srchNdx,oldStr.length);
		return newStr;
	}
	catch(exception){}
}

//À©µµ¿ì Ã¢ °¡¿îµ¥ ¿­±â
function fn_OpenCenterPopup(url, width, height, winName, feature)
{
	var nTop = 0;
	var nLeft = 0;
	var nHeight = height;
	var nWidth = width;
	var strFeature = "";
	try
	{
		if(feature != null && feature.length > 0)
			strFeature = "," + feature;
		else
			strFeature = strFeature;

		nTop = (window.screen.height / 2) - (nHeight / 2);
		nLeft = (window.screen.width / 2) - (nWidth / 2);
	
		window.open(url, winName, "width=" + nWidth.toString() + ",height=" + nHeight.toString() + ",top=" + nTop.toString() + ",left=" + nLeft.toString() + strFeature);
	}
	catch(e)
	{
		alert(e.description);
	}
}

//Xml¹Þ¾Æ¿À±â
function fn_GetXmlDomDocument(sPage)
{
	var oXmlDoc;
	try
	{
		oXmlDoc = new ActiveXObject("Microsoft.XMLDOM");
		oXmlDoc.async = false;
		oXmlDoc.load(sPage);
		if(oXmlDoc.readyState != 4 && !oXmlDoc.parseError)
		{
			return null;
		}
		else
		{
			return oXmlDoc;
		}
	}
	catch(exception){}
}

//XML http
function fn_SetXmlHttpDocument(postXml, getUrl, sendMethod)
{	
	var oXmlHttp;
	var strTemp;
	try
	{
		oXmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
		oXmlHttp.Open(sendMethod, getUrl, false);
		oXmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
		oXmlHttp.send(postXml);

		if(oXmlHttp.status == 500)
		{
			strTemp = "";
		}
		else
		{
			strTemp = oXmlHttp.responseText;
		}

		return strTemp;
	}
	catch(exception){}
	finally
	{
		oXmlHttp = null;
	}
}

//¹Ìµð¾îÇÃ·¹ÀÌ¾î
function fn_InsertMediaPlayer(srcUrl)
{
    strWidth = "430";
	strHeight = "381";
	try
	{
		/*
		document.write("<object id=\"objMediaPlayer\" classid=\"CLSID:22d6f312-b0f6-11d0-94ab-0080c74c7e95\" style=\"FILTER:xray\" width=\"430\" height=\"381\" VIEWASTEXT>");
		document.write("	<param name=\"AutoStart\" value=\"true\">");
		document.write("	<param name=\"ShowControls\" value=\"true\">");
		document.write("	<param name=\"ShowStatusBar\" value=\"false\">");
		document.write("	<param name=\"FileName\" value=\"" + srcUrl + "\">");
		document.write("	<PARAM name=\"showtracker\" value=\"true\">");
		document.write("</object>");
		*/
		//document.write("<object id=\"objMediaPlayer\" width=\"" + strWidth + "\" height=\"" + strHeight + "\" style=\"FILTER:gray\"  classid=\"6BF52A52-394A-11d3-B153-00C04F79FAA6\" type=\"application/x-mplayer2\" codebase=\"http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=5,1,52,701\">");
		document.write("<object id=\"objMediaPlayer\" width=\"" + strWidth + "\" height=\"" + strHeight + "\" style=\"FILTER:gray\"  classid=\"6BF52A52-394A-11d3-B153-00C04F79FAA6\" type=\"application/x-mplayer2\" codebase=\"http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=6,4,5,715,\">");
		document.write("<param name=\"FileName\" value=\"" + srcUrl + "\">");
		document.write("<param name=\"AutoStart\" value=\"1\">");
		document.write("<param name=\"ShowStatusBar\" value=\"1\">");
		document.write("<param name=\"ShowControls\" value=\"1\">");
		document.write("<param name=\"uiMode\" value=\"full\">");
		document.write("</object>");
	}
	catch(exception){}
}
    
//¿ÀºêÁ§Æ® ½ºÅ©¸³Æ® Ãâ·Â
function RenderObjectScript(scriptValue)
{
	try
	{
	    document.write(scriptValue);
	}
	catch(exception){}
}

var caution = false;
//ÄíÅ° ¼³Á¤
function fn_SetCookie(name, value, expires, path, domain, secure)
{
	var strCurCookie = "";	
	try
	{
		strCurCookie = name + "=" + escape(value) + 
		((expires) ? "; expires=" + expires.toGMTString() : "") +
		((path) ? "; path=" + path : "") +
		((domain) ? "; domain=" + domain : "") +
		((secure) ? "; secure" : "");

		if (!caution || (name + "=" + escape(value)).length <= 4000)
			document.cookie = strCurCookie;
		else
			if (confirm("Cookie exceeds 4KB and will be cut!"))
				document.cookie = strCurCookie;
	}
	catch(exception){}
}

//ÄíÅ° °¡Á®¿À±â
function fn_GetCookie(name)
{
	var strPrefix = "";
	var nCookieStartIndex = -1;
	var nCookieEndIndex = -1;
	
	try
	{
		strPrefix = name + "=";
		nCookieStartIndex = document.cookie.indexOf(strPrefix);
		
		if (nCookieStartIndex == -1)
			return null;
			
		nCookieEndIndex = document.cookie.indexOf(";", nCookieStartIndex + strPrefix.length);
		
		if (nCookieEndIndex == -1)
			nCookieEndIndex = document.cookie.length;
		
		return unescape(document.cookie.substring(nCookieStartIndex + strPrefix.length, nCookieEndIndex));
	}
	catch(exception){}
}

//ÄíÅ°¿­ Áß¿¡ uName2ÀÇ °ªÀ» ±¸ÇÑ´Ù 
function fn_GetCookie2(uName,uName2)
{
	var strReturnValue = "";
	var strString = "";
	var nFlag = -1;
	var nEnd = -1;
	try
	{
		strString = fn_GetCookie(uName);
		nFlag = strString.indexOf(uName2+'=');
		
		if (nFlag != -1) 
		{ 
			nFlag += uName2.length + 1
			nEnd = strString.indexOf('&', nFlag) 

			if (nEnd == -1) 
				nEnd = strString.length;

			strReturnValue = unescape(strString.substring(nFlag, nEnd));
		}
		else
		{
			strReturnValue = "";
		}
		
		return strReturnValue;
	}
	catch(exception){}
}

//Äí±â°ª Ãß°¡
function fn_CookieAdd(name,value)
{
	try
	{
		fn_SetCookie(name,value, 0,"/","");
	}
	catch(exception){}
}

//·Î±×ÀÎ/·Î±×¾Æ¿ô¹öÆ°
function fn_GetLoingString()
{ 
	var str_login = "";
	try
	{
		if (fn_GetCookie("Joins_LoginStatus") == "True" && fn_GetCookie("Joins_ValidLogin") == "True" )
 			str_login = "<a href='http://login.joins.com/Logout.asp' class='gn' target='_top'><img src=http://images.joins.com/ui_joins/news06/common/btn_gn_logout01.gif width=47 height=16 border=0 align=absmiddle></a><a href='http://myjoins.joins.com/' class='gn' target='_top'><img src=http://images.joins.com/ui_joins/news06/common/btn_gn_amend01.gif width=46 height=16 border=0 align=absmiddle></a>";
		else
			str_login = "<a href='http://login.joins.com' class='gn' target='_top'><img src=http://images.joins.com/ui_joins/news06/common/btn_gn_login01.gif width=38 height=16 border=0 align=absmiddle><a href='http://myjoins.joins.com/register/member_reg.asp' class='gn' target='_top'><img src=http://images.joins.com/ui_joins/news06/common/btn_gn_join01.gif width=47 height=16 border=0 align=absmiddle></a>";
		
		return str_login;
	}
	catch(exception){}
}

//¼ýÀÚ Æ÷¸Ë.. ¼¼ÀÚ¸®¼ö¸¶´Ù.. ÄÞ¸¶ Ç¥½Ã
function fn_ReturnMoneyFormatString(numValue) 
{ 
	var strValue = "";
	var retValue = ""; 
	try
	{
		strValue = "" + numValue + "";

		for(i=0; i<strValue.length; i++) 
		{ 
			if(i > 0 && (i%3)==0)
			{ 
				retValue = strValue.charAt(strValue.length - i -1) + "," + retValue; 
			} 
			else
			{ 
				retValue = strValue.charAt(strValue.length - i -1) + retValue; 
			} 
		} 
		return retValue; 
	}
	catch(exception){}
} 

    function popupWindow(Url,windowName,Width,Height,scroll){
       if((scroll==null) || (scroll=="")){
    	   scroll = "no";
       }
       var win = window.open(Url,windowName,"toolbar=no,location=no,directory=no,status=no,menubar=no,scrollbars="+ scroll +",resizable=no,top=50,left=50,width="+ Width +",height="+ Height);
       if(win!=null) win.focus();
    }

    function ArticlePrint(){

        popupWindow("/print.asp?","print",600,650,"yes");
    }
    function ArticleEmail(){
        popupWindow("/mail.asp?","email",510,560,"no");
    }    

    function checkForm(frmobj){
    	with(frmobj){
    		for(var i=0; i<elements.length; i++) {
    			if(elements[i].valid!=null){				
    				var ret = CheckValid(frmobj,elements[i]);
    				if(ret==false) return ret;
    			}
    		}
    		return true;
    	}
    }
    