$(function(){
	$('.side ul>li>a:not(".side ul.catalogueMenu>li>a"):not(.active)').hover(function(){
		a = $(this);
		a.parent().prev().find('a').addClass('hovered');
	},function(){
		a = $(this);
		a.parent().prev().find('a').removeClass('hovered');
	});
	
	if ($('#NextLink').length){
		$('.pathBar .ar-right').attr('href',$('#NextLink').attr('href')).html($('#NextLink').attr('title'));
		$(document).bind('keydown', 'Ctrl+right', function(evt){
			popup = $('#photoPopup');
			if (popup.length!=1) {
				document.location.href($('#NextLink').attr('href'))
				evt.stopPropagation();evt.preventDefault();return false;
			};
		});
	};
	if ($('#PrevLink').length){
		$('.pathBar .ar-left').attr('href',$('#PrevLink').attr('href'));
		$(document).bind('keydown', 'Ctrl+left', function(evt){
			popup = $('#photoPopup');
			if (popup.length!=1) {
				document.location.href($('#PrevLink').attr('href'))
				evt.stopPropagation();evt.preventDefault();return false;
			};
		});
	};
	
	$('.toFav').hover(function(){
		$(this).css({opacity:0.7});
	},function(){
		$(this).css({opacity:1});
	});
	
	if ($.browser.msie) {
		$('.textInput').focus(function(){
			$(this).addClass('textInputFocus');
		}).blur(function(){
			$(this).removeClass('textInputFocus');
		});
		$('.button').hover(function(){
			$(this).addClass('buttonHover');
		},function(){
			$(this).removeClass('buttonHover');
		});
	}
});

function showPopup(popup){
	popup = $('#'+popup);
	blind = $('<div class="blind"></div>');
	pageHeight = (document.documentElement.offsetHeight > document.body.clientHeight) ? document.documentElement.offsetHeight : document.body.clientHeight;
	blind.height(pageHeight).click(function(){
		closePopup(popup,blind);
		return false;
	}).appendTo('body');
	setCenter(popup);
	popup.find('.p-close').click(function(){
		closePopup(popup,blind);
		return false;
	});
	popup.show();
	
};
function setCenter(item) {
	windowHeight = document.documentElement.clientHeight;
	currentOffset = document.documentElement.scrollTop || document.body.scrollTop;
	currentOffset = currentOffset + parseInt((windowHeight - ($(item).height()+56)) / 2);
	pLeft = $(item).width() / 2;
	$(item).css({top:currentOffset,marginLeft:-pLeft}).show();
};
function closePopup(popup,blind) {
	blind.remove();
	popup.find('.p-close').unbind();
	popup.hide();
}
