function slideLeft() {
    if (!window.canSlide) return;
    window.canSlide = false;
    
    var current = $('div.slider-content.active');
    var prev = current.prev();
    
    if (prev.length == 0) {
        prev = current.parent().children(':last-child');
    }
    
    $('#slider .bottom .bullets div').removeClass('active');
    $('#slider .bottom .bullets div').eq(prev.prevAll().size()).addClass('active');
    
    $('iframe').hide();
    
    prev.css('z-index', 2);
    prev.show('slide', {direction: "left"}, 1500, function () {
        current.css('z-index', 0);
        window.canSlide = true;
        $('iframe').show();
    });
    current.hide('slide', {direction: "right"}, 1500);
    current.removeClass('active');
    prev.addClass('active');
    current.css('z-index', 1);
}

function slideRight() {
    if (!window.canSlide) return;
    window.canSlide = false;
    
    var current = $('div.slider-content.active');
    var next = current.next();
    
    if (next.length == 0) {
        next = current.parent().children(':first-child');
    }
    
    $('#slider .bottom .bullets div').removeClass('active');
    $('#slider .bottom .bullets div').eq(next.prevAll().size()).addClass('active');
    
    $('iframe').hide();
    
    next.css('z-index', 2);
    next.show('slide', {direction: "right"}, 1500, function () {
        current.css('z-index', 0);
        window.canSlide = true;
        $('iframe').show();
    });
    current.hide('slide', {direction: "left"}, 1500);
    current.removeClass('active');
    next.addClass('active');
    current.css('z-index', 1);
}

function slideInterval() {
    window.sliderInterval = setInterval("slideRight();", 8000);
}

$(document).ready(function () {
    $('#slider a.nav-left').live('click', function () {
        slideLeft();
        
        return false; 
    });
    
    $('#slider a.nav-right').live('click', function () {
        slideRight();
        
        return false; 
    });
    
    window.canSlide = false;
    if ($('#slider-container').children().length > 1) {
        window.canSlide = true;
    }
    
    
    slideInterval();
    
    $("#slider").live('mouseenter', function () {
        clearInterval(window.sliderInterval);
    }).live('mouseleave', function () {
        slideInterval();
    });








});

