/***************************************************************************
 * @Copyright: CSSJockey - Unique & Practical Web Presence
 * @Website: http://www.cssjockey.com/
 * @Portfolio: http://www.cssjockey.com/portfolio
 * @Contact: http://www.cssjockey.com/get-in-touch
 * @Privacy Policy & Terms of Use: http://www.cssjockey.com/terms-of-use
 ***************************************************************************/
DD_roundies.addRule('.round5, div.top-nav li a', 5, true);
DD_roundies.addRule('.round10, .button-secondary', 10, true);
DD_roundies.addRule('.round15', 10, true);
DD_roundies.addRule('.round20', 20, true);
$(document).ready(function(){
    $('#home-portfolio').cycle({
        fx:     'fade',
        speed:  500,
        timeout: 3000,
        next:   '#home-next',
        prev:   '#home-prev'
    });

    $("#testimonials").cycle({
        fx: 'fade',
        speed: 200,
        timeout: 10000,
        next:   '#tnext',
        prev:   '#tprev'

    })

    $(".cjgallery").cycle({
        fx:     'fade',
        speed:  '500',
        timeout: 2000,
        next:   'a.gnext',
        prev:   'a.gprev'
    });
    $(".gprev").fadeOut(0);
    $(".gnext").fadeOut(0);
    $(".cjgalcontainer").hover(function(){
        $(".gprev").fadeIn(300);
        $(".gnext").fadeIn(300);
    },function(){
        $(".gprev").fadeOut(300);
        $(".gnext").fadeOut(300);
    })

    $('a, .ttip, abbr, .entry img').tooltip({
        track: true,
        delay: 100,
        showURL: false,
        showBody: " # ",
        fade: 250
    });
    $("p.nobg").parent().parent().addClass('nobg');
    $("p.nobg").parent().parent().find('.r10fix-l, .r10fix-r').hide();

    //Trackbacks

    var trackback = $("ol#trackbacks li:last").text();
    if(trackback == "No Trackbacks"){
        $("div.trackbacks").hide();
    }

    //Comments
    $('.error').click(function(){
        $(this).fadeOut(200);
        $(this).parent().find('input').focus();
    })
    $("#author, #email, #comment").blur(function(){
        $('.error').fadeOut(200);
    })
    $("#commentform").submit(function(){
        var author = $("#author");
        var email = $("#email");
        var comment = $("#comment");
        var emailFormat = /^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}$/i;

        if (author.val() == "Your Name" || author.val() == "") {
            $('.author').fadeIn(200);
            author.focus();
            return false;
        }

        if (email.val() == "Your Email" || email.val() == "") {
            $('.email').fadeIn(200);
            email.focus();
            return false;

        }

        if (email.val().search(emailFormat) == -1) {
            alert("Please enter valid email address!");
            email.focus();
            return false;
        }

        if (comment.val() == "Your Comments" || comment.val() == "") {
            $('.commentbox').fadeIn(200);
            comment.focus();
            return false;
        }
    }) // End Function

    // CONTACT FORM
    $(".mail-form-input").bind('blur', function(){
        $(".mail-form-error").html('');
    })
    $("#mail-form").submit(function(){
        var fullname = $(this).find("#fullname");
        var emailid = $(this).find("#email");
        var message = $(this).find("#message");
        var emailFormat = /^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}$/i;


        if (fullname.val() == "") {
            fullname.parent().find('span.mail-form-error').html("This field is required.").removeClass('hidden');
            fullname.focus();
            return false;
        }
        else
        if (emailid.val() == "") {
            emailid.parent().find('span.mail-form-error').html("This field is required.").removeClass('hidden');
            emailid.focus();
            return false;
        }
        else
        if (emailid.val().search(emailFormat) == -1) {
            emailid.parent().find('span.mail-form-error').html("Not a valid email address.").removeClass('hidden');
            emailid.focus();
            return false;
        }
        else
        if (message.val() == '') {
            message.parent().find('span.mail-form-error').html("Got nothing to say?").removeClass('hidden');
            message.focus();
            return false;
        }
        else {
            return true;
        }
        return false;
    })

    //Schedule an Appointment
    //$("#lightbox, #set-appointment").hide(0);
    $("#schedule-appointment").live('click', function(){
        $("#lightbox, #set-appointment").removeClass('hidden');
    })
    $("#close").click(function(){
        $("#lightbox, #set-appointment").addClass('hidden');
        return false;
    })

})
$(window).ready(function(){
   $("#loading, #loading-content").fadeOut(500);
})