//zoom

function setZoom(img, dir, width, height, margin, zIndex, delay) {
  setTimeout(function() {
    if (img.dir==dir) {
      img.style.width=width;
      img.style.height=height;
      img.style.margin=margin;
      img.style.zIndex=zIndex;
      img.parentNode.parentNode.style.zIndex=zIndex;
    }
  }, delay);
}

function larger(img, width, height) {
  img.dir='rtl';
  now=parseInt(img.style.zIndex);
  for (i=now+1; i<=10; i++) {
    w=(width*(10+i))/20+'px';
    h=(height*(10+i))/20+'px';
    m=(i)+'px 0 0 '+(width*i/40)+'px';
    setZoom(img, 'rtl', w, h, m, i, 20*(i-now));
  }
}

function smaller(img, width, height) {
  img.dir='ltr';
  now=parseInt(img.style.zIndex);
  for (i=now-1; i>=0; i--) {
    w=(width*(10+i))/20+'px';
    h=(height*(10+i))/20+'px';
    m=(i)+'px 0 0 '+(width*i/40)+'px';
    setZoom(img, 'ltr', w, h, m, i, 20*(now-i));
  }
}

// slideshow
function animate(alfa,step){
	div = document.getElementById('slideshow');
	var item = new Array();
	for(c=i=0;i<div.childNodes.length;i++){
		if (div.childNodes[i].tagName=="IMG"){
			item[c] = div.childNodes[i];
			c++;
		}
	}

	last = item[item.length-1];
	next = item[item.length-2];
	last.style.opacity= alfa/100;
	last.style.filter= "progid:DXImageTransform.Microsoft.Alpha(opacity="+alfa+")";
	last.style.filter= "alpha(opacity="+alfa+")";

	if ((alfa-step)>0){
		setTimeout("animate("+(alfa-step)+","+step+");",50);
	}else{
		next.style.opacity= 1;
		next.style.filter= "progid:DXImageTransform.Microsoft.Alpha(opacity=100)";
		next.style.filter= "alpha(opacity=100)";
		tmp = last;
		div.removeChild(last);
		div.insertBefore(tmp,item[0]);
		tmp.style.opacity= 1;
		tmp.style.filter= "progid:DXImageTransform.Microsoft.Alpha(opacity=100)";
		tmp.style.filter= "alpha(opacity=100)";

		setTimeout( "slideSwitch(5000)", 3000 );
	}
}
function slideSwitch(speed){
	div = document.getElementById('slideshow');
	if (div.style.visibility!="visible"){
      div.style.visibility = "visible";
	}
	items = div.getElementsByTagName('img');
	if (items.length>0){
		animate(100,10);
	}
}
setTimeout( "slideSwitch(5000);",6000 );

//

