
function SelPhoto(pNum, pPageId) {
	if(document.getElementById("img1"+pPageId)) {
		document.getElementById("img1"+pPageId).style.display = "none";
	}
	if(document.getElementById("img2"+pPageId)) {
		document.getElementById("img2"+pPageId).style.display = "none";
	}
	if(document.getElementById("img3"+pPageId)) {
		document.getElementById("img3"+pPageId).style.display = "none";
	}
	
	if(document.getElementById("img"+pNum+pPageId)) {
		document.getElementById("img"+pNum+pPageId).style.display = "";
	}
} 



window.ints = null;

var childrenArray = new Array();
var step;
var iterations = 0;
var countsteps =0;

function Scroll(id, speed, steps) {
	childrenArray = document.getElementById(id).getElementsByTagName("A");	
	step=steps;
	window.ints = setInterval(move, speed);
}

function move()	{
		var re = /px/g;
		var leftN=0;
		var l = childrenArray.length;
		
		for (var i = 0; i < l; i++) {
			leftN=childrenArray[i].style.left;
			leftN=parseInt(leftN.replace(re, ""));
			childrenArray[i].style.left=leftN-step+"px";
			if(i==l-1){
				countsteps = countsteps + step;
			}
			if(countsteps >= 134)
			{
				countsteps = 0;
				childrenArray[iterations].style.left = 10 + 134 * iterations + 134 * (l-1-iterations) + "px";
				iterations = iterations + 1;
				if(iterations == l)
				{
					iterations = 0;
				}
				
			}
		}		
	}
	
	
$.fn.start = function() {
	var next = $(this).next();
	if(!next.attr("src")) {
		next = $('#img_show img:first');
	}
	
	$(this).fadeOut(800, function() {
		$(this).removeClass("cur");
		next.addClass("cur");
	});
	next.fadeIn(800);
}
	
$(document).ready(function() {
	Scroll('slideshow', 25, 1);
	
	var gis = new Image();
	gis.onload = function() {
		$("#gismeteo").attr("src", this.src);
	}
	gis.src = "http://informer.gismeteo.ru/new/4313-47.GIF";
	
	setInterval("$('#img_show img.cur').start()", 4000);
	
	if($.fn.fancybox) {
		$("a[rel='fbox']").fancybox({
			'transitionIn'		: 'none',
			'transitionOut'	: 'none',
			'overlayColor'		: '#000',
			'overlayOpacity'	: 0.6,
			'titlePosition' 	: 'over',
			'titleFormat'		: function(title, currentArray, currentIndex, currentOpts) {
				if(currentArray.length > 1) {
					return '<span id="fancybox-title-over">' + (currentIndex + 1) + ' / ' + currentArray.length + (title.length ? ' &nbsp; ' + title : '') + '</span>';
				} else {
					return (title.length ? '<span id="fancybox-title-over">' + title + '</span>' : '');
				}
			}
		});
	}
});




