
document.write("<style>@media screen{ #main-nav {visibility:hidden;overflow:visible;} #main-nav ul ul {position:absolute;} #main-nav {position:absolute;width:90%} #main-nav ul li{background:transparent}}<\/style>");

// defaults
var 
cursor="pointer", 
filterNumber=7,
ie,ie50,ie55,ie6plus,ie8,
col=[], currentcollection,
hiddendesc,trigger; 


var q=new domFunction(function(){init()});

function init() 
{

foldmenu();

if(ie&&document.body.hasAttribute)  {ie8="ie8";}

hiddendesc = getElementsByClass("hidden-description"); 

if(hiddendesc) 
{
for(i=0;i< hiddendesc.length;i++) 
{toggle(hiddendesc[i])};
}

trigger    = getElementsByClass("trigger"); 
if(trigger)
{
for(i=0;i< trigger.length;i++)
{
trigger[i].style.textDecoration="underline";
trigger[i].style.cursor=cursor;
trigger[i].onclick=function(x){return function(){toggle(hiddendesc[x])}}(i);
}}



var x=getElementsByClass("picturesNav","div"); 
if(x){
for (var j=0; j< x.length;j++)
{
var n = parseInt(x[j].id.split("Nav")[1]); 
col[n]=[];
col[n].div=document.getElementById("collection"+n) || null; 
col[n].nav=document.getElementById("picturesNav"+n); 
col[n].pic=document.getElementById("picturesNav"+n).getElementsByTagName("a");
col[n].image    = getElementsByClass("collection-image","img",col[n].div); 
col[n].colldesc = getElementsByClass("colldesc");
if (col[n].colldesc) {for(var f=0;f< col[n].colldesc.length;f++){col[n].colldesc[f].style.display="none"};}
col[n].count=0;
col[n].prev=0;
col[n].filterNumber=7;

//col[n].div.onclick      = function(k) {return function() {np(1,k)}}(n)
col[n].div.onclick      = function(k) {return function() {np(1,k)}}(n);
col[n].div.style.cursor = cursor;

navigationNumbers(n);

for(i=0;i< col[n].pic.length;i++) {col[n].pic[i].onclick = function(k,i) {return function() {changeSrc(k,i);this.blur();return false}}(n,i);}

if(col[n].colldesc&&col[n].image){
if  (col[n].colldesc[0].parentNode==col[n].div ||
     col[n].colldesc[0].parentNode.parentNode==col[n].div ||
     col[n].colldesc[0].parentNode.parentNode.parentNode==col[n].div) 
{for(z=0;z< col[n].colldesc.length;z++) {col[n].colldesc[z].style.position="absolute";col[n].colldesc[z].style.display="none"} }
}

//развилка для картинки

if((col[n].image&&!ie)||(col[n].image&&ie8)){
if (/middle/.test(col[n].image[0].className))      {col[n].image[0].style.top='50%';col[n].image[0].style.marginTop=-(col[n].image[0].height/2)+'px'}
if (!/left|right/.test(col[n].image[0].className)) {col[n].image[0].style.left='50%';col[n].image[0].style.marginLeft=-(col[n].image[0].width/2)+'px'}
}
/* somehow the addition of these events makes right-floated collection divs with margin jump in IE */

//changeSrc(n,0);

}
}

}

//////////////////////////////////////////////////////////////////////////

function foldmenu()
{
var m=document.getElementById("main-nav");
var ul=m.getElementsByTagName("ul")[0].getElementsByTagName("ul");
for(i=0;i< ul.length;i++)
{
ul[i].parentNode.onmouseover=function(k) {return function() {ul[k].className="visible";}}(i);
ul[i].parentNode.onmouseout=function(k) {return function() {ul[k].className="hidden";}}(i);
ul[i].onmouseout=function(k) {return function() {ul[k].className="hidden";}}(i);
ul[i].className="hidden";
}
m.style.visibility="visible";
}

//////////////////////////////////////////////////////////////////////////




function changeSrc(n,i) //////////////////////////////////////////////////////
{
var x=null;
if (col[n].div.filters&&col[n].filterNumber!=9&&col[n].image) {x=col[n].image?col[n].image[0]:col[n].div} 
if (ie6plus&&col[n].filterNumber!=9&&col[n].image)  {x.style.filter=dFilters[col[n].filterNumber];x.filters[0].apply()}

col[n].image[0].src=col[n].pic[i];

if (ie6plus&&col[n].filterNumber!=9&&col[n].image)  {x.filters[0].play()};
if (window.opera) {document.documentElement.className=document.documentElement.className} //for Opera

markNav(n,i);

if (col[n].colldesc)
{
if	(document.getElementById("colldesc"+n+col[n].count)&&col[n].count!=i)
	{document.getElementById("colldesc"+n+col[n].count).style.display="none";}
if	(document.getElementById("colldesc"+n+col[n].prev)&&col[n].prev!=i)
	{document.getElementById("colldesc"+n+col[n].prev).style.display="none";}
if	(document.getElementById("colldesc"+n+i))
	{document.getElementById("colldesc"+n+i).style.display="block";}
}

col[n].count=i;

currentcollection=n;

}//////////////////////////////////////////////////////////////////////////





///////////////////// mark the current image ////////////////////////////
function markNav(n,i)
{
col[n].pic[col[n].count].childNodes[0].className='';
col[n].pic[col[n].prev].childNodes[0].className='';
col[n].pic[i].childNodes[0].className='selectImage';
if(col[n].numbers[2])
{
col[n].numbers[col[n].count].className='linkedNumber';
col[n].numbers[col[n].prev].className='linkedNumber';
col[n].numbers[i].className='selectNumber';
}
}
//////////////////////////////////////////////////////////////////////////



///////////////////// Create numbered navigation /////////////////////////
function navigationNumbers(n)
{
col[n].numbers=[];
var numbersNav = document.getElementById("numbersNav"+n);
if(numbersNav)
{
for(i=0;i< col[n].pic.length;i++)
{
var t = document.createElement("span");
    t.className="linkedNumber";
    t.title="фото "+(i+1);
    t.onclick = function(x) {return function() {changeSrc(n,x)}}(i);
    t.appendChild(document.createTextNode(i+1));
    t.style.cursor=cursor;
document.getElementById("numbersNav"+n).appendChild(t);
document.getElementById("numbersNav"+n).appendChild(document.createTextNode(" "));
col[n].numbers[i]=t;
}
}
}//////////////////////////////////////////////////////////////////////////



/////////////////// [назад][дальше] /////////////////////////////////////
function np(kuda,n)
{
if(col[n].div.id=="collection-merged") {n=currentcollection;}
col[n].prev=col[n].count; 
col[n].count=col[n].count+kuda;
if (col[n].count==col[n].pic.length) {col[n].count=0;}    //ограничиваем верхний предел
if (col[n].count==-1) {col[n].count=col[n].pic.length-1;}; //ограничиваем нижний предел 
changeSrc(n,col[n].count);                              //передаем параметры в функцию смены картинок
}////////////////////////////////////////////////////////////////////////
















function toggle(el) {el.style.display = el.style.display=="none" ? "block":"none";}


///////////////////////////// getElementsByClassName ///////////////////////////////////////
/*
Written by Jonathan Snook, http://www.snook.ca/jonathan
Add-ons by Robert Nyman, http://www.robertnyman.com
USAGE:
getElementsByClassName(document, "a", "info-links"); 
getElementsByClassName(document.getElementById("container"), "div", "col");
getElementsByClassName(document, "*", "click-me");
getElementsByClassName(document.getElementById("container"), "div", ["col", "left"]); // both classes
*/

function getElementsByClassName(oElm,strTagName,oClassNames)
{
var arrElements=(strTagName=="*" && oElm.all)?oElm.all:oElm.getElementsByTagName(strTagName); // ie 5+
var arrReturnElements   = [];
var arrRegExpClassNames = [];
if(typeof oClassNames == "object"){for(var i=0; i< oClassNames.length;i++){arrRegExpClassNames.push(new RegExp("(^|\\s)"+oClassNames[i].replace(/\-/g, "\\-")+"(\\s|$)"));}}
else{arrRegExpClassNames.push(new RegExp("(^|\\s)" + oClassNames.replace(/\-/g, "\\-") + "(\\s|$)"));}
var oElement,bMatchesAll;
for(var j=0; j< arrElements.length; j++)
{
oElement = arrElements[j];bMatchesAll = true;
for(var k=0; k< arrRegExpClassNames.length; k++){if(!arrRegExpClassNames[k].test(oElement.className)){bMatchesAll=false;break;}}
if(bMatchesAll){arrReturnElements.push(oElement);}
}
if(arrReturnElements.length==0) arrReturnElements=null;
return (arrReturnElements)
}

////////////////////////////////////////////////////////////////////////////////






///////////////////////////// getElementsByClass by Yuri Shoroxof ///////////////////////////////////////

function getElementsByClass(name,tag,el)
{
var scope=el||document;
var allElements=tag ? allElements=scope.getElementsByTagName(tag):scope.all||scope.getElementsByTagName("*");
var matchedElements=[];
for (var i=0, j=0; i< allElements.length; i++)
{
if(allElements[i].className!='') {
if (/ /.test(allElements[i].className)) {names=allElements[i].className.split(" ");for(var k=0;k< names.length;k++) {if(names[k]==name) {matchedElements[j]=allElements[i];j++}}}
else if(allElements[i].className==name) {matchedElements[j]=allElements[i];j++}
}
}
if(matchedElements.length>0) {return matchedElements} else {return null};
}

////////////////////////////////////////////////////////////////////////////////






//////////////////////////////////////////////////////////////////////////////////
/* DF1.1 :: domFunction 
   DOM scripting by brothercake -- http://www.brothercake.com/
   GNU Lesser General Public License -- http://www.gnu.org/licenses/lgpl.html
******************************************************/
/*USAGE:
var anything=new domFunction(function() 
{
yourFunctionToExecuteOnDocumentLoaded(params);
});
*/


function domFunction(f, a)
{
var n = 0; //initialise the counter
var t = setInterval(function() { //start the timer

                  //continue flag indicates whether to continue to the next iteration
var c = true;     //assume that we are going unless specified otherwise
n++;              //increase the counter
	
//if DOM methods are supported, and the body element exists
//(using a double-check including document.body, for the benefit of older moz builds [eg ns7.1] 
//in which getElementsByTagName('body')[0] is undefined, unless this script is in the body section)

if(typeof document.getElementsByTagName != 'undefined' && (document.getElementsByTagName('body')[0] != null || document.body != null))
{
c = false;                //set the continue flag to false because other things being equal, we're not going to continue
if(typeof a=='object')    //but ... if the arguments object is there
{
for(var i in a) //iterate through the object
{
/* if its value is "id" and the element with the given ID doesn't exist 
   or its value is "tag" and the specified collection has no members */
if((a[i]=='id' && document.getElementById(i)==null)||(a[i]=='tag' && document.getElementsByTagName(i).length < 1)) 
{ 
c = true;  /*set the continue flag back to true because a specific element or collection doesn't exist*/
break;     /*no need to finish this loop as long a single element is found*/
}
}
}
if(!c) {f();clearInterval(t);} /*if we're not continuing we can call the argument function and clear the timer*/
}
/*if the timer has reached 60 (so timeout after 15 seconds)
in practice, I've never seen this take longer than 7 iterations in kde3 
in second place was IE6, which takes 2 or 3 iterations roughly 5% of the time */
if(n >= 10){clearInterval(t);}  //clear the timer
},750); // gotta be careful with this parameter - very often IE compalins it hasn't finished loading yet
};
////////////////////////////////////////////////////////////////////////////////////


/* conditional compilation, known since IE4,  for details see 
http://www.javascriptkit.com/javatutors/conditionalcompile.shtml */ 
/*@cc_on                         var ie="ie" ;cursor="hand";
@if   (@_jscript_version >= 5.6) var ie6plus="ie6plus";
var dFilters=[]; 
dFilters[0]='progid:DXImageTransform.Microsoft.Pixelate(MaxSquare=10)';
dFilters[1]='progid:DXImageTransform.Microsoft.Barn(motion=out,orientation=vertical)';
dFilters[2]='progid:DXImageTransform.Microsoft.Barn(motion=out,orientation=horizontal)';
dFilters[3]='progid:DXImageTransform.Microsoft.GradientWipe(GradientSize=0,wipestyle=0)';
dFilters[4]='progid:DXImageTransform.Microsoft.GradientWipe(GradientSize=0,wipestyle=0,motion=reverse)';
dFilters[5]='progid:DXImageTransform.Microsoft.Slide(slidestyle=PUSH,Bands=1)'; //options:PUSH,HIDE,SWAP
dFilters[6]='progid:DXImageTransform.Microsoft.Slide(slidestyle=SWAP,Bands=1)';
dFilters[7]='progid:DXImageTransform.Microsoft.Fade(Overlap=1)';
dFilters[8]='progid:DXImageTransform.Microsoft.Iris(irisstyle=STAR,motion=out)';
dFilters[9]='none';
@elif (@_jscript_version >= 5.5) var ie55="ie55";
@elif (@_jscript_version >= 5.0) var ie50="ie50";
@end
@*/
