var username, userid
var _ns = (navigator.appName.indexOf("Netscape") >= 0)
var _ieindex = navigator.userAgent.indexOf("MSIE")
var _ie = (_ieindex > 0)
var _ie4 = (navigator.userAgent.substring((_ieindex + 5), (_ieindex+6))<5)
var _ie3 = (navigator.userAgent.substring((_ieindex + 5), (_ieindex+6))<4)

////////////////////////////////////////////////////////////////////////////////
// written by sgkim (2003-02-27)
// Helper¸¦ ActiveX·Î º¯°æÇÏ¿´´Ù.
// Object ÄÚµå Á¤ÀÇ.
var g_dialpadurl		= "http://www.dial070.co.kr"
var g_helperclass		= "clsid:16B21577-3ABA-49AA-96F9-811B7BCFA9CA";
var g_helpername		= "Helper";
var g_helperversion     = "3,5,0,0";
var g_helpercabbase		= g_dialpadurl + "/webdial/lib/helper.cab";	


// Application ID Define
var g_id_app_web  = 1;
var g_id_app_plus = 2;

// Error Ã³¸® »ó¼ö Á¤ÀÇ.
var g_err_proc_not_install  = 1;
var g_err_desc_not_install	= "´ÙÀÌ¾ó070ÀÌ ¼³Ä¡µÇ¾î ÀÖÁö ¾Ê½À´Ï´Ù.";
var g_define_usewebonly = 1; // 1·Î ¼³Á¤ÇÏ¸é À¥¸¸ Áö¿øÇÑ´Ù.
// ¿©±â±îÁö sgkimÀÌ Ãß°¡ÇÔ.
////////////////////////////////////////////////////////////////////////////////




function getBrowserVersion()				// called by start function in the Web2PhoneApplet's applet
{
  	return navigator.appVersion;
}

function setCookie(name, value, expire)			// basic fuction for Cookie
{
	//alert("[#] SetCookie " + name + "=[" + value + "],"+expire);
	//var currentDate = new Date();
	//var NeverDay = new Date(currentDate.getTime() + 1000 * 100);
	//alert(expire.toGMTString());
  	document.cookie = name + "=" + escape(value)
    		+ ((expire == null) ? "" : ("; expires=" + expire.toGMTString()))
    		+ "; path=/; domain=.dial070.co.kr";
    //alert(document.cookie);
}

function setCookieForNoEscape(name, value, expire)			// basic fuction for Cookie
{
	//var currentDate = new Date();
	//var NeverDay = new Date(currentDate.getTime() + 1000 * 100);
  	document.cookie = name + "=" + value
    		+ ((expire == null) ? "" : ("; expires=" + expire.toGMTString()))
    		+ "; path=/; domain=.dial070.co.kr";
}

function setCookieForSeconds(name, value, secs)
{
	//alert("[#] setCookieForSeconds (: " + name + "=" + value + "," + secs + "sec)");
  	var currentDate = new Date();
  	var newDate;

  	newDate = new Date(currentDate.getTime() + 1000 * secs);

  	setCookie(name, value, newDate);
}

function setCookieForDays(name, value, expire)
{
	//alert("[#] setCookieForDays (: " + name + "=" + value + "," + expire + "day)");
	var currentDate = new Date();
	
	currentDate.setDate( currentDate.getDate() + expire );

  	setCookie(name, value, currentDate);
}

function getCookie(Name)				// basic fuction for Cookie
{
	//alert("[#] GetCookie (" + Name + ")");
	
  	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 "";
}

/* Called after login process */
function insertHelper(name)
{
  	if (!checkEnv())
  		return
  		
  	// 2003-02-27, »õ·Î¿î ActiveX·Î ¹Ù²Ù¾ú´Ù.	
	WriteHelperObjectCode(name);
}

function downloadIE()
{
  	if (confirm("You need to have Internet Explorer 4.0 or upper. Do you want to download it now?"))
    		window.open("http://windowsupdate.microsoft.com", "_blank")
}

function downloadNS()
{
  	if (confirm("You need to have Netscape 4.74 or upper. Do you want to download it now?"))
    		window.open("http://211.169.247.162/download/cc32d474.exe")
}

function checkEnv()
{
  	var majorApp = (navigator.appVersion.substring(0, navigator.appVersion.indexOf(".")))
  	var minorApp = (navigator.appVersion.substring(navigator.appVersion.indexOf(".")+1,navigator.appVersion.indexOf(' ')))

  	if (navigator.platform != "Win32")
 	{
    		alert(navigator.platform + " is not supported. Please refer to the FAQ.")
    		return false
  	}
  	if (_ie && _ie3)
  	{
    		downloadIE()
    		return false
  	}
  	if (_ns && majorApp <= 4)
  	{
    		if (majorApp < 4)
		{
      			downloadNS()
      			return false
    		}
    		else if (majorApp == 4)
    		{
    			if(minorApp < 74)
			{
      				downloadNS()
      				return false
      			}
    		}
  	}
  	if (!navigator.javaEnabled())
  	{
    		alert("Java should be enabled to run this applet. Refer to the FAQ to enable it.")
    		return false
  	}
  	return true
}
	
// 2000/08/31 hyoungs for center popup
function NewWindow(mypage, myname, w, h, scroll) 
{
	var winl,wint;

	if (screen.width <=640 || screen.height <=480)
	{
		winl = 0;
		wint = 0;
	}
	else{
		winl = (screen.width - w) / 2;
		wint = (screen.height - h) / 2;
	}
		winprops = 'height='+ h +',width='+ w +',top=0'+ ',left='+ winl +',scrollbars='+ scroll +',resizable=no'
		win = window.open(mypage, myname, winprops)
		if (parseInt(navigator.appVersion) >= 4){
			win.window.focus(); 
	}
}

function launchApplet()
{
	// ¸¸¾à Plus°¡ ½ÇÇàµÇ¾î ÀÖ´Ù¸é skip
	if (RunCheck(2)) {
		ShowDialpad();
		return;
	}
	
	top.name = "DialPadMain";
	openDialpadWeb('_phone','');
}

function onCallID(ContactID)
{
	// ¸¸¾à Plus°¡ ½ÇÇàµÇ¾î ÀÖ´Ù¸é Plus·Î ¸í·ÉÀ» º¸³¿.
	if (RunCheck(2)) {
		Call(ContactID);
		return;
	}
	
	// written by sgkim, DirectCall ½Ã »ç¿ëÀÚ ¾ÆÀÌµð¸¦ ³Ñ±âµµ·ÏÇß´Ù.
  	if (RunCheck(1)) {
  		Call(ContactID);
  		return;
  	}
  	else
  	{
    		setCookieForSeconds("PeerContactID", ContactID, 30)
    		setCookieForSeconds("CalledValue", ContactID, 30)
    		setCookieForSeconds("TryDirectCall", "1", 30)
    		launchApplet()
  	}
}

function onCallID2(ContactID)
{
	setCookieForSeconds("PeerContactID", ContactID, 30)
    setCookieForSeconds("TryDirectCall", "1", 30)
    setCookieForSeconds("CalledValue", ContactID, 30)
    launchApplet()
}

function onCallNumber(ContactID, number)
{

	if (RunCheck(2)) {
		Call(number);
		return;
	}
	
	// written by sgkim
  	if (RunCheck(1)) {
  		Call(number);
  		return
  	}
  	else
  	{
    		setCookieForSeconds("PeerContactID", ContactID, 30)
    		setCookieForSeconds("CalledValue", number, 30)
    		launchApplet()
  	}
}

function onCallNumber2(ContactID, number)
{
	if (RunCheck(2)) {
		Call(number);
		return;
	}
	
	// written by sgkim
  	if (RunCheck(1)) {
  		Call(number);
  		return
  	}
  	else
  	{
    		setCookieForSeconds("PeerContactID", ContactID, 30)
    		setCookieForSeconds("CalledValue", number, 30)
    		launchApplet()
  	}
}

function onCall(ContactID)
{
  	if (RunCheck(1)) {
  		Call(ContactID);
  		return
  	}
  	else
  	{
    		setCookieForSeconds("PeerContactID", ContactID, 30)
    		setCookieForSeconds("TryDirectCall", "0", 30)
    		setCookieForSeconds("CalledValue", ContactID, 30)
    		launchApplet()
  	}
}

function onCall2(ContactID)
{
  	if (RunCheck(1)) {
  		Call(ContactID);
  		return
  	}
  	else
  	{
    	setCookieForSeconds("PeerContactID", ContactID, 30)
    	setCookieForSeconds("TryDirectCall", "0", 30)
    	setCookieForSeconds("CalledValue", ContactID, 30)
    	launchApplet()
	}
}

function sortPage()
{
  	//top.bannerad.location.reload()
  	setSubCookie('PhoneBook','Page','1',null);
  	document.SortForm.submit()
}

function showPage(Page)
{
  	//top.bannerad.location.reload()
  	setSubCookie('PhoneBook','Page',Page,0);
  	
  	document.PageForm.Page.value = Page
  	document.PageForm.submit()
}

function modifyContact(ContactID)
{
  	document.ModifyContactForm.ContactID.value = ContactID
  	document.ModifyContactForm.submit()
}

//session °Ë»ç 
function isSession(from,sub)
{
	if (!getCookie('SessionID'))
	{
		location.href="/login.php3?from=" + from + "&sub=" + sub;
//		location.reload();
	}
}

//±Ý°í¼­ºñ½º ½ÇÇà
function sendData()
{
	if (getCookie('SessionID'))
		document.execute.SessionID.value =getCookie('SessionID'); 
	else
	{
		location.href="../loginstorage.html";
		location.reload();	
		return;
	}
	
	document.execute.ProcID.value = 7;
	document.execute.submit();
}

// yakim added next functions /////////////////////////////////////////////////////////////////////////////

// set sub cookie value
function setSubCookie(main_name,name, value, expire) 	//set cookie for realmedia
{
	var main_cookie = getCookie(main_name);
	var search = name + "="
	
  	if (main_cookie.length > 0)
  	{
    		var offset = main_cookie.indexOf(search)
    		
    		if (offset != -1)
    		{
    			// if cookie exists
    			// set index of beginning of value
    			var end = main_cookie.indexOf("&", offset)
    			
    			// set index of end of cookie value
    			if (end == -1)
    				end = main_cookie.length
				
				main_cookie = main_cookie.substring(0, offset) + search + value + main_cookie.substring(end,main_cookie.length);
				main_cookie = unescape(main_cookie);
			}
    		else
    		{
    			main_cookie = main_cookie.substring(0,main_cookie.length) + "&" + search + value;
				main_cookie = unescape(main_cookie);
			}
  	} 	
  	else
  	{
  		main_cookie = search + value;
		main_cookie = unescape(main_cookie);
	}
    //set temporary cookie 
    currentDate = new Date()
    currentDate.setMonth(currentDate.getMonth()+1)
    
    document.cookie = main_name + "=" + escape(main_cookie)
				+ "; expires=" + currentDate.toGMTString() + "; path=/; domain=.dial070.co.kr"
		
}

// get sub cookie value
function getSubCookie(main_name,name)
{
	var main_cookie = getCookie(main_name);
	var search = name + "="
	
	if (main_cookie.length > 0)
  	{
    		var offset = main_cookie.indexOf(search)
        	
    		if (offset != -1)
    		{
    			// if cookie exists
    			offset += search.length
    			// set index of beginning of value
    			var end = main_cookie.indexOf("&", offset)
    			
    			// set index of end of cookie value
    			if (end == -1)
    				end = main_cookie.length
        	
				return unescape(main_cookie.substring(offset, end))
    		}
  	}
	return ""
}
				
// remove sub cookie name & value
function terminateSubCookie(main_name,name, expire) 	//set cookie for realmedia
{
	var main_cookie = getCookie(main_name);
	var search = name + "="
	
  	if (main_cookie.length > 0)
  	{
    		var offset = main_cookie.indexOf(search)
    		
    		if (offset != -1)
    		{
    			// if cookie exists
    			// set index of beginning of value
    			var end = main_cookie.indexOf("&", offset)
    			
    			// set index of end of cookie value
    			if (end == -1)
    				end = main_cookie.length
				
				main_cookie = main_cookie.substring(0, offset) + main_cookie.substring(end,main_cookie.length);
				main_cookie = unescape(main_cookie);
			}
  	} 	
    //set cookie
	document.cookie = main_name + "=" + escape(main_cookie) + "; path=/; domain=.dial070.co.kr"
}


///////////////////////////////////////////////////////////////////////
// ÀÌÁö¿¬ ¼öÁ¤ [½ÃÀÛ] : ÁÖ¼Ò·Ï¿¡¼­ ºÎ¸£´Â°Í °°´Ù. 
///////////////////////////////////////////////////////////////////////
function openDialpadWeb(layer,phonenum)
{
	// written by sgkim
	// ÀÌ¹Ì ¶°ÀÖÀ¸¸é ½ÇÇàÇÏÁö ¸»ÀÚ.
	if (RunCheck(1)) {
		ShowDialpad();
		if (phonenum != '')
			Call(phonenum);
		return;
	}
	
	var AppUrl = "";
	top.name = "DialPadMain";
	
	// 2003-03-17 LoginµÇ¾ú´ÂÁö °Ë»ç¸¦ ÇØ ÁØ´Ù.
	// ÄíÅ°°¡ ÀÚ²Ù ¸»½éÀÌ´Ù.. :)
	if(mylogincheck() == true)
	{
		AppUrl = g_dialpadurl+'/webdial/webdial_idx.html?showlayer='+ layer + '&phonenum='+phonenum ;
	}
	else
	{
		AppUrl = g_dialpadurl+'/webdial/login.html?showlayer='+ layer + '&phonenum='+phonenum ;
		//AppUrl = '/dialpadweb/login.html?phonenum='+phonenum ;
	}	
	
	var wnd = window.open('','´ÙÀÌ¾ó070', 'left = 0,top=0, fullscreen=no,resizable=no,menubar=no,toolbar=no,scrollbars=no,width=478,height=391');
	
	// ÀÌ¹Ì ½ÇÇàµÇ¾î ÀÖ´Ù¸é?
	if((wnd != null) && (wnd.fmcenter != null))
	{
		wnd.focus();
		//wnd.fmcenter.showlayer(layer);
		if (phonenum != '') {
				
			wnd.fmcenter.phoneframe.SetDialNumber(phonenum);
			wnd.fmcenter.phoneframe.onDialClick();
		}
	}
	else
	{
		// »õ·Î ¶ç¿î´Ù.
		wnd = window.open(AppUrl,'´ÙÀÌ¾ó070', 'left = 0,top=0, fullscreen=no,resizable=no,menubar=no,toolbar=no,scrollbars=no,width=478,height=391');
	}
}

// hyoungs add
function mylogincheck()
{
	var sessionid = getCookie("SessionID");
	var userName  = getCookie("UserName");

	// by sgkim.
	if (sessionid == "" || sessionid == "undefined" || sessionid == null)
		return false;
	if (userName == "" || userName == "undefined" || userName == null)
		return false;

	// ok		
	return true
}

function onCallNumber700(phonenum)
{
	// Main Helper°¡ ÀÖ´Ù¸é..
	if (document.MainHelper != null) {
		//¸ÕÀú Plus°¡ ÀÖ´ÂÁö¸¸ °Ë»çÇÑ´Ù.
		document.MainHelper.RunCheck(2);
		dwError = document.MainHelper.LastError;
		
		// °á°ú°¡ 0:OK, ±× ÀÌ¿Ü´Â ½ÇÆÐ.
		if (dwError == 0) {
			// Plus·Î Call.
			document.MainHelper.Show(2);
			if (phonenum != '')
				document.MainHelper.Call(2,phonenum);
			return;
		}
		
		// WebÀÌ ½ÇÇàµÇ¾î ÀÖ´Ù¸é ÀüÈ­¸¦ °ÉÀÚ.
		document.MainHelper.RunCheck(1);
		dwError = document.MainHelper.LastError;
		
		// °á°ú°¡ 0:OK, ±× ÀÌ¿Ü´Â ½ÇÆÐ.
		if (dwError == 0) {
			// WebÀ¸·Î Call.
			document.MainHelper.Show(1);
			if (phonenum != '')
				document.MainHelper.Call(1,phonenum);
			return;
		}
		
	}
	
	// ±× ÀÌ¿Ü´Â À¥À¸·Î..
	if(mylogincheck() == true)
	{
	    //setCookieForSeconds("CalledValue", phonenum, 30)
		top.name = "DialPadMain";
		//var url = g_dialpadurl + '/webdial/webdial_idx.html?showlayer=_phone&phonenum='+phonenum;		
		var url = 'http://www.dial070.co.kr/webdial/webdial_idx.html?showlayer=_phone&phonenum='+phonenum;		
		var wnd = window.open('','´ÙÀÌ¾ó070', 'left = 0,top=0, fullscreen=no,resizable=no,menubar=no,toolbar=no,scrollbars=no,width=478,height=391');
		
		
		if((wnd != null) && (wnd.fmcenter != null))
		{
			wnd.focus();
			//wnd.fmcenter.showlayer("_phone");
			if (phonenum != '') {
				wnd.fmcenter.phoneframe.SetDialNumber(phonenum);
				wnd.fmcenter.phoneframe.onDialClick();
			}	
		}
		else
		{
			wnd = window.open(url,'´ÙÀÌ¾ó070', 'left = 0,top=0, fullscreen=no,resizable=no,menubar=no,toolbar=no,scrollbars=no,width=478,height=391');
		}
	}
	else
	{
		//setCookieForSeconds("CalledValue", phonenum, 30)
		//url = g_dialpadurl + '/webdial/login.html?showlayer=_phone&phonenum='+phonenum;
		url =  'http://www.dial070.co.kr/webdial/login.html?showlayer=_phone&phonenum='+phonenum;
		wnd = window.open(url,'´ÙÀÌ¾ó070', 'left = 0,top=0, fullscreen=no,resizable=no,menubar=no,toolbar=no,scrollbars=no,width=478,height=391');
	}
}

////////////////////////////////////////////////////////////////////////////////
//   Dialpad Web ActiveX »ç¿ë ¸Þ¼Òµå Á¤ÀÇ (2003-02-27) written by sgkim       //
////////////////////////////////////////////////////////////////////////////////

// Object ÄÚµå »ý¼º ÇÔ¼ö.
////////////////////////////////////////////////////////////////////////////////
function WriteHelperObjectCode(name)
{
	document.writeln("<OBJECT id='"
		+ name + "' name='"
		+ name + "' CLASSID='"
		+ g_helperclass + "' width=0 height=0 codebase='" 
		+ g_helpercabbase + "#version=" + g_helperversion + "'>");
	document.writeln("</OBJECT>");
	
    document.writeln("<SCRIPT FOR='"+name+"' EVENT='OnCommand(nCmd)' LANGUAGE='JScript'>");
    document.writeln("HelperOnCommand(nCmd)");
	document.writeln("</SCRIPT>");
	
}

function HelperOnCommand(nCmd)
{
	var CM_NOTIFY_INITIALIZED = 20001;
	
	alert("!");
	
	var Helper = document.Helper;
	// ¸í·É¾î Ã³¸®.
	switch(nCmd) {
		case CM_NOTIFY_INITIALIZED:
		{
			// Ã³À½ ÃÊ±âÈ­ µÇ¾úÀ¸´Ï, ÀÚµ¿À¸·Î ÀüÈ­Ã¢ ¿­ÀÚ.
			launchApplet();
			break;
		} 
	}
}

// Dialpad Å¬¶óÀÌ¾ðÆ® °Ë»ç.
////////////////////////////////////////////////////////////////////////////////
function getDialpad() //  ¼³Ä¡µÇ¾î ÀÖ´Â Dialpad ±¸ÇÏ±â. Áï, ½ÇÇà°¡´ÉÇÑ È¯°æ°Ë»ç.
{
	var dwError;
	
	if (g_define_usewebonly == 1) return g_id_app_web;
	
	// Plus¸¦ °Ë»çÇÑ´Ù.
	document.Helper.InstallCheck(g_id_app_plus);
	dwError = document.Helper.LastError;
	// ErrorÄÚµå¿Í ApplicationID°¡ °°´Ù¸é ÇØ´ç Å¬¶óÀÌ¾ðÆ®°¡ ¼³Ä¡µÇ¾î ÀÖ´Ù´Â °Í.
	if (dwError == g_id_app_plus)
		return g_id_app_plus;
		
	// WebÀº Á» ³ªÁß¿¡ Áö¿øÇÏÀÚ
	return 0;
}

function getActiveDialpad() //  ½ÇÇàµÇ¾î ÀÖ´Â Dialpad ±¸ÇÏ±â.
{
	var nID = 0;
	nID = document.Helper.RunningAppID;
	// 0 : ½ÇÇàÁßÀÎ Å¬¶óÀÌ¾ðÆ® ¾øÀ½ or ¿À·ù ¹ß»ý.
	// 1 : Dialpad Web 2 : Dialpad Plus
	return nID;
}

// Æ¯Á¤ ApplicationID·Î ½ÇÇàµÇ¾î ÀÖ´ÂÁö °Ë»çÇÑ´Ù.
function RunCheck(nID)
{
	document.Helper.RunCheck(nID);
	dwError = document.Helper.LastError;
	
	// °á°ú°¡ 0:OK, ±× ÀÌ¿Ü´Â ½ÇÆÐ.
	if (dwError == 0) 
		return true;
	else
		return false;
}


// Dialpad ½ÇÇà / Á¤Áö
////////////////////////////////////////////////////////////////////////////////
function RunDialpad()
{
	var nID;
	var dwError;

	nID = getDialpad();
	if (nID == 0) {
		doErrorProc(g_err_proc_not_install);
		return 0;
	}
	
	// ÀÌ¹Ì ½ÇÇàµÇ¾î ÀÖ´Ù¸é ¼öÇàÇÒ ÇÊ¿ä°¡ ¾ø´Ù.
	if (getActiveDialpad() > 0 ) return getActiveDialpad();
	
	document.Helper.Run(nID);
	dwError = document.Helper.LastError; 
	
	// °á°ú´Â. 
	// 0º¸´Ù Å©¸é, nAppID°ªÀ» ÀÇ¹ÌÇÏ°í.
	// 0º¸´Ù ÀÛÀ¸¸é ¿À·ùÀÌ´Ù.
	return nID;	
}

function StopDialpad()
{
	var nID;
	var dwError;
	nID = getDialpad();
	if (nID == 0) {
		doErrorProc(g_err_proc_not_install);
		return 0;
	}
	
	// ½ÇÇàµÇ¾î ÀÖ´Â Å¬¶óÀÌ¾ðÆ®°¡ ¾ø´Ù¸é ´ÝÀ» ÇÊ¿ä°¡ ¾ø´Ù.
	if (getActiveDialpad() == 0 ) return 0;
	
	nID = getActiveDialpad();
	document.Helper.Stop(nID);
	dwError = document.Helper.LastError; 
	// 0:OK, 1:½ÇÇà¾ÈµÊ, 2:Á×À¸¸é ¾ÈµÇ´Â »óÈ², 3:¾Ë ¼ö ¾ø´Â ¿À·ù.
	return 0;
}


// ÀüÈ­ °É±â/²÷±â
////////////////////////////////////////////////////////////////////////////////
function Call(szCallNumber)
{
	var nID;
	var dwError;
	nID = getDialpad();
	if (nID == 0) {
		doErrorProc(g_err_proc_not_install);
		return -1;
	}
	
	szCallNumber	= szCallNumber.replace(/-/g,""); // ÀüÈ­¹øÈ£ÀÇ - Á¦°Å
	szCallNumber	= szCallNumber.replace(/ /g,""); // ÀüÈ­¹øÈ£ÀÇ - Á¦°Å


	// ½ÇÇàµÇ¾î ÀÖ´ÂÁö °Ë»çÇÏ¿© ±×·¸Áö ¾Ê´Ù¸é ½ÇÇàÇÑ´Ù.
	nID = RunDialpad();

	if (nID == 0) 
		return -1;
		
	//alert(nID);
	
	// ÀüÈ­¸¦ °Ç´Ù.
	document.Helper.Call(nID,szCallNumber);
	dwError = document.Helper.LastError; 
	
	if (dwError != 0)
		return -1;
	// 0:OK, 1:½ÇÇà¾ÈµÊ, 2:ÅëÈ­ÇÏ°í ÀÖ´Â »óÈ², 3:¾Ë ¼ö ¾ø´Â ¿À·ù.
	return 0;
}


// by sgkim : 2003-05-13
// ÀüÈ­¹øÈ£ ºñ¹ÐÈ­ ¸Þ¼Òµå°¡ Ãß°¡µÇ¾ú´Ù.
// Helper Version 1.0.5.13 ÀÌ»ó¿¡¼­ Áö¿øÇÔ.
function SecureCall(szCallNumber)
{
	var nID;
	var dwError;
	nID = getDialpad();
	if (nID == 0) {
		doErrorProc(g_err_proc_not_install);
		return -1;
	}
	
	// ½ÇÇàµÇ¾î ÀÖ´ÂÁö °Ë»çÇÏ¿© ±×·¸Áö ¾Ê´Ù¸é ½ÇÇàÇÑ´Ù.
	nID = RunDialpad();

	if (nID == 0) 
		return -1;
		
	//alert(nID);
	
	// ÀüÈ­¸¦ °Ç´Ù.
	document.Helper.SecureCall(nID,szCallNumber);
	dwError = document.Helper.LastError; 
	
	if (dwError != 0)
		return -1;
	// 0:OK, 1:½ÇÇà¾ÈµÊ, 2:ÅëÈ­ÇÏ°í ÀÖ´Â »óÈ², 3:¾Ë ¼ö ¾ø´Â ¿À·ù.
	return 0;
}

function Hangup()
{
	var nID;
	var dwError;
	nID = getDialpad();
	if (nID == 0) {
		doErrorProc(g_err_proc_not_install);
		return 0;
	}
	nID = getActiveDialpad();
	
	document.Helper.Hangup(nID);
	dwError = document.Helper.LastError; 
	// 0:OK, 1:½ÇÇà¾ÈµÊ, 2:ÅëÈ­ÁßÀÌ ¾Æ´Ô, 3:¾Ë ¼ö ¾ø´Â ¿À·ù
	return 0;
}

// ÇÁ·Î±×·¥ º¸ÀÌ±â/°¨Ãß±â.
////////////////////////////////////////////////////////////////////////////////
function ShowDialpad()
{
	var nID;
	var dwError;
	nID = getDialpad();
	if (nID == 0) {
		doErrorProc(g_err_proc_not_install);
		return 0;
	}
	
	// ½ÇÇàµÇ¾î ÀÖ´ÂÁö °Ë»çÇÏ¿© ±×·¸Áö ¾Ê´Ù¸é ½ÇÇàÇÑ´Ù.
	nID = RunDialpad();
	
	document.Helper.Show(nID);
	dwError = document.Helper.LastError; 
	// 0:OK, 1:½ÇÇà¾ÈµÊ, 2:¾Ë ¼ö ¾ø´Â ¿À·ù
	
	return 0;
}

function HideDialpad()
{
	var nID;
	var dwError;
	nID = getDialpad();
	if (nID == 0) {
		doErrorProc(g_err_proc_not_install);
		return 0;
	}

	nID = getActiveDialpad();
	
	document.Helper.Hide(nID);
	dwError = document.Helper.LastError; 
	// 0:OK, 1:½ÇÇà¾ÈµÊ, 2:¾Ë ¼ö ¾ø´Â ¿À·ù
	return 0;
}

// ÇÁ·Î±×·¥ ¿À·ù ¹× ¸Þ½ÃÁö Ã³¸® ÇÔ¼ö ¸ðÀ½.
////////////////////////////////////////////////////////////////////////////////
function doErrorProc(nErrorClass)
{
	switch (nErrorClass)
	{
	case 1:
		// NOT_INSTALL
		alert(g_err_desc_not_install);
		// ¼³Ä¡¸¦ ±ÇÇÏ°í, ¼³Ä¡ÆäÀÌÁö·Î ÀÌµ¿..
		// ÀÌµ¿ÇÔ¼ö ³ªÁß¿¡ Ãß°¡ÇØ¾ß ÇÑ´Ù.. :)
		break;
	}
}

////////////////////////////////////////////////////////////////////////////////
// HelperÃß°¡.
//insertHelper("MainHelper");
function WriteName()
{
	lastname = getCookie('LastName');
	document.write (unescape(lastname));
}



