$(document).ready(function() {

	$('.content img').each(function(index) {
		var hspace = $(this).attr('hspace');
		var vspace = $(this).attr('vspace');
		if (vspace > 0) {
			$(this).css('margin-top', vspace + 'px');
			$(this).css('margin-bottom', vspace + 'px');
		}
		if (hspace > 0) {
			$(this).css('margin-left', hspace + 'px');
			$(this).css('margin-right', hspace + 'px');
		}
	});

	$('.content table').each(function(index) {
		//console.log($(this).attr('border'));
		if ($(this).attr('border') != 0) {
			$(this).addClass("border");
		}
	});

	//$(".news_open .price").css('top', ($(".news_open img.picture").height() - 40) + 'px');
	//console.log($(".news_open img.picture"));
	if ($(".news_open img.picture").height() > 0) {
		$(".news_open .price").css('top', ($(".news_open img.picture").height() - 40) + 'px');
	} else {
		$(".news_open img.picture").load(function(){
			$(".news_open .price").css('top', ($(this).height() - 40) + 'px');
		});
	}

	moveImages();

	if(jQuery.fancybox) { 
		$("a[rel=gallery_images]").fancybox({
			'transitionIn'		: 'none',
			'transitionOut'		: 'none',
			'titleFormat'		: function(title, currentArray, currentIndex, currentOpts) {
				return (title.length ? ' &nbsp; ' + title : '');
			}
		});

		$("a[rel=ajax]").fancybox({
			'transitionIn' : 'none',
			'transitionOut' : 'none',
			'type' : 'ajax',
			'showNavArrows' : false
		}); 

		$("a[rel=novatours]").fancybox({
			'transitionIn' : 'none',
			'transitionOut' : 'none',
			'type' : 'iframe',
			'width' : 800,
			'height' : 1200,
			'showNavArrows' : false
		}); 
	}
});

$(window).resize(function() { 
	//$('body').prepend('<div>' + $(window).width() + '</div>'); 
	moveImages();
}); 

function moveImages() {
	//$('body').prepend('<div>' + $(window).width() + '</div>');
	var winWidth = $(window).width();
	if (winWidth < 1400)
	{
		var offset = Math.round((winWidth - 1400) / 2);
		var width = Math.round((winWidth - 1000) / 2) + 150;
		$("#footer .left").css('left', offset + 'px');
		//$("#footer .right").css('right', offset + 'px');
		$("#footer .right").css('width', width + 'px');
		$("#footer .right_top").css('width', (width - 105) + 'px');
	}
}


