
$(document).ready(function(){
   var size = $('#arraySize').html();
   var arraysize = parseInt(size);

   if(arraysize < 4 )
   {
      c1 = setTimeout("playShow('main','')",500);
      c2 = setTimeout("playShow('0','main')",4000);
      c3 = setTimeout("playShow('1','0')",7000);
      c4 = setTimeout("playShow('2','1')",10000);
      c5 = setTimeout("playShow('main','2')",13000);

   }else{

      c1 = setTimeout("playShow('main','')",500);
      c2 = setTimeout("playShow('0','main')",4000);
      c3 = setTimeout("playShow('1','0')",7000);
      c4 = setTimeout("playShow('2','1')",10000);
      c5 = setTimeout("playShow('3','2')",13000);
      c6 = setTimeout("playShow('main','3')",16000);
   }
  

   $('#promo li').click(function(){

       if(arraysize < 4 )
       {
          clearTimeout(c1);
          clearTimeout(c2);
          clearTimeout(c3);
          clearTimeout(c4);
          clearTimeout(c5);

       }else{

           clearTimeout(c1);
           clearTimeout(c2);
           clearTimeout(c3);
           clearTimeout(c4);
           clearTimeout(c5);
           clearTimeout(c6);
       }

   });

});

function img (picturenr){
	document.getElementById("pic").src = "/uploads/promo_player_images/" + picturenr ;
}

function sendKey(key)
{
    $('#promo_text').html('');
    $('#promo_text').html($('#promo_'+key+'_text').html());
    $('#promo_link').attr('href',$('#promo_'+key+'_link').html());
    $('#'+key).attr('class','active');
}

function playShow(key,previousKey)
{
    document.getElementById("pic").src = "/uploads/promo_player_images/" +$('#promo_'+key+'_image').html();
    $('#promo_text').html($('#promo_'+key+'_text').html());
    $('#promo_link').attr('href',$('#promo_'+key+'_link').html());

    if(previousKey != '')
    {
       $('#'+previousKey).attr('class','');
    }
    
    $('#'+key).attr('class','active');
    
     $('#promo li').click(function() {
         $('#'+key).attr('class','');
     });
}

function getArraySize(size)
{
    return size;
}

