function MM_preloadImages() { //v2.0

  if (document.images) {

    var imgFiles = MM_preloadImages.arguments;

    if (document.preloadArray==null) document.preloadArray = new Array();

    var i = document.preloadArray.length;

    with (document) for (var j=0; j<imgFiles.length; j++) if (imgFiles[j].charAt(0)!="#"){

      preloadArray[i] = new Image;

      preloadArray[i++].src = imgFiles[j];

  } }

}

$.fn.wait = function(time, type) {
        time = time || 1000;
        type = type || "fx";
        return this.queue(type, function() {
            var self = this;
            setTimeout(function() {
                $(self).dequeue();
            }, time);
        });
    };
    
function init() {
	var domsel="ul.upmenu li";
	var domse2=".galeriaFoto";
	$(domsel).each(function() {
		$(domse2).prepend('<img src="http://jmjpro.sk/files/images/main_tree/' + $(this).attr("class") + '.jpg" alt="J.M.J. Pro, s.r.o."  class="' + $(this).attr("class") + '" id="' + $(this).attr("id") + '"/>');
		})
	$(".galeriaFoto img:not(#active)").hide();	
	$("ul.upmenu li").hover(function() {
		$(".galeriaFoto img:not(." + $(this).attr("class") + ")").css('z-index', 0);
		$(".galeriaFoto img:not(." + $(this).attr("class") + ")").fadeOut("slow");
		$(".galeriaFoto img." + $(this).attr("class") + "").fadeIn("slow");
   	});
}
function init2() {
	
      $("div#projects div").each(function (i) {
      	$(this).hide();	
      });
      $("div#projects div").each(function (i) {
     	$(this).hide();
     	$(this).wait(10500*(i));
	  	$(this).fadeIn("slow");
	  	$(this).wait(7000);
	  	$(this).fadeOut("slow");
      });
      var $foo = $("div#projects div");
      setTimeout('init2()',$foo.length*10500);
}
function init3() {
	var domsel="ul.upmenu2 li";
	var domse2=".galeriaFoto2";
	$(domsel).each(function() {
		$(domse2).prepend('<img src="http://jmjpro.sk/files/images/main_tree/' + $(this).attr("class") + '.jpg" alt="J.M.J. Pro, s.r.o."  class="' + $(this).attr("class") + '" id="' + $(this).attr("id") + '" width="300" height="168"/>');
		})
	$("ul.upmenu2 li").hover(function() {
		$(".galeriaFoto2 img:not(." + $(this).attr("class") + ")").css('z-index', 0);
		$(".galeriaFoto2 img:not(." + $(this).attr("class") + ")").fadeOut("slow");
		$(".galeriaFoto2 img." + $(this).attr("class") + "").fadeIn("slow");
		$("ul.upmenu2 li:not(hover)").css("background","#6289a8");
		$("ul.upmenu2 li#first2:not(hover)").css("background","#6289a8");
		$("ul.upmenu2 li#last2:not(hover)").css("background","#6289a8");
		$(this).css("background", "#373b3f" );
   	});
}
$(document).ready(function() {
  	init();
  	init2();
  	init3();
  	$('a.slideshow').zoomimage({
		border: 1,
		centered: true,
		hideSource: true
	});
	
 });

 
function showPleaseWait(){
		
    	
   		var div_wait = document.getElementById("div_wait_content");   
  		if (div_wait != null){
				div_wait.style.display = "block";
				
		}
	}	
   
function hidePleaseWait(){
		
    	
   		var div_wait = document.getElementById("div_wait_content");   
  		if (div_wait != null){
				div_wait.style.display = "none";
		}
}	
