/** Read cookie */
var g_BrowserType = getBrowserType();
function leftMenuOver(code)
{
	if(!document.getElementById("mu_"+code)) return;
	document.getElementById("mu_"+code).style.display = "block";
}

function leftMenuOut(code)
{
	if(!document.getElementById("mu_"+code)) return;
    document.getElementById("mu_"+code).style.display = "none";
}

function getBrowserType()
{
    var ua = navigator.userAgent;

	if(ua.split('AppleWebKit/')[1])
		return "safari";
	else if(ua.split('Konqueror/')[1])
		return "konqueror";
	else if(ua.split('Gecko/')[1])
		return "gecko";
	else if (!!window.opera && (typeof XMLHttpRequest) == 'function')
		return "opera";
	else if (!!window.ActiveXObject)
		return "msie";
	else 
		return "unknown";

}

function getBrowser()
{
    var a, ua = navigator.userAgent;

    this.bw =
    {
        safari : ((a=ua.split('AppleWebKit/')[1]) ? a.split('(')[0]:0) >=124,
        konqueror : ((a=ua.split('Konqueror/')[1]) ? a.split('(')[0]:0) >=124,
        mozes : ((a=ua.split('Gecko/')[1]) ? a.split('(')[0]:0) >=124,
        opera : (!!window.opera) && ((typeof XMLHttpRequest) == 'function'),
        msie : (!!window.ActiveXObject) ? (!!createHttpRequest()) : false
    }

    return (this.bw.safari || this.bw.konqueror || this.bw.mozes || this.bw.opera || this.bw.msie);
}

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 setCookie(name, value, expiredays)
{
    var todayDate = new Date();
    todayDate.setDate( todayDate.getDate() + expiredays );
    document.cookie = name + "=" + escape( value ) + "; path=/; expires=" + todayDate.toGMTString() + ";"
}

function goURL(url)
{
	document.location.href = url;
}

function removeOptions(ob)
{
    var len = ob.options.length;
    for(i = len - 1; i >= 0; i--)
        ob.options[i] = null;
}

function hoverRecode(obj)
{
	obj.style.backgroundColor = '#ccc;'
}

function addOption(ob, title, val)
{
    ob.options[ob.length] = new Option(title, val);
}

function insertComma(num) 
{
	var rtn = "";
	var val = "";
	var kq1 = 0;

	var str = '' + num;
	var len = str.length;
	for(kq0 = len; kq0 > 0; kq0--) 
	{
		if(str.substring(kq0, kq0-1) != ",") 
		{
			val = str.substring(kq0, kq0-1) + val;
		}
	}

	len = val.length;

	for(kq0 = len; kq0 > 0; kq0--) 
	{
		if(kq1%3 == 0 && kq1 !=0) 
		{
			rtn = val.substring(kq0, kq0-1)+","+rtn; 
		} else {
			rtn = val.substring(kq0, kq0-1)+rtn;
		}
		kq1++;
	}
	return rtn;
}

/** Show Flash */
function showFlash(name, width, height, cpos)
{
    document.write('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"');
    document.write(' codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0"  width=' + width);
    document.writeln(' height=' + height + ' id="' + name + '" align="middle">');
    document.writeln('<param name="movie" value="/img/' + name + '.swf?pageNum=<? echo $cur_pos; ?>" />');
    document.writeln('<param name="quality" value="high" />');
    document.writeln('<param name="wmode" value="opaque" />');
    //document.writeln('<param name="wmode" value="transparent" />');
	document.writeln('<param name="bgcolor" value="#ffffff" />');
    document.writeln('<embed src="/img/' + name + '.swf?pageNum=' + cpos + '" quality="high" ');
	document.writeln('bgcolor="#ffffff" width="' + width + '" height="' + height + '" ');
    document.writeln('name="' + name + '" align= "middle" type="application/x-shockwave-flash" wmode="opaque" /');
	document.writeln('pluginspage="http://www.macromedia.com/go/getflashplayer" />');
    document.writeln('</object>');
}

function checkInputDate(obj)
{
	var str = obj.value;
	var valid = true;
	
	if(/^[-0-9]+$/.test(str))
	{
		if(str.length > 12 || str.length < 6)
			valid = false;
		else
		{
			if(/^[-]+$/.test(str) == false)
			{
				var y = str.substr(0, 4);
				var m = str.substr(4, 2);
				var d = str.substr(6, 2);

				var nd = y+'-'+m+'-'+d;

				obj.value = nd;
			}
		}	
	}
	else
		valid = false;
		
	if(valid == false)
	{
		alert('날짜는 yyyy-mm-dd (예:2000-2-20)와 같은 형식으로 입력하셔야 합니다.');
		obj.focus();
		return;
	}	
}

function loginMessage()
{
	alert('로그인 후 사용해 주세요.');
}


