/*
 * @(#)Window.Util.js
 *
 * À©µµ¿ì À¯Æ¿¸®Æ¼ ÇÔ¼ö ¸ðÀ½
 *
 * Copyright 2002 HelloPHP.COM All rights reserved.
 * 
 * @author ´«ÀÌ¿À¸é, ifsnow@korea.com
 * @version 1.0.000, 2002/07/15
 */


/**
 * ºê¶ó¿ìÀúÀÇ ¹öÀüÀ» Ã¼Å©ÇÕ´Ï´Ù.
 */
function GetBrowser() 
{
	var tempDocument = window.document;

	if (tempDocument.all && tempDocument.getElementById) // ÀÎÅÍ³Ý ÀÍ½ºÇÃ·Î·¯ 5.x
	{ 
		return 1;
	}
	else if (tempDocument.all && !tempDocument.getElementById) // ÀÎÅÍ³Ý ÀÍ½ºÇÃ·Î·¯ 4.x
	{ 
		return 2;
	}
	else if (tempDocument.getElementById && !tempDocument.all) // ³Ý½ºÄÉÀÌÇÁ 6
	{ 
		return 3;
	}
	else if (tempDocument.layers) // ³Ý½ºÄÉÀÌÇÁ 4.x
	{	 
		return 4;
	}
}

/**
 * ÆË¾÷Ã¢À» ¿øÇÏ´Â À§Ä¡¿¡ »ý¼ºÇÕ´Ï´Ù.
 */
function OpenWindow(url, name, width, height, align, valign, option) 
{
    var x,y;
	var window_option = "width="+width+",height="+height;

	if (option!=null) window_option+=","+option;
    if (align==null) align="center";
    if (valign==null) valign="center";

    if (align=="left") x=0;
    else if (align=="right") x=(screen.width-width);
    else if (align=="center") x=(screen.width-width)/2

    if (valign=="top") y=0;
    else if (valign=="bottom") y=(screen.height-height);
    else if (valign=="center") y=(screen.height-height)/2

    window_option+=",left="+x+",top="+y;

    var win = window.open(url,name,window_option);

	focus();
    win.focus();
	return win;
}

/**
 * À©µµ¿ì°¡ ¿­·ÁÀÖ´ÂÁö Ã¼Å©ÇÕ´Ï´Ù.
 */
function isAliveWindow(win)
{
	if (!win.closed) return true;
	else return false;
}

/**
 * »ç¿îµå¸¦ µéÀ»¼ö ÀÖ´ÂÁö È¯°æÀÎÁö Ã¼Å©ÇÕ´Ï´Ù. (IEÀü¿ë)
 */
function EnableSound()
{
  document.write("<OBJECT ID='Player64' CLASSID='CLSID:22d6f312-b0f6-11d0-94ab-0080c74c7e95' STYLE='display:none'></OBJECT>");
  return Player64.IsSoundCardEnabled();
}

/**
 * ¸®¾óÇÃ·¹ÀÌ¾î(RealPlayer) ¼³Ä¡ ¿©ºÎ Ã¼Å©ÇÕ´Ï´Ù.
 */
function EnableRealPlayer()
{
	var nRealMode=0;
	var nRealPlayer5=0;
	var nRealPlayer4=0;
	var nRealPlayerG2=0;

	if (window.document.all) // IE
	{
		document.write('<SCRIPT LANGUAGE=VBScript\> \n');
		document.write('on error resume next \n');
		document.write('nRealPlayerG2 = (NOT IsNull(CreateObject("rmocx.RealPlayer G2 Control")))\n');
		document.write('nRealPlayer5 = (NOT IsNull(CreateObject("RealPlayer.RealPlayer(tm) ActiveX Control (32-bit)")))\n');
		document.write('nRealPlayer4 = (NOT IsNull(CreateObject("RealVideo.RealVideo(tm) ActiveX Control (32-bit)")))\n');
		document.write('</SCRIPT\> \n');
	}
	else // NS
	{
		var numPlugins = navigator.plugins.length;
		for (var i = 0; i < numPlugins; i++)
		{
			plugin = navigator.plugins[i];
			if (plugin.name.substring(0,10)=="RealPlayer")
			{
				nRealMode=1;
			}
		}
	}

	if (nRealMode || nRealPlayerG2 || nRealPlayer5 || nRealPlayer4) 
		return true;
	else 
		return false;
}

/**
 * ÆäÀÌÁö ÀÌµ¿À» ÇÕ´Ï´Ù.
 * @param		delay		ÆäÀÌÁö ÀÌµ¿ Áö¿¬ ½Ã°£ (milliseconds)
 */
function MovePage(str,delay)
{
	if (delay==null) 
		window.location.href=str;
	else 
		window.setInterval("window.location.href='"+str+"'",delay);
}

/**
 * ÇöÀç È÷½ºÅä¸® ¿£Æ®¸®¿¡ ÆäÀÌÁö¸¦ ÀÐ¾îµéÀÔ´Ï´Ù. (µÚ·Î°¡±â ¹öÆ° ºñÈ°¼ºÈ­)
 */
function ReplacePage(str,delay)
{
	if (delay==null) 
		window.location.replace(str);
	else 
		window.setInterval("window.location.replace('"+str+"')",delay);
}

/**
 * ÇöÀç ÆäÀÌÁö »õ·Î °íÄ§
 */
function ReloadPage(delay)
{
if (delay==null) 
		window.location.reload();
	else 
		window.setInterval("window.location.reload()",delay);
}

/**
 * ¹®ÀÚ¿­À» Å¬¸³º¸µå¿¡ º¹»çÇÕ´Ï´Ù. (IEÀü¿ë)
 */
function CopyToClip(str) 
{
	if (window.document.all) // IEÀÏ¶§
		window.clipboardData.setData('Text',str);
}

/**
 * ºê¶ó¿ìÀúÀÇ ½ÃÀÛÆäÀÌÁö º¯°æÃ¢À» ¶ç¿ó´Ï´Ù. (IEÀü¿ë)
 */
function SetHomePage(url) 
{
	window.document.write("<SPAN ID='objHomePage' STYLE='behavior:url(#default#homepage); display:none;' >s</SPAN>");
	window.document.all.objHomePage.setHomePage(url);
}

/**
 * ºê¶ó¿ìÀúÀÇ Áñ°ÜÃ£±â Ãß°¡Ã¢À» ¶ç¿ó´Ï´Ù. (IEÀü¿ë)
 */
function AddFavorite(url, homename) 
{
	window.external.AddFavorite(url, homename);
}

/**
 * ¸ð´ÏÅÍ ÇØ»óµµ¸¦ ±¸ÇÕ´Ï´Ù.
 */
function GetWindowResolution() 
{
	if (window.screen)
	{
		var returnArray = new Array(2);
		returnArray[0] = window.screen.width;
		returnArray[1] = window.screen.height;
		return returnArray;
	}
	else return false;
}

/**
 * »ç¿ëÀÚÀÇ »ö»ó ¼³Á¤À» ±¸ÇÕ´Ï´Ù.
 * @return		»ö»óºñÆ®¼ö¸¦ ¹ÝÈ¯ÇÕ´Ï´Ù. ( 8ºñÆ® : 256»ö, 16ºñÆ® : ÇÏÀÌÄÃ·¯ , 24ºñÆ® : Æ®·çÄÃ·¯ )
 */
function GetWindowColor() 
{
	if (window.screen)
	{
		return screen.colorDepth;
	}
}

/**
 * ºê¶ó¿ìÀúÀÇ Á¦¸ñÇ¥½ÃÁÙÀ» ¼³Á¤ÇÕ´Ï´Ù.
 */
function SetWindowTitle(str) 
{
	document.title = str;
}

/**
 * ºê¶ó¿ìÀúÀÇ Á¦¸ñÇ¥½ÃÁÙÀÇ ¹®ÀÚ¿­À» ¹ÝÈ¯ÇÕ´Ï´Ù.
 */
function GetWindowTitle() 
{
	return document.title;
}

/**
 * ºê¶ó¿ìÀúÀÇ »óÅÂÇ¥½ÃÁÙÀ» ¼³Á¤ÇÕ´Ï´Ù.
 */
function SetStatusTitle(str) 
{
	window.status = str;
}

/**
 * ºê¶ó¿ìÀúÀÇ »óÅÂÇ¥½ÃÁÙÀÇ ¹®ÀÚ¿­À» ¹ÝÈ¯ÇÕ´Ï´Ù.
 */
function GetStatusTitle() 
{
	return window.status;
}