﻿function ChangeA(aid,pos,bphwidth,bphheight,bphsrc,bphtitle,cont) {
	CurrentPos=pos-1;
	document.getElementById(aid).onclick=function(){OpenBigPhoto(bphwidth,bphheight,bphsrc,bphtitle);}
	document.getElementById(aid).innerHTML=cont;  
	}
function ChangePic(imgName,imgFile,imgAlt) {
	document.images[imgName].src=imgFile;	
	if (imgAlt) document.images[imgName].alt=imgAlt;
	}
function PrevPhoto(){
if (CurrentPos<=0){
    CurrentPos=0;    
    }
else{
CurrentPos=CurrentPos-1;
ChangePic('mainpic',Photos[CurrentPos].imgSrc,Photos[CurrentPos].title);
ChangeA('opnpht',CurrentPos+1,Photos[CurrentPos].bimgWidth,Photos[CurrentPos].bimgHeight,Photos[CurrentPos].bimgSrc,Photos[CurrentPos].title,Photos[CurrentPos].title);
}
}
function NextPhoto(){
if (CurrentPos>=Photos.length-1){
    CurrentPos=Photos.length-1;    
}
else{
CurrentPos=CurrentPos+1;
ChangePic('mainpic',Photos[CurrentPos].imgSrc,Photos[CurrentPos].title);
ChangeA('opnpht',CurrentPos+1,Photos[CurrentPos].bimgWidth,Photos[CurrentPos].bimgHeight,Photos[CurrentPos].bimgSrc,Photos[CurrentPos].title,Photos[CurrentPos].title);
}
}	
function ShowSelect(divid) {
	if (document.layers) {
		if (document.layers[divid]) document.layers[divid].display="";
	} else if (document.all) {
		if (document.all[divid]) document.all[divid].style.display="";
		} 
	}

function HideSelect(divid) {
	if (document.layers) {
		if (document.layers[divid]) document.layers[divid].display="none";
	} else if (document.all) {
		if (document.all[divid]) document.all[divid].style.display="none";
		} 
	}
	
	
function ShowMenu(divid) {
		if (document.getElementById(divid)) document.getElementById(divid).style.display="";
}
	
function HideMenu(divid) {
		if (document.getElementById(divid)) document.getElementById(divid).style.display="none";
	}
	
	
function getForIeX(El) {
	  var X = 0;
	  
	  do { 
		X += El.offsetLeft;
		
		} while ((El = El.offsetParent) != null);
	  return X;
	}
	
function show_map(divid)
	{
		if (document.getElementById(divid)){
			if (document.getElementById(divid).style.display=='none'){
			document.getElementById(divid).style.display='';			
			}else{
			document.getElementById(divid).style.display='none';			
			}
		}
	}
	
function show(divid,imgName,El)
	{
		if (document.getElementById(divid).style.display=='none'){
		document.getElementById(divid).style.display='';
		ChangePic(imgName,'/images/minus.gif');
		document.getElementById(El).className='CatHeader_a';
		}else{
		document.getElementById(divid).style.display='none';
		ChangePic(imgName,'/images/plus.gif');
		document.getElementById(El).className='CatHeader';
		}	
	}
mapDivs=Array();
function showall(templ)
	{
		
		for(i=0;i < mapDivs.length;i++){
		if (document.getElementById('type_'+mapDivs[i]).style.display=='none')
		  if(templ=='sitemap') 
		    show_map('type_'+mapDivs[i]);		    
		    else show('type_'+mapDivs[i],'folder_'+mapDivs[i],'sm_'+mapDivs[i]);
		}
	}
function hideall(templ)
	{
	for(i=0;i < mapDivs.length;i++){
		if (document.getElementById('type_'+mapDivs[i]).style.display=='')
		  if(templ=='sitemap') 
		    show_map('type_'+mapDivs[i]);		    
		    else show('type_'+mapDivs[i],'folder_'+mapDivs[i],'sm_'+mapDivs[i]);
		}
	}
	
function ShowFilterSelect(divid) {
		if (document.getElementById(divid)) 
			document.getElementById(divid).style.visibility="visible";
	};

function HideFilterSelect(divid) {
	if (document.getElementById(divid)) 
			document.getElementById(divid).style.visibility="hidden";
	};

function ChangeSelector(imgName, FieldName) {
	SelectorImages= new Array();
	SelectorImages[0]='/images/checkbox_a.gif';
	SelectorImages[1]='/images/checkbox.gif';
	
	state=!document.getElementById(FieldName).checked;	
	
	if (state)
		document.getElementById(FieldName).checked=true;
	else
		document.getElementById(FieldName).checked=false;
	
		if (document.images[imgName])
			document.images[imgName].src=SelectorImages[state?0:1];
	//window.status=document.getElementById(FieldName).value;
}
function OpenBigPhoto(w,h,img_src,tit){
txt="<html><head><meta http-equiv='Content-Type' content='text/html; charset=UFT-8'/><title>"+tit+"</title><link rel=stylesheet type='text/css' href='/style.css' title='style'></head><body leftmargin='20' topmargin='10' rightmargin='20' bottommargin='20' marginwidth='20' marginheight='10' bgcolor='#ffffff'><table cellpadding='0' cellspacing='0' border='0'><tr><td><img src='"+img_src+"' alt='' border='0' width='"+w+"' height='"+h+"' vspace='10'></td></tr><tr><td align='right'><a href='javascript:window.close();'>закрыть окно</a></td></tr></table></body></html>";
w=parseInt(w)+40;
h=parseInt(h)+60;
win=window.open('','win','width='+w+',height='+h+',scrollbars=0,resizable=0');
win.document.write(txt);
win.document.close(txt);
}	