﻿jQuery('html').addClass('js');

jQuery(function ($) {
    var tweetSettings = {
        username: "parse3",
        join_text: "auto",
        avatar_size: 32,
        auto_join_text_default: "we said,",
        auto_join_text_ed: "we",
        auto_join_text_ing: "we were",
        auto_join_text_reply: "we replied to",
        auto_join_text_url: "we were checking out",
        loading_text: "loading tweets..."
    };

    $('.tweet').each(function (index, element) {
        var $this, count, settings;
        settings = $.extend({}, tweetSettings);
        $this = $(this);
        count = parseInt($this.attr('data-tweet-count'));
        settings.count = count || 1;
        $this.tweet(settings);
    });

    $('.video a > img, a.video > img, a > img.video').each(function (index, element) {
        var $a,
            $img,
            params,
            attributes,
            flashvars,
            id,
            width,
            height;

        $img = $(this);
        $a = $img.parent();

        id = 'p3Video' + index;
        width = $img.width();
        height = $img.height() + 25;

        flashvars = {
            'src': $a.attr('href'),
            'preview': $img.attr('src')
        };
        params = {
            'bgcolor': '#000000',
            'allowFullScreen': 'true'
        };
        attributes = {};

        $('<div>').attr('id', id).replaceAll($a);

        swfobject.embedSWF('/Assets/Flash/MediaPlayer-2.1.swf', id, width, height, '9.0.0', null, flashvars, params, attributes);
    });

    $('a.fancy, p.fancy a').attr('rel', 'fancybox-group').fancybox({
        type: 'image'
    });

    (function () {
        var $ml,
            href;
        $ml = $('.mobile-link');
        href = $ml.attr('href');
        $ml.attr('href', href + '?origUrl=' + encodeURI(window.location));
    })();

});
