// JavaScript Document
$(document).ready(function() {
    $(".imgover").imageOver();
    
    var $el = $(),
        linkHeight = parseInt($("p").css("line-height")),
        speed = 175;  //  1000 = 1 second
    
    // Content Link Hover Function
    $(".content a").hover(function() {
        
        $el = $(this);
                
        $el.stop().animate({ backgroundPosition: "(0px 0px)", color: "#333" }, 300);
    
    }, function() {
    
        $el = $(this);
                
        $el.stop().animate({ backgroundPosition: "(0px 100px)", color: "#FFF" }, 300);
    
    });
    
    $("#commentForm").validate();
    
    $("#commentForm").validate({meta: "validate"});
});

$.metadata.setType("attr", "validate");

$.fn.imageOver = function() {
    return this.each(function() {
        var objSrc = $(this).attr("src");
        var ftype = objSrc.substring(objSrc.lastIndexOf("."), objSrc.length);
        var objSrcOver = objSrc.replace(ftype, "-ovr" + ftype);
        // var objSrcActive = objSrc.replace(ftype, "-active" + ftype);

        //        $(this).parent().append('<img src=\"'+objSrcOver+'\ class=' + 'hide' + ' />');
        //        $(this).parent().append('<img src=\"'+objSrcActive+'\ class=' + 'hide' + ' />');

        $(this).hover(function() {
            $(this).attr("src", objSrcOver);
        }, function() {
            $(this).attr("src", objSrc);
        });
    });
}; 

//Slideshow
$(function(){
	$('#slides').slides({
		preload: true,
		preloadImage: 'img/loading.gif',
		play: 5000,
		pause: 2500,
		hoverPause: true,
		animationStart: function(){
			$('.caption').animate({
				bottom:-35
			},100);
		},
		animationComplete: function(current){
			$('.caption').animate({
				bottom:0
			},200);
			if (window.console && console.log) {
				// example return of current slide number
				console.log(current);
			};
		}
	});
});

Cufon('.content h1')('.content h2')('.content h3')('.content h4')('.content h5')('#footer h1')('#footer h2')('#footer h3')('.pagination');
