// Marks the page as Javascript enabled with a <body> class
document.documentElement.className = 'js';

$(document).ready(function(){

    // Initialize colorbox
    $("a[rel^='lightbox']").colorbox({
        slideshow: true, 
        slideshowAuto: false,
        slideshowSpeed: 5000,        
        transition: "fade",
		inline: "true",
		href: function(){
			return $(this).attr('href');
		}
    });

    // Initialize hover of colorbox links
    $('#indirect-mail a').each(function(){

        var $link = $(this);
        var $strong = $link.find('strong');
        $strong.css({opacity: 0.7});

        $link.hover(            
        function(){
            $strong.stop().animate({paddingLeft: 20, opacity: 1}, {duration: 250});   
        },
        function(){
            $strong.stop().animate({paddingLeft: 5, opacity: 0.7}, {duration: 250});   
        }
        );

    });

    // Hover of share icons
    $('div.addthis_toolbox a').each(function(){

        var $link = $(this);
        var $img = $link.find('img');
        if($img){
        $img.css({opacity: 0.5, visibility: 'visible'});           
        $link.hover(            
            function(){
            $img.stop().fadeTo(250, 1);   
            },
            function(){
            $img.stop().fadeTo(250, 0.5);   
            }
        );
        }

    });
});

/*
 * Validates the captcha 
 */
function validateCaptcha() {

    challengeField = $("#recaptcha_challenge_field").val();
    responseField = $("#recaptcha_response_field").val();
	
    var html = $.ajax({
		type: "POST",
		url: "http://www.fearnotproject.com/lib/ajax.recaptcha.php",
		data: "recaptcha_challenge_field=" + challengeField + "&recaptcha_response_field=" + responseField,
		async: false
    }).responseText;
 
    if(html == "success") {
        $("#captchaStatus").removeClass("error").text(" ");
        return true;
		
    } else  {
		console.log(html);
        $("#captchaStatus").addClass("error").text("Your captcha is incorrect. Please try again");
        Recaptcha.reload();
        return false;
    }
}
