/* Custom scripts */


	jQuery(document).ready(function($){
		 /* Search Box */
		 var sinput = "Search";
		 $('#searchform input#s').val(sinput);
		 $('#searchform input#s').focus(function() {  
		     if (this.value == sinput){  
		         this.value = '';  
		     }  
		     if(this.value != sinput){  
		         this.select();  
		     }  
		 });  
		 $('#searchform input#s').blur(function() {  
		     if (this.value == ''){  
		         this.value = (sinput ? sinput : '');  
		     }  
		 });
		 
		/* Navigation */
		function addMenu(){ 
			$(this).addClass("hovering");
		}
		
		function removeMenu(){ 
			$(this).removeClass("hovering");
		}

		var config = {    
		     sensitivity: 3,    
		     interval: 100,
		     over: addMenu,
		     timeout: 200,
		     out: removeMenu
		};
		$("li.dd").hoverIntent( config );

		/* Image Preloader */
		var cache = [];
		// Arguments are image paths relative to the current page.
		$.preLoadImages = function() {
			var args_len = arguments.length;
			for (var i = args_len; i--;) {
				var cacheImage = document.createElement('img');
				cacheImage.src = arguments[i];
				cache.push(cacheImage);
			}
		}
		
		/* Weather Feature */
		jQuery("div#wcurr").bind('click', function(event){openWeather();});
		jQuery("div#wcurr-more span.wclose").bind('click', function(event){closeWeather();});
		var configw = {    
		     sensitivity: 3,    
		     interval: 100,
		     over: openWeather,
		     timeout: 800,
		     out: closeWeather
		};
		jQuery("div#wcurr-more").hoverIntent( configw );
		function closeWeather() {
				jQuery("#wcurr-more").animate({top: '-400px'}, {duration: 'slow', easing: 'easeInOutExpo'});
		}
		function openWeather() {
				jQuery("#wcurr-more").animate({top: '0'}, {duration: 'slow', easing: 'easeInOutExpo'});
		}


	});

	/* Basic Slideshow function */
	function slideSwitch() {
	    var $active = jQuery('#featured-photo IMG.active');
	    if ( $active.length == 0 ) $active = jQuery('#featured-photo IMG:last');
	    var $next =  $active.next().length ? $active.next()
	        : jQuery('#featured-photo IMG: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() {
		if (jQuery('#featured-photo').length > 0){
			setInterval( "slideSwitch()", 5000 );
		}
	});
	