/*
    Copyright (c) 2009, SpatialPoint, LLC.
    
    All rights reserved.
    
    http://www.spatialpoint.com
*/

function hideControl(id)
{
    var obj = document.getElementById(id);
    
    obj.style.visibility = "hidden"
    obj.style.display = "none";
}

function showControl(id)
{
    var obj = document.getElementById(id);
    
    obj.style.visibility = "visible";
    obj.style.display = "block";
}

function toggleDisplay(id)
{
    var obj = document.getElementById(id);
    
    if (obj.style.visibility == "hidden")
    {
        obj.style.visibility = "visible";
        obj.style.display = "block";
    }
    else
    {
        obj.style.visibility = "hidden"
        obj.style.display = "none";
    }
}

function toggleFramelet(control, id)
{ 
	toggleDisplay(control.id);
	toggleDisplay(id);
}

function trim(text)
{
   return text.replace(/^\s*|\s*$/g, "");
}

function isKeyPressed(evt, code)
{
	// this function supports IE, Netscape, and FireFox
	evt = (evt) ? evt : (window.event) ? event : null;
  
	if (evt)
	{
		var charCode = (evt.charCode) ? evt.charCode :
			((evt.keyCode) ? evt.keyCode : ((evt.which) ? evt.which : 0));

		return (charCode == code);
	}
	
	return false;
}

function addBookmark(title, url)
{
    if (window.sidebar) // Mozilla Firefox Bookmark.
    { 
		window.sidebar.addPanel(title, url, "");
	} 
	else 
	    if (window.external) // IE Favorite.
	    { 
		    window.external.AddFavorite( url, title); 
		}
}
