//Clear fields
function clearText(field){

    if (field.defaultValue == field.value) field.value = '';
    else if (field.value == '') field.value = field.defaultValue;

}
// Rollovers
function createRollovers() {
    var onText = "-on",
        offText = "-off";
 
    $('img.rollover' ).each( function() {

        var onImg = $(this).attr('src').replace(offText,onText),
            offImg = $(this).attr('src').replace(onText,offText);
        
        $(this).bind('mouseenter', function () {
            $(this).attr('src', onImg );
        });
        $(this).bind('mouseleave', function () {
            $(this).attr('src', offImg );
        });
    });
 
    return;
}

$(document).ready(function () {
    createRollovers();
});


// show/hide subnavs
	var timeout = 500;
	var closetimer = 0;
	var navitem = 0;

	function nav_open(){
		nav_canceltimer();
		nav_close();
		show_sub();
		navitem = $(this).find('ul').css('visibility', 'visible');
	}

	function nav_close(){
		if(navitem) navitem.css('visibility', 'hidden');
	}

	function nav_timer(){
		closetimer = window.setTimeout(hide_sub, timeout);
	}

	function nav_canceltimer(){
		if(closetimer){
			window.clearTimeout(closetimer);
		        closetimer = null;
	}}
	
	function hide_sub(){
	$("#aboutSubnav,#practiceSubnav,#newsSubnav,#officeSubnav").fadeOut(300);
	}
	
	function show_sub(){
	$("#aboutSubnav,#practiceSubnav,#newsSubnav,#officeSubnav").fadeIn(1000);
	
	}


	$(document).ready(function(){
		$('#nav > li').bind('mouseover', nav_open)
		$('#nav > li').bind('mouseout',  nav_timer)
	});
	
// function to get URL parameters
function getParameterByName(name)
{
  name = name.replace(/[\[]/, "\\\[").replace(/[\]]/, "\\\]");
  var regexS = "[\\?&]" + name + "=([^&#]*)";
  var regex = new RegExp(regexS);
  var results = regex.exec(window.location.href);
  if(results == null)
    return "";
  else
    return decodeURIComponent(results[1].replace(/\+/g, " "));
}

function loadSearch(param) {
	if (getParameterByName(param) != '') {
		document.search.keywords.value = getParameterByName(param);
	}
}


