var noweokno = null;
var timer = new Array();
var images = new Array();
var menushow = new Array();
var lista = new Array ();

var lp_0 = 0;
var lp_1 = 0;
var pre_0;
var pre_1;

var poczatek = 0;

images[0] = 'head/zespol_1.jpg';
images[1] = 'head/zespol_2.jpg';
images[2] = 'head/zespol_3.jpg';

images[3] = 'head/zespol_g_1.jpg';
images[4] = 'head/zespol_g_2.jpg';

images[5] = 'head/zespol_p_1.jpg';
images[6] = 'head/zespol_p_2.jpg';
images[7] = 'head/zespol_p_3.jpg';
images[8] = 'head/zespol_p_4.jpg';
images[9] = 'head/zespol_p_5.jpg';
images[10] = 'head/zespol_p_6.jpg';

images[11] = 'head/widok_1_1.jpg';
images[12] = 'head/widok_1_2.jpg';
images[13] = 'head/widok_1_3.jpg';

images[14] = 'head/widok_2_1.jpg';
images[15] = 'head/widok_2_2.jpg';
images[16] = 'head/widok_2_3.jpg';

images[17] = 'head/widok_3_1.jpg';
images[18] = 'head/widok_3_2.jpg';
images[19] = 'head/widok_3_3.jpg';

images[20] = 'head/widok_4_1.jpg';
images[21] = 'head/widok_4_2.jpg';
images[22] = 'head/widok_4_3.jpg';

function start(menu_id)
{	
	if (menu_id=='7')
	{
		menushow[0] = [10,5,8,9,6,7];				
		menushow[1] = [0,1,2,3];
	}
	else  
    {
	  if (menu_id=='1' || menu_id=='3' || menu_id=='6')
	  {		
	    menushow[0] = [20,21,22,11,12,13];
	    menushow[1] = [14,15,16,17,18,18];				  
	  }
	  else
	  {
	    menushow[0] = [19,18,17,13,12,11];
	    menushow[1] = [16,15,14,22,21,20];				  
	  }
	}	
    nextImage_1();		
    nextImage_0(); 	
}
	
function nextImage_0()
{
  if (lp_0>=menushow[0].length)
  {
  	lp_0 = 0;	  
  }
  pre_0 = new Image();  
  pre_0.src = images[menushow[0][lp_0]];
  checkLoading_0();
}

function nextImage_1()
{
  if (lp_1>=menushow[1].length)
  {
  	lp_1 = 0;	  
  }
  pre_1 = new Image();
  pre_1.src = images[menushow[1][lp_1]];  
  checkLoading_1();
}

function checkLoading_0() 
{ 
  if (!pre_0.complete) 
  { 
     setTimeout("checkLoading_0()",20); 
     return; 
  } 
  nextImage(0, 'pan0', 'pan_image0',images[menushow[0][lp_0]]);
  ++lp_0;
}

function checkLoading_1() 
{ 
  if (!pre_1.complete) 
  { 
     setTimeout("checkLoading_1()",20); 
     return; 
  } 
  nextImage(1, 'pan1', 'pan_image1',images[menushow[1][lp_1]]);
  ++lp_1;
}


function nextImage(lp,span_id,img_id,plik)
{
  if (poczatek<2)
  {
    $('#'+ span_id + ' img').fadeOut(200, function () {	  
       document.getElementById(img_id).src = plik;
       $('#'+ span_id + ' img').fadeIn(500, function () { 
	        if (poczatek==1)
              timer[lp] = setTimeout("nextImage_"+lp+"()",7000); 
		    else	
			  timer[lp] = setTimeout("nextImage_"+lp+"()",13000); 
		    ++poczatek;				  
          });		     
       });		     
  }
  else
  {
    $('#'+ span_id + ' img').fadeOut(3000, function () {
         document.getElementById(img_id).src = plik;
         $('#'+ span_id + ' img').fadeIn(3000, function () { 
            timer[lp] = setTimeout("nextImage_"+lp+"()",8000); 
	  	    });		     
         });		  
  }
}


function openEdytor(plik,h,w)
{
  if (w==null) w=990; if (h==null) h=750;
  if (window.screen) { aw=window.screenLeft; ah=window.screenTop;} else { aw=640; ah=450; }
  ustawienia= "left="+(aw+20)+",top="+(ah+50)+",width="+w+",height="+h+",toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=yes,resizable=yes";
  if (noweokno != null) noweokno.close();
  noweokno=window.open(plik,'edytor',ustawienia);
  noweokno.focus();
}


function pokazStrone(strona)
{
 f = document.getElementById("lista_form");			
 f.strona.value = strona;
 f.submit();
}				


