
function enterClickHandler(e, buttonId) {
    //alert("HERE");
    var keynum = 0;
    if (window.event) // IE
    {
        keynum = window.event.keyCode;
    }
    else if (e.which) // Netscape/Firefox/Opera
    {
        keynum = e.which;
    }
    if (keynum == 13) {
        var button = document.getElementById(buttonId);
        var result = true;
        if (button.onclick) {
            result = button.onclick();
        }
        if (result) {
            document.location.href = button.href;
        }
        return false;
    }
    return true;
}

/* clears the text value out of  an input field */
 function clearInput(formfield)
 {
  if (formfield.defaultValue==formfield.value)
   formfield.value = ""
 }

 /* search */
 function navigateSearch(searchfield, searchURL, ignoreDefault, page, totalItems) {
     if (!page) page = 1;
     if ((!ignoreDefault && searchfield.defaultValue == searchfield.value) || searchfield.value == '') {
         alert('Please enter a search term');
     }
     else {
         if (searchURL.indexOf("?") < 0) searchURL = searchURL + "?";
         searchURL = searchURL + "&q=" + searchfield.value;
         if (page) searchURL = searchURL + "&page=" + page;
         if (totalItems) searchURL = searchURL + "&totalItems=" + totalItems;
         window.location.href = searchURL;
     }
 }
 
		
 /* Hide/Show Language Box */
 function HideContent(d) {
	if(d.length < 1) { return; }
		document.getElementById(d).style.display = "none";
	}
 function ShowContent(d) {
	if(d.length < 1) { return; }
		document.getElementById(d).style.display = "block";
	}
 function ReverseContentDisplay(d) {
	if(d.length < 1) { return; }
	if(document.getElementById(d).style.display == "none") { document.getElementById(d).style.display = "block"; }
	else { document.getElementById(d).style.display = "none"; }
	}

//TABS
	var tabObjects = new Array();

	function tabObject(tabElement) {
	    this.tabId = tabElement.id;
	    this.tab = $("#" + this.tabId);
	    this.box = $(".navbox_container_" + this.tabId);
	    this.initialized = false;

        //methods
	    this.show = tabObject_show;
	    this.hide = tabObject_hide;
	    this.init = tabObject_init;
	    //this.hover =
	    this.tab.hover(
	        function() {
	            tabObjects[this.id].show();
	        },
            function() {
                //tabObjects[this.id].hide();
            }
	    );

        this.box.hover(
            function() {

            },
            function() {
                closeNavBox();
            }
	    );
	    
        tabObjects[this.tabId] = this;
	}

	function tabObject_init() {

	    if (/MSIE 6/i.test(navigator.userAgent)) {
	        //Put an iframe behind
	        var iframe = document.createElement("iframe");
	        //this.frame = $("#" + this.tabId + "_iframe");
	        this.frame = $(iframe);

	        this.frame.width(this.box.width());
	        this.frame.height(this.box.height());

	        this.frame.attr("border", "0");
	        this.frame.css({ 'position': 'absolute', 'left': this.box.position().left, 'top': this.box.position().top, 'z-index': 1, 'border': 'none' });
	        this.box.css({ 'z-index': 2 });
	        //this.frame.attr("id", this.tabId + "_iframe");
	        this.frame.insertAfter(this.box);
	    }
	}
	
	function tabObject_show() {
	    closeNavBox();
	    this.box.show();
	    if (!this.initialized) {
	        this.init();
	    }
	}

	function tabObject_hide() {
	    if (this.frame) this.frame.hide();
	    this.box.hide();
	}
	
/* closes the Harder Working Nav windows */
    function closeNavBox() {
        $(".main_nav a").each(function() {
            tabObjects[this.id].hide();
        });
    }

    $(document).ready(function() {

        $(document).click(function() {
            closeNavBox();
        });

        //Make all of the tabs
        $(".main_nav a").each(function() {
            new tabObject(this);
        });

        // End Main Nav Rollovers

        //move nav contents to content div
        $("div[class*='navbox_container_top_menu']").each(function() {
            $(this).prependTo($("div[class='content']"));
        });

        //Localization formatting
        $('.date').formatter({ type: 'date' });
        $('.number').formatter({ type: 'number' });
        $('.currency').formatter({ type: 'currency' });
        $('.formatted').formatter();

        //Callback to grab anything with resources class out of the App_GlobalResources/Resources.resx file
        $('.translated-resource').formatter({ handlerUrl: 'LocalizeContent.ashx' });
        //to add more resx files:
        //$('.someother').formatter({ handlerUrl: 'LocalizeContent.ashx?resx=nameoffile not including .resx' });

        // this toggles the leftnav tabs (when applicable)
        $(".leftnav_tabs a").click(function() {
            whichTab = this.id;
            $(".leftnav_tabs a").removeClass("on");
            $(this).addClass("on");
            $(".tabA").hide();
            $(".tabB").hide();
            $('.' + whichTab).show();
        });

        $(".leftnav ul:empty").remove();
        $(".leftnav_dblline ul:empty").remove();
        $(".navbox_col ul>li>ul>placeholder").parent().remove();
        $(".navbox_col li:empty").remove();
    });

function productNavigation(dest) {
    if (dest != '') {
        document.location.href = dest;
    }
}

$(document).ready(function() {

    $('#resourelib_selectall').click(function() {
        $('.resourcelibrary_results_rightcol input').each(function() {
            this.checked = true;
        });
    });

    $('#resourelib_clearall').click(function() {
        $('.resourcelibrary_results_rightcol input').each(function() {
            this.checked = false;
        });
    });


});

//Navigation
$(document).ready(function() {

    //Navigation items (top left menu and left menu) are given a class name of their section
    //For instance, for the following url they are given the class "about"
    //http://www.avocent.de/About/Newsroom/Press_Releases/2009/ACS_Wins_Readers_Choice_Awards.aspx
    var regex = /\/\/.*?\/([A-Z_]+)/gi;
    var matchInfo = regex.exec(document.location.href);
    if (matchInfo && matchInfo.length > 1) {
        var section = matchInfo[1].toLowerCase();
        $("#left-nav").addClass(section);
        //Products left nav
        $("#nav_tab_content_1").addClass(section);
        $("#nav_tab_content_2").addClass(section);
        
        $("#top-left-heading").addClass(section);        
    }

});
