document.write('<script src="/js/prototype.js" type="text/javascript"></script>');
document.write('<script type="text/javascript" src="/js/datepickercontrol.js"></script>');
if (navigator.platform.toString().toLowerCase().indexOf("linux") != -1){
	document.write('<link type="text/css" rel="stylesheet" href="/js/datepickercontrol_lnx.css">');
}else{
	document.write('<link type="text/css" rel="stylesheet" href="/js/datepickercontrol.css">');
}

function getElementsByClassName(classname,tag) {
	 if(!tag) tag = "*";
	 var anchs =  document.getElementsByTagName(tag);
	 var total_anchs = anchs.length;
	 var regexp = new RegExp('\\b' + classname + '\\b');
	 var class_items = new Array()
	 
	 for(var i=0;i<total_anchs;i++) {
	  var this_item = anchs[i];
	  if(regexp.test(this_item.className)) {
	   class_items.push(this_item);
	  }
	 }
	 return class_items;
	}
	function toggleEl(elem, anc) {
		var t_el = document.getElementById(elem);
		if (t_el.style.display == 'none') {
		for (var i = 0, j = getElementsByClassName('inner_ul').length; i < j; i++) {
		   getElementsByClassName('inner_ul')[i].style.display = 'none';
		}
		for (var i = 0, j = getElementsByClassName('active').length; i < j; i++) {
		   getElementsByClassName('active')[i].className = '';
		}	
		t_el.style.display = 'block';
		}
		else t_el.style.display = 'none';
		anc.className = anc.className == '' ? 'active' : '';
	}
	function getBrowserWidth(){
		if (window.innerWidth){
			return window.innerWidth;}  
		else if (document.documentElement && document.documentElement.clientWidth != 0){
			return document.documentElement.clientWidth;    }
		else if (document.body){return document.body.clientWidth;}      
			return 0;
	}
	function getBrowserHeight(){
		if (window.innerHeight){
			return window.innerHeight;}  
		else if (document.documentElement && document.documentElement.clientHeight != 0){
			return document.documentElement.clientHeight;    }
		else if (document.body){return document.body.clientHeight;}      
			return 0;
	}
	function hideBigLayer(divId){
		var div=document.getElementById(divId);
		var dwrap=document.getElementById('bigImgWrap');
		dwrap.style.visibility='hidden';
		div.style.display='none';
	}
	function animWidth(divId, start, finish){
		var div=document.getElementById(divId);
		var currWidth=start+10;
		div.style.width=currWidth+'px';
		if(currWidth<finish){
			setTimeout(function(){animWidth(divId, currWidth, finish);}, 0.5);
		}else{
			return currWidth;
		}
	}
	function animHeight(divId, start, finish){
		var div=document.getElementById(divId);
		var currHeight=start+10;
		div.style.height=currHeight+'px';
		if(currHeight<finish){
			setTimeout(function(){animHeight(divId, currHeight, finish);}, 0.5);
		}else{
			return currHeight;
		}
	}
	function showBigLayer(divId, w, h, bigimg){
		var l=(getBrowserWidth()/2)-(w/2);
		var t=(getBrowserHeight()/2)-(h/2);
		var div=document.getElementById(divId);
		var dwrap=document.getElementById('bigImgWrap');
		dwrap.style.visibility='visible';
		div.style.left=l.toFixed(0)+'px';
		div.style.top=t.toFixed(0)+'px';
		div.style.display='block';
		animWidth(divId, 10, w);
		animHeight(divId, 10, h);
		div.innerHTML='<img class="galleryBigImg" src="'+bigimg+'" onclick="hideBigLayer(\'bigImg\')">';
	}
	

document.write('<script src="/js/JsHttpRequest/lib/JsHttpRequest/JsHttpRequest.js"></script>');

function getNextPrev(id, cat){
 var req = new JsHttpRequest();
    req.onreadystatechange = function() {
        if (req.readyState == 4) {
            document.getElementById('arrows').innerHTML = req.responseText;
        }
    }
    req.open(null, '/js/nextprev.php', true);
    req.send( { currid: id, currcat: cat } );
}

function reportError(request){
	alert('Ошибка соединения с сервером!\nПроверьте соединение с интернетом или обновите страницу.');
}

// This Script was written by Benjamin Meier, b2m@gmx.de
// The DHTML-function for creating a overlaying div-layer uses parts of the Dynamic Image Mambot, written by Manuel Hirsch
// and Lightbox => core code quirksmode.org
var pg_ffwrong = "red";
var pg_padding = "5";
var pg_filenamewithjs = "1";
var pg_dhtml_border = "gray";
var pg_openjs_background = "white";
var pg_disableclick = "1";
var pg_use_code = "1";
var pg_show_title_in_dhtml = "1";
var pg_show_description_in_dhtml = "1";
var ponygallery_image = "Фото";
var ponygallery_of = "из";
var ponygallery_close = "Закрыть";
var ponygallery_prev = " Назад";
var ponygallery_next = "Дальше";
var ponygallery_press_esc = "(Esc)";
var resizeJsImage = "1";
function opendhtml(id, cat, imgsource, imgtitle, imgtext, imgwidth, imgheight) {
  imgwidth = parseInt(imgwidth);
  imgheight = parseInt(imgheight);
	//var dwrap=document.getElementById('bigImgWrap');
		//dwrap.style.visibility='visible';
	var windowWidth, windowHeight;
	if (self.innerHeight) {	// all except Explorer
		windowWidth = self.innerWidth;
		windowHeight = self.innerHeight;
	} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
		windowWidth = document.documentElement.clientWidth;
		windowHeight = document.documentElement.clientHeight;
	} else if (document.body) { // other Explorers
		windowWidth = document.body.clientWidth;
		windowHeight = document.body.clientHeight;
	}
	//dwrap.style.height=(document.body.scrollHeight > document.body.offsetHeight)?document.body.scrollHeight:document.body.offsetHeight+'px';
	var yScroll, xScroll;

	if (self.pageYOffset) {
		yScroll = self.pageYOffset;
		xScroll = self.pageXOffset;
	} else if (document.documentElement && document.documentElement.scrollTop){	 // Explorer 6 Strict
		yScroll = document.documentElement.scrollTop;
		xScroll = document.documentElement.scrollLeft;
	} else if (document.body) {// all other Explorers
		yScroll = document.body.scrollTop;
		xScroll = document.body.scrollLeft;
	}
	var fullHeight=(document.body.scrollHeight > document.body.offsetHeight)?document.body.scrollHeight:document.body.offsetHeight;
	//Create wrap layer
	var bodyObj = document.getElementsByTagName('BODY')[0];
  if(!document.getElementById("bigImgWrap")) {
    divObjWrapper = document.createElement("div");
    divObjWrapper.setAttribute("id", "bigImgWrap");
    bodyObj.appendChild(divObjWrapper);
  } else {
    divObjWrapper = document.getElementById("bigImgWrap");
  }
  with(divObjWrapper.style){
	position='absolute'; 
	backgroundColor='#000000'; 
	top='0px'; 
	left='0px'; 
	zIndex='90'; 
	width='100%';
	height=fullHeight+'px'; 
	filter='alpha(opacity=60)'; 
	mozOpacity='0.6';	
	opacity='0.6';
	visibility='visible';
  }

  if(resizeJsImage==1) {
   if((imgwidth+3*pg_padding)>windowWidth) {
     imgheight = (imgheight * (windowWidth-2*pg_padding))/imgwidth;
     imgwidth = windowWidth-2*pg_padding;
   }
   if((imgheight+2*pg_padding+80)>windowHeight) {
     imgwidth = (imgwidth * (windowHeight-2*pg_padding-80))/imgheight;
     imgheight = windowHeight-2*pg_padding-80;
   }
  }
  var postop =(windowHeight/2)-(imgheight/2)+yScroll+document.body.style.padding-10;
  var posleft =(windowWidth/2)-(imgwidth/2)+xScroll+document.body.style.padding;
  if(postop >= 30) { 
   postop = postop-30;
  }
 // var bodyObj = document.getElementsByTagName('BODY')[0];
  if(!document.getElementById("pg_photocontainer")) {
    divObjContainer = document.createElement("div");
    divObjContainer.setAttribute("id", "pg_photocontainer");
    bodyObj.appendChild(divObjContainer);
  } else {
    divObjContainer = document.getElementById("pg_photocontainer");
  }

  var closeimg = new Image();
  closeimg.src = "/images/close.gif";

  var dhtmltext, dhtmltext2="";

  divObjContainer.style.display = "block";
  dhtmltext  = "<div class=\"pg_photocontainer\" style=\"top:"+postop+"px; left:"+posleft+"px; position: absolute; display:block;z-index:99999;\">";
  dhtmltext += "<div class=\"photoborder\" style=\"background-color: "+pg_openjs_background+"; padding: "+pg_padding+"px; border: solid 1px "+pg_dhtml_border+";\">";
  dhtmltext += "<img onclick=\"pg_photocontainershut()\" style=\"cursor:pointer;border: solid 1px #000;width:"+imgwidth+"px;height:"+imgheight+"px;\" src=\""+imgsource+"\" alt=\""+imgtitle+"\" width=\""+imgwidth+"px\" height=\""+imgheight+"px\" class=\"pngfile\" \/>";
  dhtmltext += "<div id='arrows' style='text-align:center'></div><img onclick=\"pg_photocontainershut()\" style=\"cursor:pointer;position:absolute;bottom:"+pg_padding+"px;right:"+pg_padding+"px;width:"+closeimg.width+"px;height:"+closeimg.height+"px;\" src=\""+closeimg.src+"\" title=\"Закрыть\" id=\"dhtml_close\" class=\"pngfile\" />";  
  dhtmltext += "<br /><div id=\"pony_dhtml_imgtext\" style=\"color:#000000; margin-top:"+pg_padding+"px;text-align: justify; width:"+imgwidth+"px;\">&nbsp;<br />&nbsp;</div>";
  //dhtmltext += "<\/div></div>";
  divObjContainer.innerHTML = dhtmltext;
     document.getElementById("pony_dhtml_imgtext").style.width2 = document.getElementById("pony_dhtml_imgtext").style.width-document.getElementById("dhtml_close").style.width;
  if (pg_show_title_in_dhtml==1) {
   dhtmltext2 += "<strong>"+imgtitle+"</strong><br />";
  }
  if (pg_show_description_in_dhtml==1) {
   dhtmltext2 += imgtext;
  }
  dhtmltext2 += "<\/div></div>";
  if (dhtmltext2!="") {
   document.getElementById("pony_dhtml_imgtext").innerHTML = dhtmltext2;
  }

  if (pg_disableclick==1) { 
    divObjContainer.oncontextmenu = function(){return false;}
  }
  getNextPrev(id, cat);
}

function pg_photocontainershut() {
  document.getElementById("pg_photocontainer").style.display = "none";
  var dwrap=document.getElementById('bigImgWrap');
		dwrap.style.visibility='hidden';
}