// JavaScript Document
var action, fadeact;
var path, lastimg;
var i, j;
var picnum = 8;
var imgobj, spnobj, imgnum; 
var speed = 4000;
var nextpic = 2;

window.onload = function StartChange()
{
	//Change();
	startfl();
	action = window.setInterval("firstStart()",speed);
}

function firstStart()
{
	j = 100;
	window.clearInterval(action);
	fadeoutact = window.setInterval("fadeOut()",speed/200);
}

function Change()
{
	imgobj = document.getElementById('img1');
	path = 'img/';
			
	imgobj.style.opacity = 0;
	imgobj.style.MozOpacity = 0;
	imgobj.style.filter = 'alpha(opacity=0)';
	//do{
		imgobj.src = path + 'stroka' + Math.round(nextpic) + '.gif';
		//imgobj.src = path + 'stroka' + Math.round(Math.random()*(picnum-1)+1) + '.gif';
	//}while( lastimg == imgobj.src );
	nextpic++;
	if(nextpic > picnum) nextpic = 1;		

	fadeinact = window.setInterval("fadeIn()",speed/200);
}

function fadeIn()
{
	if(j < 100)
	{
		j+=5;
		
		imgobj = document.getElementById('img1');
		imgobj.style.opacity = 0.01*j;
		imgobj.style.MozOpacity = 0.01*j;
		imgobj.style.filter = 'alpha(opacity=' + j + ')';

	}else{
		window.clearInterval(fadeinact);
		action = window.setInterval("firstStart()",speed);
	}
}
function fadeOut()
{
	if(j >= 0)
	{
		j-=5;
		
		imgobj = document.getElementById('img1');
		imgobj.style.opacity = 0.01*j;
		imgobj.style.MozOpacity = 0.01*j;
		imgobj.style.filter = 'alpha(opacity=' + j + ')';
	}else{
		window.clearInterval(fadeoutact);
		Change();
	}
}
function show(name, w, h)
{ 
	var url = "";
	var name = 'win'+name;
	var w_add = 50;
	var h_add = 60;
	if(w!=0)
	{	w += w_add;}
	else
	{	w = 600 + w_add;}
	if(h!=0)
	{	h += h_add;}
	else
	{	h = 600 + h_add;}
		
	var l = window.screen.availWidth/2 - w/2;
	var t = window.screen.availHeight/2 - h/2;
	window.open( url, name, "top="+t+"px,left="+l+"px,width="+w+"px,height="+h+"px,resizeable=yes,toolbar=no,location=no,status=no,menubar=no,scrollbars=yes");
} 

function startfl()
{
  if (document.getElementsByTagName) {
      var objs = document.getElementsByTagName("object");
	
      for (i=0; i<objs.length; i++) {

        objs[i].outerHTML = objs[i].outerHTML;
		objs[i].style.visibility = 'visible';
      }
   }
}
