var aberto = null;

function reserva(hotel,pacote,tipo,linha){
	addRow(linha,tipo,pacote,hotel);
	
	$('#td' + aberto).load('index.php/pacote/exibeReserva' + tipo +'/' + pacote);
	
	return false;
}
function fechar(){$('#' + aberto).css('display','none');}
function ge(e){ return document.getElementById(e); }

//addrow
function addRow(numero,tipo,id,hotel)
{
	if(aberto && ge(aberto)){
		 ge(aberto).style.display = "none";
		 //alert(aberto);
		 //document.removeChild(aberto);
	}   
	
	aberto = "linha_" + hotel + "_" + numero + '_' + tipo + 'x';
	if(!ge(aberto))
	{
		var novaLinha = ge("linha_" + hotel + "_" + numero).cloneNode(true);
		novaLinha.id = aberto;
	   
		var linha = ge("linha_" + hotel + "_" + (numero + 1));
		$("#" + aberto).html("");
	   
		if(linha) {
			document.getElementById("bodyTabela" + hotel).insertBefore(novaLinha,linha);
		} else {
			document.getElementById("bodyTabela" + hotel).appendChild(novaLinha);
		}
		
		$("#"+aberto).html("<td colspan=\"6\" style=\"background-color:#fff;border-right:solid 1px #000;border-bottom:solid 1px #000;padding:0px;\" id=\"td" + aberto + "\"></td>");
	}
	else
		ge(aberto).style.display="";
}


