// all
function $(x){return document.getElementById(x);}
function $T(x){return document.getElementsByTagName(x);}
// system
function x(m){with(document.form){rzm.value=m;submit();}return;}
function sp(ch){var k="k"+ch.name,c="c"+ch.name,i="i"+ch.name,e=document.form.elements;e[k].value=(ch.checked)?'1':'0';e[i].value=parseFloat(e[k].value)*parseFloat(e[c].value);sc();return;}
function sc(t){var sum_all=0,e=document.form.elements;
for(var i=0;i<e.length;i++){
  if(e[i].name.substring(0,1)=='c' && i<e.length-3 && e[i+2].name.substring(0,1)=='k' && e[i+3].name.substring(0,1)=='i'){
    var s=parseFloat(e[i].value)*parseFloat(e[i+2].value);
    if(s>0){e[i+3].value=s;sum_all+=s;e[i+1].checked=true;}else{e[i+2].value=e[i+3].value=0;e[i+1].checked=false;}
  }
}
document.form.itogo.value=sum_all;
return;
}
// tabs
var tabIDs=new Object();
function tabsIni(){for(var i=0;i<arguments.length;i++){var id=arguments[i],li=$(id).getElementsByTagName("li"),aa=null;for(var x=0;x<li.length;x++){var a=li[x].getElementsByTagName("a")[0],rel=a.getAttribute("rel");if(rel){if(typeof tabIDs[id]=="undefined")tabIDs[id]=new Array();tabIDs[id][tabIDs[id].length]=rel;a.onclick=function(){tabsPut(this);return false;};if($(rel))$(rel).style.display=(li[x].className=="sel")?"block":"none";}}}}
function tabsPut(a){var id=a.parentNode.parentNode.id;if(!id){id=a.parentNode.parentNode.parentNode.id;}var li=$(id).getElementsByTagName("li");for(var x=0;x<li.length;x++){li[x].className="";if(typeof tabIDs[id][x]!="undefined"){$(tabIDs[id][x]).style.display="none";}}a.parentNode.className="sel";$(a.getAttribute("rel")).style.display="block";}
// pops
var popsStart,popsMaxW=0,popsMaxH=0,popsOut='',popsStartH=0,popsStartTop=0;
function off(x){$(x).style.display='none';$('whitescr').style.display='none';}

function HinW(w,h,d){ if(w)return parseInt(h/w*d); else return 0; }
function popsIni(x){
  popsStartH=document.body.clientHeight;
  popsStartTop=document.body.scrollTop;
  var z=$(x).style;
  if(z.display!='none')off(x);
  z.display='block';
  with($('whitescr').style) {
    var v=0.8;
    height=document.body.offsetHeight;
		backgroundColor='#606060';
	  if(typeof MozOpacity!="undefined")MozOpacity=v;
  	else if(typeof opacity!="undefined")opacity=v;
	  else filter="alpha(opacity="+v*100+")";
		display='block';
	}
  popsMaxW=$('blimg').offsetWidth;popsMaxH=$('blimg').offsetHeight;
  popsMaxW=popsMaxW+100;
  popsMaxH=popsMaxH+HinW(popsMaxW,popsMaxH,100);
  with($(x).style){left=width='0px';top='0px';height='0px';}
  popsStart=setInterval("popsPut('"+x+"')",1);
}

function popsPut(x){
var step=document.all?60:60;
var dw=parseInt(popsMaxW/step),dh=HinW(popsMaxW/2,popsMaxH/2,dw);
c1=$(x).style,c1w=parseInt(c1.width),c1h=parseInt(c1.height);
if(c1w<popsMaxW-dw*2){
  c1.top=parseInt(popsStartH/2-popsMaxH/2)+popsStartTop+"px";
  c1.left=parseInt(document.body.clientWidth/2-c1w/2-dw)+"px";
  c1.width=(c1w+dw*2)+"px";c1.height=(c1h+dh*2+20)+"px";
}
else clearInterval(popsStart);
}

function popsIni2(x,co,text){
  var x2=$('blimg'),x3=$('bltext');
  x2.src='/imggallery3/'+rzm+'/'+co;
  x3.innerHTML=text;
  popsStart,popsMaxW=0,popsMaxH=0,popsOut='';
  setTimeout(function(){ popsIni(x); },0);
}
//
var gradualFader={}
gradualFader.baseopacity=0.1
gradualFader.increment=0.1
gradualFader.setopacity=function(obj, v){
  var t=obj;
  if(t&&typeof t.style.MozOpacity!="undefined")t.style.MozOpacity=v;
  else if(t&&typeof t.style.opacity!="undefined")t.style.opacity=v;
  else t.style.filter="alpha(opacity="+v*100+")";

  t.currentopacity=v;
}
gradualFader.fadeupdown=function(obj, d){
  var t=obj;
  var f=(d=="fadeup")?this.increment:-this.increment;
  if(t&&(d=="fadeup"&&t.currentopacity<1||d=="fadedown"&&t.currentopacity>this.baseopacity)){
    gradualFader.setopacity(obj,t.currentopacity+f);
    window["opacityfader"+obj._fadeorder]=setTimeout(function(){gradualFader.fadeupdown(obj,d)},50);
  }
}
gradualFader.clearTimer=function(obj){if(typeof window["opacityfader"+obj._fadeorder]!="undefined")clearTimeout(window["opacityfader"+obj._fadeorder]);}
function view_gal(co,co2){
  var x=$('blck'),x2=$('blck2');
  x2.style.backgroundImage='';
  setTimeout(function(){
    x2.style.backgroundImage='url(/imggallery3/'+rzm+'/'+co+')';
    x2.style.backgroundPosition='center center';
    x2.style.backgroundRepeat='no-repeat';
  },500);
  x._fadeorder=1;
  gradualFader.setopacity(x,0.5);
  gradualFader.clearTimer(x);
  gradualFader.fadeupdown(x,"fadeup");
  x.style.backgroundImage='url(/imggallery3/'+rzm+'/'+co+')';
  x.style.backgroundPosition='center center';
  x.style.backgroundRepeat='no-repeat';
  if(!co2){popsOut=co;}
}
function view_out(){view_gal(popsOut);}
var ini_=0;
function test(z0) {
	if(!ini_){
  	var gals=$T('img');
		for(var j=0;j<gals.length;j++){
			var rel=gals[j].getAttribute("image");
			if(rel){
				gals[j].onmouseover=(function(rel){return function(){view_gal(rel,1);}})(rel);
				gals[j].onmouseout=view_out;
			}
		}
		ini_=1;
	}
  if(x_ind.length){
    if(z0>=x_ind.length-1)z0=0; 
    view_gal(x_ind[z0]); z0++;
    setTimeout(function(){test(z0);},5000); 
  }
}


