var left, offset, quotes, quotes_pos, pics;

jQuery = jQuery.noConflict();

pics = function() {
    jQuery('div.slides div:visible').fadeOut(800, function() {
        if (jQuery(this).next('div').length > 0) {
            jQuery(this).next('div').fadeIn(800);
        } else {
            jQuery('div.slides div:first').fadeIn(800);
        }
    });

    setTimeout(function() { pics(); }, 4000);
};

quotes_pos = function () {
    offset = jQuery('#wrapper').offset();
    left = offset.left + 130 + 'px';

    jQuery('#quotes')
        .css('left', left)
        .show()
        .find('li:first')
        .show();
};

quotes = function() {
    if (jQuery('#quotes').is(':visible')) {
        jQuery('#quotes li:visible').fadeOut(500, function() {
            if (jQuery(this).next('li').length > 0) {
                jQuery(this).next('li').fadeIn(500);
            } else {
                jQuery('#quotes li:first').fadeIn(500);
            }
        });
    } else {
        quotes_pos();
        jQuery(window).bind('resize', quotes_pos);
    }

    setTimeout(function() { quotes(); }, 5000);
};

share = function() {
    var $div, divs, h, i, l, $parent, stop, t, w;
    divs = jQuery('p.postmeta span.right div');
    stop = divs.length;
    h = 16;
    w = 83;

    for (i = 0; i < stop; i += 1) {
        $div = jQuery(divs[i]);
        $parent = $div.parents('.post');
        l = Math.round($parent.width() + $parent.offset().left - w);
        t = Math.round($parent.height() + $parent.offset().top - h - 17);

        $div.css({
            position: 'absolute',
            left: l,
            top: t
        });
    }
};

jQuery(document).ready(function($) {
    share();
    quotes();
    setTimeout(function() { pics(); }, 4000);

    $('a').click(function() {
        if ($(this).attr('href') == '#') { return false; }
    }).hover(function() {
        if ($(this).attr('rel') == 'external') { $(this).attr('target', '_blank'); }
    });
});