function getCookie(Name)				// basic fuction for Cookie
{
  	var search = Name + "="

  	if (document.cookie.length > 0)
  	{
    		// if there are any cookies
    		var offset = document.cookie.indexOf(search)
    		if (offset != -1)
    		{
      			// if cookie exists
      			offset += search.length
      			// set index of beginning of value
      			var end = document.cookie.indexOf(";", offset)
      			// set index of end of cookie value
      			if (end == -1)
        			end = document.cookie.length

			return unescape(document.cookie.substring(offset, end))
    		}
  	}

  	return ""
}
function LogIN()
{
	var sessionID =getCookie('SessionID');
	if (sessionID!=""){
		return true;
	}
	else{
		return false;
	}
}
function writeWelcome()
{
	var str = "";
	var userid   = getCookie("ADUserID");
	var grad = getCookie('ADGrade');
	
	if (username!="")
	{
		//if (userid == "yakim4444")
		//	userid = userid + "123434444";
			
		if (userid.length > 9)
			userid = userid.substring(0,9)+ ".."; 
			
		str += "<table width=780 cellpadding=0 cellspacing=0 border=0>\n";
		str += "<tr><td><img src=http://www.dial070.co.kr/images/topmenu.gif width=780 height=29 border=0 usemap=#topmenu></td></tr>\n";
		str += "<tr bgcolor=#EAE7E7 height=28><td width=780><b>&nbsp;&nbsp;&nbsp;" + username + "("+userid +")´Ô</b> È¯¿µÇÕ´Ï´Ù! &nbsp;&nbsp;&nbsp;<a href=http://www.dial070.co.kr/cgi-bin/logoff.pl><b><u>·Î±×¾Æ¿ô</u></b></a>\n";
		str += "</td></tr>\n";
		str += "</table>\n";
		
		document.write(str);
	}
	else
	{
		document.write("Welcome to Dialpad\n");
	}
}
function ImgNone()
{
   document.LoginForm.ID.style.backgroundImage = "";
}

function Imginsert()
{
   var text = document.LoginForm.ID.value; //ÅØ½ºÆ®¶óÀÎÀÇ ¹ë·ù°ª
   //À§¿¡ text ¸¦ Áö¿ì¸é ½ºÆäÀÌ½º¹Ù·Î ¸¸µç °ø¹éÀÌ °ªÀ¸·Î Ã³¸®µÇ¾î ÀÌ¹ÌÁö°¡ ³ª¿ÀÁö ¾Ê½À´Ï´Ù.
	if (!text)
	{
		document.LoginForm.ID.style.backgroundImage = "url('http://www.dial070.co.kr/images/main/id.gif')"; //°ø¹éÀÌ¶ó¸é ÀÌ¹ÌÁö¸¦ ³Ö½À´Ï´Ù.
	}
	else
	{
		ImgNone(); //±×·¸Áö ¾Ê°í °ªÀÌ Á¸Àç ÇÑ´Ù¸é ImgNone() ½ÇÇà ÀÌ¹ÌÁö¸¦ ³ÖÁö ¾Ê½À´Ï´Ù.
	}
}

function writeInitialize()
{
   if (!LogIN()){
	   var userid   	= getCookie("rememberName");
	  
	   if (userid != ""){
			ImgNone();
			document.LoginForm.ID.value = userid;
	   		document.LoginForm.rememberID.checked = true ;
	   		document.LoginForm.Passwd.focus();
	   }
	   else {
			//document.LoginForm.ID.focus();
	   }
   }	
}

function writeInitialize1() //indexorigin.html
{
   if (!LogIN()){
	   var userid   	= getCookie("rememberName");
	   if (userid != ""){
	   	   document.LoginForm.ID.value = userid;
	   	   document.LoginForm.rememberID.checked = true ;
	   	   document.LoginForm.Passwd.focus();
	   }
	   else{ 
	   	   //document.UserNameForm.UserName.focus();
   	   }
   }	
}
function welcomeInitialize()
{
   if (LogIN()){
	   
	   var autoPnWnd   	= getCookie("autoPnWnd");
	   if (autoPnWnd == "Y" || autoPnWnd == "" || autoPnWnd == null){
		   setCookieForDays("autoPnWnd","Y",365);
	   	   document.UserNameForm.autoPnWnd.checked = true ;	   	   
	   }
	   else if (autoPnWnd == "N") { 
	   	   document.UserNameForm.autoPnWnd.checked = false ;
   	   }
   }	
}

function setAutoPnWnd()
{		
	var check = document.UserNameForm.autoPnWnd.checked;
	
	if(check) {		
		setCookieForDays("autoPnWnd","Y",365);
	}
	else {		
		setCookieForDays("autoPnWnd","N",365);
	}	
}

function blurid()
{
	var userid   	= getCookie("rememberName");
	if (userid == ""){
		document.LoginForm.ID.value = '';
	}
}

function blurpass() 
{
	document.LoginForm.Passwd.value = '';
}

function formSubmit()
{
	
	document.LoginForm.UserName.value=document.LoginForm.ID.value; 
	if (document.LoginForm.ID.value == '') {
		alert("¾ÆÀÌµð¸¦ ÀÔ·ÂÇØ ÁÖ½Ê½Ã¿À"); 
		return false;
	}

	if (document.LoginForm.Passwd.value == '') {
		alert("ºñ¹Ð¹øÈ£¸¦ ÀÔ·ÂÇØ ÁÖ½Ê½Ã¿À"); 
		document.LoginForm.Passwd.focus();
		return false;
	}
	
	
	return true;
}
function formReset()
{
	document.LoginForm.reset();
	return false;
}

function goForgotPage()
{
	parent.document.location.href="http://www.dial070.co.kr/register/idpw.html";
}

function writeLoginBox()
{
	var str = "";
	
	if (LogIN()){
	
	<!---- ·Î±×ÀÎ µÇ¾îÀÖÀ»¶§ ---->
	writeWelcome();

	//hyoungs  
	//var modem = getCookie("Modem");
	
	//if (!getCookie("Modem"))
	//{
	//str += "<td><a href=\"/cgi-bin/mypage.pl\"><img src=\"/images/hm_button_tell.gif\" width=\"105\" height=\"34\" border=0></a></td>\n";
	//}
	//else{
	//str += "<td><a href=\"/dialpad/index_modem.html\"><img src=\"/images/hm_button_tell.gif\" width=\"105\" height=\"34\" border=0></a></td>\n";
	//}

	
	}
	else{
	
	<!---- ·Î±×¾Æ¿ô µÇ¾îÀÖÀ»¶§ -->

	str += "<table width=780 cellpadding=0 cellspacing=0 border=0>\n";
	str += "<form name=\"UserNameForm\" method=\"get\" onsubmit=\"document.LoginForm.Passwd.focus();return false;\">\n";
	str += "<tr><td colspan=2><img src=http://www.dial070.co.kr/images/topmenu.gif width=780 height=29 border=0 usemap=#topmenu></td></tr>\n";
	str += "<tr bgcolor=#EAE7E7 height=28><td width=120><font face=±¼¸² color=black>&nbsp;&nbsp;&nbsp;¾ÆÀÌµð <input type=text name=UserName class=log size=9 maxlength=19></td></form>\n";
	str += "<td width=660><form name=\"LoginForm\" method=\"post\" action=\"http://www.dial070.co.kr/cgi-bin/login2.pl\" onsubmit=\"return formSubmit()\">\n";
	str += "	<input type=hidden name=\"UserName\">\n";
	str += "  &nbsp;ºñ¹Ð¹øÈ£ <input type=password class=log name=Passwd size=9 maxlength=19>\n";
	str += " <input type=image src=http://www.dial070.co.kr/images/log.gif width=49 height=15 border=0 hspace=3 alt=·Î±×ÀÎ> \n";
	str += "</td> <td>";
	str += " <input type=checkbox name=rememberID value=Y>&nbsp;IDÀúÀå&nbsp;&nbsp;\n";
	str += "<a href=javascript:goForgotPage()>&nbsp;&nbsp;ºñ¹Ð¹øÈ£ºÐ½Ç</a>| \n";
	str += "<a href=http://www.dial070.co.kr/register/join_step1.html><b>¹«·áÈ¸¿ø°¡ÀÔ</b></a></font></td></tr>\n";
	str += "</form></table>\n";
	
	}

	document.write(str);
	writeInitialize1();
//	window.open('/gongji/notice.html', 'systemerror', 'resizable=no,width=420,height=380');
}

function inputboxInit() {
	if(document.LoginForm.ID.value) {
		ImgNone();
	}
}

function mainInit() {	
	var autoPnWnd = getCookie("autoPnWnd");	
	if (mylogincheck() == true && autoPnWnd == "Y")	{		
		javascript:onCallNumber700('');;
	}
	else {
		// pass
	}
}

function WriteName()
{
	lastname = getCookie('LastName');
	document.write (unescape(lastname));
}

function writeMainTop()
{
	var str = "";
	
	if (LogIN()){
	
	<!---- ·Î±×ÀÎ µÇ¾îÀÖÀ»¶§ ---->
	str += "<table border=0 cellspacing=0 cellpadding=0>\n";
	str += "	<tr><td><img src=\"http://www.dial070.co.kr/images/main/top_log.gif\" width=573 height=21 border=0></td>\n";
	str += "		<td><a href=\"http://www.dial070.co.kr/cgi-bin/logoff.pl\"><img src=\"http://www.dial070.co.kr/images/main/top_logout.gif\" width=54 height=21 border=0></a></td>\n";
	str += "		<td><a href=\"http://www.dial070.co.kr/cgi-bin/mydialpad/mydialpad.pl\"><img src=\"http://www.dial070.co.kr/images/main/top_log02.gif\" width=78 height=21 border=0></a></td>\n";
	str += "		<td><a href=\"http://www.dial070.co.kr/help/help_main.html\"><img src=\"http://www.dial070.co.kr/images/main/top_log03.gif\" width=73 height=21 border=0></a></td></tr>\n";
	str += "</table>\n";
	}
	else{
	
	<!---- ·Î±×¾Æ¿ô µÇ¾îÀÖÀ»¶§ -->

	str += "<table border=0 cellspacing=0 cellpadding=0>\n";
	str += "	<tr><td><img src=\"http://www.dial070.co.kr/images/main/top_log.gif\" width=573 height=21 border=0></td>\n";
	str += "		<td><a href=\"http://www.dial070.co.kr/login.php\"><img src=\"http://www.dial070.co.kr/images/main/top_log01.gif\" width=54 height=21 border=0></a></td>\n";
	str += "		<td><a href=\"http://www.dial070.co.kr/cgi-bin/mydialpad/mydialpad.pl\"><img src=\"http://www.dial070.co.kr/images/main/top_log02.gif\" width=78 height=21 border=0></a></td>\n";
	str += "		<td><a href=\"http://www.dial070.co.kr/help/help_main.html\"><img src=\"http://www.dial070.co.kr/images/main/top_log03.gif\" width=73 height=21 border=0></a></td></tr>\n";
	str += "</table>\n";
	
	}

	document.write(str);
	//writeInitialize1();
}
