

function disableElements()
{
	document.getElementById('loading').style.display = 'block';
	if(document.getElementById('selMesLat').disabled == false)
	{
		document.getElementById('selMesLat').disabled = true;
	}
	if(document.getElementById('selZonaLat').disabled == false)
	{
		document.getElementById('selZonaLat').disabled = true;
	}
	if(document.getElementById('selNavieraLat').disabled == false)
	{
		document.getElementById('selNavieraLat').disabled = true;
	}
	if(document.getElementById('selDuracion').disabled == false)
	{
		document.getElementById('selDuracion').disabled = true;
	}
	if(document.getElementById('selBoatLat').disabled == false)
	{
		document.getElementById('selBoatLat').disabled = true;
	}
	
}

function enableElements()
{
	document.getElementById('loading').style.display = 'none';
	if(document.getElementById('selMesLat').disabled == true)
	{
		document.getElementById('selMesLat').disabled = false;
	}
	if(document.getElementById('selZonaLat').disabled == true)
	{
		document.getElementById('selZonaLat').disabled = false;
	}
	if(document.getElementById('selNavieraLat').disabled == true)
	{
		document.getElementById('selNavieraLat').disabled = false;
	}
	if(document.getElementById('selDuracion').disabled == true)
	{
		document.getElementById('selDuracion').disabled = false;
	}
	if(document.getElementById('selBoatLat').disabled == true)
	{
		document.getElementById('selBoatLat').disabled = false;
	}	
}

function disableRadioFilter()
{
	if(document.getElementById('radPrice').disabled == false)
	{
		document.getElementById('radPrice').disabled = true;
	}
	if(document.getElementById('radDuration').disabled == false)
	{
		document.getElementById('radDuration').disabled = true;
	}
	if(document.getElementById('radNavy').disabled == false)
	{
		document.getElementById('radNavy').disabled = true;
	}
}

function enableRadioFilter()
{
	if(document.getElementById('radPrice').disabled == true)
	{
		document.getElementById('radPrice').disabled = false;
	}
	if(document.getElementById('radDuration').disabled == true)
	{
		document.getElementById('radDuration').disabled = false;
	}
	if(document.getElementById('radNavy').disabled == true)
	{
		document.getElementById('radNavy').disabled = false;
	}
}

function getItiCount (zona, naviera, mes, duracion, boat) 
{
	disableElements();
	sendRequestCount('/cruises/countItinerary.do?selectedZoneId='+zona+'&selectedDate='+mes+'&selectedNavyId='+naviera+'&selectedDuration='+duracion + '&selectedBoatId='+boat);

}
// Contador de cruceros disponibles
function sendRequestCount(doc)
{
	if(xmlobj!=null&&xmlobj.readyState!=0&&xmlobj.readyState!=4)
	{
       	xmlobj.abort();
	}
	if (window.ActiveXObject) {
		xmlobj = new ActiveXObject("Microsoft.XMLHTTP");
	} else if (window.XMLHttpRequest) {
		xmlobj = new XMLHttpRequest();
	}
	// assign state handler
	
	xmlobj.onreadystatechange=stateCheckerCount;
	// open socket connection
	xmlobj.open('GET',doc,true);
	xmlobj.send(null);
}
function getBoatsByNav (zona, naviera, mes, duracion, boat)
{
	sendRequestByNaviera('/cruises/countItinerary.do?selectedZoneId='+zona+'&selectedDate='+mes+'&selectedNavyId='+naviera+'&selectedDuration='+duracion+'&selectedBoatId='+boat);
}
function getBoatsByNav2(zona, naviera, mes, duracion, boat)
{
	sendRequestByNaviera2('/cruises/countItinerary.do?selectedZoneId='+zona+'&selectedDate='+mes+'&selectedNavyId='+naviera+'&selectedDuration='+duracion+'&selectedBoatId='+boat);
}
function sendRequestByNaviera(docPath)
{
	if(xmlobj!=null&&xmlobj.readyState!=0&&xmlobj.readyState!=4)
	{
       	xmlobj.abort();
	}
	if (window.ActiveXObject) {
		xmlobj = new ActiveXObject("Microsoft.XMLHTTP");
	} else if (window.XMLHttpRequest) {
		xmlobj = new XMLHttpRequest();
	}
	// assign state handler
	
	xmlobj.onreadystatechange=stateGetBoatsByNaviera;
	// open socket connection
	xmlobj.open('GET',docPath,true);
	xmlobj.send(null);
}
function sendRequest(doc)
{
	if(xmlobj!=null&&xmlobj.readyState!=0&&xmlobj.readyState!=4)
	{
       	xmlobj.abort();
	}
	if (window.ActiveXObject) {
		xmlobj = new ActiveXObject("Microsoft.XMLHTTP");
	} else if (window.XMLHttpRequest) {
		xmlobj = new XMLHttpRequest();
	}
	// assign state handler
	
	xmlobj.onreadystatechange=stateChecker;
	// open socket connection
	xmlobj.open('GET',doc,true);
	xmlobj.send(null);
}

function sendRequestRecommended(doc)
{
	disableRadioFilter();
	if(httpRequest!=null&&httpRequest.readyState!=0&&httpRequest.readyState!=4)
	{
       	httpRequest.abort();
	}
	if (window.ActiveXObject) {
		httpRequest = new ActiveXObject("Microsoft.XMLHTTP");
	} else if (window.XMLHttpRequest) {
		httpRequest = new XMLHttpRequest();
	}
	// assign state handler
	
	httpRequest.onreadystatechange=stateCheckerRecommended;
	// open socket connection
	httpRequest.open('GET',doc,true);
	httpRequest.send(null);
}

function stateCheckerRecommended()
{
	if(httpRequest.readyState==4)
	{
       	if(httpRequest.status==200)
		{
			//recogemos el json como string.
			var profileJson = httpRequest.responseText;
			//parseamos el json.
			var jsonParsed = eval('(' + profileJson + ')');
			//cogemos el array de recomendados.
			var recommendeds = jsonParsed.oferta;
			
			displayRecommended(recommendeds);
			enableRadioFilter();
		}
	    else
		{
       		alert('Fallo al recibir json recommended');
	    }
    }
}
//muestra los recomendados.
function displayRecommended(recommendeds)
{
	var recomendedsDiv = document.getElementById('nuestras_ofertas');
	if (recomendedsDiv != null && recomendedsDiv != "") {
		recomendedsDiv.innerHTML = '';
				
		var tableofertas = document.createElement('table');
		var tbodyofertas = document.createElement('tbody');
		tableofertas.appendChild(tbodyofertas);
		recomendedsDiv.appendChild(tableofertas);
		
		var troferta;
		var tdimagen;
		var divimg;
		var aconimg;
		var aimg;
		var tdtexto;
		var h5;
		var divtit;
		var diviti;
		var divdur;
		var divsal;
		var divpre;
		var tdnaviera;
		var imgitinerario;
		var trsepara;
		var tdsepara;
		
		var tdOfertas;
		var trOfertas;
		var divResultado;
		var divImg;
		var imgBarco;
		var divInfo;
		var ulTexto;
		var liTitulo;
		var liItinerario;
		var divLiTitulo;
		var textTitulo;
		var divLiMarca;
		var imgLogo;
		var spanItinerario;
		var textItinerario;
		var divLiClearer;
		var aTitulo;
		var texItinerario;
		var liDuracion;
		var spanDuracion;
		var textDuracion;
		var texDuracion;
		var liSalidas;
		var spanSalidas;
		var textSalidas;
		var texSalidas;
		var divMapa;
		var divPrecio;
		var aPrecio;
		var textPrecioDesde;
		var divBotonSeleccionar;
		var imgBotonSeleccionar;
		var textBoatName;
		var spanBoatName;
		var linkBoatName;
		var imgDescBarco;
		
		for (var i = 0; i < recommendeds.length; i++) {
			// Crear el TR para los recomendados.
			trOfertas = document.createElement('tr');
			// Crear el TD para los recomendados.
			tdOfertas = document.createElement('td');
			// Crear el DIV global
			divResultado = document.createElement('div');
			// Añadair la clase al DIV
			divResultado.setAttribute('class', 'resultado-crc');
			divResultado.className = 'resultado-crc';
			// Crear el DIV para la imagem
			divImg = document.createElement('div');
			// Añadir la clase al DIV de la imagem.
			divImg.setAttribute('class', 'img');
			divImg.className = 'img';
			
			divLiMarca = document.createElement('div');
			// Añadir la clase al DIV marca.
			divLiMarca.setAttribute('class', 'marca');
			divLiMarca.className = 'marca';
			// Crear el IMG para el logo.
			imgLogo = document.createElement('img');
			// Añadir el SRC a la imagem.
			imgLogo.setAttribute('src', '/pictures/logo_' + recommendeds[i].codigoNaviera + '.gif');
			// Añadir el DIV marca a la linea de la lista.
			divImg.appendChild(imgLogo);
			
			
			var divDescuentoImagen = document.createElement('div');
			divDescuentoImagen.setAttribute('id', 'imgDescu');
			divDescuentoImagen.idName = 'imgDescu';
			
			imgDescBarco = document.createElement('img');
			imgDescBarco.setAttribute('src', '/pictures/dto-10-crc.gif');
			
			divDescuentoImagen.appendChild(imgDescBarco);
			divImg.appendChild(divDescuentoImagen);
			
			// Crear la IMG para a la imagem.
			imgBarco = document.createElement('img');
			// Añadir la referencia de la imagem.
			imgBarco.setAttribute('src', '/images/cruises/' + recommendeds[i].codigoNaviera + recommendeds[i].codigoBarco + '.jpg');
			// Añadir el alt a la imagem.
			imgBarco.setAttribute('alt', recommendeds[i].nombreBarco);
			// Añadir el Width a la imagem.
			imgBarco.setAttribute('width', '161');
			// Añadir el Height a la imagem.
			imgBarco.setAttribute('height', '106');
			// Añadir el border a la imagem.
			imgBarco.setAttribute('border', '0');
			// Añadir la imagem al DIV de la imagem.
			divImg.appendChild(imgBarco);
			//Crear span par ael texto del nombre del barco.
			spanBoatName = document.createElement('span');
			//Añadir los estilos.
			spanBoatName.setAttribute('style', 'float: left; padding-bottom: 3px; padding-top: 3px;');
			// Crear un texto con el nombre del barco.
			textBoatName = document.createTextNode(recommendeds[i].nombreBarco.toUpperCase());
			//Poner el texto como link.
			linkBoatName = document.createElement('a');
			//Poner la clase al link.
			linkBoatName.setAttribute('class', 'textos-enlaces-bold');
			//Poner los estilos.
			linkBoatName.setAttribute('style', 'white-space: nowrap');
			//Añadir el href al link.
			linkBoatName.setAttribute('href', '/cruises/showCruiseDetailMatriz.do?selectedCruise=' +
			recommendeds[i].codigoItinerario +
			'&selectedDate=' +
			recommendeds[i].fechaprecio +
			'&tab=ficha&ship=' +
			recommendeds[i].codigoBarco +
			'&cruise=' +
			recommendeds[i].codigoItinerario +
			'&navy=' +
			recommendeds[i].codigoNaviera +
			'');
			//Añadir el texto al link.
			linkBoatName.appendChild(textBoatName);
			//Añadir el link al span.
			spanBoatName.appendChild(linkBoatName);
			//Añadir el span con el nombre del barco al divImg.
			divImg.appendChild(spanBoatName);
			// Añadir el DIV de la imagem al DIV global
			divResultado.appendChild(divImg);
			
			// Crear el DIV de Info
			divInfo = document.createElement('div');
			// Añadir la clase al DIV info.
			divInfo.setAttribute('class', 'info');
			divInfo.className = 'info';
			// Añadir el DIV info al DIV global.
			divResultado.appendChild(divInfo);
			// Crear una lista no ordenada para mostar las caracteristicas de de la oferta.
			ulTexto = document.createElement('ul');
			// Crear la linea de la lista para el Titulo
			liTitulo = document.createElement('li');
			// Crear el DIV para la linea del titulo.
			divLiTitulo = document.createElement('div');
			// Añadir la clase al DIV del titulo.
			divLiTitulo.setAttribute('class', 'titulo');
			divLiTitulo.className = 'titulo';
			// Crear el texto para el titulo.
			aTitulo = document.createElement('a');
			// href título.
			aTitulo.setAttribute('href', '/cruises/searchCruises.do?selectedDate=' + recommendeds[i].fechaprecio + '&selectedCruise=' + recommendeds[i].codigoItinerario + '&selectedNavyId=' + recommendeds[i].codigoNaviera);
			// Nombre del itinerario.
			textTitulo = document.createTextNode(recommendeds[i].nombreItinerario);
			// Añadir el nombre del itinerario al enlace.
			aTitulo.appendChild(textTitulo);
			// Añadir el textNode al DIV de Tiutlo.
			divLiTitulo.appendChild(aTitulo);
			// Añadir el DIV al LI.
			liTitulo.appendChild(divLiTitulo);
			//añadir div precio.
			divPrecio = document.createElement('div');
			//Añadir el class al div precio,
			divPrecio.setAttribute('class','precio');
			//class
			divPrecio.className='precio';
			//precio.
			textPrecioDesde = document.createTextNode(recommendeds[i].precio + String.fromCharCode(8364));
			//link precio.
			aPrecio = document.createElement('a');
			//href precio.
			aPrecio.setAttribute('href', '/cruises/searchCruises.do?selectedDate=' + recommendeds[i].fechaprecio + '&selectedCruise=' + recommendeds[i].codigoItinerario + '&selectedNavyId=' + recommendeds[i].codigoNaviera);
			//Añadir precio al enlace.
			aPrecio.appendChild(textPrecioDesde);
			//Añadir enlace al div precio.
			divPrecio.appendChild(aPrecio);
			//Añadir el div precio a la li
			liTitulo.appendChild(divPrecio);
			//Crear el DIV clearer.
			divLiClearer = document.createElement('div');
			//Añadir la clase al DIV clearer.
			divLiClearer.setAttribute('class', 'clearer');
			divLiClearer.className = 'clearer';
			
			// Añadir el DIV clearer a Li de la lista.
			liTitulo.appendChild(divLiClearer);
			// Añadir el LI al UL.
			ulTexto.appendChild(liTitulo);
			// Crear el LI de la linea con Itinerario,
			liItinerario = document.createElement('li');
			// Crear el SPAN para el Itinerario.
			spanItinerario = document.createElement('span');
			// Crear el texto de Itinerario.
			textItinerario = document.createTextNode('Itinerario:');
			// Añaadir el text al spanItinerario.
			spanItinerario.appendChild(textItinerario);
			// Añadir el SPAN itinerario al LI de la lista.
			liItinerario.appendChild(spanItinerario);
			//Crear el texto de itinerario.
			var str = recommendeds[i].nombreItinerario;
			if (str.length >= 30) {
				//Anadir el itinerario  al Li de la lista.
				texItinerario = document.createTextNode(str.substring(0, 30) + '...');
			}
			else {
			
				texItinerario = document.createTextNode(str);
			}
			//Anadir el itinerario  al Li de la lista.
			liItinerario.appendChild(texItinerario);
			// Añadir el LI de Itinerario a la lista.
			ulTexto.appendChild(liItinerario);
			// Crear el LI de la Duracion
			liDuracion = document.createElement('li');
			// Crear el SPAN de la duracion.
			spanDuracion = document.createElement('span');
			// Crear el texto de duracion.
			var duraccion = 'Duracion';
			textDuracion = document.createTextNode(duraccion+':');
			// Añadir el texto al SPAN
			spanDuracion.appendChild(textDuracion);
			// Añadir el SPAN duracion al LI de Duracion
			liDuracion.appendChild(spanDuracion);
			// Crear el texto de duracion;
			texDuracion = document.createTextNode(recommendeds[i].duracion);
			// Añadir el texto duracion al LI de lista.
			liDuracion.appendChild(texDuracion);
			//Añadir el LI de la duracion a la lista
			ulTexto.appendChild(liDuracion);
			// Crear el LI para las salidas.
			liSalidas = document.createElement('li');
			//crear el span de salidas.
			spanSalidas = document.createElement('span');
			//crear el texto de salidas.
			textSalidas = document.createTextNode('Salidas:');
			//Añadir el texto salidas al spanSalidas.
			spanSalidas.appendChild(textSalidas);
			//Añdair el spanSalidas al LI de salidas.
			liSalidas.appendChild(spanSalidas);
			//crear el texto para salidas.
			texSalidas = document.createTextNode(recommendeds[i].salidas);
			// Añadir el texto de salidas al Li de salidas.
			liSalidas.appendChild(texSalidas);
			// Añadir el LI de salidas al UL
			ulTexto.appendChild(liSalidas);
			// Añadir el Ul al DIV de info.
			divInfo.appendChild(ulTexto);
			//Añadir el DIV info al DIV resultado
			divResultado.appendChild(divInfo);
			//crear el DIV para el Mapa
			divMapa = document.createElement('div');
			//Añadir la class al DIV mapa.
			divMapa.setAttribute('class','mapa');
			divMapa.className='mapa';
			
			//Crear el img del mapa.
			var imgMap = document.createElement('img');
			// Añadir la imagem del mapa.
			imgMap.setAttribute('src', '/images/cruises/itineraries/' + recommendeds[i].codigoNaviera + '/' + recommendeds[i].codigoNaviera + recommendeds[i].codigoItinerario + '.jpg');
			//añadir la imagem al divMapa
			divMapa.appendChild(imgMap);

			//Añadir el divMapa al div resultado.
			divResultado.appendChild(divMapa);
			//crear el div del boton seleccionar
			divBotonSeleccionar = document.createElement('div');
			//Añadir la class al div del boton seleccionar
			divBotonSeleccionar.setAttribute('class','boton-resultado');
			divBotonSeleccionar.className='boton-resultado';
			//crear la img dek boton seleccionar
			imgBotonSeleccionar = document.createElement('img');
			//Añadir el SRC de la imagem
			imgBotonSeleccionar.setAttribute('src','/pictures/boton_seleccionar.gif');
			//Añadir el alt a la imagem
			imgBotonSeleccionar.setAttribute('alt','seleccionar crucero');
			//Añadir el border al boton
			//Añadir el border al boton
			imgBotonSeleccionar.setAttribute('border','0');
			
			// Crear el href del boton seleccionar.
			var aBotonSelec = document.createElement('a');
			//añadir el href al a.
			aBotonSelec.setAttribute('href', '/cruises/searchCruises.do?selectedDate=' + recommendeds[i].fechaprecio + '&selectedCruise=' + recommendeds[i].codigoItinerario + '&selectedNavyId=' + recommendeds[i].codigoNaviera);
			//Añadir el link al boton.
			aBotonSelec.appendChild(imgBotonSeleccionar);
			
			//Añadir al imagem del boton al divBotonSeleccionaar
			divBotonSeleccionar.appendChild(aBotonSelec);

			//Añadir el divBotonSelecionar al divResultado.
			divResultado.appendChild(divBotonSeleccionar);
			// Añadir el DIV al TD
			tdOfertas.appendChild(divResultado);
			// Añadir el TD al TR
			trOfertas.appendChild(tdOfertas);
			// Añadir el TR al TBODY
			tbodyofertas.appendChild(trOfertas);
		}
	}	
	document.getElementById('group-left').style.visibility = 'visible';
}




// check request status
function stateChecker()
{
	if(xmlobj.readyState==4)
	{
       	if(xmlobj.status==200)
		{
			//recogemos el json como string.
			var searchBoxJson = xmlobj.responseText;
			//parseamos el json.
			var jsonSearchBoxParsed = eval('(' + searchBoxJson + ')');
			//cogemos el array de recomendados.
			var navieras = jsonSearchBoxParsed.navieras;
			displayOptionsNaviera(navieras);
			var zonas = jsonSearchBoxParsed.zonas;
			displayOptionsZona(zonas);
			var barcos = jsonSearchBoxParsed.barcos;
			displayOptionBoat(barcos);
			var itinerarios = jsonSearchBoxParsed.itinerarios;
			displayDataCount(itinerarios);
			enableElements();
		}
	    else
		{
       		alert('Fallo al recibir json recommended');
	    }
    }	
}

function stateGetBoatsByNaviera()
{
	if(xmlobj.readyState == 4)
	{
		if(xmlobj.status==200)
		{
			try //Internet Explorer
			{
				xmlDoc=new ActiveXObject("Microsoft.XMLDOM");
				xmlDoc.async="false";
				xmlDoc.loadXML(xmlobj.responseText);
			}
			catch(e) 
			{
				null;
			}
			listOfBoats=xmlobj.responseXML.getElementsByTagName('barco');
			displayListOfBoats();
			
		}
		else
		{
			alert('Fallo al abrir fichero barcos:'+ xmlobj.statusText);
		}
	}
		if(xmlobj.readyState==4)
	{
       	if(xmlobj.status==200)
		{
			//recogemos el json como string.
			var listOfBoatsJson = xmlobj.responseText;
			//parseamos el json.
			var listOfBoatsParsed = eval('(' + listOfBoatsJson + ')');
			var boats = listOfBoatsParsed.barcos;
			displayListOfBoats(boats);
	    }
	    else
		{
       		alert('Fallo al abrir fichero barcos:'+ xmlobj.statusText);
	    }
    }	
}
// display data at a given time interval
function displayListOfBoats(boats)
{
	var selecte = document.getElementById('Barc');
	selector = selecte.childNodes[1];
	/* Limpiar el contenido del select. */
	for (var j = selector.options.length-1; j >= 1 ; j--)
	{
		selector.options[j] = null;
	}
	if (selector != null)
	{
		for (var bo = 0; bo < listOfBoats.length; bo++)
		{
			var option=document.createElement('option');
			option.setAttribute('value',boats[bo].id);
			option.appendChild(document.createTextNode(boats[bo].nombre));
			selector.appendChild(option);
		}
	}	
}

// check request status
function stateCheckerCount()
{
	if(xmlobj.readyState==4)
	{
       	if(xmlobj.status==200)
		{
			//recogemos el json como string.
			var searchBoxJson = xmlobj.responseText;
			//parseamos el json.
			var jsonSearchBoxParsed = eval('(' + searchBoxJson + ')');
			var barcos = jsonSearchBoxParsed.barcos;
			displayOptionBoat(barcos);
			var itinerarios = jsonSearchBoxParsed.itinerarios;
			displayDataCount(itinerarios);
			enableElements();
		}
	    else
		{
       		alert('Fallo al recibir json');
	    }
    }	
}

// create data container
function createDataContainer(){
    var div=document.getElementById('container');
    if(div){return};
    var div=document.createElement('div');
    div.setAttribute('id','container');
    document.getElementsByTagName('body')[0].appendChild(div);
}

// display data at a given time interval
function displayOptionsNaviera(navieras){
    // reset data container
    selector = document.getElementById('selNavieraLat');
	if(selector != null){
		for(var i=0;i<navieras.length;i++){
			// create option
			var option=document.createElement('option');
			// assign 'value' attribute
			option.setAttribute('value',navieras[i].code);
			// add link labels
			option.appendChild(document.createTextNode(navieras[i].nombre));
			selector.appendChild(option);
		}
	}
}
function displayOptionBoat(barcos)
{
	selector = document.getElementById('selBoatLat');
	if (selector.options[selector.selectedIndex].value == -1)
	{
		/* Limpiar el contenido del select. */
		for (var j = selector.options.length-1; j >= 1 ; j--)
		{
			selector.options[j] = null;
		}
		if (selector != null)
		{
			for (var bo = 0; bo < barcos.length; bo++)
			{
				var option=document.createElement('option');
				option.setAttribute('value',barcos[bo].id);
				option.appendChild(document.createTextNode(barcos[bo].nombre));
				selector.appendChild(option);
			}
		}
	}
	else
	{
		var boatCode = selector.options[selector.selectedIndex].value;
		var boatName = selector.options[selector.selectedIndex].text;
		for (var j = selector.options.length; j > 0 ; j--)
		{
			selector.options[j] = null;
		}
		if (selector != null)
		{
			var option=document.createElement('option');
			option.setAttribute('value', boatCode);
			option.appendChild(document.createTextNode(boatName));
			option.selected= true;
			selector.appendChild(option);
		}
	}
}


// display data at a given time interval
function displayOptionsZona(zonas){
    // reset data container
    selector = document.getElementById('selZonaLat');
	if(selector != null){
		for(var i=0;i<zonas.length;i++){
			// create option
			var option=document.createElement('option');
			// assign 'value' attribute
			option.setAttribute('value',zonas[i].code);
			// add optionText
			option.appendChild(document.createTextNode(zonas[i].nombre));
			selector.appendChild(option);
		}
	}
}

// display data at a given time interval
function displayDataCount(itinerarios)
{
	var result = document.getElementById('numResult');
	result.innerHTML = '';
	result.appendChild(document.createTextNode(itinerarios));	
}


function expandCollapseCheck(idPanel,checkBox)
{
 var panel = document.getElementById(idPanel);
 
 if(checkBox.checked==true)
 {
	 panel.style.display="block";
 }
 else
 {
	panel.style.display="none";
 }
}
function validateSelectForm(formBuscador){
	var selectMes  = document.getElementById("selMesLat").value;
	if(selectMes == ""){
		alert("Debe seleccionar por lo menos el mes.");
		return false;
	}else{
		return true;
	}
}

function displayMonthAndYear()

{
    var mappingOfMonths =  new Array(12);
    mappingOfMonths[0]='Enero';
    mappingOfMonths[1]='Febrero';
    mappingOfMonths[2]='Marzo';
    mappingOfMonths[3]='Abril';
    mappingOfMonths[4]='Mayo';
    mappingOfMonths[5]='Junio';
    mappingOfMonths[6]='Julio';
    mappingOfMonths[7]='Agosto';
    mappingOfMonths[8]='Septiembre';
    mappingOfMonths[9]='Octubre';
    mappingOfMonths[10]='Noviembre';
    mappingOfMonths[11]='Diciembre';
    /* Numero de meses de  rango.*/
    var numberOfMonths = 12;
    var todaysDate = new Date();
    /* Obtener el select de la fecha.*/
    var selectBox = document.getElementById('selMesLat');
    /* Limpiar el contenido que tenga si no se acumula. Se empieza por borrar desde el ultimo hasta el primero pero no se borra el primero para que salge el Cualquiera.*/
    for (var i = selectBox.options.length-1; i >= 1;i--)
    {
        selectBox.options[i] = null;
    }
    for (var months = 0 ; months < numberOfMonths ; months++)
    {
        /* Formatear la fecha para el formato utilizado . Mes(nombre)  Año (4digitos), por ejemplo Mayo 2010.*/
        var option = document.createElement('option');
        if ((todaysDate.getMonth()+parseInt(1)) < 10 )
        {
            option.setAttribute('value', ('0'+(todaysDate.getMonth()+parseInt(1)))+" "+todaysDate.getFullYear());
        }
        else
        {
            option.setAttribute('value', (todaysDate.getMonth()+parseInt(1))+" "+todaysDate.getFullYear());
        }
        var s = mappingOfMonths[todaysDate.getMonth()]+' '+todaysDate.getFullYear();
        var textOption = document.createTextNode(mappingOfMonths[todaysDate.getMonth()]+' '+todaysDate.getFullYear());
        option.appendChild(textOption);
        selectBox.appendChild(option);
        (todaysDate.setMonth((todaysDate.getMonth()+parseInt(1))));        
    }
}


function getItineraryByNa(navyCode)
{
	sendRequestGetNavyByCode('/cruises/searchCruises.do?selectedNavyId='+navyCode);
}

function sendRequestGetNavyByCode(urlAndParams)
{
	if(xmlobj != null && xmlobj.readyState !=0 && xmlobj.readyState != 4)
	{
		xmlobj.abort();
	}
	try
	{
		xmlobj=new XMLHttpRequest();
		xmlobj.overrideMimeType('application/xml');   
	}
	catch(e)
	{
		try
		{
			xmlobj=new ActiveXObject('Microsoft.XMLHTTP');
		}
		catch(e)
		{
			xmlobj=null;
			return false;
		}
	}
        xmlobj.onreadystatechange;
	xmlobj.open('GET',urlAndParams,true);
        xmlobj.send(null);
}
// create data container
function createDataContainer(){
    var div=document.getElementById('container');
    if(div){return};
    var div=document.createElement('div');
    div.setAttribute('id','container');
    document.getElementsByTagName('body')[0].appendChild(div);
}


















