var m_gSearchLabel = "Search";

var isIE7 = (navigator.userAgent.toLowerCase().indexOf("msie 7.0") != -1);
var isSaf = (navigator.userAgent.toLowerCase().indexOf("safari") != -1);
var isMac = (navigator.appVersion.indexOf('Mac') != -1);

function init() {

    var searchElement = document.getElementById("searchBox");
    if( searchElement ) {
        m_gSearchLabel = searchElement.value;
        searchElement.onfocus = function()	{
             this.className+=" focused";
             if(this.value==m_gSearchLabel)	{
                 this.value="";
             }
         }
         searchElement.onblur = function()	{
             this.className=this.className.replace(/\bactive/g, "");
             this.className=this.className.replace(/\bfocused/g, "");
             if(this.value=="")	{
                 this.value=m_gSearchLabel;
             }
         }
         searchElement.onmouseover = function()	{
             this.className+=" active";
         }
         searchElement.onmouseout = function()	{
             this.className=this.className.replace(/\bactive/g, "");
         }
    }
	initNavElements();
}

function initNavElements() {
    if (isSaf || document.all&&document.getElementById) {
        var navElement = document.getElementById("kodeware-mainNav");
        if( navElement ) {
            var nodes = navElement.getElementsByTagName("LI");
            for (var i=0; i<nodes.length; i++) {
                node = nodes[i];
                if (node.nodeName=="LI") {
                    nodes[i].onmouseover= function() {
                        if (!isIE7 && !isSaf) {
                            this.className+=" navHover";
                        } else {
                            var uls = this.getElementsByTagName("UL");
                            if (uls[0] != null){
                                uls[0].style.left = 0;
                                uls[0].style.top = 16;
                            }
                        }
                    }
                    nodes[i].onmouseout=function() {
                        if (!isIE7 && !isSaf) {
                            this.className=this.className.replace(" navHover", "");
                        } else {
                            var uls = this.getElementsByTagName("UL");
                            if (uls[0] != null) uls[0].style.left = "-999em";
                        }
                    }
                }
            }
        }
    }
}

function search() {
	var searchElement = document.getElementById("searchBox");
	window.location = "index.php?pageId=search&query=" + searchElement.value;
}
