var i = 0;
var news;
var interval;
var count = 1;
function showPromo() {
    for(j=0; j<news.length; j++) {
        if(j==i)
            jQuery(news[j]).fadeIn("normal");
        else jQuery(news[j]).fadeOut("normal");
    }
    i++;
    if(i>=news.length) i=0;
}
$(function() {
   var news1;
   var news2;
   var news3;
   //jQuery("#promobox").css({height: '261px',width: '580px', overflow: 'hidden'});
   jQuery("#promobox").find("div.promo").css({position: 'absolute',top: '0px'});
   jQuery(".promoswitch").click(function() {
       var nr = parseInt(jQuery(this).attr('href').replace("#",""));
       i = nr -1;
       clearInterval(interval);
       showPromo();
       interval = setInterval(showPromo, 8000);
       return false;
   });
   news = jQuery("#promobox > div.promo");
   //alert(news.length);
   //jQuery
   jQuery("#promobox > div.promo").each(function () {
       count = 0;
       jQuery(this).find(".promoswitch").each(function() {

            if(count++ >= news.length)
                jQuery(this).remove();

        });
    });
   showPromo();
   interval = setInterval(showPromo, 8000);

});


