
$.fn.preload = function() {
    this.each(function(){
        $('<img/>')[0].src = this;
    });
};


$(document).ready(function() {

    // Declare the array variable
    var imgSwap = [];
    
    // Select all images used in the image swap function - in our case class "img-swap"
    $(".img-swap").each(function(){
    
        // Loop through all images which are used in our image swap function
        // Get the file name of the active images to be loaded by replacing _off with _on
        imgUrl = this.src.replace("-off","-on");
        
        // Store the file name in our array
        imgSwap.push(imgUrl);
    });
    
    // Pass the array to our preload function
    $(imgSwap).preload();
    
    
    
	$("#tabs ul a").click(function () {
	
		$("#tabs ul a").toggleClass("off");
		$("#tabs ul a").toggleClass("on");
	
	});
	
    
    // Clears a form input when given focus
    $('.clearme').one("focus", function() {
  		$(this).val("");
	});
    
    

    // Slideshow on homepage
    $('#slideshow').cycle();
    
    
    $('#quotes').cycle();

});



/* Tabs */

$(function() {
	$( "#tabs" ).tabs();
});




