	
	/*
	 * 
	 */
	
	//var arTourAnounceSlides = new Array();
	
	/*
	 * Галлерея
	 */
	
	function checkGalleryArrows(imgKey) {
		
		totalThumbs = $("img[id^='thumb']").length;
		
		if ( 1 == imgKey ) {
			$("#galleryArrowLeft").fadeOut(100);
			$("#galleryArrowRight").fadeIn(100);
		} else if ( totalThumbs == imgKey ) {
			$("#galleryArrowRight").fadeOut(100);
			$("#galleryArrowLeft").fadeIn(100);
		} else {
			$("#galleryArrowLeft").fadeIn(100);
			$("#galleryArrowRight").fadeIn(100);
		}
		
	}
	
	function showGallery(curImageNumber) {
		
		left = (document.width - $("#imageGallery").width())/2;
		
		$("#imageGallery").css({
			'left': left
		});
		
		$("#galleryLayout").fadeIn();
		
		$("#imageGallery").fadeIn();
		
		checkGalleryArrows(curImageNumber);
		
	}
	
	/*
	 * 
	 */
	
	function showMainImage(imgSrc, imgKey) {
		
		checkGalleryArrows(imgKey);
		
		var i = 1;
		
		curImageNumber = imgKey;
		
		imgSrc = '/upload/images/thumb.php?w=750&h=450&img=' + imgSrc;
		
		$("#mainImage").attr('src', imgSrc);
		
		$("img[id^='thumb']").each(function(){
			
			if ( i == curImageNumber ) {
				$(this).addClass('thumbActive');
			} else {
				$(this).removeClass('thumbActive');
			}
			
			i++;
		});
		
	}
	
	/*
	 * 
	 */
	
	function showNextImage() {
		
		var i = 1;
		var imageLoaded = false;
		
		$("img[id^='thumb']").each(function(){
			
			/*
			 * Загрузка основной картинки
			 */
			
			if ( i == (parseInt(curImageNumber) + 1) && false == imageLoaded ) {
				
				imgSrc = $(this).attr('imgSrc');
				
				imgSrc = '/upload/images/thumb.php?w=750&h=450&img=' + imgSrc;
				
				$("#mainImage").attr('src', imgSrc);
				
				curImageNumber++;
				imageLoaded = true;
			}
			
			/*
			 * Подгрузка следующей картинки (для скорости)
			 */
			
			if ( (i + 1) == (parseInt(curImageNumber) + 1) ) {
				
				imgSrc = $(this).attr('imgSrc');
				
				imgSrc = '/upload/images/thumb.php?w=750&h=450&img=' + imgSrc;
				
				$("#mainImagePreload").attr('src', imgSrc);
			}
			
			i++;
			
		});
		
		var j = 1;
		
		$("img[id^='thumb']").each(function(){
			
			if ( j == curImageNumber ) {
				$(this).addClass('thumbActive');
			} else {
				$(this).removeClass('thumbActive');
			}
			
			j++;
		});
		
		checkGalleryArrows(curImageNumber);
		
		
	}
	
	/*
	 * 
	 */
	
	function showPrevImage() {
		
		var i = 1;
		var imageLoaded = false;
		
		$("img[id^='thumb']").each(function(){
			
			/*
			 * Загрузка основной картинки
			 */
			
			if ( i == (parseInt(curImageNumber) - 1) && false == imageLoaded ) {
				
				imgSrc = $(this).attr('imgSrc');
				
				imgSrc = '/upload/images/thumb.php?w=750&h=450&img=' + imgSrc;
				
				$("#mainImage").attr('src', imgSrc);
				
				curImageNumber--;
				imageLoaded = true;
			}
			
			i++;
			
		});
		
		var j = 1;
		
		$("img[id^='thumb']").each(function(){
			
			if ( j == curImageNumber ) {
				$(this).addClass('thumbActive');
			} else {
				$(this).removeClass('thumbActive');
			}
			
			j++;
		});
		
		checkGalleryArrows(curImageNumber);
		
	}
	
	/*
	 * 
	 */
	
	function toggleWorldPart(partID) {
		
		$("tr[class^='worldPart']").fadeOut(0);
		
		$('.worldPart'+partID).fadeIn(0);
		
	}
	
	/*
	 * tourAnounce functions
	 */
	
	function tourAnounceNextSlide(key, i) {
		
		var imageSrc = arTourAnounceSlides[key][i]['IMAGE'];
		var name = arTourAnounceSlides[key][i]['NAME'];
		var link = arTourAnounceSlides[key][i]['LINK']; 
		
		imageSrc = "url('/upload/images/thumb.php?w=300&h=195&img=" + imageSrc + "')";
		
		$("#tourAnounce"+key).css({
			"background-image": imageSrc,
		}, 200);
		
		$("#tourAnounceDescription"+key).html('<a href="' + link + '">' + name + '</a>');
		
		if ((Object.keys(arTourAnounceSlides[key]).length - 1) <= i) {
			i = 0;
		} else {
			i++;
		}
		
		var t = setTimeout('tourAnounceNextSlide(' + key + ', ' + i + ')', 5000);
		
	}

