$(document).ready(function() {

	function popup(link, width, height) {
		var left = (screen.width - width - 20) / 2;
		var top = (screen.height - height - 30) / 2;
		var date = new Date();
		var sName = 'win' + date.getHours() + date.getMinutes() + date.getSeconds();
		window.open(link, sName, 'width='+width+',height='+height+',left='+left+',top='+top+',toolbar=no,location=no,status=no,resizable=yes,scrollbars=yes');
		//return false;
	}

	$(".tabelHover tr").mouseover(function() { $(this).addClass('hover'); });
	$(".tabelHover tr").mouseout(function() { $(this).removeClass('hover'); });
	$(".tabelHover tr a.pop").click(function() { 
		popup('/firme/detalii_client/' + $(this).attr("id").substring(3),300,400);
		return false;
	});
	$(".tabelHover tr").click(function() { 
		link = $("a.linkRow", this).attr('href');
		if(link) document.location = link;
	});

	$("#comanda, #comanda2").click(function() {
		$("#formComanda").toggle("slow");
		return false;
	});

	$(".ajDetalii").click(function() {
		var link = $(this);
		var dest = $(this).parent().parent();

		$(".det").remove()

		dest.after("<tr class=\"det\" id=\"row" + link.attr("id").substring(2) + "\"><td colspan=\"9\"><center><img src=\"/layout/standard/images/ajax-loader.gif\"/></center></td></tr>");		

		$.ajax({
		  url: '/auth/login_tabel/' + link.attr("id").substring(3),
		  success: function(data) {
			dest.next().html(data);
		  }
		});

		return false;
	});
});
