
$j(document).ready(function() {
    setTimeout("switch_newsitem()", 4000);
	
	
	if ($j('#switch_banner_short').length > 0){
		switch_banner_short();
	}
	
	if ($j('#switch_banner_long').length > 0){
		switch_banner_long();
	}
    
	
	var x = document.createElement('ul');
    x.id = 'newssrc';
    x.style.display = 'none';
    document.getElementsByTagName("BODY")[0].appendChild(x);
});

var news_src;
function switch_newsitem()
{
    news_src = document.getElementById('newssrc');

    $j($j('#newsticker li')[0]).fadeOut("fast", function() {
        $j($j('#newsticker li')[0]).remove();
    });
    
    if ($j('#newssrc li').length == 0)
    {
        $j.get('/lib/rawactie.php', function(data) {
            $j('#newssrc').html(data);
            
                $j('#newssrc li')[0].style.display = 'none';
                document.getElementById('newsticker').appendChild($j('#newssrc li')[0]);
                $j($j('#newssrc li')[0]).remove();
                
                $j($j('#newsticker li')[$j('#newsticker li').length - 1]).fadeIn("slow");
            });
    }
    else
    {
        $j('#newssrc li')[0].style.display = 'none';
        document.getElementById('newsticker').appendChild($j('#newssrc li')[0]);
        $j($j('#newssrc li')[0]).remove();
        
        $j($j('#newsticker li')[$j('#newsticker li').length - 1]).fadeIn("slow");
    }
    

    
     setTimeout("switch_newsitem()", 4000);
}


function switch_banner_long(notImg)
{
	if (notImg > 0) {
		$j('#switch_banner_long').fadeOut(1000, function() {
			$j.getJSON('/switch_bannerUPDATE.php', { type: 'long', not: notIDl } , function(data) {
				notIDl = data._notl;
				$j('#url_switch_banner_long').attr('href', data._url);
				$j('#switch_banner_long').attr('src', 'http://www.verenigingspas.nl'+data._img);
			});
			$j('#switch_banner_long').fadeIn(1000);
		});		
	}
	else {
		$j('#switch_banner_long').fadeOut(1000, function() {
			$j.getJSON('/switch_bannerUPDATE.php', { type: 'long' }, function(data) {
				notIDl = data._notl;
				$j('#url_switch_banner_long').attr('href', data._url);
				$j('#switch_banner_long').attr('src', 'http://www.verenigingspas.nl'+data._img);
			});
			$j('#switch_banner_long').fadeIn(1000);
		});
	}

	setTimeout("switch_banner_long(notIDl)", 8000);
}

function switch_banner_short(notImg)
{
	if (notImg > 0) {
		$j('#switch_banner_short').fadeOut(1000, function() {
			$j.getJSON('/switch_bannerUPDATE.php', { type: 'short', not: notIDs } , function(data) {
				notIDs = data._nots;
				$j('#url_switch_banner_short').attr('href', data._url);
				$j('#switch_banner_short').attr('src', 'http://www.verenigingspas.nl'+data._img);
			});
			$j('#switch_banner_short').fadeIn(1000);
		});		
	}
	else {
		$j('#switch_banner_short').fadeOut(1000, function() {
			$j.getJSON('/switch_bannerUPDATE.php', { type: 'short' }, function(data) {
				notIDs = data._nots;
				$j('#url_switch_banner_short').attr('href', data._url);
				$j('#switch_banner_short').attr('src', 'http://www.verenigingspas.nl'+data._img);
			});
			$j('#switch_banner_short').fadeIn(1000);
		});
	}

	setTimeout("switch_banner_short(notIDs)", 8000);
}
