<!-- Javascript starts - hide from javascript impaired browsers with this line.

//---------------------------------------------------------------------------------------------------------
// Java Function: createXMLHttpRequest - returns the proper xml http request object
//---------------------------------------------------------------------------------------------------------
function createXMLHttpRequest() 
{
   var xmlHttp;
   if (window.XMLHttpRequest) 
   {
        xmlHttp = new XMLHttpRequest();
   } 
   else if (window.ActiveXObject) 
   {
        xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
   }
   return xmlHttp;
}

function getDropDownListSelectedValue(elementID)
{
    var dropDownList = document.getElementById(elementID);
    
    if ( dropDownList )
        return dropDownList.options[dropDownList.selectedIndex].value;
    else
        return null;
}

function getDropDownListSelectedValuesAsParams(elementID)
{
    var dropDownList = document.getElementById(elementID);
    
    if ( dropDownList )
    {
        var paramList = "";
    	for (var i=0;i<dropDownList.options.length;i++)
        {
            if ( dropDownList.options[i].selected == true )
                paramList = paramList + "&" + elementID + "=" + dropDownList.options[i].value;
    	}
        return paramList;
    }
    else
        return null;
}


function clearDropDownList(elementID)
{
    var dropDownList = document.getElementById(elementID);

    if ( dropDownList )
    {
        while(dropDownList.childNodes.length > 0)
        {
            dropDownList.removeChild(dropDownList.childNodes[0]);
        }
    }
}

function unselectDropDownListAllOptions(elementID)
{
    var dropDownList = document.getElementById(elementID);

    if ( dropDownList )
    {
        for( var i=0;i<dropDownList.options.length;i++)
        {
            dropDownList.options[i].selected = false;
        }
    }
}

//---------------------------------------------------------------------------------------------------------
// Java Function: appendDropDownList - add option to a drop down
// Params       ; elementID, name, value, selected (optional: true/false)
//---------------------------------------------------------------------------------------------------------
function appendDropDownList(elementID, name, value, selected)
{
    var dropDownList = document.getElementById(elementID);

    if ( dropDownList )
    {
        var option    = null;
        option = document.createElement("option");
        option.setAttribute("value",value);
        option.appendChild(document.createTextNode(name));

        if (selected != null && selected == true)
            option.setAttribute("selected",selected);

        dropDownList.appendChild(option);
    }
}

function setDropDownList(elementID,value)
{
    var dropDownList = document.getElementById(elementID);
	
    if ( dropDownList )
    {
        for (var i=0;i<dropDownList.options.length;i++)
        {
            if ( dropDownList.options[i].value == value )
            {
                dropDownList.options[i].selected = true;
                i = dropDownList.options.length;
            }
    		else
                dropDownList.options[i].selected = false;
    	}
    }
}

function setDropDownListMultiSelect(elementID,xmlElements)
{
    // First unselect all options
    unselectDropDownListAllOptions(elementID);

    var dropDownList = document.getElementById(elementID);
    
    if ( dropDownList && xmlElements != null && xmlElements.length > 0)
    {
        for (var i=0;i<xmlElements.length;i++)
        {
            for (var j=0;j<dropDownList.length;j++)
            {
                if ( xmlElements[i].firstChild.nodeValue == dropDownList[j].value )
                {
                    dropDownList[j].selected = true;
                    j = dropDownList.length;
                }
            }
        }
    }
}

function replaceTextNode(elementID,newValue)
{
	// Get element for id
    var element = document.getElementById(elementID);

    if ( element != null )
    {
        // Remove previous text node if exists
        if (element.childNodes.length > 0)
            element.removeChild(element.childNodes[0]);

        // Add a text node with proper value
        element.appendChild(document.createTextNode(newValue));
    }
}


// Javascript ends - finish hiding from old browers with this line -->

