// JavaScript Document
var action, fadeact;
var path, lastimg;
var i, j;
var picnum = 4;
var imgobj, spnobj, imgnum; 
var speed = 10000;
var nextpic = 1;

window.onload = function StartChange()
{
	action = window.setInterval("firstStart()",speed/10);
}

function firstStart()
{
	Change();
	window.clearInterval(action);
	action = window.setInterval("Change()",speed);
}

function Change()
{
	imgobj = document.getElementById('flash');
	spnobj = document.getElementById('flashspn');
	path = imgobj.src.substring(0, imgobj.src.lastIndexOf('/')+1);
			
	spnobj.style.backgroundImage = 'url(' + imgobj.src + ')';

	imgobj.style.opacity = 0;
	imgobj.style.MozOpacity = 0;
	imgobj.style.filter = 'alpha(opacity=0)';
	lastimg = imgobj.src;
	//do{
		imgobj.src = path + 'img0' + Math.round(nextpic) + '.jpg';
	//}while( lastimg == imgobj.src );
	nextpic++;
	if(nextpic > picnum) nextpic = 1;
	j = 0;
	fadeact = window.setInterval("fade()",50);
}

function fade()
{
	if(j < 100)
	{
		j+=2;
		
		imgobj = document.getElementById('flash');
			
		imgobj.style.opacity = 0.01*j;
		imgobj.style.MozOpacity = 0.01*j;
		imgobj.style.filter = 'alpha(opacity=' + j + ')';
			
	}else{
		window.clearInterval(fadeact);
	}
}
function showimg(imgPath, title, alt)
{ 
	var win = window.open('','preview', 'width=50,height=50,left=0,top=0,screenX=0,screenY=0,resizable=1,scrollbar=0,status=no,location=no');

 	

    var winDoc = win.document;

    if (title == undefined) title = 'Увеличение';

    if (alt   == undefined) alt   = 'Увеличение';
	

    var content = '<html><head><title>'+title+'</title></head><body><a href="javascript:self.close()">' +

      '<img alt="' + alt + '" id="image" src="' + imgPath + '" /></a></body></html>'
	  

    win.document.write(content);
	win.document.title = title;
	win.document.body.style.overflow = 'hidden';
	win.document.body.style.margin = '0';
	win.document.getElementById('image').style.border ='0';

 

    winDoc.body.onload = function() {

    var obj = winDoc.getElementById('image');

    var w = obj.width, h = obj.height;

    var iHeight= document.body.clientHeight, iWidth = self.innerWidth;

 

    var left = (self.opera ? iWidth : screen.availWidth)/2 - w/2;

    var top =  (self.opera ? iHeight : screen.availHeight)/2 - h/2;

    if(self.opera)
		win.resizeTo(w+10, h+26);
	else
		win.resizeTo(w+10, h+75);

    win.moveTo(left, top);

    }

 

    win.onload = winDoc.body.onload; // special for Mozilla

 

    // !!! Important statement: popup onload won't execute without it!

    win.document.close();

    win.focus();

} 

