   
	// CND In Field Labeler
	//////////////////////////////////////////////////////////////////////////////////////
	
   $(document).ready(function() {
   
       $("input[data-label]").each(function(i,v) {
                                    
           var theInput = $(this).attr("data-label");  // Default search input text
           $(this).val(theInput);
        
           // When search input is focused, clear default value
           $(this).focus(function() {
            
               if($(this).val() == theInput) {
                
                   theInput = $(this).val();
                   $(this).val("");
                
               }
            
           });
            
           // When search input is unfocused and blank, return to default state
           $(this).focusout(function() {
            
               if($(this).val() == "") {
                   $(this).val(theInput);
               }
            
           });
        
                                
       });
   
	// CND Image Slider
	//////////////////////////////////////////////////////////////////////////////////////
			
		var cndSlider = $("#bannerImages"), // DIV that contains slider Images
        info = $("#bannerInfo"),
		delay = 9000, // Delay between automatic advancement
		cndCnt = 0, // Initialize Counter
		cndVisible = 0, // Default visible image (index)
		interval = null,
		changing = false;
		  
		  
		function onChange() {
		
         var title = $("a img", cndSlider).eq(cndVisible).attr("alt"),
           caption = $("a img", cndSlider).eq(cndVisible).attr("data-text");
           
           $("h3", info).html(title);
           $("p", info).html(caption);
			
		}    
								  
 
			  
		function nextPic() {

			changing = true;
				  
            // Hide current image before advancing  
				$("a", cndSlider).eq(cndVisible).fadeOut("slow", function() {  
					  
					// If we've reached the end, wrap back to the beginning
		
					if((cndVisible + 1) == cndCnt) { var feq = 0; } else { var feq = (cndVisible + 1); }
				
				  
					// Bring in next image
					$("a", cndSlider).eq(feq).fadeIn("slow", function() {
						  				 	  
						cndVisible = feq; // Set index of new visible image
						onChange(); // Refresh information panel
					  
					}); 
					  
		  
					  
				});
				
		
			                               
										   
		}
		  
			  
		  
		// Count Slider Images
		$("a", cndSlider).each(function(i,v) {
			  
			cndCnt++;
			
			// Show default image
			if(i == cndVisible) {
				$(this).show();
			}
			  
		});
		  
		  

						  
		if(cndCnt > 1) {  // Only setup timer if there are multiple images loaded
			  		  
			interval = setInterval(nextPic, delay); // Set timer
			onChange();  // Initialize information panel
			  
		}
		
		

		 
		// This will stop the slideshow when the window/tab is not focused, 
		// and then it will start again when the window/tab is focused.
		  
		var blurred = false; 
			
		$(window).focus(function(){
		  
			if(blurred) {
				setTimeout(function() { nextPic(); }, delay);
			}
			  
		});
		  
		$(window).blur(function(){
		  
			 blurred = true;
			 clearInterval(interval);
			   
		});
			
		// Superfish Menu
        $('ul.sf-menu').superfish({ 
            delay:       100,
            animation:   {opacity:'show',height:'show'},
            speed:       'fast',
            dropShadows: false,
            autoArrows:  false
        }); 	
	
	});
	



	
	
	

