﻿function makeWin(tUrl, strheight, strwidth) {
	agent = navigator.userAgent;
	windowName = "DefinitionWindow";
	
	var vwidth = strwidth;
	var vheight = strheight;
	var vtop = ((screen.height - vheight)/2);
	var vleft = ((screen.width - vwidth)/2); 
	params  = "";
	params += "toolbar=0,";
	params += "location=0,";
	params += "directories=0,";
	params += "status=0,";
	params += "menubar=0,";
	params += "scrollbars=1,";
	params += "resizable=1,";
	params += "width=" + vwidth + ",";
	params += "height=" + vheight + ",";
	params += "top=" + vtop + ",";
	params += "left=" + vleft;
	
	win = window.open(tUrl, windowName, params);
	if (agent.indexOf("Mozilla/2") != -1 && agent.indexOf("Win") == -1) {
	    win = window.open(url, windowName , params);
	}
	if (!win.opener) {
	    win.opener = window;
	}
}

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)
{
    showLocation(latitude, longitude, description, "/Common/Images/custom/pushpin.gif");
}

function showLocation(latitude, longitude, description, pushPin)
{
    var icon = new GIcon();
    icon.image = pushPin;
    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)
{
    centerAndDisplayLocation(latitude, longitude, description, "/Common/Images/custom/pushpin.gif");
}

function centerAndDisplayLocation(latitude, longitude, description, pushPin)
{
    var icon = new GIcon();
    icon.image = pushPin;
    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);
}


//CUSTOM!!!!!!!!!!!!!!!!!
//**************************************************************************************
// Highlight Tabs
//**************************************************************************************
function setAnchors(){    //Get all divs
	var anchors = document.getElementsByTagName("a");

    //Get Level 1-3 paths information (only Level1 used so far)
	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    var iCtr = 0;	for(var t = 0; t < anchors.length; t++)	{	    //Get next div in loop		var tab = anchors[t];
		
		//Extract rel/url attributes
		var relAttribute = String(tab.getAttribute('rel'));
    	var urlAttribute = String(tab.getAttribute('href'));
    	urlAttribute = urlAttribute.replace("http://67.192.55.250", "");
    	urlAttribute = urlAttribute.replace("http://sbrllc.com", "");
    	urlAttribute = urlAttribute.replace("http://www.sbrllc.com", "");

        //Is this a top level nav tab?
		if (relAttribute.toLowerCase().match("tab"))
		{
		    tab.className = "";

		    iCtr++;

            //Home
		    if (sLevel1Path == "/" && sLevel2Path == "" && sLevel3Path == "" && urlAttribute == "/")
				tab.className = "active";		    
	
            //Subpages	    
		    if (sLevel2Path == urlAttribute || sLevel3Path == urlAttribute)
				tab.className = "active";

			//Always make clickable
			tab.onclick = function()
			{
				var urlAttribute = String(this.getAttribute('url'));
				currentTab = urlAttribute;
				document.location.href = urlAttribute;
			}
		}		
	}
}

window.onload = function() { setAnchors(); }