/**
 * pageHandler stuff
 */

if (!pageHandler)
{
    var pageHandler = {};
}

pageHandler.getId = function()
{
    return this.id;
}

pageHandler.getRef = function()
{
    return this.ref;
}

pageHandler.getLang = function()
{
    return this.lang;
}

pageHandler.getTitle = function()
{
    return this.title;
}

pageHandler.getAuthor = function()
{
    return this.author;
}

pageHandler.getKeywords = function()
{
    return this.keywords;
}

pageHandler.getThread = function()
{
    return this.thread;
}

pageHandler.getTags = function()
{
    return this.tags;
}

pageHandler.hasTag = function(tag)
{
    return (this.tags.indexOf(tag) != -1);
}

pageHandler.getTopic = function()
{
    return this.topic;
}

pageHandler.setTopic = function(topic)
{
    this.topic = topic;
}

pageHandler.getMarker = function()
{
    return this.marker;
}

pageHandler.setMarker = function(marker)
{
    this.marker = marker;
}

pageHandler.setMarkerParameter = function(name, value)
{
    if (typeof this.marker != "object")
    {
        this.marker = {};
    }

    this.marker[name] = value;
}

pageHandler.getMarkerParameter = function(name)
{
    if (typeof this.marker == "object")
    {
        return this.marker[name];
    }

    return null;
}

/**
 * Accessibility stuff
 */

function accessiblePopup(elt, width, height)
{
    if (!width)
    {
        width = screen.width;
    }

    if (!height)
    {
        height = screen.height;
    }

    var left = Math.floor((screen.width - width) / 2);
    var top = Math.floor((screen.height - height) / 2);
    var popupWindow = window.open(
        elt.getAttribute('href'),
        "popup",
        "top=" + top + ", left=" + left + ", width=" + width + ", height=" + height + ", menubar=yes, toolbar=yes, resizable=yes, scrollbars=yes"
    );

    popupWindow.focus();

    return false;
}

function accessiblePrint(elt)
{
    if (window.print)
    {
        window.print();
    }
    else if (elt)
    {
        window.location.href = elt.getAttribute('href');
    }

    if (elt)
    {
        return false;
    }
}

function accessibleAddToFavorite(elt)
{
    if (window.sidebar && window.sidebar.addPanel)
    {
        window.sidebar.addPanel(document.title, document.location.href, '');
    }
    else if (document.all && window.external)
    {
        window.external.AddFavorite(document.location.href, document.title);
    }
    else if (elt)
    {
        window.location.href = elt.getAttribute('href');
    }

    if (elt)
    {
        return false;
    }
}


/**
 * @author intbonjf 2007-05-29
 * Use this function to register a function to be executed when the page has
 * loaded.
 * This works on most of the recent JavaScript-enabled browsers, from Firefox2
 * to... IE5 for Mac :)
 */
function addLoadListener(func)
{
	if (window.addEventListener)
	{
	  window.addEventListener("load", func, false);
	}
	else if (document.addEventListener)
	{
	  document.addEventListener("load", func, false);
	}
	else if (window.attachEvent)
	{
	  window.attachEvent("onload", func);
	}
	else if (typeof window.onload != "function")
	{
	  window.onload = func;
	}
	else
	{
	  var oldonload = window.onload;
	  window.onload = function() {
	     oldonload();
	     func();
	  };
	}
}





startList = function()
{
	if(document.getElementById)
	{
		navRoot = document.getElementById("nav");
		for(i=0; i<navRoot.childNodes.length; i++)
		{
			node = navRoot.childNodes[i];
			if(node.nodeName=="LI")
			{
				node.style.zIndex = 100000-i;
				for(j=0; j<node.childNodes.length; j++)
				{
					if(node.childNodes[j].nodeName=="UL")
					{
						node.childNodes[j].className = "hidden";
					}
				}
				node.onmouseover=function()
				{
					if(this.className == "" || this.className == null || this.className == "undefined" )
					{
						this.className+="over";
					}
					else
					{
						this.className+=" over";
					}
				}
				node.onmouseout=function()
				{
					this.className=this.className.replace("over", "");
				}
			}
		}
	}
}
window.onload=startList;


$(document).ready(function() 
	{
		$(".toggle-display").click(function () 
	    {
	      $(this).parents("li.toggle-theme").find("div.theme-description").slideToggle("slow");
	      $(this).parents("li.toggle-theme").find(".toggle-pic").toggle();
	      
	    });
	}
);
