// JavaScript Document
/*******

	***	Anchor Slider by Cedric Dugas   ***
	*** Http://www.position-absolute.com ***
	
	Never have an anchor jumping your content, slide it.

	Don't forget to put an id to your anchor !
	You can use and modify this script for any project you want, but please leave this comment as credit.
	
*****/
		


$(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;
		})
	})
}

/*
    Based on this article:      
    http://www.html-advisor.com/javascript/hide-email-with-javascript-jquery/

    Example markup:
    ---------------
    
    <span class="mailme" title="Send me a letter!">me at mydomain dot com</span>

    Example code:
	-------------
	
	// Replaces all the matching elements with a <a href="mailto:..> tag.
		
	$('span.mailme').mailme();
    
*/
    
jQuery.fn.mailme = function() {
    var at = / at /;
    var dot = / dot /g;
    this.each( function() {
        var addr = jQuery(this).text().replace(at,"@").replace(dot,".");
        var title = jQuery(this).attr('title')
        $(this)
            .after('<a href="mailto:'+addr+'" title="'+title+'">'+ addr +'</a>')
            .remove();
    });
};

 $(document).ready(function() { /* Initialize Scrollable "Coda Slider" */
	    $("div.scrollable").scrollable({size:1});
            $('span.mailme').mailme();/* Set up the mailer */
            $(".nav ul li a.first").addClass("active").show(); // Activate first tab
            $(".nav ul li a").click(function() {
            	$(".nav ul li a").removeClass("active"); // Remove any "active" class
                $(this).addClass("active"); // Add "active" class to selected tab
            });
            $(".bottom .introLink").click(function() {
                $(".nav ul li a").removeClass("active");
                $(".nav ul li a#anchor2").addClass("active");
            });
	    $("#verbiage .contactLink").click(function() {
		$(".nav ul li a").removeClass("active");
		$(".nav ul li a#anchor6").addClass("active");
	    });
});
