jQuery.fn.imageLoad = function(src){ 
    var img = new Image();
    img.src = src;
	//jQuery(this).attr({"style":"cursor:wait"});
	img.onload = this.fadeIn(300); this.html(img); 
};

jQuery.fn.captionLoad = function(caption){
	/*
	 jQuery(this).parent().stop().animate({opacity:"0"},300, function(){
	 jQuery(this).parent().stop().animate({opacity:"1"},300, function(){
	 jQuery(this).find("span").html(caption);
	 });
	 });*/
	jQuery(this).html(caption).typewriter(25);
};

jQuery.fn.typewriter = function(speed) { 
        return this.each(function(){ 
                var elem = jQuery(this); 
                var contents = elem.html(); 
                var count = 1; 
                if(contents.length){ 
                        elem.html(""); 
                        var interval = setInterval(addText, speed); 
                } 
                function addText(){ 
                        elem.html(contents.substr(0, count)); 
                        count++; 
                        if(count > contents.length){ 
                                clearInterval(interval); 
                        } 
                } 
        }); 
}; 


jQuery(document).ready(function(){

		jQuery("a.thumbgallery").click(function(){
			var href = jQuery(this).attr("href");
			var caption = jQuery(this).attr("title");
			
			jQuery("div.gallery-full-image").imageLoad(href);
			jQuery("span.gallery-caption-text").captionLoad(caption);
			//jQuery("span.gallery-caption-text").html(caption);
			
			return false;
		});
		
});