/*

var menu_arr = new Array(); //lista zdjec menu

function show_menu_side_OLD(img){

	preloader_show();

	var id = menu_arr.indexOf(img);
	$('#menu_side').attr('src', 'photos/menu/'+img);

	
	if((id-1) in menu_arr){
		var prev = menu_arr[id-1];
		$('#menu_side_prev').show();
		$('#menu_side_prev').attr('onClick', "show_menu_side('"+prev+"')");
	}
	else{
		$('#menu_side_prev').hide();
		$('#menu_side_prev').attr('onClick', "");
	}
	
	if((id+1) in menu_arr){
		var next = menu_arr[id+1];
		$('#menu_side_next').show();
		$('#menu_side_next').attr('onClick', "show_menu_side('"+next+"')");
	}
	else{
		$('#menu_side_next').hide();
		$('#menu_side_next').attr('onClick', "");
	}
}
*/

function animator(numer) {

	nastepny = (numer < 6) ? numer+1 : 1;
	
	$("#podpis_"+numer).fadeOut(500);
	setTimeout(function() {
    $("#podpis_"+nastepny).fadeIn(500);
  },500);

}

function top_changer(top_numer) {
 
  top_nastepny = (top_numer < 2) ? top_numer+1 : 1;
	
	$("#top"+top_numer).fadeOut(500);
	setTimeout(function() {
    $("#top"+top_nastepny).fadeIn(500);
  },500);

}



function show_menu_side(img){

	preloader_show();

	$(".imgs_url, .imgs_url_chef").fadeOut(500);
	setTimeout(function() {
		$("img[name="+img+"]").fadeIn(500);
	},500);
	
	if($("img[name="+img+"]").prev().hasClass("imgs_url")){
		var prev = $("img[name="+img+"]").prev().attr('name');
		$('#menu_side_prev').show();
		$('#menu_side_prev').attr('href', "javascript:show_menu_side('"+prev+"')");
	}
	else{
		$('#menu_side_prev').hide();
		$('#menu_side_prev').attr('href', "javascript:void(0)");
	}
	
	if($("img[name="+img+"]").next().hasClass("imgs_url")){
		var next = $("img[name="+img+"]").next().attr('name');
		$('#menu_side_next').show();
		$('#menu_side_next').attr('href', "javascript:show_menu_side('"+next+"')");
	}
	else{
		$('#menu_side_next').hide();
		$('#menu_side_next').attr('href', "javascript:void(0)");
	}
	
}

function preloader_show() {

	//wielkosc okna
	var xScroll, yScroll;
	if (window.innerHeight && window.scrollMaxY) {	
		xScroll = window.innerWidth + window.scrollMaxX;
		yScroll = window.innerHeight + window.scrollMaxY;
	} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
		xScroll = document.body.scrollWidth;
		yScroll = document.body.scrollHeight;
	} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
		xScroll = document.body.offsetWidth;
		yScroll = document.body.offsetHeight;
	}
	var windowWidth, windowHeight;
	if (self.innerHeight) {	// all except Explorer
		if(document.documentElement.clientWidth){
			windowWidth = document.documentElement.clientWidth; 
		} else {
			windowWidth = self.innerWidth;
		}
		windowHeight = self.innerHeight;
	} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
		windowWidth = document.documentElement.clientWidth;
		windowHeight = document.documentElement.clientHeight;
	} else if (document.body) { // other Explorers
		windowWidth = document.body.clientWidth;
		windowHeight = document.body.clientHeight;
	}	
	// for small pages with total height less then height of the viewport
	if(yScroll < windowHeight){
		pageHeight = windowHeight;
	} else { 
		pageHeight = yScroll;
	}
	// for small pages with total width less then width of the viewport
	if(xScroll < windowWidth){	
		pageWidth = xScroll;		
	} else {
		pageWidth = windowWidth;
	}
	
	//polozenie na stronie
	var xPos, yPos;
	if (self.pageYOffset) {
		yPos = self.pageYOffset;
		xPos = self.pageXOffset;
	} else if (document.documentElement && document.documentElement.scrollTop) {	 // Explorer 6 Strict
		yPos = document.documentElement.scrollTop;
		xPos = document.documentElement.scrollLeft;
	} else if (document.body) {// all other Explorers
		yPos = document.body.scrollTop;
		xPos = document.body.scrollLeft;	
	}

	var str = '<div id="info" style="display: none; z-index: 100; opacity: 0.9; filter: alpha(opacity=90); background-color: #e45600; position: absolute; left: 0px; top: 0px; width: '+pageWidth+'px; height: '+pageHeight+'px;">';
	str += '<img src="dom/gfx/preloader.gif" style="float: none; position: absolute;  z-index: 2; left: '+(parseInt(xPos+windowWidth/2)-20)+'px; top: '+(parseInt(yPos+windowHeight/2)-20)+'px; opacity: 0.9;" />';
	str += '</div>';
	
	$("body").append(str);

	$("#info").fadeIn(500);
	setTimeout(function() {
		$("#info").fadeOut(500);
	},2500);

}


$(document).ready(function(){
  // lista zdjec menu
  
  /*
  $(".imgs_url").each(function(){
	menu_arr.push($(this).attr('name'));
  });*/
 
  //$('#menu_side_next').show();
 
  // animacja podpisow
  var akt_numer = 0;
  setInterval(function() {
      
      if(akt_numer == 6) { 
        akt_numer = 1; 
      } else { 
        akt_numer++; 
      }
      
      animator(akt_numer);      
  
  }, 3000);
  
  // animacja topow
  var top_numer = 1;
  setInterval(function() {
      
      if(top_numer == 2) { 
        top_numer = 1; 
      } else { 
        top_numer++; 
      }
      
      top_changer(top_numer);      
  
  }, 5000);

  

});
