
function setCookie( name, value )
{
   document.cookie = name + "=" + escape( value ) + "; path=/;";
}

function SaveID( id )
{
        var todayDate = new Date();
        todayDate.setDate( todayDate.getDate()+30 );
        document.cookie = "NHOSTING_SAVE_ID="+escape(id)+"; expires="+todayDate.toGMTString()+";domain=.netian.com; path=/";
}

function deleteCookie( name, domain )
{
var todayDate = new Date();
todayDate.setDate( todayDate.getDate()-1 );
document.cookie = name+"=; domain="+domain+"; path=/; expires="+todayDate.toGMTString()+";";
}

function removeCookie( name )
{
deleteCookie( name, ".netian.com" );
}

function logout()
{

        removeCookie( "NHOSTING_ID" );
        removeCookie( "NHOSTING_PW" );
        removeCookie( "NHOSTING_NAME" );
        removeCookie( "NHOSTING_ENAME" );
        removeCookie( "NHOSTING_CPMAILPW" );
        removeCookie( "NHOSTING_DOMAIN" );
        removeCookie( "NHOSTING_TEMPLATE" );
        removeCookie( "NHOSTING_CASE" );
        removeCookie( "NHOSTING_REQNO" );
/*************** add crazyong@neitan.com ************************/
	removeCookie( "ASP_TELMK" );		// ¿µ¾÷°ü¸® ½Ã½ºÅÛ »ç¿ë°èÁ¤
/******************************************************************/
	location.href="http://wsp-login.netian.com"

}

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 checkForm01()
{

    if ( document.forms[0].id.value.length == 0 )
    {
       alert( "¾ÆÀÌµð¸¦ ³ÖÀ¸¼¼¿ä" );
       return false;
    }
    if ( document.forms[0].pw.value.length == 0 )
    {
       alert( "ºñ¹Ð¹øÈ£¸¦ ³ÖÀ¸¼¼¿ä" );
       return false;
    }
    if ( ( document.forms[0].pw.value.length > 12 ) || ( document.forms[0].pw.value.length < 3 ) )
    {
       alert( "3ÀÚ¸® ÀÌÇÏ 12ÀÚ¸® ÀÌ»ó ºñ¹Ð¹øÈ£´Â ÀÌ¿ëÇÒ ¼ö ¾ø½À´Ï´Ù." );
       return false;
    }

    if ( document.forms[0].save_id.checked )
        SaveID( document.forms[0].id.value );

    return true;
}

function loadDoc()
{
	if ( getCookie( "NHOSTING_PW" ) == "" )
	{
        	save_id = getCookie("NHOSTING_SAVE_ID");

	        if ( save_id != "" )
			document.forms[0].id.value = save_id;

	        if ( document.forms[0].id.value.length == 0 )
			document.forms[0].id.focus();
		else
			document.forms[0].pw.focus();
	}
}

function printLoginButton()
{
	var img, url;
	if ( getCookie( "NHOSTING_PW" ) != "" ) // logout
	{
		img ='<img src=/netian_img/im_logout.gif border=0 hspace=4>';
		url ='logout();';
	   document.write( '<A href="" Onclick="'+url+' return false;">'+img+'</A>' );
    }
	else // login
	{
		img ='<img src=/netian_img/im_login.gif border=0 hspace=4>';
		url ="http://wsp-login.netian.com";
//        document.write( '<A href="'+url+'" onClick=\"logout(); return false;\">'+img+'</A>' );
		document.write("<a href=\"\" onClick=\"logout(); return false;\">");
 	}
}