menu = function()
{
	var divs = document.getElementById("nav").getElementsByTagName("div");
	for (var i=0; i<divs.length; i++) {
		divs[i].onmouseover = function()
        {
            this.className = "selected";
		}
		divs[i].onmouseout = function()
        {
            this.className = "";
		}
	}
}

if (window.attachEvent) {
    window.attachEvent("onload", menu);
}
if (window.addEventListener) {
    window.addEventListener("load", menu, false);
}


/**
 * Sets and clears a default message from a textfield
 */

toggleMessage = function()
{
    elm = document.getElementById('keyword');
    elm.onfocus = function()
    {
        toggleTextfieldMessage('clear', this, 'Search by Keyword');
    }
    elm.onblur = function()
    {
        toggleTextfieldMessage('set', this, 'Search by Keyword');
    }
}

function toggleTextfieldMessage(action, field, message)
{
   if (action == 'set') {
       if (field.value == '') {
           field.value = message;
       }
   } else if (action == 'clear') {
       if (field.value == message) {
           field.value = '';
       }
   }
}

if (window.attachEvent) {
    window.attachEvent("onload", toggleMessage);
}
if (window.addEventListener) {
    window.addEventListener("load", toggleMessage, false);
}


/**
 * Set rollover for search button
 */

setSearchButton = function()
{
    elm = document.getElementById('search-button');
    elm.onmouseover = function()
    {
        this.style.backgroundPosition = "center top";
    }
    elm.onmouseout = function()
    {
        this.style.backgroundPosition = "center bottom";
    }
}

if (window.attachEvent) {
    window.attachEvent("onload", setSearchButton);
}
if (window.addEventListener) {
    window.addEventListener("load", setSearchButton, false);
}


/**
 * Activate print button
 */

setPrintButton = function()
{
    elm = document.getElementById('print');
    
    if(elm != null)
    {
    elm.onclick = function()
    {
        window.print();
    }
    }
}

if (window.attachEvent) {
    window.attachEvent("onload", setPrintButton);
}
if (window.addEventListener) {
    window.addEventListener("load", setPrintButton, false);
}

function toggleElement(elementName)
{
	var element = document.getElementById(elementName);
	element.style.display=((element.style.display=='none')?'block':'none');
}