$(document).ready(function() {
    $(".home-actions-business, .home-actions-agencies").mouseenter(function() {
        $(this).css("backgroundPosition", "0px -57px");
    }).mousedown(function() {
        $(this).css("backgroundPosition", "0px -114px");
    }).mouseup(function() {
        $(this).css("backgroundPosition", "0px 0px");
    }).mouseleave(function() {
        $(this).css("backgroundPosition", "0px 0px");
    });

    $("#home-seo-analyzer .get-results").mouseenter(function() {
        if (!$(this).hasClass('processing')) $(this).css("backgroundPosition", "0px -31px");
    }).mousedown(function() {
        if (!$(this).hasClass('processing')) $(this).css("backgroundPosition", "0px -62px");
    }).mouseup(function() {
        if (!$(this).hasClass('processing')) $(this).css("backgroundPosition", "0px 0px");
    }).mouseleave(function() {
        if (!$(this).hasClass('processing')) $(this).css("backgroundPosition", "0px 0px");
    });

    $("#home-seo-analyzer input[name='url']").focus(function() {
        if ($(this).val() == 'yourdomain.com') {
            $(this).val('');
        }
    }).blur(function() {
        if ($(this).val() == '') {
            $(this).val('yourdomain.com');
        }
    });

    $("#home-seo-analyzer input[name='email']").focus(function() {
        if ($(this).val() == 'your@emailaddress.com') {
            $(this).val('');
        }
    }).blur(function() {
        if ($(this).val() == '') {
            $(this).val('your@emailaddress.com');
        }
    });

    $("form#seoanalyzer").submit(function() {
        email = $("#home-seo-analyzer input[name='email']");
        url = $("#home-seo-analyzer input[name='url']");
        if (url.val() != '' && url.val() != 'yourdomain.com' && email.val() != '' && email.val() != 'your@emailaddress.com' && validEmail(email.val()) && filterURL(url.val())) {
            $("#home-seo-analyzer button[name='submit']").removeClass('get-results').addClass('processing').css("backgroundPosition", "0px -93px");
            return true;
        } else {
            if (email.val() == '' || email.val() == 'your@emailaddress.com' || !validEmail(email.val())) {
                $("#home-seo-analyzer input[name='email']").trigger("formError");
            }
            if (url.val() == '' || url.val() == 'yourdomain.com' || (filterURL(url.val()) == null)) {
                $("#home-seo-analyzer input[name='url']").trigger("formError");
            }
            return false;
        }
    });

    $("#home-seo-analyzer input[name='email']").qtip({
        position: {
            corner: {
                target: 'topMiddle',
                tooltip: 'bottomMiddle'
            }
        },
        style: {
            name: 'red',
            tip: {
                corner: 'bottomMiddle',
                size: {
                    x: 15,
                    y: 10
                }
            }
        },
        content: 'Please enter your email address',
        show: {
            when: {
                event: 'formError'
            }
        }
    });

    $("#home-seo-analyzer input[name='url']").qtip({
        position: {
            corner: {
                target: 'topMiddle',
                tooltip: 'bottomMiddle'
            }
        },
        style: {
            name: 'red',
            tip: {
                corner: 'bottomMiddle',
                size: {
                    x: 15,
                    y: 10
                }
            }
        },
        content: 'Please enter your URL',
        show: {
            when: {
                event: 'formError'
            }
        }
    });


//    $(".home-screenshot").qtip({
//        position: {
//            corner: {
//                target: 'bottomMiddle',
//                tooltip: 'bottomMiddle'
//            }
//        },
//        style: {
//            width: 308,
//            background: '#000',
//            color: '#fff'
//        },
//        content: "View this module's features"
//    });


    $(".bigquote").scrollable({ size:1, loop: true, clickable: false }).autoscroll({autoplay: true, interval: 5000});;
    
});