function paramEscape(paramValue)
{
    return encodeURIComponent(paramValue);
}

function formData2QueryString(docForm)
{    
    var submitString = '';
    var formElement = '';
    var lastElementName = '';
    
    for(i = 0 ; i < docForm.elements.length ; i++)
    {
        formElement = docForm.elements[i];
        switch(formElement.type)
        {
            case 'text' :
            case 'select-one' :
            case 'hidden' :
            case 'password' :
            case 'textarea' :
                submitString += formElement.name + '=' + paramEscape(formElement.value) + '&';
                break;
            case 'radio' :     
                if(formElement.checked)
                {
                    submitString += formElement.name + '=' + paramEscape(formElement.value) + '&';
                }
                break;
            case 'checkbox' :    
                if(formElement.checked) 
                {
                    if(formElement.name = lastElementName)
                    {
                        if(submitString.lastIndexOf('&') == submitString.length - 1)
                        {
                            submitString = submitString.substring(0, submitString.length - 1);
                        }
                        submitString += ',' + paramEscape(formElement.value);
                    }
                    else
                    {
                        submitString += formElement.name + '=' + paramEscape(formElement.value); 
                    }
                    submitString += '&';
                    lastElementName = formElement.name;
                }
                break;  
        }                                                                                                                  
    }
    submitString = submitString.substring(0, submitString.length - 1);
    //document.all("result").value = submitString;
    return submitString;                                               
}

function xmlHttpPost(actionUrl, submitParameter, resultFunction)
{
    var xmlHttpRequest = false;
    
    //IEÀÎ°æ¿ì
    if(window.ActiveXObject)
    {
        xmlHttpRequest = new ActiveXObject('Microsoft.XMLHTTP');
    }
    else
    {
        xmlHttpReq = new XMLHttpRequest();
        xmlHttpReq.overrideMimeType('text/xml');
    }    
            
    xmlHttpRequest.open('POST', actionUrl, true);
    //xmlHttpRequest.open('GET', actionUrl, true);
    xmlHttpRequest.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
    xmlHttpRequest.onreadystatechange = function() {
        if(xmlHttpRequest.readyState == 4)
        {
            switch (xmlHttpRequest.status) 
            {
                case 404:
                    alert('¿À·ù: ' + actionUrl + 'ÀÌ Á¸ÀçÇÏÁö ¾ÊÀ½');
                    break;
               case 500:
                   alert('¿À·ù: ' + xmlHttpRequest.responseText);
                   break;
               default:
                   eval(resultFunction + '(xmlHttpRequest.responseText);');
                   break;        
            }            
        }
    }
    
    xmlHttpRequest.send(submitParameter);                    
}                                    
