
/*
 * truncatable 1.2 - jQuery lightwieght text truncation plugin
 *
 * Copyright (c) 2009 Philip Beel (http://www.theodin.co.uk/)
 * Dual licensed under the MIT (http://www.opensource.org/licenses/mit-license.php) 
 * and GPL (http://www.opensource.org/licenses/gpl-license.php) licenses.
 *
 * Revision: $Id: jquery.truncatable.js 2009-08-20 $
 * $('.text').truncatable({	limit: 200, more: '.....', less: true, hideText: '[hide]' }); 
 */

(function($){$.fn.truncatable=function(options){var defaults={limit:100,more:'...',less:false,hideText:'[read less]'};var options=$.extend(defaults,options);return this.each(function(num){var stringLength=$(this).html().length;if(stringLength>defaults.limit){var splitText=$(this).html().substr(defaults.limit);var splitPoint=splitText.substr(0,1);var whiteSpace=new RegExp(/^\s+$/);for(var newLimit=defaults.limit;newLimit<stringLength;newLimit++){var newSplitText=$(this).html().substr(0,newLimit);var newHiddenText=$(this).html().substr(newLimit);var newSplitPoint=newSplitText.slice(-1);if(whiteSpace.test(newSplitPoint)){var hiddenText='<span class="hiddenText_'+num+'" style="display:none">'+newHiddenText+'</span>';var setNewLimit=(newLimit-1);var trunkLink=$('<a>').attr('class','more_'+num+'');$(this).html($(this).html().substr(0,setNewLimit)).append('<a class="more_'+num+'" href="#">'+defaults.more+'<a/> '+hiddenText);$('a.more_'+num).bind('click',function(){$('span.hiddenText_'+num).show();$('a.more_'+num).hide();if(defaults.less==true){$('span.hiddenText_'+num).append('<a class="hide_'+num+'" href="" title="'+defaults.hideText+'">'+defaults.hideText+'</a>');$('a.hide_'+num).bind('click',function(){$('.hiddenText_'+num).hide();$('.more_'+num).show();$('.hide_'+num).empty();return false})}});newLimit=stringLength}}}})}})(jQuery);




$(document).ready(function(){			 	 

		$("#home-button2").mouseover(function(event){
			$("#home-button2 a:first").addClass("menu-open");
  });  // keep hover state on if sub-menu is open
		
		$("#home-button2").mouseout(function(event){
			$("#home-button2 a:first").removeClass("menu-open");
  });  // remove hover state
		
		$("#home-button2").mouseover(function(event){
			$("#home-button2 ul").css('display', 'block');
  });  // fix for ie6 submenu bug
				
		$("#home-button2").mouseout(function(event){
			$("#home-button2 ul").css('display', 'none');
  }); // fix for ie6 submenu bug 	
		
		
		$("#home-button1").mouseover(function(event){
			$("#home-button1 a:first").addClass("menu-open");
  });  // keep hover state on if sub-menu is open
		
		$("#home-button1").mouseout(function(event){
			$("#home-button1 a:first").removeClass("menu-open");
  });  // remove hover state
		
		$("#home-button1").mouseover(function(event){
			$("#home-button1 ul").css('display', 'block');
  });  // fix for ie6 submenu bug
				
		$("#home-button1").mouseout(function(event){
			$("#home-button1 ul").css('display', 'none');
  }); // fix for ie6 submenu bug 	
		
	
		$("#home-button4").mouseover(function(event){
			$("#home-button4 a:first").addClass("menu-open");
  });  // keep hover state on if sub-menu is open
		
		$("#home-button4").mouseout(function(event){
			$("#home-button4 a:first").removeClass("menu-open");
  });  // remove hover state
		
		$("#home-button4").mouseover(function(event){
			$("#home-button4 ul").css('display', 'block');
  });  // fix for ie6 submenu bug
				
		$("#home-button4").mouseout(function(event){
			$("#home-button4 ul").css('display', 'none');
  }); // fix for ie6 submenu bug 
		
		
		
		
		$("#nav-home h2").click(function(){
			window.location = 'http://www.yourdomain.com'
		})
		

		// kill e-newsletter right column if on e-newsletter page
		if (document.location.href.indexOf("e-newsletter") != -1){					
					$("#inner-content-subscribe").hide();
					
		}
		

		// kill featured on featured
		if (document.location.href.indexOf("feature-products") != -1){					
					$("#inner-content-feature").hide();
					
		}
		
		if (document.location.href.indexOf("CustomContentRetrieve.aspx") != -1){					
					$("#inner-content-feature").hide();
					
		}
		
		
		// kill lenders block on lenders page
		if (document.location.href.indexOf("our-lenders") != -1){					
					$("#inner-content-lenders").hide();
					
		}
		
		
		// kill testimonial feature on testimonial page
		if (document.location.href.indexOf("testimonials") != -1){					
					$("#inner-content-testimonial").hide();
					
		}
		
		
		
// kill finance sub menus		
		// kill all finance sub menus except Vehicle on Vehicle page
		if (document.location.href.indexOf("vehicle-car-finance") != -1){					
					$("#finance-submenu-technology, #finance-submenu-plant, #finance-submenu-business, #finance-submenu-home").hide();
					
		}
		// kill all finance sub menus except Technology on Technology page
		if (document.location.href.indexOf("technology-loans") != -1){					
					$("#finance-submenu-vehicle, #finance-submenu-plant, #finance-submenu-business, #finance-submenu-home").hide();
					
		}
		// kill all finance sub menus except Plant on Plant page
		if (document.location.href.indexOf("plant-and-equipment") != -1){					
					$("#finance-submenu-vehicle, #finance-submenu-technology, #finance-submenu-business, #finance-submenu-home").hide();
					
		}
		// kill all finance sub menus except Businss on Business page
		if (document.location.href.indexOf("business-finance-solutions") != -1){					
					$("#finance-submenu-vehicle, #finance-submenu-technology, #finance-submenu-plant, #finance-submenu-home").hide();
					
		}
		// kill all finance sub menus except Home on Home page
		if (document.location.href.indexOf("home-loans") != -1){					
					$("#finance-submenu-vehicle, #finance-submenu-technology, #finance-submenu-plant, #finance-submenu-business").hide();
					
		}
		
		
		
		
		
		// kill more link in featured right col
		$("#inner-content-feature .more").hide();
		
		// latest blog post 1
		
		$(".blog-post:nth-child(1)").each(function(){
		
			var $postTitle = $(this).find(".entry h3").text();
			var $postLink = $(this).find(".entry").find("a").attr("href");
			var $postBody = $(this).find(".entry .postAction").text();
			//var $postBody = $postBody.substr(0,190);
			
				
		
			$postHtml = "<h3><a href='"+ $postLink + "'>" + $postTitle + "</a></h3><p><span class='postText'>" + $postBody + "</span>... <a href='"+ $postLink +"' class='more'>more</a></p>";
	
	
			$(".latestBlogEntry").html($postHtml);
			
			$(".postText").truncatable({	limit: 70, more: '' }); 
		
		
		});
		
		// latest blog post 2
		
		$(".blog-post:nth-child(2)").each(function(){
		
			var $postTitle = $(this).find(".entry h3").text();
			var $postLink = $(this).find(".entry").find("a").attr("href");
			var $postBody = $(this).find(".entry .postAction").text();
			//var $postBody = $postBody.substr(0,190);
			
				
		
			$postHtml = "<h3><a href='"+ $postLink + "'>" + $postTitle + "</a></h3><p><span class='postText'>" + $postBody + "</span>... <a href='"+ $postLink +"' class='more'>more</a></p>";
	
	
			$(".latestBlogEntry2").html($postHtml);
			
			$(".postText").truncatable({	limit: 70, more: '' }); 
		
		
		});
		
		
	
});
				
		
			
		
	
