var anim;
var an;

$(document).ready(function() {
	$('a.photogal').click(doam)

	$('a[href*=nashi-klienti]').click(function(){
		$.modal({
			postfix: 'site',
			url: '/clients.php',
			isResizable: null,
			buttons: null,
			width: 400,
			height: 432
		})
		return false;
	})

	$('a[href*=nashi-proekti]').click(function(){
		$.modal({
			postfix: 'site',
			url: '/our_projects.php',
			isResizable: null,
			buttons: null,
			width: 400,
			height: 432
		})
		return false;
	})

	$('a[href*=nash-kreativ]').click(function(){
		$.modal({
			postfix: 'site',
			url: '/our_creative.php',
			isResizable: null,
			buttons: null,
			width: 400,
			height: 432
		})
		return false;
	})

});

function doam()
{
		var n = parseInt($(this).attr('id').replace(/\D/g,''));
		var cw = 270;
		var ch = 167;
		var zzz;
		if(n == 1)
		{
			var zzz = 
			{
				left: 0,
				top: 0,
				width: cw,
				height: ch
			};
		}
		else if(n == 2)
		{
			var zzz = 
			{
				right: 0,
				top: 0,
				width: cw,
				height: ch
			};
		}
		else if(n == 3)
		{
			var zzz = 
			{
				left: 0,
				bottom: 0,
				width: cw,
				height: ch
			};
		}
		else if(n == 4)
		{
			var zzz = 
			{
				right: 0,
				bottom: 0,
				width: cw,
				height: ch
			};
		}
		//alert(coords.left)
		//alert(coords.top)
		var goo = true;
		if(anim && an == n)
		{
			goo = false;
		}
		if(anim)
		{
			$('#pn').hide();
			$('.primagem:visible').animate(anim,'fast','linear',function(){
				$(this).hide().unbind('click');
				anim = null;
				an = null;
				return;
			})
		}
		if(goo)
		{
			$('.pm' + n).css(zzz).show()
			.animate({
				width: 541,
				height: 335
			},'fast','linear',function(){
				anim = zzz;
				an = n;
				$(this).unbind('click').click(doam);
				$('#pn').show();
			})
		}
		return false;
}