﻿function propertySwitch()
{
    if (document.getElementById("localitiesDiv").firstChild)
    {
        var node = document.getElementById("localitiesDiv").firstChild;
        var nodeClass;

        var checkBox = document.getElementsByName("checkbox0")[0];
        var checkBoxCount = 0;
       
        while (node)
        {
            node.style.display = "block";
            node = node.nextSibling;
        }
        
        node = document.getElementById("localitiesDiv").firstChild;
        
        while (checkBox)
        {
            if (!checkBox.checked)
            {
                while (node)
                {
                    nodeClass = node.className;
                    if (nodeClass.match("#" + checkBox.id + "#"))
                    {
                     node.style.display = "none";
                    }
                    node = node.nextSibling;
                }
                node = document.getElementById("localitiesDiv").firstChild;
            }
            checkBoxCount++;
            checkBox = document.getElementsByName("checkbox" + checkBoxCount)[0];
        }
    }
}

var shownLayer = "";
function showDetails(localityId,top,left)
{
    var detailBox = document.getElementById(localityId);
    shownLayer = detailBox.id;
    if(z_box)
    {
        detailBox.style.display = "none";
        document.getElementById('mapholder').style.zIndex=112;
    }else{
        detailBox.style.display = "block";
        document.getElementById('mapholder').style.zIndex=100;
    }
    if((top + (191)) >= 400){
        detailBox.style.top = (top - (170-5)) + 'px';
        if((top - (170-5))>217){detailBox.style.top = '217px';}
    }
    if(top<0){detailBox.style.top='0px';}
    if((left + (210)) >= 500){
        detailBox.style.left = (left - (200-10)) + 'px';
        if((left - (200-10))>291){detailBox.style.left = '291px';}
    }
    if(left<0){detailBox.style.left='0px';}
}

function hideDetails()
{
    if(document.getElementById(shownLayer))
    {
		document.getElementById(shownLayer).style.display = 'none';
	}
}



function togglehjaelp(lagid, switchOn){
    var LagObj = document.getElementById(lagid);
    
    if (switchOn)
    {
        var visningsBool = switchOn;
    }
    else var visningBool = (LagObj.style.visibility =='hidden') ? false : true;
    LagObj.style.visibility = (visningBool) ? 'hidden' : 'visible';
    //KnapObj.src = (visningBool) ? 'Grafik/help.gif':	'Grafik/closehelp.gif';
    //KnapObj.alt = (visningBool) ? 'Hjælp':	'Luk hjælp';
}


function isPostal()
{
    
    if (!document.getElementById('postalCodeTextBox').value)
    {
         if(document.getElementById('prevExtent').value == "0|0|0|0"){togglehjaelp('huskpostby', true)};
    }
}
