// *****************
// * mainmenu
// *****************
Event.observe(window, 'load', function() {
    $$('.dropDownMenu li.topLevel').each(function(listEl) {
        listEl.observe('mouseover', function() {
            this.select('div.subMenu').each(function(el) {
                el.setStyle({ 'display': 'block', 'zIndex': '1001' });
                el.parentNode.setStyle({ 'zIndex': '1000' });
            });

        });

        var hideList = function(e) {
            var elt = $(Event.element(e));
            if (!elt.descendantOf(listEl)) {
                listEl.select('div.subMenu').each(function(el) {
                    el.hide();
                    el.setStyle({ 'zIndex': '999' });
                    el.parentNode.setStyle({ 'zIndex': '998' });
                });
            } else {

            }
        };
        Event.observe(document, 'mouseover', hideList.bind(this));
    });

    $$('.toggleSubcontent').each(function(e) {
        if (e.getAttribute('href') == '#') {
            e.setAttribute('href', 'javascript:void(0);'); // avoid jumping to top of page
        }
        e.observe('click', function() {
            this.up().select('.subcontent').each(function(el) {
                el.toggle();
            });
        });
    });
});

// *****************
// * google search
// *****************
//- ExecuteSearch -//
function ExecuteSearch() {
    var searchInput = document.aspnetForm.ctl00_ctl00_SearchInput;
	var keyword = searchInput.value;
	if ((keyword) && (keyword.length > 0)) {
	    document.location.href = 'http://search.lockton.com/search?q=' + escape(keyword)+'&output=xml_no_dtd&client=default_frontend&proxystylesheet=lockton_website&site=default_collection';
	} else {
	    alert('Please enter a search term');
		searchInput.focus();
    }
    return(false);
}

//- searchFromTextBox -//	
function searchFromTextbox()
{
    key = window.event.keyCode;
    if (key == 13) {
        var searchInput = document.aspnetForm.ctl00_ctl00_SearchInput;
		var keyword = searchInput.value;
		if ((keyword) && (keyword.length > 0)) {
		    document.location.href = 'http://search.lockton.com/search?q=' + escape(keyword)+'&output=xml_no_dtd&client=default_frontend&proxystylesheet=lockton_website&site=default_collection';
	        window.event.returnValue = false;		
		} else {
			alert('Please enter a search term');
			searchInput.focus();
			window.event.returnValue = false;
		}
    }
}

