var titleHeight = 30;

var doCenter = true;

function positionContent() {
	if (!doCenter) return;

	var height = $(window).height();

	$('.contentExtraLarge').css('height', height-50);	

	var img = $('.contentExtraLarge').children('.imgLeft').children('a').children('img');
	if (img.get(0) != undefined) {
		var t = img.height() / 2;
		if (t == 0) t = 200;	
		var f = (height /2)-t-50;
		if (f < 0) f = 0;
		img.css('margin-top', f);
		return;
	}

	var img = $('.contentExtraLarge').children('div').children('a').children('img');
	if (img.get(0) != undefined) {
		var t = img.height() / 2;
		if (t == 0) t = 250;
		var f = (height /2)-t-50;
		if (f < 0) f = 0;
		img.css('margin-top', f);
		return;
	}

	var img = $('.contentExtraLarge').children('center').children('a').children('img');
	if (img.get(0) != undefined) {
		var t = img.height() / 2;
		if (t == 0) t = 250;	
		var f = (height /2)-t-50;
		if (f < 0) f = 0;
		img.css('margin-top', f);
		return;
	}
}

$(document).ready(function () {
	positionContent();
	setTimeout("positionContent();", 500);
	
	$('.imgList').live('click', function() {
		var position = $(this).offset();

		$('#imgList').show();
	});
	
	//return;
	$('a').live("click", function() {
		if ($(this).attr('rel') == 'ajax'){
			var url = $(this).attr('href').replace("http://"+window.location.host, '');
			$.ajax({
   				type: "POST",
   				url: "/ajax.php",
   				data: "req="+url,
   				success: function(msg){
     				var data = msg.split('######');
     				$('#loader').html(msg);
     				
     				$('#interfaceBlocRight').fadeOut('slow'); 
     				$('#interfaceBlocLeft').fadeOut('slow'); 
     				$('#lineBottom').fadeOut('slow'); 
     				$('#lineTop').fadeOut('slow'); 
     				
     				$('#content').fadeOut('slow', function() {
		     			$('#content').attr('class', data[0]);
     					
     					$('#content').html(data[1]);
     					positionContent();
     					$('#content').fadeIn('slow');
     					$('#interface').html(data[2]);
     				});
	     			
   				}
 			});
			return false;
		}
	});
});

$(window).resize(function() {
	positionContent();
});
