//**************************************************************************************
//GENERAL
//**************************************************************************************
function OpenBrWindow(theURL,winName,features) {
	Window = window.open(theURL,winName,features);
}
//**************************************************************************************
//TABS
//**************************************************************************************
function setTabs(){    //Get all divs
	var tabs = document.getElementsByTagName("div");

    //Get Level 1-3 paths information
	var sLevel1Path = document.getElementById('KLTCMS_Level1URL').value;
	var sLevel2Path = document.getElementById('KLTCMS_Level2URL').value;
	var sLevel3Path = document.getElementById('KLTCMS_Level3URL').value;

    //Loop through all divs	for(var t = 0; t < tabs.length; t++)	{	    //Get next div in loop		var tab = tabs[t];
		
		//Extract rel/url attributes
		var relAttribute = String(tab.getAttribute('rel'));
    	var urlAttribute = String(tab.getAttribute('url'));

        //Is this a top level nav tab?
		if (relAttribute.toLowerCase().match("tab"))
		{
		    //Does this page match the 1st level URL
			if (sLevel1Path == urlAttribute)
				tab.className = "divTabIn";
			else
			{			
				tab.onmouseover = function(){this.className = "divTabOn";}
				tab.onmouseout = function(){this.className = "divTabOff";}
			}
			//Always make clickable
			tab.onclick = function()
			{
				var urlAttribute = String(this.getAttribute('url'));
				currentTab = urlAttribute;
				document.location.href = urlAttribute;
			}
		}			}}

function verticalOn(which,e){
	which.className = (e == "on") ? "divVerticalOn" : "divVerticalOff";
}
//**************************************************************************************

window.onload = function(){
	setTabs();
}

//**************************************************************************************



function hideItemLayer(Layer) 
{	
	document.getElementById('div' + Layer).style.display = "none";
}

function showItemLayer(Layer)
{	
    //Hide all
    for (i = 1; i < 21; i++)
    {
        if (document.getElementById('divItem' + i) != null)
            hideItemLayer('Item' + i);
        else
            break;
    }

    //Show 1 layer
    document.getElementById('div' + Layer).style.display = "block";	
}


var mapCounter = 0;

function showLocation(latitude, longitude, description)
{
    var icon = new GIcon();
    icon.image = "/Common/Images/custom/pushpin.gif";
    icon.iconSize = new GSize(47, 24);
    icon.iconAnchor = new GPoint(6, 20);
    icon.infoWindowAnchor = new GPoint(5, 1);

    var point = new GLatLng(latitude, longitude);
    var marker = new GMarker(point, icon);
    GEvent.addListener(marker, "click", 
        function() 
        {
            marker.openInfoWindowHtml(description);
        }
    );
    map.addOverlay(marker);
    if (mapCounter == 0)
        marker.openInfoWindowHtml(description);
    mapCounter++;
}

function centerAndDisplayLocation(latitude, longitude, description)
{
    var icon = new GIcon();
    icon.image = "/Common/Images/custom/pushpin.gif";
    icon.iconSize = new GSize(47, 24);
    icon.iconAnchor = new GPoint(6, 20);
    icon.infoWindowAnchor = new GPoint(5, 1);

    var point = new GLatLng(latitude, longitude);
    var marker = new GMarker(point, icon);
    GEvent.addListener(marker, "click", 
        function() 
        {
            marker.openInfoWindowHtml(description);
        }
    );
    map.addOverlay(marker);
    marker.openInfoWindowHtml(description);
    map.setCenter(new GLatLng(latitude, longitude), 13);
}