var $j = jQuery.noConflict();
var base = '';
jQuery(document).ready(function(){
	var base = $j('#topNav').html();
	$j('.topNavItemLinkTop').live('mouseenter', function(){
		//first, change the colors
		$j('.topNavItem').css('background-color', $j('#backgroundColor').val());
                $j('.topNavItem').children('a').css('color', $j('#textColor').val());
                $j(this).parents("div.topNavItem").children('a').css('color', $j('#selectedTextColor').val())
		$j(this).parents("div.topNavItem").css('background-color', $j('#selectedBackgroundColor').val())
		
		//next hide all sub nav items
		$j('.topNavSubRow').css('display', 'none');
		//now show the hovered submenu
		var row = "topNavSubRow" + $j(this).attr('submenu');
		$j('#'+row).css('display', 'block');
	});
	$j('#topNav').bind('mouseleave', function(){
		$j('#topNav').html(base);
	});
});

function search(memberGroup){
	var keywordFromPost = $j("#q").val();
	var keyword  = new String(keywordFromPost);
	keyword = keyword.strip().replace("+", "%2B");
	if(keyword.length == 0){
		return true;
	}
	
	//where are we searching?
    var checked = $j("#searchAll").attr('checked');
	var searchUrl = '';
    var all = 0;
	if(checked){
		//global search
		searchUrl = $j("#globalSearchUrl").val();
        all = 1;
	}else{
		//site search
		searchUrl = $j("#siteSearchUrl").val();
	}
    //for now, always have it be the site search as per Halldor 5/26/2011
    searchUrl = searchUrl = $j("#siteSearchUrl").val();
	var action = searchUrl + "&q=" + keyword + "&all=" + all + "&site=" + memberGroup;
	location.href=action;
	return false;
}


