function buildTranslateLink(lang) {
    return 'http://translate.google.com/translate?u=' + encodeURIComponent(location.href) + '&hl=en&langpair=en|' + lang + '&tbb=1&e=UTF-8';
}

$(document).ready(function() {
    // Start up featured slide cycle
    $('#slide-container').cycle({
        timeout: 6000
    });

    // Wire up google translate links
    $('.translate-flags img').each(function() {
        var a = $('<a/>', {
            title: $(this).attr('alt'),
            href: buildTranslateLink($(this).attr('id'))
        });
        $(this).wrap(a);
    });

    // Bind input placeholder text
    $('input[placeholder]').each(function() {
        // Check for placeholder support
        if (!this.placeholder) {
            // Set initial value and class
            if ($(this).val() == '') {
                $(this).val($(this).attr('placeholder')).addClass('placeholder-text');
            }

            // Bind handlers
            $(this).blur(function() {
                if ($(this).val() == '') {
                    $(this).val($(this).attr('placeholder')).addClass('placeholder-text');
                }
            }).focus(function() {
                if ($(this).val() == $(this).attr('placeholder')) {
                    $(this).val('').removeClass('placeholder-text');
                }
            });
        }
    });
});

