var cGalleryImage = 0;
function popupMenu() {
}

$(document).ready( function () {
	$('#RightMenu li').mouseover(function () {
		$(this).addClass('hover');
	});
	$('#RightMenu li').mouseout(function () {
		$(this).removeClass('hover');
	});
	$('#Content .showtime').each(function () { this.innerHTML += ''; });	
	$('#Content .showtime .thumbs img').click(function () {
		$(this).parents('.showtime:first').children('img').css('display', 'none');
		var imgs = $(this).parents('.showtime:first').children('img');

		if (imgs.length) {

			for (var i = 0; i < imgs.length; i++) {
				if (imgs[i].src == this.src.replace(/small\.jpg/, '.jpg')) {
					$(imgs[i]).css('display', 'inline');
				}
			}
		}
	});


	
	$('.gallery .single img').click(function () {
		$('#galleryPopup img:first').attr('src', this.src.replace(/small\./, '.'));
		
		if (cGalleryImage == 0 || cGalleryImage == $(this).parents('.single').attr('id')) {
			// close
			getMagicPopup('galleryPopup').close();
			cGalleryImage = 0;
		}
		showMagicPopup('galleryPopup', this);
		cGalleryImage = $(this).parents('.single').attr('id');
	});
	$('#galleryPopup img:first').click(function () {getMagicPopup('galleryPopup').close(); cGalleryImage = 0;});
	
	$('.imgClickable img').click(function () {
		if (document.getElementById('galleryPopup')) {
			$('#galleryPopup img').remove();
			$('#galleryPopup').html( '<img src="' + this.src.replace(/([^\/]+)$/, 'o_$1') + '" />' );
			showMagicPopup('galleryPopup', this);
			$('#galleryPopup img:first').click(function () {
				showMagicPopup('galleryPopup');
			});
//			alert(this.src.replace(/([^\/]+)$/, 'o_$1'));
		}
	});
});