function troca_posicao(ident,image,lado){

	document.getElementById(ident).style.background= "url(../../img/"+image+") top "+lado+" no-repeat";

}

function mostraAcomodacao() {

        $("#area_acomodacao").show('drop', {direction: 'right'}, 1500);

}

function mostraContato() {
 
 		$("#area_contato").show('drop', {direction: 'right'}, 1500);

} 

function mostraEstive() {

		$("#area_estive").show('drop', {direction: 'left'}, 1500);

} 

function mostraGastronomia() {

        $("#area_gastronomia").show('drop', {direction: 'left'}, 1500);

}

function mostraHome() {

        $("#area_home").show('drop', {direction: 'right'}, 1500);

} 

function mostraHotel() {

        $("#area_hotel").show('drop', {direction: 'left'}, 1500);

}

function mostraPacotes() {

        $("#area_pacotes").show('drop', {direction: 'left'}, 1500);

}

function mostraPraia() {

        $("#area_praia").show('drop', {direction: 'right'}, 1500);

}; 

function mostraPromocao() {

        $("#area_promocao").show('drop', {direction: 'left'}, 1500);

}

function mostraReservas() {

        $("#area_reservas").show('drop', {direction: 'right'}, 1500);

}

function mostraGaleria() {

        $("#demo_fotos").show('drop', {direction: 'right'}, 1500);

}




function mostraBox (id) {
		var alt_pre = 100;
		var alt_pos = $("#box_"+id).height();
		if(alt_pos > alt_pre)
			$("#box_"+id).css("height",alt_pre);

		// Verifica se há algum box diferente do selecionado aberto e o fecha

		// Se box já estiver aberto, é fechado
		
		if ($("#box_"+id).css("display")=='block'){
			$("#box_"+id).hide('fold', {direction: 'up'}, 'fast');
			return false;
		}
			
		$(".selects").hide();
		$("#box_"+id).show('fold', {direction: 'down'}, 'fast');
}

function fechaBox(id,input,valor) {
	document.getElementById(input).value=valor;
	$(id).hide('fold', {direction: 'up'}, 'fast');
}



function fechaBox2(id,input,valor,input2,valor2) {
	document.getElementById(input2).value=valor2;
	document.getElementById(input).value=valor;
	$(id).hide('fold', {direction: 'up'}, 'fast');
}

function inserirLinhaAcompanhante() {

    var table = document.getElementById("tblAcompanhante");
    var numOfRows = table.rows.length;
    var numOfCols = table.rows[numOfRows-1].cells.length;

    var newRow = table.insertRow(numOfRows);

    var colunas=new Array(1);
    colunas[0] = '';
    colunas[1] = 'nome_acom';
    colunas[2] = 'documento_acom';
	colunas[3] = 'parente_acom';

    for (var j = 0; j < colunas.length; j++) {
    	if(document.getElementById("nome_acom").value == ""){
    		alert("É necessário informar um acompanhante!");
    		break;
    	}
        newCell = newRow.insertCell(j);
        if (j == 0)
        	newCell.innerHTML = "<input class=\"marcado\" type=\"checkbox\" name=\"item[]\" id=\"ckb_"+j+"\" value=\"1\" />";
        else{
        	if(colunas[j]=="nome_acom"){
        		aux = (document.getElementById(colunas[j]).value);
        		var texto = "<input type='hidden' name='categoria[]' value='"+aux[0]+"'>";
	            newCell.innerHTML = document.getElementById(colunas[j]).value+texto;
        	}
        	if(colunas[j]=="documento_acom"){
        		var texto = "<input type='hidden' name='qtde[]' value='"+document.getElementById(colunas[j]).value+"'>";
	            newCell.innerHTML = document.getElementById(colunas[j]).value+texto;
        	}
        	if(colunas[j]=="parente_acom"){
        		var texto = "<input type='hidden' name='parente[]' value='"+document.getElementById(colunas[j]).value+"'>";
	            newCell.innerHTML = document.getElementById(colunas[j]).value+texto;
        	}
        }
    }
    limpaCamposTabAcompanhante();
}

function limpaCamposAcompanhante(){
	document.getElementById("nome_acom").value="";
	document.getElementById("documento_acom").value="";
	document.getElementById("parente_acom").value="";
}

function removerLinhaAcompanhante(){

	var table = document.getElementById("tblAcompanhante");
	var numOfRows = (table.rows.length-1);
	if (numOfRows == 0)
		alert("Nenhum ítem adicionado à lista!")
	else{
		for (var i=numOfRows; i>=1; i--){
			var elemento = table.rows[i].getElementsByClassName("marcado")[0];
			if(elemento.checked){ 
				var checado = true;
				break;
			}
		}
		if(checado==true){
			if(confirm("Tem certeza que deseja remover da lista o(s) acompanhante(s) selecionado(s)?")){
				for (var i=numOfRows; i>=1; i--){
					var elemento = table.rows[i].getElementsByClassName("marcado")[0];
					if(elemento.checked) 
						table.deleteRow(i);
				}
			}
		}
		else
			alert("Selecione algum ítem da lista para remoção!");
	}
}


