//Turn on the carousel - this is because I want to provide an alternative for people who don't have JS
jQuery(document).ready(function(){
	jQuery("#jsCarousel").show();
});

var theInt = null;
		var $crosslink;
		var curclicked = 0;
		
		theInterval = function(cur){
			clearInterval(theInt);
			
			if( typeof cur != 'undefined' )
				curclicked = cur;
			
			$crosslink.removeClass("active-thumb");
			
			$crosslink.eq(curclicked).addClass("active-thumb");
				jQuery(".stripNav ul li a").eq(curclicked).trigger('click');
			
			theInt = setInterval(function(){
				$crosslink.removeClass("active-thumb");
				$crosslink.eq(curclicked).addClass("active-thumb");
				jQuery(".stripNav ul li a").eq(curclicked).trigger('click');
				
				curclicked++;
				if( 3 == curclicked )
					curclicked = 0;
				
			}, 3500);
		};
		
jQuery(function(){
			
			//Turn on the carousel - this is because I need to provide an alternative for people who don't have JS
			jQuery("#jsCarousel").show();
						
			jQuery("#main-photo-slider").codaSlider();
			
			$crosslink = jQuery(".cross-link");
			
			$crosslink
			.click(function() {
				var $this = jQuery(this);
				theInterval($this.attr('href').slice(1) - 1);
				return false;
			});
			
			theInterval();
		});
		

//Miscellaneous
jQuery(document).ready(function(){
	
	//Even and Odd Striping
	jQuery(".recentcomments li:odd").addClass("odd");
	jQuery(".popularposts li:odd").addClass("odd");
	jQuery(".widget_recent_entries li:odd").addClass("odd");
	
	//Comments allowed tags
	jQuery(".allowedTagsLink").click(function(){
		jQuery('#allowedTags').slideToggle('fast');
	})
	
	//External Links
	jQuery('.external').click(function(){
		window.open(this.href);
        return false;
	})
	
	//Special styling on sidebar titles 
	jQuery('.widget_recent_entries').find('h2').html('<span class="green">latest</span>posts');
	jQuery('.widget_fp_recentcomments').find('h2').html('<span class="green">latest</span>comments');
	jQuery('.widget_rm_popular_posts').find('h2').html('<span class="green">popular</span>posts');
});

/*
 * Tooltip script 
 * powered by jQuery (http://www.jquery.com)
 * 
 * written by Alen Grakalic (http://cssglobe.com)
 * 
 * for more info visit http://cssglobe.com/post/1695/easiest-tooltip-and-image-preview-using-jquery
 *
 */
 


this.tooltip = function(){	
	/* CONFIG */		
		xOffset = 35;
		yOffset = 0;		
		// these 2 variable determine popup's distance from the cursor
		// you might want to adjust to get the right result		
	/* END CONFIG */		
	jQuery(".tooltip").hover(function(e){											  
		this.t = this.title;
		this.title = "";									  
		jQuery("body").append("<div id='tooltip'><small>"+ this.t +"</small></div>");
		jQuery("#tooltip")
			.css("top",(e.pageY - xOffset) + "px")
			.css("left",(e.pageX + yOffset) + "px")
			.fadeIn("fast");		
    },
	function(){
		this.title = this.t;		
		jQuery("#tooltip").remove();
    });	
	jQuery(".tooltip").mousemove(function(e){
		jQuery("#tooltip")
			.css("top",(e.pageY - xOffset) + "px")
			.css("left",(e.pageX + yOffset) + "px");
	});			
};



// starting the script on page load
jQuery(document).ready(function(){
	tooltip();
});
