function initBgSlides(){
	var count = $("#imgs div.imgBg").size();
	var cur=0;
	
	if(count > 1){
		$("#imgs div.imgBg").css("opacity", "0");
		$("#imgs div.imgBg").css("display", "block");
		showCurPhoto();
	}
	else{
		$("#imgs div.imgBg").css("opacity", "1");
		$("#imgs div.imgBg").css("display", "block");
	}
	
	function showCurPhoto(){
		$("#imgs div.imgBg").eq(cur).animate({opacity: "1"}, 1000);
		setTimeout(doHide, 3000);
	}
	function doHide(){
		$("#imgs div.imgBg").eq(cur).animate({opacity: "0"}, 1000);
		setTimeout(function(){
			if(cur < count - 1){
				cur++;	
			}
			else{
				cur=0;	
			}
			showCurPhoto()
							}, 1000);
	}
}
function initBigGallery(){
	var count = $("#gallery div.galleryItemBlock").size();
	var cur=0;
	showCurPhoto();	
	
	function showCurPhoto(){
		$("#gallery div.galleryItemBlock").css("display", "none");
		$("#gallery div.galleryItemBlock").css("opacity", "0");
		
		$("#gallery div.galleryItemBlock").eq(cur).css("display", "block");
		$("#gallery div.galleryItemBlock").eq(cur).animate({opacity: "1"}, 1000);
		
		$("#gallery div.galleryItemBlock").eq(cur).find("div.info").css("bottom", -$("#gallery div.galleryItemBlock").eq(cur).find("div.info").height() - 20 + "px");
		$("#gallery div.galleryItemBlock").eq(cur).find("div.info").animate({bottom: "0"}, 500);
		
		setTimeout(doHide, 5000);
	}
	function doHide(){
		$("#gallery div.galleryItemBlock").eq(cur).animate({opacity: "0"}, 1000);
		$("#gallery div.galleryItemBlock").eq(cur).find("div.info").animate({bottom: -$("#gallery div.galleryItemBlock").eq(cur).find("div.info").height() - 20}, 500);
		setTimeout(function(){
			if(cur < count - 1){
				cur++;	
			}
			else{
				cur=0;	
			}
			showCurPhoto()
							}, 1000);
	}
}
function initHorizontalGallery(){
	var step = $(".positionHorGallery .horGalleryItem").eq(1).height() + 2;
	
	$(".arrowLeftHorgallery").click(function(){
		if(parseInt($(".positionHorGallery").css("margin-top")) <= -step){
												 
			$(".positionHorGallery").animate({
				opacity: 0
			  }, 500, function() {
				$(".positionHorGallery").css("margin-top", parseInt($(".positionHorGallery").css("margin-top")) + step + "px");
				$(".positionHorGallery").animate({opacity: 1}, 500);		
			  });
		}
		else{
			$(".positionHorGallery").css("margin-top", "0px");	
		}		
	});
	$(".arrowRightHorgallery").click(function(){
		if(parseInt($(".positionHorGallery").css("margin-top")) > - (Math.floor($(".positionHorGallery .horGalleryItem").size()/4)*step)){
			
			$(".positionHorGallery").animate({
				opacity: 0
			  }, 500, function() {
				$(".positionHorGallery").css("margin-top", parseInt($(".positionHorGallery").css("margin-top")) - step + "px");
				$(".positionHorGallery").animate({opacity: 1}, 500);		
			  });
		}
	});
}

function initLeftAccordion(){
	$("ul.menuLeft li.li").click(function(){
		//$(this).find("ul").slideToggle("fast");
		//$(this).find("a").eq(0).toggleClass("down");
	});
}
function showBigGalleryPhoto(img, id){
	$("#" + id).attr("src", img);
}


var timeout2 = 500;
var galleryId;

function showAllPhotos(id)
{ 
	galleryId = id;
	clearTimeout(timeout2);
   	$("#" + galleryId).css('display', 'block');
}

function hideAllPhotos()
{
	timeout2 = setTimeout(function(){
								   $(".otherPhotos").css('display', 'none');
								   }, 500);
}
function initFAQ(){
	$(".faqName").click(function(){
		$(this).parents(".faqBlock").find(".faqText").slideToggle("fast");
		$(this).toggleClass("faqNameClose");
	});
}
function initVideoBlock(num){
	var videoBlock = document.getElementById("videoBlock");
	videoBlock.innerHTML = videos[num - 1];
}
