function doClear(theText) {
 if (theText.value == theText.defaultValue) {
	 theText.value = ""
 }
}

jQuery(document).ready(function(){	
	//jQuery("#slider").easySlider();
    
    jQuery("#home_announce #closeMe").click(function () {
      jQuery("#home_announce").fadeOut("slow");
      return false;
    });
    
	jQuery("li#wp-admin-bar-my-account-with-avatar.menupop > a").attr('href','/dashboard/');

/*-----------------------------------------------------------------------------------*/
/* Tide Functions
/*-----------------------------------------------------------------------------------*/
    
   	//tide rollovers
    jQuery("map#tidemap .state").hover(function () {
    	
    	statename = jQuery(this).attr('id');
    	
      	jQuery('#'+statename+'-on').show();
   		 }, function() {
			
		jQuery('#'+statename+'-on').hide();

	});
	
	 jQuery("li.tide-state-main a").hover(function () {
    	
    	state_abbr = jQuery(this).attr('class');
    	
      	jQuery('#'+state_abbr+'-on').show();
   		 }, function() {
			
		jQuery('#'+state_abbr+'-on').hide();

	});
	
	//test for numeric zip code
	
	jQuery('#tides-search form').submit(function()
		{
	
	var zip = jQuery("#tides-search form #zipcode").val();
	var intRegex = /^\d+$/; //test for numeric value
	var isValid = true; 
	
		if(zip=='Zip' || !intRegex.test(zip) || zip.length < 5) {
					jQuery("#tides-search").addClass('form-error');
					isValid = false;
		}
	
		if (isValid == false ) {
			alert('Please enter a valid U.S. zip code.');
			return false;
		}
				
	});
	
	jQuery('#print-tide').click(function()
		{
			
			jQuery('#tideframe').jqprint(); 

	});
	
/*-----------------------------------------------------------------------------------*/
/* Addthis Print Function
/*-----------------------------------------------------------------------------------*/

	jQuery('a.addthis-print').click(function() {

		window.print();

		return false;
				
	});

/*-----------------------------------------------------------------------------------*/
/* Moon Phase Fade-In
/*-----------------------------------------------------------------------------------*/

	jQuery('#stack_nav .moon-click').click(function() {
		jQuery('#new-moon-phase-wrap').fadeToggle('slow');
		
		jQuery.ajax(
			{
			  type: "GET",
			  url: "/ajax/moon-phase-counter.php"
					
			});
		
		return false; //prevents hash from rendering				
	});
	
/*-----------------------------------------------------------------------------------*/
/* Window Resizing
/*-----------------------------------------------------------------------------------*/

//on window load
	  
	  var window_width = jQuery(window).width();
	  
	  //alert(window_width);
	  
	 	 if(window_width < '1040') {			  	
	  	 	jQuery('body, .widen-me').addClass('fixed');
	  	 	//jQuery('body').addClass('fixed');	  		
	  	 } else {
	  	 	jQuery('body, .widen-me').removeClass('fixed');
	  	 	//jQuery('body').removeClass('fixed');
	  	 }
	
	  
//on resize
	  
	  jQuery(window).resize(function() {
			
	  var window_width = jQuery(window).width();
	  
	 	 if(window_width < '1040') {			  	
	  	 	jQuery('.widen-me').addClass('fixed');
	  	 	jQuery('body').addClass('fixed');
	  	 } else {
	  	 	jQuery('.widen-me').removeClass('fixed');
			jQuery('body').removeClass('fixed');
	  	 }
			
			
	  });

/*-----------------------------------------------------------------------------------*/
/* WP Admin Bar
/*-----------------------------------------------------------------------------------*/

	jQuery('#wpadminbar .quicklinks li a.login-click').click(function() {
		jQuery('#wpadminbar .quicklinks li.register').fadeOut('slow');
		jQuery(this).fadeOut('slow', function() {
			jQuery('#wpadminbar .quicklinks li#login-top').fadeIn('slow');
			});
	
	return false;
	});

/*-----------------------------------------------------------------------------------*/
/* Overlay Menu
/*-----------------------------------------------------------------------------------*/

	jQuery('#wp-admin-bar-the_hole').click(function() {
		jQuery('#overlay-menu').toggleClass('show-me');
		
		jQuery.ajax(
			{
			  type: "GET",
			  url: "/ajax/hole-counter.php"
					
			});
		
		return false; //prevents hash from rendering
	});

	//duped this for close without ajax so we don't
	//track "closes" -- only "opens"
	jQuery('#overlay-menu #overlay-close').click(function() {
		jQuery('#overlay-menu').toggleClass('show-me');
		
		return false; //prevents hash from rendering
	});
	  
/*-----------------------------------------------------------------------------------*/
/* Main Navigation Rollover
/*-----------------------------------------------------------------------------------*/

	jQuery('#main-nav-wrap ul li.parent').hover(function () { jQuery(this).children('ul.dropdown').slideDown('fast'); }, function() {
			
		jQuery(this).children('ul.dropdown').slideUp('fast');

	});


	//dropdown effects
	jQuery('ul.dropdown li').hover(function () {
		jQuery(this).children('a').animate({ fontSize: "14px", paddingLeft: "0px" }, 50 );
		jQuery(this).addClass('drop-hover');
	}, function() {
		jQuery(this).children('a').animate({ fontSize: "12px", paddingLeft: "0px" }, 50 );
		jQuery(this).removeClass('drop-hover');
	});



/*-----------------------------------------------------------------------------------*/
/* Next function can go below here
/*-----------------------------------------------------------------------------------*/

}); //end on doc ready





//home page main content slideshow
function slideSwitch() {
    var $active = jQuery('#slideshow div.active');

    if ( $active.length == 0 ) $active = jQuery('#slideshow div:last');

    var $next =  $active.next().length ? $active.next()
        : jQuery('#slideshow div:first');

    $active.addClass('last-active');

    $next.css({opacity: 0.0})
        .addClass('active')
        .animate({opacity: 1.0}, 1000, function() {
            $active.removeClass('active last-active');
        });
}

jQuery(function() {
    setInterval( "slideSwitch()", 6000 );
});


function show(id){
tag = document.getElementsByTagName("div")
   for(x=0; x<tag.length; x++){
      if(tag[x].id.substr(0,2) == 'td'){
         document.getElementById(tag[x].id).style.display = 'none';
      }
   }
   document.getElementById(id).style.display = 'block';
}

