
/// Method  :   visKommune
/// Purpose :   Inserts an entry (municipalityID) in a selectbox, but verifies before insert
///             that the value does not already exists   
function ListEntryInsert(entry)
{
    
    //var listObject = window.parent.document.getElementById('ctl00_ctl00_BucketsContent_ctl00__ListBoxChosenItems');
    var listObject = window.parent.document.getElementById('_ListBoxChosenItems');
    
    // Check that entry with same value doesn't already exists
    for (i = 0; i < listObject.length; i++)
    {
        if (listObject.options[i].text == entry)
            return;
    }
    
    var listEntry = document.createElement('option');
    listEntry.text = entry;
    
    if(navigator.userAgent.indexOf("Firefox")!=-1)
    {
        //alert("Firefox");
        listObject.appendChild(listEntry);
    }
    else
    {
        //alert("IE");
        listObject.add(listEntry);
    }
    
}

function visKommune(entry)
{
    ListEntryInsert(window.parent.GetSingleMunicipalityByID(entry));
}


function visPost(entry)
{
    ListEntryInsert(entry)
}

function RemoveSelected()
{
   
    var listObject = document.getElementById('_ListBoxChosenItems');
    
    while(listObject.selectedIndex > -1)
        listObject.remove(listObject.selectedIndex);
}

function RemoveAll()
{    
    var listObject = document.getElementById('_ListBoxChosenItems');
    
    while(listObject.options.length>0)
	{
	    listObject.options[listObject.options.length-1] = null;
	}


}
    



