$(document).ready( function() {
	
	//CHECK FOR COOKIE
	var cookie = $.cookie('savevoting_sign_up');
	if(cookie!="shown") { //IF COOKIE DOES NOT EXISTS
		//RUN MODAL WINDOW
		tb_show("Sign Up", "/signup.html?height=160&width=400&modal=true");
		$("#TB_overlay").click(tb_remove);
		
		//SET COOKIE
		$.cookie('savevoting_sign_up', 'shown', { expires: 30 }); //EXPIRES IN A MONTH
	}

	//SLIDESHOW
	$(function() {
	    setInterval( "slideSwitch()", 5000 );
	});
		
});

function slideSwitch() {
    var $active = $('#slideshow DIV.active');
    var $active_thumb = $('#buttons LI.current'); 

    if ( $active.length == 0 ) $active = $('#slideshow DIV:last');
    
    var $next =  $active.next().length ? $active.next()
        : $('#slideshow DIV:first');
    var $next_thumb = $active_thumb.next().length ? $active_thumb.next()
        : $('#buttons LI:first');

    $active.addClass('last-active');
    $active_thumb.removeClass('current');

    $next.css({opacity: 0.0})
        .addClass('active')
        .animate({opacity: 1.0}, 1000, function() {
            $active.removeClass('active last-active');
        });
     $next_thumb.addClass('current', 1000, function() {
            $active_thumb.removeClass('current');
        });
}