/*
 * hrefID jQuery extention - returns a valid #hash string from link href attribute in Internet Explorer
 */
(function($){$.fn.extend({hrefId:function(){return $(this).attr('href').substr($(this).attr('href').indexOf('#'));}});})(jQuery);

/*
 * Scripts
 *
 */
jQuery(function($) {
 
	var Engine = {
		utils : {
			links : function(){
				$('a[rel*=external]').click(function(e){
					e.preventDefault();
					window.open($(this).attr('href'));						  
				});
			},
			mails : function(){
				$('a[href^=mailto:]').each(function(){
					var mail = $(this).attr('href').replace('mailto:','');
					var replaced = mail.replace('/at/','@');
					$(this).attr('href','mailto:'+replaced);
					if($(this).text() == mail) {
						$(this).text(replaced);
					}
				});
			}
		},
		
		tweaks : {
			
			homePageRotator : function(){
				if ($('#cycle').length){
						$('#cycle').cycle({
							fx: 'fade', // choose your transition type, ex: fade, scrollUp, shuffle, etc...
							pause: true,
							timeout: 5000
						});
				}
			}, // homePageRotator
			
			listFixes : function(nav){
				$('#nav li a').contents().each(function(){
						$(this).wrap("<span></span>");
				});
				
				$("#nav").show();
				
				//$("#nav ul").attr("id","nav");
			 
			},
			
			latestBlogs : function(){ // for home page truncation of latest blog post text
				$(".blogsitesummary").addClass("list-p");
				
				$(".blogsitesummary li").each(function(){

				var $text = $(this).find("a").text();
				$text = $text.substr(0,30);
				$text = $text + "...";
				
				$(this).find("a").text($text);
				
				});	
			}
			
			
			
		}// tweaks
	};

	Engine.utils.links();
	Engine.utils.mails();
	Engine.tweaks.homePageRotator();
	Engine.tweaks.listFixes();
	Engine.tweaks.latestBlogs();
	
});