$(document).ready(function ()
{ 	
	setMargin();
	$(window).bind('resize', function() 
	{
		setMargin();
	});

	$("#centerimage").load(function () 
	{    
		setMargin();
	});
	
	$("a.configrow").click(function ()
	{
		$("input:[name=idarticle]").attr("value", $(this).attr("idarticle"));
		$("#formconfig").submit();
	});
	
	$("tr:.commandelistrow").click(function ()
	{
		parent.location = "commande.php?action=detail&idcommande=" + $(this).attr("idcommande");
	});

	$("tr:.categoriesrow").click(function ()
	{
		parent.location = "article.php?action=find&idcategorie=" + $(this).attr("idcategorie");
	});

	$("tr:.categoriemrow").click(function ()
	{
		parent.location = "article.php?action=find&idcategoriem=" + $(this).attr("idcategoriem");
	});

	/*
	$("tr:.articlelistrow").click(function ()
	{
		parent.location = "panier.php?action=addform&idarticle=" + $(this).attr("idarticle");
	});
	*/
	
	$('.hover').hover(
		function() { $(this).addClass('ui-state-hover'); },
		function() { $(this).removeClass('ui-state-hover'); }
	);

	$('.hover-big').hover(
		function() { $(this).addClass('ui-state-hover-big'); },
		function() { $(this).removeClass('ui-state-hover-big'); }
	);
	
	$('.hover-orange').hover(
		function() { $(this).addClass('ui-state-active'); },
		function() { $(this).removeClass('ui-state-active'); }
	);
	
	$(".submit").click(function () 
	{
		$("#defaultform").submit();
	});
	
	//$("#defaultform input").bind("keydown", "return", function () { $("#defaultform").submit(); return false; });
	
	//$(".content-center").each(function() { $(this).css("margin-left", (980 - $(this).width()) / 2); });
	
	$(".js-center").each(function() 
	{ 
		$(this).css("left", Math.round(($(this).parent().width() - $(this).width()) / 2));
	});
});
	
function setMargin()
{
	var width = ($(window).width() - ($(window).height() >= $("#content").height()?16:0));
	//alert(width);
	width = ((width / 2) - ($("#content").width() / 2));
	if(width < 0) width = 0;
	$("#content").css('margin-left', width);
	
	
	$("#maincontent").height("");
	if($("#content").height() < $(window).height())
	{
		$("#maincontent").height($("#maincontent").height() + ($(window).height() - $("#content").height()));
	}
	
	/*
	$("#bottom").css("margin-top", 0);
	if($("#content").height() < $(window).height())
	{
		$("#bottom").css("margin-top", $(window).height() - $("#content").height());
	}
	*/
}