var currentDiv = "";
function refreshrooms(){
	var select_rooms = document.getElementById('fldQuartos'); 
	if ( select_rooms.selectedIndex == 0){
		document.getElementById('room0').style.visibility = "visible";
		document.getElementById('room1').style.display = "none";
		document.getElementById('room1').style.visibility = "hidden";
		document.getElementById('room2').style.display = "none";
		document.getElementById('room2').style.visibility = "hidden";
	}
	if ( select_rooms.selectedIndex == 1){
		document.getElementById('room0').style.visibility = "visible";
		document.getElementById('room1').style.display = "";
		document.getElementById('room1').style.visibility = "visible";
		document.getElementById('room2').style.display = "none";
		document.getElementById('room2').style.visibility = "hidden";
	}
	if ( select_rooms.selectedIndex == 2){
		document.getElementById('room0').style.visibility = "visible";
		document.getElementById('room1').style.display = "";
		document.getElementById('room1').style.visibility = "visible";
		document.getElementById('room2').style.display = "";
		document.getElementById('room2').style.visibility = "visible";
	}
}

function ValidValueHotel(value){
	return value != "" && value != null && value != "undefined";
}

function TextFieldValidationHotel(value, errorMsg, obj){
	var retVal=1;
	if (!ValidValueHotel(value)){
		obj.focus();
		document.getElementById('errorDivHotel').className = "errorDiv_block";
		document.getElementById('errorDivHotel').innerHTML = errorMsg;
		retVal = -1;
	}
	return retVal;
}

function ValidateHotel(){
	var retVal=1;
	if(TextFieldValidationHotel(document.getElementById('fldCidade').value, "<font class='error_msg'>Cidade desconhecida ou por preencher</font>", document.getElementById('fldCidade')) == -1) {
		retVal = -1;;
	}
	//alert(retVal);
	return retVal;
}

// resets a form given a name
function ResetForm(aFormName) {
	var f = document.getElementById(aFormName);
	if ( f!=null )
		f.reset();
}

function submit_hotel(arg){
	var hform = document.getElementById('hotelSearch');
	
	if(arg == "loading"){
		if(ValidateHotel()==1){
			hform.action = "/loading.aspx";
			hform.submit();
			
		}
		
	}
	if(arg == "hotel"){
		hform.target = "searchBoxIFrame";
		//hform.target = "_new";
		hform.action = "/Hotel/SearchBoxHotel.aspx";
		document.getElementById('citydivclick').style.visibility = "hidden";
		document.getElementById('fldCidade').value = "";
		hform.submit();
	}
	
}

function submit_hotel_detail(){
	var hform = document.getElementById('hotelSearch');
	hform.action = "loading.aspx";
	hform.submit();
}

function showHotelariaListaDestinos(divElemId){
	if(divElemId == "fldPais")
		show('pesquisaTblListaPaisesHoteis');
	else
		show('pesquisaTblListaCidadesHoteis');
	hideObject('fldPartidaDia');
	hideObject('fldPartidaMes');
	hideObject('fldPartidaAno');
	hideObject('fldRegressoDia');
	hideObject('fldRegressoMes');
	hideObject('fldRegressoAno');
	hideObject('room2');
	
	currentDiv = divElemId;
}

/*function showHotelariaListaDestinosByRef(divElemId, refID)
{	
	var offset = 0;
	
	if (document.getElementById("slbHeaderDIV") != null)
		offset = document.getElementById("slbHeaderDIV").clientHeight;
		
	if (divElemId == "fldPais")
	{
		document.getElementById("pesquisaTblListaPaisesHoteis").style.top = GetPageCoordsById(refID).y - 5;
		document.getElementById("pesquisaTblListaPaisesHoteis").style.left = GetPageCoordsById(refID).x;
		showDisplayVisibility('pesquisaTblListaPaisesHoteis');
	}
	else
	{
		document.getElementById("pesquisaTblListaCidadesHoteis").style.top = GetPageCoordsById(refID).y - 5;
		document.getElementById("pesquisaTblListaCidadesHoteis").style.left = GetPageCoordsById(refID).x;
		showDisplayVisibility('pesquisaTblListaCidadesHoteis');
	}
	hideObject('fldPartidaDia');
	hideObject('fldPartidaMes');
	hideObject('fldPartidaAno');
	hideObject('fldRegressoDia');
	hideObject('fldRegressoMes');
	hideObject('fldRegressoAno');
	hideObject('room2');
	
	currentDiv = divElemId;
}*/

function showHotelsCities(divId, screenRefId)
{	
	var divElem = document.getElementById(divId);

	divElem.style.top = GetPageCoordsById(screenRefId).y - 5;
	divElem.style.left = GetPageCoordsById(screenRefId).x;
	
	showDisplayVisibility(divId);
	
	// In IE the dates selects stay on top of the cities div. They must be hidden.
	hideObject('fldPartidaDia');
	hideObject('fldPartidaMes');
	hideObject('fldPartidaAno');
	hideObject('fldRegressoDia');
	hideObject('fldRegressoMes');
	hideObject('fldRegressoAno');
	
	currentDiv = divId;
}

function hideHotelsCities(divId)
{
	hideDisplayVisibility(divId);
	
	showObject('fldPartidaDia');
	showObject('fldPartidaMes');
	showObject('fldPartidaAno');
	showObject('fldRegressoDia');
	showObject('fldRegressoMes');
	showObject('fldRegressoAno');
}

function showDisplayVisibility(divID)
{
	document.getElementById(divID).style.visibility = "visible";
	document.getElementById(divID).style.display = "block";
}

function hideDisplayVisibility(divID)
{
	document.getElementById(divID).style.visibility = "hidden";
	document.getElementById(divID).style.display = "none";
}

function hideHotelariaListaDestinos(formElemID){
	
	if(currentDiv == "fldPais"){
		hide('pesquisaTblListaPaisesHoteis');
		if (formElemID != "undefined" && formElemID != null)
			document.getElementById('wait').style.visibility = 'visible';
	}
	else
		hide('pesquisaTblListaCidadesHoteis');
	showObject('fldPartidaDia');
	showObject('fldPartidaMes');
	showObject('fldPartidaAno');
	showObject('fldRegressoDia');
	showObject('fldRegressoMes');
	showObject('fldRegressoAno');
	showObject('room2');
	//formElemID = (formElemID != "undefined" && formElemID != null) ? formElemID : "";
	if (formElemID != "undefined" && formElemID != null)
		document.getElementById(currentDiv).value = formElemID;
}

function showListaDestinos(divElemId){
	show('pesquisaTblListaDestinos');			
	hideObject('fldClasse');
	hideObject('fldCompanhia');
	hideObject('fldAdults');
	hideObject('fldChildren');
	hideObject('fldBabies');
	currentDiv = divElemId;
}

function hideListaDestinos(formElemID) {
	hide('pesquisaTblListaDestinos');
	showObject('fldClasse');
	showObject('fldCompanhia');
	showObject('fldAdults');
	showObject('fldChildren');
	showObject('fldBabies');
	
	formElemID = (formElemID != "undefined" && formElemID != null) ? formElemID : "";
	document.getElementById(currentDiv).value = formElemID;
}

function OnKeyPressEnterWithArg( aFunctionToCall, arg ) {
	if ( event.keyCode == 13 )
		aFunctionToCall(arg);
	return true;
}


function Changeclass(idselected, box1, box2, box3, linkselected, link1, link2, link3)
{
	document.getElementById(linkselected).className = 'linkpesquisaBoxOptionActive';
	document.getElementById(link1).className = 'pesquisaBoxOption';
	document.getElementById(link2).className = 'pesquisaBoxOption';
	document.getElementById(link3).className = 'pesquisaBoxOption';
	document.getElementById(idselected).className = 'pesquisaBoxOptionActive';
	document.getElementById(box1).className = 'pesquisaBoxOption';
	document.getElementById(box2).className = 'pesquisaBoxOption';
	document.getElementById(box3).className = 'pesquisaBoxOption';
	
	
}

