/***********************************************************************
* ½ºÅ©¸³Æ®¸í : ÆäÀÌÁö Å¸ÀÌÆ² Á¤ÀÇ
***********************************************************************/
document.title="»ïÀÌÄÚÆ÷·¹ÀÌ¼Ç";



function setNavigation( str )
{
    try
    {
        parent.frames[0].document.all.navigation.value = str;
        parent.frames[0].document.all.navigation.size  = getByteLength(str);
        parent.frames[0].document.all.navi_img.style.visibility = "visible";
    }
    catch(errorObject)
    {
        setFrameNavigation(str);
    }
}

function setFrameNavigation( str )
{
    try
    {
        parent.parent.frames[0].document.all.navigation.value = str;
        parent.parent.frames[0].document.all.navigation.size  = getByteLength(str);
        parent.parent.frames[0].document.all.navi_img.style.visibility = "visible";
    }
    catch(errorObject)
    {
    }
}

function clearNavigation()
{
    try
    {
        parent.frames[0].document.all.navigation.value = "";
        parent.frames[0].document.all.navigation.size  = 0;
        parent.frames[0].document.all.navi_img.style.visibility = "hidden";
    }
    catch(errorObject)
    {
    }
}


// ÄÞº¸¹Ú½º¸¦ ¼±ÅÃÇÑ´Ù.
function setSelect(obj, val)
{
    if( val != "" )
    {
        for( var i = 0 ; i < obj.length ; i++ )
        {
            if( obj.options[i].value == val )
            {
                obj.options[i].selected = true;
                break;
            }
        }
    }
}

var IsSubmit = false;

function formSubmit( obj )
{
    try
    {
        if( !IsSubmit )
        {
            IsSubmit = true;
            obj.submit();
        }
    }
    catch(errorObject)
    {
    }
}


// strÀÇ byte ±æÀÌ¸¦ ¸®ÅÏ.
function getByteLength(str)
{
    var len = 0;
    if( str == null )
        return 0;

    for( var i = 0 ; i < str.length ; i++ )
    {
        var c = escape(str.charAt(i));
        if ( c.length == 1 )
            len ++;
        else if( c.indexOf("%u") != -1 )
            len += 2;
        else if( c.indexOf("%") != -1 )
            len += c.length/3;
    }
    return len;
}

function isEmpty( data )
{
    for( var i = 0 ; i < data.length ; i++ )
    {
        if( data.substring( i , i + 1 ) != " " )
        {
            return false;
        }
    }
    return true;
}

// ¸Þ¼¼Áö¸¦ Ãâ·ÂÇÏ°í, Object·Î focus¸¦ µ¹·ÁÁØ´Ù.
function ErrMsg( obj, msg )
{
    try
    {
        alert( msg );

        if( obj.type == "select-one" )
        {
            obj.focus();
        }
        else
        {
            obj.focus();
            obj.select();
        }
        return false;
    }
    catch(errorObject)
    {
        var msg = errorObject.description + "\n\n"
               + "Error Number : " + (errorObject.number>>16 & 0x1FFF) + "\n\n";
	    alert(msg);
        return false;
    }
}


// Object¿¡ value°¡ ¼ýÀÚ·Î¸¸ µÇ¾îÀÖ´ÂÁö Ã¼Å©ÇÑ´Ù.
function isDigit(obj)
{
    try
    {
        inputStr = obj.value;
        for( var i = 0 ; i < inputStr.length ; i++ )
        {
            var oneChar = inputStr.charAt(i)
            if (oneChar < "0" || oneChar > "9")
            {
                return false;
            }
        }
        return true;
    }
    catch(errorObject)
    {
        var msg = errorObject.description + "\n\n"
               + "Error Number : " + (errorObject.number>>16 & 0x1FFF) + "\n\n";
	    alert(msg);
        return false;
    }
}

function isKorean( value ) 
{
	for( var i = 0; i < value.length; i++ )
	{
		if(!((value.charCodeAt(i) > 0x3130 && value.charCodeAt(i) < 0x318F) || (value.charCodeAt(i) >= 0xAC00 && value.charCodeAt(i) <= 0xD7A3)))
		{
			return false;
		}
	}
	return true;
}

// value°¡ ¼ýÀÚ·Î¸¸ µÇ¾îÀÖ´ÂÁö Ã¼Å©ÇÑ´Ù.
function isDigitValue(value)
{
    try
    {
        inputStr = value;
        for( var i = 0 ; i < inputStr.length ; i++ )
        {
            var oneChar = inputStr.charAt(i)
            if (oneChar < "0" || oneChar > "9")
            {
                return false;
            }
        }
        return true;
    }
    catch(errorObject)
    {
        var msg = errorObject.description + "\n\n"
               + "Error Number : " + (errorObject.number>>16 & 0x1FFF) + "\n\n";
	    alert(msg);
        return false;
    }
}

// Object¿¡ value°¡ ¼ýÀÚ·Î¸¸ µÇ¾îÀÖ´ÂÁö Ã¼Å©ÇÑ´Ù.
function isTel(obj)
{
    try
    {
        inputStr = obj.value;
        for( var i = 0 ; i < inputStr.length ; i++ )
        {
            var oneChar = inputStr.charAt(i)
            if( oneChar < "0" || oneChar > "9" )
            {
                if( oneChar != "-" )
                {
                    return false;
                }
            }
        }
        return true;
    }
    catch(errorObject)
    {
        var msg = errorObject.description + "\n\n"
               + "Error Number : " + (errorObject.number>>16 & 0x1FFF) + "\n\n";
	    alert(msg);
        return false;
    }
}


//¼ýÀÚ¸¸ ÀÔ·Â°¡´ÉÇÏ°ÔÇÔ »ç¿ë¿¹<   OnKeyPress="numChk()"   >
function numChk()
{
    if ((event.keyCode<48) || (event.keyCode>57))
        event.returnValue=false;
}

function numDotChk()
{
    if ((event.keyCode != 46) && (event.keyCode<48) || (event.keyCode>57))
    {
        event.returnValue=false;
    }
}


// ¸ÞÀÏ Ã¼Å©
function checkEmail(strEmail)
{
	var arrMatch = strEmail.match(/^(\".*\"|[A-Za-z0-9_-]([A-Za-z0-9_-]|[\+\.])*)@(\[\d{1,3}(\.\d{1,3}){3}]|[A-Za-z0-9][A-Za-z0-9_-]*(\.[A-Za-z0-9][A-Za-z0-9_-]*)+)$/);
	if( arrMatch == null )
	{
		return false;
	}

	var arrIP = arrMatch[2].match(/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/);
	if( arrIP != null )
	{
		for( var i = 1 ; i <= 4 ; i++ )
		{
			if( arrIP[i] > 255 )
			{
				return false;
     		}
   		}
	}
	return true;
}


// ´Þ·Â »ý¼º
function Calendar( obj_year, obj_month, obj_day )
{
	var result = "false";
	    result = window.showModalDialog('/webhome/common/module/calendar.php','Calendar','dialogWidth:365px;dialogHeight:295px; center:yes; help:no; status:no; scroll:no; resizable:no');

	if( result == null )
        return;

    if( result.length != 3 )
        return;

    if( obj_month != null && obj_day != null )
    {
        obj_year.value  = result[0];
        obj_month.value = result[1];
        obj_day.value   = result[2];
    }
    else
    {
        obj_year.value  = result[0] + result[1] + result[2];
    }
}


function openWin(url,winName,width,height,scroll)
{
    window.open( url , winName,"toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=" + scroll + ",resizable=no,width=" + width + ",height=" + height);
    return ;
}

function openWin1(url,winName,width,height,scroll)
{
    window.open( url , winName,"toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=" + scroll + ",resizable=yes,width=" + width + ",height=" + height);
    return ;
}

function isExtCheck( filename )
{
	var strFileName = filename.toUpperCase();

    if ( filename.match(/\.(GUL|JPG|GIF|BMP|XLS|PPT|DOC|HWP|PDF|TIF)$/i) ) 
	{
		return true;
	}
	else
	{
		return false;
	}
}



/** µðÀÚÀÎ ÀÛ¾÷ ½ºÅ©¸³Æ® **/
/***********************************************************************
* ½ºÅ©¸³Æ®¸í : ÆäÀÌÁö Å¸ÀÌÆ² Á¤ÀÇ
***********************************************************************/
document.title="»ïÀÌÄÚÆ÷·¹ÀÌ¼Ç";

//ÆË¾÷Ã¢ ½ºÅ©¸³Æ® - ½ºÅ©·Ñ¹Ù ¾ø´Â °Í
function popwindow(pop,width,height)
{
	var url = pop;  
	var wd = width;
	var he = height;
	
	window.open(url,"","toolbar=0,menubar=0,scrollbars=no,resizable=no,width=" + wd +",height=" + he + ";")
}

//ÆË¾÷Ã¢ ½ºÅ©¸³Æ® - ½ºÅ©·Ñ¹Ù ÀÖ´Â °Í
function popwindow2(pop,width,height)
{
	var url = pop;  
	var wd = width;
	var he = height;
	
	window.open(url,"","toolbar=0,menubar=0,scrollbars=yes,resizable=no,width=" + wd +",height=" + he + ";")
}


//·¹ÀÌ¾î shoe / hide ½ºÅ©¸³Æ®
function LayerSH(LayerName,Status) {
ns4 = (document.layers)?true:false
ie4 = (document.all)?true:false

if (ns4) {
	LayerN = document.layers[LayerName]
	if (Status == 'show') LayerN.visibility = 'show';
	if (Status == 'hide') LayerN.visibility = 'hidden';
	}	
if (ie4) {
	LayerN = document.all[LayerName].style
	if (Status == 'show') LayerN.visibility = 'visible';
	if (Status == 'hide') LayerN.visibility = 'hidden';
	}
}


// layer
function LayerSH(LayerName,Status) 
{
	LayerN = document.all[LayerName].style;
	if (Status == 'show') LayerN.display = '';
	if (Status == 'hide') LayerN.display = 'none';
}

//Æ¯Á¤ºÎºÐ ÀÎ¼â	
function printDiv () {
  if (document.all && window.print) {
    window.onbeforeprint = beforeDivs;
    window.onafterprint = afterDivs;
    window.print();
  }
}
function beforeDivs () {
  if (document.all) {
    objContents.style.display = 'none';
    objSelection.innerHTML = document.all['d1'].innerHTML;
  }
}
function afterDivs () {
  if (document.all) {
    objContents.style.display = 'block';
    objSelection.innerHTML = "";
  }
}


//ÇÃ·¡½¬¿¡¼­ ¿¬°á
function fullscreen(theURL) {
window.open(theURL, '', 'fullscreen=yes, scrollbars=0');
}


//activeX  ÇÃ·¡½¬ °ü·Ã 
function flash(url, width, height){
document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="'+width+'" height="'+height+'" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" id=ShockwaveFlash1>'
+'<param name="movie" value="'+url+'">'
+'<param name="quality" value="high">'
+'<embed src="'+url+'" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" width="'+width+'" height="'+height+'" type="application/x-shockwave-flash"></embed>'
+'</object>');
}

//activeX  ÇÃ·¡½¬ °ü·Ã 
function getEPObject(){
document.write('<object ID="EpAdm2 Control" name="EpAdmC" CLASSID="CLSID:C63E3330-049F-4C31-B47E-425C84A5A725" width="0" height="0"></OBJECT>');
}

function Go(url) {
   //¾Æ·¡¿¡¼­ width¿Í  height ¼öÄ¡·Î »õÃ¢ÀÇ Å©±â Á¶Àý,left¿Í topÀ¸·Î À§Ä¡ Á¶Àý
    window.open(url, "mywin1", "width=350, height=200, left=350, top=450, location=0, menubar=0, toolbar=0, directories=0")
}
	
function Resize_Frame(name)
{
    var Frame_Body  = document.frames(name).document.body;
    var Frame_name  = document.all(name);

    Frame_name.style.width = Frame_Body.scrollWidth + (Frame_Body.offsetWidth-Frame_Body.clientWidth);
    Frame_name.style.height = Frame_Body.scrollHeight + (Frame_Body.offsetHeight-Frame_Body.clientHeight);
 
    if (Frame_name.style.height == "0px" || Frame_name.style.width == "0px")
    {
        Frame_name.style.width = "300px";       //±âº» iframe ³Êºñ
        Frame_name.style.height = "30px";      //±âº» iframe ³ôÀÌ
        window.status = 'iframe resizing fail.';
    }
    else
    {
        window.status = '';
    }
}


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 "";
}

function setCookieCommon( name, value, expiredays )
{
	var todayDate = new Date();
	todayDate.setDate( todayDate.getDate() + expiredays );
	document.cookie = name + "=" + escape( value ) + "; path=/; expires=" + todayDate.toGMTString() + ";"
}


function getFileExtension(filePath){
	var lastIndex = -1;
	lastIndex  = filePath.lastIndexOf('.');
	var extension = "";

	if(lastIndex != -1)
	{
		extension = filePath.substring( lastIndex+1, filePath.len );
	}
	else
	{
		extension = "";
	}
	return extension;
}


function fnImg_Check(value){  
	var src = getFileExtension(value);

	if( value != "" )
	{
		if( !(src.toLowerCase() == "gif" || src.toLowerCase() == "jpg" || src.toLowerCase() == "bmp") )
		{
			return false;
		}
		else
		{
			return true;
		}
	}
	else
	{
		return true;
	}
}
