function getCookieVal(offset)
{
    var endstr = document.cookie.indexOf (";", offset);
    if (endstr == -1)
    	endstr = document.cookie.length;
    return unescape(document.cookie.substring(offset, endstr));
}


function getCookie(name)
{
    var arg = name + "=";
    var alen = arg.length;
    var clen = document.cookie.length;
    var i = 0;
    while(i < clen)
    {
    	var j = i + alen;
    	if (document.cookie.substring(i, j) == arg)
    		return getCookieVal(j);
    	i = document.cookie.indexOf(" ", i) + 1;
    	if (i == 0)
    		break;
    }
    return null;
}

function setCookie(name, value, expires, path, domain, secure)
{

    var todayDate = new Date()
    todayDate.setDate( todayDate.getDate() + expires );
    var argv = setCookie.arguments;
    var argc = setCookie.arguments.length;
    var expires = (2 < argc) ? argv[2] : null;
    var path = (3 < argc) ? argv[3] : null;
    var domain = (4 < argc) ? argv[4] : null;
    var secure = (5 < argc) ? argv[5] : false;
    document.cookie = name + "=" + escape (value) +
    	((expires == null) ? "" : ("; expires=" + todayDate.toGMTString())) +
    	((path == null) ? "" : ("; path=" + path)) +
    	((domain == null) ? "" : ("; domain=" + domain)) +
    	((secure == true) ? "; secure" : "");

}

function setCookieMinute(name, value, expires, path, domain, secure)
{

    var todayDate = new Date()
    todayDate.setMinute( todayDate.getMinute() + expires );
    var argv = setCookie.arguments;
    var argc = setCookie.arguments.length;
    var expires = (2 < argc) ? argv[2] : null;
    var path = (3 < argc) ? argv[3] : null;
    var domain = (4 < argc) ? argv[4] : null;
    var secure = (5 < argc) ? argv[5] : false;
    document.cookie = name + "=" + escape (value) +
    	((expires == null) ? "" : ("; expires=" + todayDate.toGMTString())) +
    	((path == null) ? "" : ("; path=" + path)) +
    	((domain == null) ? "" : ("; domain=" + domain)) +
    	((secure == true) ? "; secure" : "");
alert(document.cookie);
}

function DeleteCookie (name,path,domain) {
  if (GetCookie(name)) {
    document.cookie = name + "=" +
      ((path) ? "; path=" + path : "") +
      ((domain) ? "; domain=" + domain : "") +
      "; expires=Thu, 01-Jan-70 00:00:01 GMT";
  }
}

function close_pop(cookie_name, expire, URL)
{
    if(document.closeForm.decide.checked)
    {
        setCookie(cookie_name,"yes", expire,"/");
    }
    if(URL != "none" && URL != "")
       opener.window.location=URL;
    window.close();
}

function popup_win(cookie_name, win_name, src, width, height, scrollbar, menubar)
{
    if(getCookie( cookie_name ) != "yes")
    {
        small_window = window.open(src, win_name,
            'width='+width+',height='+height+',marginwidth=0, marginheight=0,'+
            'resizable=0,scrollbars='+scrollbar+',menubar='+menubar)
    }
    else
        return
}

function open_win(win_name, src, width, height, scrollbar, menubar)
{
    open_window = window.open(src, win_name,
            'width='+width+',height='+height+',marginwidth=0, marginheight=0,'+
            'resizable=0,scrollbars='+scrollbar+',menubar='+menubar);
    open_window.focus();
}

function searchZipCode(form_name, zip_code_1, zip_code_2, address_1, address_2)
{
    w = window.open('/warp/app/sys/search_zipcode'+
            '?form_name='+form_name+
            '&zip_code_1='+zip_code_1+'&zip_code_2='+zip_code_2+
            '&address_1='+address_1+'&address_2='+address_2,
            'searchZipCode',
            'status=no,directories=no,location=no,toolbar=no,resizeable=yes,'+
            'scrollbars=yes,copyhistory=no,width=450,height=300');
    w.focus();
}

function checkKey(action, returnElement, nextElement, keyName, inputKey)
{
    w=  window.open('/warp/app/check_key/'+action+'?return_element='+returnElement+
            '&next_element='+nextElement+'&key_name='+keyName+'&key='+inputKey,
            'checkExistKey',
            'status=no,directories=no,location=no,toolbar=no,resizeable=yes,'+
            'scrollbars=yes,copyhistory=no,width=300,height=200');
    w.focus();
}

function popBlind()
{
    var width = screen.width > 800 ? 820 : 780;
    var height = screen.height >= 768 ? 700 : 560;
    var url = '/warp/handicap/';
    var win = 'pop_blind';
    var opt = 'width='+width+', height='+height+', scrollbars=yes';

    var _win = window.open(url, win, opt);
}

	submenu_ids = new Array('01','02','03','04');

	menu = new Array(2);
	menu[0] = new Array(submenu_ids.length);
	menu[1] = new Array(submenu_ids.length);

	var menu_time_out = -1;

	for(var i = 0; i<submenu_ids.length; i++)
	{
		menu[0][i] = new Image();
		menu[0][i].src = "images/menu_"+submenu_ids[i]+((submenu_ids[i] == '00') ? '_on' : '')+'.gif';
		menu[1][i] = new Image();
		menu[1][i].src = "images/menu_"+submenu_ids[i]+'_on.gif';
	}

	function clearMenu()
	{
		for(i=0; i<menu[0].length; i++)
		{
			document.images['menu_'+submenu_ids[i]].src = menu[0][i].src;
		}
	}

	function msout()
	{
		clearMenu();
	}

	function msover(enable_id)
	{
		clearMenu();

		for(i= 0; i<submenu_ids.length; i++)
		{
			if(submenu_ids[i] == enable_id && menu[1][i].src != "")
			{
				document.images['menu_'+submenu_ids[i]].src = menu[1][i].src;
				break;
			}
		}
	}

	function dispSubMenu(enable_id)
	{
		for(i=0; i < submenu_ids.length; i++)
		{
			var obj = document.getElementById('submenu_'+submenu_ids[i]);
			if(obj) obj.style.display = "none";
		}

		if(enable_id != 'undefined')
		{
			var obj = document.getElementById('submenu_'+enable_id);
			if(obj)
			{
				obj.style.display = "";
				menu_time_out = 10; //10 sec.
			}
		}
	}

	function autoClearSubMenu()
	{
		if(menu_time_out-- >= 0)
		{
			if(menu_time_out == 0) dispSubMenu();
		}
		setTimeout('autoClearSubMenu()', 1000);
	}
	autoClearSubMenu();

