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 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 popup_win_ktv(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,left=550,top=10'+
            '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);
}


function search_zipcode(form_name, zip_code_1, zip_code_2, address_1, address_2)
{
    w = window.open('/warp/webapp/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,
            'search_zipcode',
            'status=no,directories=no,location=no,toolbar=no,resizeable=yes,'+
            'scrollbars=yes,copyhistory=no,width=460,height=260');
    w.focus();
}

function check_key(column_name, return_element, next_element, key_name, input_key)
{
    w=  window.open('check?column_name='+column_name+'&return_element='+return_element+
            '&next_element='+next_element+'&key_name='+key_name+'&key_value='+input_key,
            'check_key',
            'status=no,directories=no,location=no,toolbar=no,resizeable=yes,'+
            'scrollbars=yes,copyhistory=no,width=460,height=250');
    w.focus();
}
function empty_menu()
{
    alert("¸Þ´º°¡ ¾ø½À´Ï´Ù.");
}
function postToGet(obj) {
    var getstr = "";

    for(var i = 0 ; i < obj.length ; i++ ) {
        var el = obj.elements[i];

        if(el.tagName == 'INPUT') {
            if(el.type == 'hidden' || el.type == 'text' || el.type == 'password' ) {
                getstr += el.name + "=" + el.value + "&"; 
            }
            else if(el.type == 'checkbox') {
                if(el.checked == true) {
                    getstr += el.name + "=" + el.value + "&";
                }
                else {
                    getstr += el.name + "=&";
                }
            }
            else if(el.type == 'radio') {
                if(el.checked == true) {
                    getstr += el.name + "=" + el.value + "&";
                }
                else {
                }
            }
            else if(el.type == 'file') {
            }
        }
        else if(el.tagName == 'SELECT') {
            getstr += el.name + "=" + el.options[el.selectedIndex].value + "&";
        }
        else if(el.tagName == 'TEXTAREA') {
            getstr += el.name + "=" + el.value + "&";
        }
    }
    return getstr;
}

