var vediGiocatore;

$(document).ready(function(){
	
	if($("#mainContent").height() < 550)
		$("#mainContent").height(550);
		
	$(".news .testoNews").css({opacity: 0.5});
	
	$("a").bind("mouseenter", function (ev) {
		$(this).css({opacity: 0.5});
	});
	
	$("a").bind("mouseleave", function (ev) {
		$(this).css({opacity: 1});
	});
	
	
	vediGiocatore = function(playerName) {
		var dialogLayout;
		var dialogLayout_settings = { 
				defaults :{
						resizeWithWindow:		false	// resizes with the dialog, not the window
					,	spacing_open:			6
					,	spacing_closed:			6		// allow for adding a left-border
					,	west__size:				'30%' 
					,	west__minSize:			200 
					,	west__maxSize:			400 
					,	north__spacing_closed:	4
					,	north__initClosed:	true // pane is hidden, but north__spacing_open shows
				},
				south: {
					spacing_closed:			0			// HIDE resizer & toggler when 'closed'
					,	slidable:				false
					,	initClosed:	true
				}
		};

		$("#dialogBox").dialog({
			title: 		'Informazioni giocatore',
			width: 		600,
			height: 	500,
			autoOpen: 	false,
			closeOnEscape: true,
			resizable: false,
			resize: 	function () {
				dialogLayout.resizeAll();
			},
			open: 		function (){
				if (!dialogLayout || dialogLayout == null)
				{
					dialogLayout = $("#playerStats").layout( dialogLayout_settings );
				}
			},
			close:		function (ev, ui) {
				$(this).html("");
				dialogLayout = null;
			}
		});
		
		$.ajax({
			url: "include/php/playerStats.php?mercato=1",
			data: "playerName="+playerName,
			dataType: "html",
			type: "POST",
			success: function (data) {
				$("#dialogBox").html(data);
				
				$("#dialogBox").dialog('open');
				
				$(".doOffer").css({
					'float': 'left'
				});
				
				$(".inputOfferta").css({
					display: 'none'
				});
			}
		});
	};
	
	//$('table th').addClass("ui-state-default");
});