var t,t1,t2,t3;
var i=1;
var n_max = 10;
var imgs = new Array(3);
var time_=5000;



$(document).ready(init);
$(window).resize(resize);

function init()
{
   // preload images 
  for (i=1; i<=n_max; i++)
  {
    imgs[i] = new Image();
    imgs[i].src = 'images/'+i+'.jpg';
  } 
  
 resize();   
 t1 = setTimeout('swap1()',time_); 
 t2 = setTimeout('swap2()',time_+500); 
 t3 = setTimeout('swap3()',time_+1000); 
}



function resize()
{	
	var w=document.getElementById("container").offsetWidth;
	var w_window = getClientWidth();
	var h=document.getElementById("container").offsetHeight;
	
	if (w_window<900) 
	{	document.getElementById("b").style.overflowX='auto';	} else
	{ document.getElementById("b").style.overflowX='hidden';	 }
	
	 document.getElementById("container").style.left=(w_window-w)/2+'px'; 
	
	
	var h_content = document.getElementById("main_content").offsetHeight;
	document.getElementById("kol_left_mid").style.height=h_content+120+'px';  //KOLS
	document.getElementById("kol_right_mid").style.height=h_content+120+'px';
	
	document.getElementById("back_").style.height=h_content+230+'px'; //738  h = 738-260=478	
	document.getElementById("ground").style.top=h_content+756+'px'; 
	document.getElementById("ground_shadow").style.top=h_content+690+'px';
	document.getElementById("ikebana").style.top=h_content+539+'px';
	document.getElementById("stol").style.top=h_content+662+'px';
	
	document.getElementById("footer").style.top=h_content+630+'px';		
	document.getElementById("aut").style.top=h_content+760+'px';	
	
}

function getClientWidth()
{
  return document.compatMode=='CSS1Compat' && !window.opera?document.documentElement.clientWidth:document.body.clientWidth;
}

       

function ShowFoto(albom_id,id)
{
 document.getElementById("_image").style.display='none'; 
 document.getElementById("_image").src="images/gallery/albom"+albom_id+"/full/"+id+".jpg";
 document.getElementById("_image").onload = function () {
 $("#_image").fadeIn(500);
 }
}

function next(s)
{
 var ns;	
 var n; 
 
  n = parseInt(s.slice(s.search("/")+1,s.search("jpg")-1));
  
  if (n>=n_max) {n=1} else {n++}
  ns = 'images/'+n+'.jpg'
  return ns;	
}	






function swap1()
{ 
var s = "";
var n_s = "";

  s = $("#i1").attr("src");   
  n_s = next(s); 
    
 $("#i1").fadeOut(1000, function () 
  {
  	$("#i1").attr("src",n_s);  	
      $("#image1").css({background: 'url('+next(n_s)+')' });
  	$("#i1").show();
  });
 clearTimeout(t1); 
 t1=setTimeout('swap1()',time_);
 
 
}



function swap2()
{
var s = "";
var n_s = "";

  s = $("#i2").attr("src");  	 	
  n_s = next(s);
  
  
  $("#i2").fadeOut(1000, function () 
  {
  	$("#i2").attr("src",n_s);  	
      $("#image2").css({background: 'url('+next(n_s)+')' });
  	$("#i2").show();
  });
 clearTimeout(t2); 
 t2=setTimeout('swap2()',time_);
}

function swap3()
{
var s = "";
var n_s = "";

  s = $("#i3").attr("src");   	
  n_s = next(s);
  
  
  $("#i3").fadeOut(1000, function () 
  {
  	$("#i3").attr("src",n_s);  	
      $("#image3").css({background: 'url('+next(n_s)+')' });
  	$("#i3").show();
  });
 clearTimeout(t3); 
 t3=setTimeout('swap3()',time_);
}



