﻿//Cufon replacements
Cufon.replace("#header-tel");

//sitewide jquery handlers


$(document).ready(function () {

    var totalslides = $('#hero-images').children().size();
    $('#hero-images').cycle({ pause: 1,
        timeout: 3000,
        pager: '#page-hero-nav',
        pagerAnchorBuilder: function (idx, slide) {
            //<![CDATA[
            if (totalslides > 1) {
                return '<div><a href="#"><span>' + (idx) + '</span></a></div>';
            }
            //]]>
        }



    });
    var fadeDuration = 200; //time in milliseconds
    $('.subnav li:not(:contains(li))').hover(function () {
        $(this).animate({ paddingLeft: '18px' }, fadeDuration);
    }, function () {
        $(this).animate({ paddingLeft: '15px' }, fadeDuration);
    });

    /* go to top */
    $('a[href=#pagetop]').click(function () {
        $('html, body').animate({ scrollTop: 0 }, 'slow');
        return false;
    });

    /* scroll to terms */
    $('a[href=#terms]').click(function () {
        $('html, body').animate({ scrollTop: $("#terms").offset().top }, 'slow');
        return false;
    });

    $('.brochure-form').corner();

    $('span.codedirection').each(function () {
        //<![CDATA[
        var original = $(this).html();
        var reversed = original.split("").reverse().join("");
        $(this).html('<a href="mailto:' + reversed + '" rel="nofollow">' + original + '</a>');
        //]]>
    });

    $("a.doToggle").each(function () {
        $(this).click(function () {
            elementClick = $(this).attr("id")
            $("#" + elementClick + "_answer").slideToggle('fast');
        });
    });



});        

