var news_src;
function switch_newsitem(url)
{
    news_src = document.getElementById('newssrc');

    $($('#newsticker li')[0]).fadeOut("fast", function() {
        $($('#newsticker li')[0]).remove();
    });
    
    if ($('#newssrc li').length == 0)
    {
    	
        $.get(url, function(data) {
	   	   
	
	   	   
	   	    $('#newssrc').html(data);
	   	      
	        $('#newssrc li')[0].style.display = 'none';
	        
	        
	        document.getElementById('newsticker').appendChild($('#newssrc li')[0]);
	        $($('#newssrc li')[0]).remove();
	        
	        $($('#newsticker li')[$('#newsticker li').length - 1]).fadeIn("slow");
	    });
    }
    else
    {
        $('#newssrc li')[0].style.display = 'none';
        document.getElementById('newsticker').appendChild($('#newssrc li')[0]);
        $($('#newssrc li')[0]).remove();
        
        $($('#newsticker li')[$('#newsticker li').length - 1]).fadeIn("slow");
    }
     setTimeout("switch_newsitem('"+url+"')", 4000);
}

function switch_banner_long(url, notImg)
{
	var notIDl;
	
	if (notImg > 0) {
		$('#switch_banner_long').fadeOut(1000, function() {
			$.getJSON(url, { type: 'long', not: notImg }, function(data) {
				notIDl = data._notl;
				$('#url_switch_banner_long').attr('href', data._url);
				$('#switch_banner_long').attr('src', 'http://www.verenigingspas.nl'+data._img);
			});
			$('#switch_banner_long').fadeIn(1000);
		});
	}
	else {
		$('#switch_banner_long').fadeOut(1000, function() {
			$.getJSON(url, { type: 'long' }, function(data) {
				notIDl = data._notl;
				$('#url_switch_banner_long').attr('href', data._url);
				$('#switch_banner_long').attr('src', 'http://www.verenigingspas.nl'+data._img);
			});
			$('#switch_banner_long').fadeIn(1000);
		});
	}
/* 	setTimeout("switch_banner_long('"+url+"',notIDl)", 12000);\ */
	setTimeout(function() { switch_banner_long(url, notIDl); }, 12000);
}

function switch_banner_short(url, notImg)
{
	var notIDl;
	
	if (notImg > 0) {
		$('#switch_banner_short').fadeOut(1000, function() {
			$.getJSON(url, { type: 'short', not: notImg }, function(data) {
				notIDl = data._notl;
				$('#url_switch_banner_short').attr('href', data._url);
				$('#switch_banner_short').attr('src', 'http://www.verenigingspas.nl'+data._img);
			});
			$('#switch_banner_short').fadeIn(1000);
		});
	}
	else {
		$('#switch_banner_short').fadeOut(1000, function() {
			$.getJSON(url, { type: 'short' }, function(data) {
				notIDl = data._notl;
				$('#url_switch_banner_short').attr('href', data._url);
				$('#switch_banner_short').attr('src', 'http://www.verenigingspas.nl'+data._img);
			});
			$('#switch_banner_short').fadeIn(1000);
		});
	}
/* 	setTimeout("switch_banner_short('"+url+"',notIDl)", 12000);\ */
	setTimeout(function() { switch_banner_short(url, notIDl); }, 12000);
}


/* original script below */

/*
function switch_banner_short(url)
{
	imgNlong = $('#switch_banner_long').attr('src');
	imgNlong = imgNlong.split("/");
	imgNlong = imgNlong[imgNlong.length - 1];
	
	if (imgNlong == '') {
		$('#switch_banner_long').fadeOut(1000, function() {
			$.getJSON(url, { type: 'long' }, function(data) {
			$('#url_switch_banner_long').attr('href', data._url);
			$('#switch_banner_long').attr('src', 'http://www.verenigingspas.nl'+data._img);
		}); 
					$('#switch_banner_long').fadeIn(1000);
		});
	}
	else {
		$('#switch_banner_long').fadeOut(1000, function() {
			$.getJSON(url, { type: 'long', not: imgNlong } , function(data) {
				$('#url_swicth_banner_long').attr('href', data._url);
				$('#switch_banner_long').attr('src', 'http://www.verenigingspas.nl'+data._img);
			});
			$('#switch_banner_long').fadeIn(1000);
		});		
	}

    setTimeout("switch_banner_long('"+url+"')", 12000);
}
*/
/*
function switch_banner_short(url)
{
	imgNshort = $('#switch_banner_short').attr('src');
	imgNshort = imgNshort.split("/");
	imgNshort = imgNshort[imgNshort.length - 1];
	
	if (imgNshort == '') {
		$('#switch_banner_short').fadeOut(1000, function() {
			$.getJSON(url, { type: 'short' }, function(data) {
			$('#url_switch_banner_short').attr('href', data._url);
			$('#switch_banner_short').attr('src', 'http://www.verenigingspas.nl'+data._img);
		}); 
					$('#switch_banner_short').fadeIn(1000);
		});
	}
	else {
		$('#switch_banner_short').fadeOut(1000, function() {
			$.getJSON(url, { type: 'short', not: imgNlong } , function(data) {
				$('#url_switch_banner_short').attr('href', data._url);
				$('#switch_banner_short').attr('src', 'http://www.verenigingspas.nl'+data._img);
			});
			$('#switch_banner_short').fadeIn(1000);
		});		
	}

    setTimeout("switch_banner_short('"+url+"')", 12000);
}

*/


/*

//updated functionality, need fix for ticoma sites

function switch_banner_long(notImg)
{
	if (notImg > 0) {
		$('#switch_banner_long').fadeOut(1000, function() {
			$.getJSON('/switch_bannerUPDATE.php', { type: 'long', not: notIDl } , function(data) {
				notIDl = data._notl;
				$('#url_switch_banner_long').attr('href', data._url);
				$('#switch_banner_long').attr('src', 'http://www.verenigingspas.nl'+data._img);
			});
			$('#switch_banner_long').fadeIn(1000);
		});		
	}
	else {
		$('#switch_banner_long').fadeOut(1000, function() {
			$.getJSON('/switch_bannerUPDATE.php', { type: 'long' }, function(data) {
				notIDl = data._notl;
				$('#url_switch_banner_long').attr('href', data._url);
				$('#switch_banner_long').attr('src', 'http://www.verenigingspas.nl'+data._img);
			});
			$('#switch_banner_long').fadeIn(1000);
		});
	}

	setTimeout("switch_banner_long(notIDl)", 8000);
}

function switch_banner_short(notImg)
{
	if (notImg > 0) {
		$('#switch_banner_short').fadeOut(1000, function() {
			$.getJSON('/switch_bannerUPDATE.php', { type: 'short', not: notIDs } , function(data) {
				notIDs = data._nots;
				$('#url_switch_banner_short').attr('href', data._url);
				$('#switch_banner_short').attr('src', 'http://www.verenigingspas.nl'+data._img);
			});
			$('#switch_banner_short').fadeIn(1000);
		});		
	}
	else {
		$('#switch_banner_short').fadeOut(1000, function() {
			$.getJSON('/switch_bannerUPDATE.php', { type: 'short' }, function(data) {
				notIDs = data._nots;
				$('#url_switch_banner_short').attr('href', data._url);
				$('#switch_banner_short').attr('src', 'http://www.verenigingspas.nl'+data._img);
			});
			$('#switch_banner_short').fadeIn(1000);
		});
	}

	setTimeout("switch_banner_short(notIDs)", 8000);
}
*/

