	// functions for the search box text replacement	
	function clickclear(thisfield, defaulttext) {
		if (thisfield.value == defaulttext) {
			thisfield.value = "";
			}
		}

	function clickrecall(thisfield, defaulttext) {
		if (thisfield.value == "") {
			thisfield.value = defaulttext;
		}
	}
	
	$(document).ready(function() {
		$('#search-submit').click(function() {
			document.searchform.submit();
		});
		
		$('#click-show').click(function() {
			$('div#links').toggle();
		});		
		
		// code for new slideshow.
		$('div#featured-spots').cycle({ 
		    fx: 'fade',
			timeout: 5000,
			speed: 800,
		    pause: 1,
		 	next: '#next',
		    prev: '#prev'
		});
		
		// code for the banner image step through system
		$('div#featured-spots').hover(
		      function () {
		       $('#slideshow-controls').slideDown();
		      }, 
		      function () {
				$('#slideshow-controls').hide();
		 });
		
		$('div#slideshow-controls').hover(
			function() {
				$(this).show();
				$('div#featured-spots').cycle('pause');
			},
			function() {
				$(this).slideUp();
				$('div#featured-spots').cycle('resume');
			});
			
		$('#prev').click(function() {
				$('#description').fadeIn( 'slow' );
				$('#description').fadeOut( 'slow' );
		});
		
		$('#next').click(function() {
				$('#description').fadeIn( 'slow' );
				$('#description').fadeOut( 'slow' );
		});
		
		// code to add captions to images in press releases/features
		$( 'div.news-section p img' ).each( function() {
			var alt= $(this).attr('alt');
			var stat= $(this).attr('class');
			if( alt != null && stat != 'rendered' ) {
				var width= $(this).width();
				var box_width= width + 10;
				var side= '';
					if( $(this).attr('class') == 'float-left' ) {
						side= 'float:left; padding-right: 15px; width:' + box_width + 'px';
					} 
					
					if( $(this).attr('class') == 'float-right' ) {
						side= 'float:right; padding-left: 15px; width:' + box_width + 'px';
					}
				$(this).wrap('<div class="caption" style="' + side + '"></div>').after( $( '<p style="width:' + width + 'px;">' + $(this).attr('alt') +  '</p>' ) );
				$(this).addClass('rendered');
			}
		});
	});
