var gal=0;
var ticks=0;
var crt;


function init()
{
 preload_images();
 put_clock();
 c=document.getElementById('content');
 s=document.getElementById('scroll_bar');
 if(c && s)
  {
	  if(c.offsetHeight<320) s.style.visibility='hidden';
      else s.style.visibility='visible';
  }
   else
   {put_tour();
    c=document.getElementById('content2');
    s=document.getElementById('scroll_bar2');
    if(c && s)
      {
	   if(c.offsetHeight<320) s.style.visibility='hidden';
       else s.style.visibility='visible';
      }
   }
}

function preload_images()
{
i1=new Image();
i1.src="slides/1.jpg";
i2=new Image();
i2.src="slides/2.jpg";
i3=new Image();
i3.src="slides/3.jpg";
i4=new Image();
i4.src="slides/4.jpg";
i5=new Image();
i5.src="slides/5.jpg";
i6=new Image();
i6.src="slides/6.jpg";
i7=new Image();
i7.src="slides/7.jpg";
i8=new Image();
i8.src="slides/8.jpg";
i9=new Image();
i9.src="slides/8.jpg";
i10=new Image();
i10.src="slides/8.jpg";
}

function put_clock()
{
clock();
setInterval('clock()',5000);
}

function clock()
{
check_galery();
time= new Date();
day=time.getDate();
month=time.getMonth();
year=time.getFullYear();
hour=time.getHours();
min=time.getMinutes();

if(day<10) day="0"+day;
if(month<10) month="0"+month;
if(hour<10) hour="0"+hour;
if(min<10) min="0"+min;

var timp=""+day+"&nbsp;|&nbsp;"+month+"&nbsp;|&nbsp;"+year+"&nbsp;&nbsp;&nbsp;&nbsp;"+hour+":"+min;

id=document.getElementById("clk");
if(id) id.innerHTML=timp;


}

function high(id)
{
i=document.getElementById(id);
i.visibility='hidden';
i.src="images/highlight.gif"
}

function low(id)
{
i=document.getElementById(id);
i.src="images/no_highlight.gif";
}

function redirect(dest)
{
window.location=dest;
}

function put_tour()
{
 basename="vilaIRINA";
 _max=50;
 result="<br><table border='0' cellspacing='0'><tr>";
 
 for(i=1;i<=_max;i++)
   {
	result+="<td height='100'><div class='thumb' onclick=window.open('big.php?img="+basename+i+".JPG')><img src='thumbs.php?w=90&h=90&im="+basename+i+".JPG'></div></td>";
	if(i%5==0) result+="</tr><tr>";
   }
 
 result+="</tr></table>";
 
 id=document.getElementById('content2');
 id.innerHTML=result;
}

function check_galery()
{
id=document.getElementById('p0');
if(!id) return;
if (ticks==8) ticks=0;
if (ticks==0)
       {
		rand=Math.round(Math.random()*100)%38+1;
		//"ramele"
		id=document.getElementById('r1');
		id.src='images/little_frame.gif';
		id=document.getElementById('r4');
		id.src='images/no_frame.gif';
		crt=2;
		
		//pozele
		id0=document.getElementById('p0');
		id1=document.getElementById('p1');
		id2=document.getElementById('p2');
		id3=document.getElementById('p3');
		id4=document.getElementById('p4');
		
		id0.src='thumbs.php?w=139&h=104&im=vilaIRINA'+rand+'.JPG';
		id1.src='thumbs.php?w=65&h=48&im=vilaIRINA'+rand+'.JPG';
		id2.src='thumbs.php?w=65&h=48&im=vilaIRINA'+(rand+1)+'.JPG';
		id3.src='thumbs.php?w=65&h=48&im=vilaIRINA'+(rand+2)+'.JPG';
		id4.src='thumbs.php?w=65&h=48&im=vilaIRINA'+(rand+3)+'.JPG';
	   }

else if (ticks%2==0)
       {
		id=document.getElementById('r'+crt);
		id.src='images/little_frame.gif';
		id=document.getElementById('r'+(crt-1));
		id.src='images/no_frame.gif';
		
		id0=document.getElementById('p0');
		id0.src='thumbs.php?w=139&h=104&im=vilaIRINA'+(rand+crt-1)+'.JPG';
		crt++;
	   }
ticks++;
}

function preview(loc)
{
if(loc==0 || loc==1)
window.open('big.php?img=vilaIRINA'+rand+".JPG");
if(loc==2)
window.open('big.php?img=vilaIRINA'+(rand+1)+".JPG");
if(loc==3)
window.open('big.php?img=vilaIRINA'+(rand+2)+".JPG");
if(loc==4)
window.open('big.php?img=vilaIRINA'+(rand+3)+".JPG");

}