var numSearchClicks = 0;

function validateSearch() {
   
  // return false;
   if(document.getElementById("searchField").value.length == 0) {
       
    return false;
   } 
}

function selectText() {
    numSearchClicks++
    if(numSearchClicks < 2)  
        document.getElementById("searchField").select();  
}

/*Suckerfish Dropdowns (IE hover hack)
====================================================================*/

sfHover = function() {
	var sfEls = document.getElementById("nav").getElementsByTagName("LI");
	for (var i=0; i<sfEls.length; i++) {
		sfEls[i].onmouseover=function() {
			this.className+=" sfhover";
		}
		sfEls[i].onmouseout=function() {
			this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
		}
	}
}
if (window.attachEvent) window.attachEvent("onload", sfHover);


/* 
Simple JQuery menu.
Copyright 2008 by Marco van Hylckama Vlieg

Notes: 

1: each menu MUST have an ID set. It doesn't matter what this ID is as long as it's there.
2: each menu MUST have a class 'menu' set. If the menu doesn't have this, the JS won't make it dynamic

Optional extra classnames:

noaccordion : no accordion functionality
collapsible : menu works like an accordion but can be fully collapsed
expandfirst : first menu item expanded at page load

web: http://www.i-marco.nl/weblog/
email: marco@i-marco.nl

Free for non-commercial use
*/
//function initMenus() {
	//$('ul.menu ul').hide();
	
/*
	$.each($('ul.menu li ul li a'), function(){
		var cookie = $.cookie(this.id);
		if(cookie === null || String(cookie).length < 1) {
			$('#' + this.id + '.expandfirst ul:first').show();
		}
		else {			
			$('#' + this.id + ' .' + cookie).next().show();
		}
	});


// SH: get URL, add 'active' class to menu item matching URL

*/
function initMenus() {
	var thisDoc =  document.location.href;
    $('ul.menu ul').hide();
	$("ul:has(li a.active)").show();
    
  // $('ul.menu ul').hide();      
// end SH

	$('ul.menu li a').click(
		function() {
			var checkElement = $(this).next();
			var parent = this.parentNode.parentNode.id;

			if($('#' + parent).hasClass('noaccordion')) {
				$(this).next().slideToggle('normal');
				return false;
			}
			if((checkElement.is('ul')) && (checkElement.is(':visible'))) {
				if($('#' + parent).hasClass('collapsible')) {
					$('#' + parent + ' ul:visible').slideUp('normal');
				}
				return false;
			}
			if((checkElement.is('ul')) && (!checkElement.is(':visible'))) {
				$('#' + parent + ' ul:visible').slideUp('normal');
				checkElement.slideDown('normal');
				return false;
			}
		}
	);
}
$(document).ready(function() {initMenus();});

