// This script shows the tooltip for the twitter icon
ShowTooltip = function(e)
{
	var text = $(this).next('.show-tooltip-text');
	if (text.attr('class') != 'show-tooltip-text')
		return false;

	text.fadeIn()
		.css('top', -5) // Specific to the layout
		.css('left', 500); // Specific to the layout

	return false;
}
HideTooltip = function(e)
{
	var text = $(this).next('.show-tooltip-text');
	if (text.attr('class') != 'show-tooltip-text')
		return false;

	text.fadeOut();
}

SetupTooltips = function()
{
	$('.show-tooltip')
		.each(function(){
			$(this)
				.after($('<span/>')
					.attr('class', 'show-tooltip-text')
					.html($(this).attr('title')))
				.attr('title', '');
		})
		.hover(ShowTooltip, HideTooltip);
}

$(document).ready(function() {
	SetupTooltips();
});

// Anchor Slider
$(document).ready(function() {
	$("a.anchorLink").anchorAnimate()
});

jQuery.fn.anchorAnimate = function(settings) {

 	settings = jQuery.extend({
		speed : 1100
	}, settings);	
	
	return this.each(function(){
		var caller = this
		$(caller).click(function (event) {	
			event.preventDefault()
			var locationHref = window.location.href
			var elementClick = $(caller).attr("href")
			
			var destination = $(elementClick).offset().top;
			$("html:not(:animated),body:not(:animated)").animate({ scrollTop: destination}, settings.speed, function() {
				window.location.hash = elementClick
			});
		  	return false;
		})
	})
}


// Color box launch script
$(document).ready(function(){
	    //Examples of how to assign the ColorBox event to elements
	    $("a[rel='example1']").colorbox();
	    $("a[rel='example2']").colorbox({transition:"fade"});
	    $("a[rel='example3']").colorbox({transition:"none", width:"75%", height:"75%"});
	    $("a[rel='example4']").colorbox({slideshow:true});
	    $(".single").colorbox({}, function(){
		    alert('Howdy, this is an example callback.');
	    });
	    $(".colorbox").colorbox();
	    $(".youtube").colorbox({iframe:true, width:650, height:550});
	    $(".iframe").colorbox({width:"450px", height:"570px", iframe:true});
	    $(".inline").colorbox({width:"50%", inline:true, href:"#inline_example1"});
	    
	    //Example of preserving a JavaScript event for inline calls.
	    $("#click").click(function(){ 
		    $('#click').css({"background-color":"#f00", "color":"#fff", "cursor":"inherit"}).text("Open this window again and this message will still be here.");
		    return false;
	    });
    });