﻿$(document).ready( function(){


    //Hover for navigation menu items
	$('.nav li').hover(

	  function(){
	      $(this).addClass ("active");
		  
	             },
	  
	  function(){
	  
			$(this).removeClass("active");
	            }
	
	                   );  
					   

	                   
		
		SlideshowInit();
     

           
 
}); 

function onAfter() {
}

var SlideshowInit = function(){
            //Slideshow Init
            var bc = $('#buttonContainer'); 
            var WIDTH = 650;
			var HEIGHT = 700;
            var $container = $('#container').cycle({ 
                fx:     'scrollHorz', 
                speed:   300, 
                timeout: 0 ,
				width: 650,
				containerResize: 1,
				height: HEIGHT,
                after: onAfter                                   }); 
				
				
             
            $container.children().each(function(i) { 

		
            // create list item for the show
            $('<li class="sitem' + i + '">' + $(this).find('p').html() + '</li>') 
           
            
                
            // append it to button container 
            .appendTo(bc) 
            // bind click handler 
            .click(function() { 
				bc.children().each( function(){$(this).removeClass('active');});
				$(this).addClass('active');
                // cycle to the corresponding slide 
                $container.cycle(i); 
                $container.cycle('pause');
                return false; 
                                   }); 
            
              }); 
				
				
            $('#container').cycle({
                fx: 'scrollHorz' // choose your transition type, ex: fade, scrollUp, shuffle, etc...
                }); 
                
				
				
		 // The Teaser function below will place any characters outside the teaser length into a "Read More" container.
		 $('.description').each(

					function(){
					
						TEASER_LENGTH = 400;
						copy = $(this).html();
						if(copy.length>=TEASER_LENGTH)
						{						
							teaserbreak = copy.indexOf('.',TEASER_LENGTH) +1;
							teaser = copy.substr('0',teaserbreak);
	
							
							teaser += "<a class='seemore' href='#'> Read More </a><span class='more'>";
							 
							more = copy.substr(teaserbreak);
							teaser += more +"</span>";
							$(this).html(teaser);
							$(this).find('.more').hide();
							$(this).find('.seemore').click(
							
								function(){
								$container.cycle('pause');
								$(this).next('.more').show();
								$(this).hide();
							}
							)
						
						}
					}
				)
             
            
};
