function SlideShow(slideList, image, image1, speed, name, id, slidelink, lang)          

{

  this.id=id;
  this.lang=lang;
  this.slidelink=slidelink;

  this.slideList = slideList;

  this.image = image;

  this.image1 = image1;

  this.speed = speed;

  this.name = name;

  this.current = 0;

  this.timer = 0;


this.slideimageArray = new Array(slideList.length);

  for(var i=0; i<slideList.length; i++)

  {

    this.slideimageArray[i] = new Image;

    this.slideimageArray[i].src = "/dataimages/"+slideList[i];

  }
//alert (this.slideimageArray[1].src);
//this.slideList1= this.slideimageArray[i];

}

SlideShow.prototype.play = SlideShow_play;  
SlideShow.prototype.stop = SlideShow_play;  


function SlideShow_play(status){

  with(this)

  {
if (status==1)
{
    if(current++ == slideList.length-1) current = 0;

//    switchImage(image, image1, slideList[current]);


switchImage(image, image1, slideimageArray[current].src);


	var elem = document.getElementById(slidelink);
	elem.href="/"+lang+"/gallery/"+id+"/"+current;
}
    clearTimeout(timer);

    timer = setTimeout(name+'.play('+ status +')', speed);

  }

}


function switchImageone(imgName, imgSrc, idsname, idsnums, idcur) {

for (var i = 1; i<=idsnums; i++) {
var	newname=idsname+i;
var elem = document.getElementById(newname);
if (i==idcur)
{
elem.src="/images/box_1.gif";
} else {
elem.src="/images/box_0.gif";
}

}
	  document.images[imgName].src = "/dataimages/"+imgSrc;
	  fadeOpacity.back(imgName);
}

function switchImageoneback (imgName) {
	  fadeOpacity(imgName, 'opacityRule1');
}

	function slidechanepos1(imgName,imgName1){
				document.images[imgName].style.zIndex=3;
			document.images[imgName1].style.zIndex=2;
	}

	function slidechanepos3(imgName1,imgSrc){
	//	document.images[imgName1].src = imgSrc;
	eval("document."+imgName1+".src='"+imgSrc+"'");
	}

	function slidechanepos2(imgName,imgName1){	
		document.images[imgName].style.opacity = 0.00;		
				document.images[imgName].style.zIndex=2;
			document.images[imgName1].style.zIndex=3;
	}

	function slide1dotransff(imgName,imgName1,op){	
		op=op-0.05;
if(op<(0.00)){op=0.00;}	
		if(op>(0.00)) {
			document.images[imgName].style.opacity = op;
			setTimeout("slide1dotransff('" + imgName + "','" + imgName1 + "','" + op + "')",30);
			} 
		}

function changeport (elemetid) {
for (var i = 1; i<=6; i++) {
var	newname="portshow"+i;
if (i==elemetid)
{
setTimeout("fadein('" + newname + "',0)",350);

	var	newname="hider";
	var elem = document.getElementById(newname);
	elem.style.display="block";

setTimeout("fadeout('hider',1)",349);
} else {
var elem = document.getElementById(newname);
if (elem.style.display=="block")
{
	timerss=50+i;
	setTimeout("fadeout('" + newname + "',1)",timerss);
}

}
}
setTimeout("fadein('hider',0)",1);
setTimeout("hideall('" + elemetid + "')",350);
setTimeout("setopto1('" + elemetid + "')",650);

//elem.style.display="none";
}

function hideall(noid) {
	for (var i = 1; i<=6; i++) 
	{
		if (i!=noid)
		{
			var	newname="portshow"+i;
			var elem = document.getElementById(newname);
			elem.style.display="none";
	}
}
}



function setopto1(i) {
		var	newname="hider";
	var elem = document.getElementById(newname);
	elem.style.display="none";

		var	newname="portshow"+i;
		setElementOpacity(document.getElementById(newname), 1);
		}

function fadein (newname, op) {
	if (op==0) 	{
		var elem = document.getElementById(newname);
		elem.style.display="block";
	}

op=op*10/10+0.1;
//op=Math.round(op*10)/10;
//op = Math.round(( op+0.1 )*10)/10;
//alert (op);
	if (op<=1) {
		setElementOpacity(document.getElementById(newname), op);
		setTimeout("fadein('" + newname + "', '" + op + "')",30);
	}
}

function fadeout (newname, op) {
op = Math.round(( op-0.1 )*10)/10;
	//alert (newname);
	if (op>=0) {
		setElementOpacity(document.getElementById(newname), op);
		setTimeout("fadeout('" + newname + "', '" + op + "')",30);
	}
}

function switchImage(imgName, imgName1, imgSrc) 

{

  if (document.images)

  {

    if (imgSrc != "none")

    {

uagent = window.navigator.userAgent.toLowerCase();
IEB=(uagent.indexOf('msie') != -1)?true:false;
	

if(IEB==true){
		oldimg=document.images[imgName1].src;
	eval("document."+imgName+".src='"+oldimg+"'");
	setTimeout("slidechanepos1('" + imgName + "','" + imgName1 + "')",100);
	setTimeout("slidechanepos3('" + imgName1 + "','" + imgSrc + "')",200);
	setTimeout("slidechanepos2('" + imgName + "','" + imgName1 + "')",2100);
	document.images[imgName].filters[0].play();	

	//oldimg=document.images[imgName1].src;
	//document.images[imgName].src = oldimg;
	//document.images[imgName1].src = imgSrc;
	//document.images[imgName].filters[0].play();	
	} else {

setTimeout("slidechanepos1('" + imgName + "','" + imgName1 + "')",100);
setTimeout("slidechanepos3('" + imgName1 + "','" + imgSrc + "')",200);

oldimg=document.images[imgName1].src;
//document.images[imgName].src = oldimg;
eval("document."+imgName+".src='"+oldimg+"'");
document.images[imgName].style.opacity = 1.00;	

setTimeout("slidechanepos2('" + imgName + "','" + imgName1 + "')",2100);

op=1.00;
setTimeout("slide1dotransff('" + imgName + "','" + imgName1 + "','" + op + "')",1000);
}

    }

  }

}


function setElementOpacity(oElem, nOpacity)
{

//	alert(nOpacity);
	var p = getOpacityProperty();
	(setElementOpacity = p=="filter"?new Function('oElem', 'nOpacity', 'nOpacity *= 100;	var oAlpha = oElem.filters["DXImageTransform.Microsoft.alpha"] || oElem.filters.alpha;	if (oAlpha) oAlpha.opacity = nOpacity; else oElem.style.filter += "progid:DXImageTransform.Microsoft.Alpha(opacity="+nOpacity+")";'):p?new Function('oElem', 'nOpacity', 'oElem.style.'+p+' = nOpacity;'):new Function)(oElem, nOpacity);
}

function getOpacityProperty()
{
	var p;
	if (typeof document.body.style.opacity == 'string') p = 'opacity';
	else if (typeof document.body.style.MozOpacity == 'string') p =  'MozOpacity';
	else if (typeof document.body.style.KhtmlOpacity == 'string') p =  'KhtmlOpacity';
	else if (document.body.filters && navigator.appVersion.match(/MSIE ([\d.]+);/)[1]>=5.5) p =  'filter';
	
	return (getOpacityProperty = new Function("return '"+p+"';"))();
}

function fadeOpacity(sElemId, sRuleName, bBackward)
{
	var elem = document.getElementById(sElemId);
	if (!elem || !getOpacityProperty() || !fadeOpacity.aRules[sRuleName]) return;
	
	var rule = fadeOpacity.aRules[sRuleName];
	var nOpacity = rule.nStartOpacity;
	
	if (fadeOpacity.aProc[sElemId]) {clearInterval(fadeOpacity.aProc[sElemId].tId); nOpacity = fadeOpacity.aProc[sElemId].nOpacity;}
	if ((nOpacity==rule.nStartOpacity && bBackward) || (nOpacity==rule.nFinishOpacity && !bBackward)) return;

	fadeOpacity.aProc[sElemId] = {'nOpacity':nOpacity, 'tId':setInterval('fadeOpacity.run("'+sElemId+'")', fadeOpacity.aRules[sRuleName].nDalay), 'sRuleName':sRuleName, 'bBackward':Boolean(bBackward)};
}

fadeOpacity.addRule = function(sRuleName, nStartOpacity, nFinishOpacity, nDalay){fadeOpacity.aRules[sRuleName]={'nStartOpacity':nStartOpacity, 'nFinishOpacity':nFinishOpacity, 'nDalay':(nDalay || 30),'nDSign':(nFinishOpacity-nStartOpacity > 0?1:-1)};};

fadeOpacity.back = function(sElemId){fadeOpacity(sElemId,fadeOpacity.aProc[sElemId].sRuleName,true);};

fadeOpacity.run = function(sElemId)
{
	var proc = fadeOpacity.aProc[sElemId];
	var rule = fadeOpacity.aRules[proc.sRuleName];
	
	proc.nOpacity = Math.round(( proc.nOpacity + .1*rule.nDSign*(proc.bBackward?-1:1) )*10)/10;
	setElementOpacity(document.getElementById(sElemId), proc.nOpacity);
	
	if (proc.nOpacity==rule.nStartOpacity || proc.nOpacity==rule.nFinishOpacity) clearInterval(fadeOpacity.aProc[sElemId].tId);
}
fadeOpacity.aProc = {};
fadeOpacity.aRules = {};


function simplePreload()

{ 
//alert ('загружены');
  var args = simplePreload.arguments;

  document.imageArray = new Array(args.length);

  for(var i=0; i<args.length; i++)

  {

    document.imageArray[i] = new Image;

    document.imageArray[i].src = "/dataimages/"+args[i];

  }

}


function openWinCentered(loc, winname, widthh, heightt, params)
{
    var tp = Math.ceil((screen.height - heightt) / 2);
    var lf = Math.ceil((screen.width - widthh) / 2);
    if (params.length > 0)
	    params = "," + params;

    var win = window.open(loc, winname, "width=" + widthh + ",height=" + heightt + ",top=" + tp + ",left=" + lf + params);
    win.focus();
    return win;
}

function openwindow(imageName,imageWidth,imageHeight) {
	imageHeightWin=imageHeight;
	posLeft=screen.width/2-imageWidth/2;
	posTop=screen.height/2-imageHeight/2;
	newWindow = window.open("","newWindow","width="+imageWidth+",height="+imageHeightWin+",left="+posLeft+",top="+posTop);
	newWindow.document.open();
	newWindow.document.write('<html><title>R-vision</title><body bgcolor="#FFFFFF" leftmargin="0" topmargin="0" marginheight="0" marginwidth="0" onBlur="self.close()">');
	newWindow.document.write('<div style="position: absolute;"><img src=/images/nocolor.gif width='+imageWidth+' height='+imageHeight+' ></div>');
	newWindow.document.write('<img src='+imageName+' width='+imageWidth+' height='+imageHeight+' >');
	newWindow.document.write('<br><center><a href="#">закрыть окно</a></center></body></html>');
	newWindow.document.close();
	newWindow.focus();
}
