function getOffer(p_ofecod, p_sprind, fprapr, aprcod, orden, aptcod, numnoc, fecsal, oriFirst){

	//alert("oriFirst: " + oriFirst);
	
	// link de las ofertas
	origenStr = String(vCodOrigenes[document.getElementById("s_o").selectedIndex]);
	codOri = origenStr.substring(0,origenStr.indexOf(","));
		
	if (codOri == "") codOri = oriFirst;

	if (numnoc.indexOf("-")==-1){	//caso numnoches sin rango
		noches=numnoc;
	} else {						//caso numnoches con rango cogemos el primer valor
		noches = numnoc.substring(0,numnoc.indexOf("-"));
	}
	
	var mensaje_ofertas = '';
	
	mensaje_ofertas += '<table cellSpacing="0" width="100%" height="100%" border="1" borderColor="#cc0000" cellPadding="0" bgcolor=#ffffff>';
	mensaje_ofertas += '<tr>';
	mensaje_ofertas += '<td class=mensaje_ofertas align=center borderColor="#ffffff" height=80>';
	mensaje_ofertas += 'Más información y Reservas en su Agencia de Viajes';
	mensaje_ofertas += '<br><br> <a href=javascript:oculta_login()><img src="estatico/n_volver.gif" border=0></a><br>';
	mensaje_ofertas += '</td>';
	mensaje_ofertas += '</tr>';
	mensaje_ofertas += '<tr>';
	mensaje_ofertas += '<td borderColor="#ffffff" align=center valign=top>';
	mensaje_ofertas += '<table cellSpacing="0" width="80%" border="10" cellPadding="0" bgcolor="#f1f1f6" borderColor="#f1f1f6">';
	mensaje_ofertas += '<form name="form2" method="post" onSubmit=acceso_ofertas("form2") target=_top>';
	mensaje_ofertas += '<input type="hidden" value="'+p_ofecod+'" name="p_ofecod">';
	mensaje_ofertas += '<input type="hidden" value="'+p_sprind+'" name="p_sprind">';
	mensaje_ofertas += '<input type="hidden" value="'+fprapr+"_"+aprcod+'" name="p_producto">';
	mensaje_ofertas += '<input type="hidden" value="'+codOri+'" name="p_aptcod">';
	mensaje_ofertas += '<input type="hidden" value="'+noches+'" name="p_numnoc">';
	mensaje_ofertas += '<input type="hidden" value="'+fecsal+'" name="p_fecsal">';
	mensaje_ofertas += '<input type="hidden" value="ofertas.hoteles_tt" name="p_action">';
	mensaje_ofertas += '<input type="hidden" value="S" name="p_header">';
	mensaje_ofertas += '<input type="hidden" value="S" name="p_menu">';
	mensaje_ofertas += '<tr>';
	mensaje_ofertas += '<td class=ofertas_log_tit align=left colspan=2>';
	mensaje_ofertas += 'Agencias de Viajes';
	mensaje_ofertas += '</td>';
	mensaje_ofertas += '</tr>';
	mensaje_ofertas += '</tr>';
	mensaje_ofertas += '<td class=ofertas_log_txt align=left colspan=2>';
	mensaje_ofertas += 'Si es una Agencia de Viajes registrada puede continuar el proceso introduciendo sus datos de usuario:';
	mensaje_ofertas += '</td>';
	mensaje_ofertas += '</tr>';
	mensaje_ofertas += '<tr><td class=espacio_sep colspan=2>&nbsp;</td></tr>';
	mensaje_ofertas += '<tr>';
	mensaje_ofertas += '<td class=ofertas_log_txt align=left width=50%>';
	mensaje_ofertas += '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Usuario:';
	mensaje_ofertas += '</td>';
	mensaje_ofertas += '<td class=ofertas_log_txt align=left width=50%>';
	mensaje_ofertas += '<input type="text" name="p_usuario" class="h_clogin" size="12" maxlength="20" >';
	mensaje_ofertas += '</td>';
	mensaje_ofertas += '</tr>';
	mensaje_ofertas += '<tr>';
	mensaje_ofertas += '<td class=ofertas_log_txt align=left>';
	mensaje_ofertas += '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Contraseña:';
	mensaje_ofertas += '</td>';
	mensaje_ofertas += '<td class=ofertas_log_txt align=left>';
	mensaje_ofertas += '<input type="password" name="p_password" class="h_clogin" size="12" maxlength="20"  >';
	mensaje_ofertas += '</td>';
	mensaje_ofertas += '</tr>';
	mensaje_ofertas += '<tr>';
	mensaje_ofertas += '<td class=ofertas_log_txt align=left>';
	mensaje_ofertas += '';
	mensaje_ofertas += '</td>';
	mensaje_ofertas += '<td class=ofertas_log_txt align=left height=20>';
	mensaje_ofertas += '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type="image" src="estatico/ofe_entrar.gif" border="0" alt="Login" >';
	mensaje_ofertas += '</td>';
	mensaje_ofertas += '</tr>';
	mensaje_ofertas += '</form>';
	mensaje_ofertas += '</table>';
	mensaje_ofertas += '</td>';
	mensaje_ofertas += '</tr>';
	mensaje_ofertas += '</table>';
	
	
	self.scrollTo(10);
	var pantalla = document.body.clientWidth;
	var pos = ((pantalla/2+50)-325);
	document.getElementById("login_ofertas").style.left=(pos);
	document.getElementById("login_ofertas").style.visibility="visible";
	document.getElementById("login_ofertas").innerHTML=mensaje_ofertas;

}


function getParques(p_ofecod, p_sprind, fprapr, aprcod, orden, aptcod, numnoc, fecsal, oriFirst, tipOfe){
	
	// link de las ofertas
	origenStr = String(vCodOrigenes[document.getElementById("s_o").selectedIndex]);
	codOri = origenStr.substring(0,origenStr.indexOf(","));
		
	if (codOri == "") codOri = oriFirst;

	if (numnoc.indexOf("-")==-1){	//caso numnoches sin rango
		noches=numnoc;
	} else {						//caso numnoches con rango cogemos el primer valor
		noches = numnoc.substring(0,numnoc.indexOf("-"));
	}
	
	var mensaje_ofertas = '';
	
	mensaje_ofertas += '<table cellSpacing="0" width="100%" height="100%" border="1" borderColor="#cc0000" cellPadding="0" bgcolor=#ffffff>';
	mensaje_ofertas += '<tr>';
	mensaje_ofertas += '<td class=mensaje_ofertas align=center borderColor="#ffffff" height=80>';
	mensaje_ofertas += 'Más información y Reservas en su Agencia de Viajes';
	mensaje_ofertas += '<br><br> <a href=javascript:oculta_login()><img src="estatico/n_volver.gif" border=0></a><br>';
	mensaje_ofertas += '</td>';
	mensaje_ofertas += '</tr>';
	mensaje_ofertas += '<tr>';
	mensaje_ofertas += '<td borderColor="#ffffff" align=center valign=top>';
	mensaje_ofertas += '<table cellSpacing="0" width="80%" border="10" cellPadding="0" bgcolor="#f1f1f6" borderColor="#f1f1f6">';
	mensaje_ofertas += '<form name="form2" method="post" onSubmit=acceso_ofertas("form2") target=_top>';
	mensaje_ofertas += '<input type="hidden" value="'+p_ofecod+'" name="p_ofecod">';
	mensaje_ofertas += '<input type="hidden" value="'+p_sprind+'" name="p_sprind">';
	mensaje_ofertas += '<input type="hidden" value="'+fprapr+"_"+aprcod+'" name="p_producto">';
	mensaje_ofertas += '<input type="hidden" value="'+codOri+'" name="p_aptcod">';
	mensaje_ofertas += '<input type="hidden" value="'+noches+'" name="p_numnoc">';
	mensaje_ofertas += '<input type="hidden" value="'+fecsal+'" name="p_fecsal">';
	mensaje_ofertas += '<input type="hidden" value="parques.parques" name="p_action">';
	mensaje_ofertas += '<input type="hidden" value="S" name="p_header">';
	mensaje_ofertas += '<input type="hidden" value="S" name="p_menu">';
	mensaje_ofertas += '<tr>';
	mensaje_ofertas += '<td class=ofertas_log_tit align=left colspan=2>';
	mensaje_ofertas += 'Agencias de Viajes';
	mensaje_ofertas += '</td>';
	mensaje_ofertas += '</tr>';
	mensaje_ofertas += '</tr>';
	mensaje_ofertas += '<td class=ofertas_log_txt align=left colspan=2>';
	mensaje_ofertas += 'Si es una Agencia de Viajes registrada puede continuar el proceso introduciendo sus datos de usuario:';
	mensaje_ofertas += '</td>';
	mensaje_ofertas += '</tr>';
	mensaje_ofertas += '<tr><td class=espacio_sep colspan=2>&nbsp;</td></tr>';
	mensaje_ofertas += '<tr>';
	mensaje_ofertas += '<td class=ofertas_log_txt align=left width=50%>';
	mensaje_ofertas += '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Usuario:';
	mensaje_ofertas += '</td>';
	mensaje_ofertas += '<td class=ofertas_log_txt align=left width=50%>';
	mensaje_ofertas += '<input type="text" name="p_usuario" class="h_clogin" size="12" maxlength="20" >';
	mensaje_ofertas += '</td>';
	mensaje_ofertas += '</tr>';
	mensaje_ofertas += '<tr>';
	mensaje_ofertas += '<td class=ofertas_log_txt align=left>';
	mensaje_ofertas += '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Contraseña:';
	mensaje_ofertas += '</td>';
	mensaje_ofertas += '<td class=ofertas_log_txt align=left>';
	mensaje_ofertas += '<input type="password" name="p_password" class="h_clogin" size="12" maxlength="20"  >';
	mensaje_ofertas += '</td>';
	mensaje_ofertas += '</tr>';
	mensaje_ofertas += '<tr>';
	mensaje_ofertas += '<td class=ofertas_log_txt align=left>';
	mensaje_ofertas += '';
	mensaje_ofertas += '</td>';
	mensaje_ofertas += '<td class=ofertas_log_txt align=left height=20>';
	mensaje_ofertas += '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type="image" src="estatico/ofe_entrar.gif" border="0" alt="Login" >';
	mensaje_ofertas += '</td>';
	mensaje_ofertas += '</tr>';
	mensaje_ofertas += '</form>';
	mensaje_ofertas += '</table>';
	mensaje_ofertas += '</td>';
	mensaje_ofertas += '</tr>';
	mensaje_ofertas += '</table>';
	
	
	self.scrollTo(10);
	var pantalla = document.body.clientWidth;
	var pos = ((pantalla/2+50)-325);
	document.getElementById("login_ofertas").style.left=(pos);
	document.getElementById("login_ofertas").style.visibility="visible";
	document.getElementById("login_ofertas").innerHTML=mensaje_ofertas;

}


	function acceso_ofertas(form){
		pass=document.form2.p_password.value.toUpperCase();
		document.form2.p_password.value=pass;
		user=document.form2.p_usuario.value.toUpperCase();
		document.form2.p_usuario.value=user;
		document.form2.action="/reserves/do/agencias.login";
		document.form2.submit();
	}
	
	function oculta_login() {
		document.getElementById("login_ofertas").style.visibility="hidden";
	}


function errorIcono(imagen){
	imagen.src="/www/img/airlines/cia_blanco.gif";
}

/*
function showPosterList(id){

	document.getElementById("posterOn").value = 1;
	
	postersLib.showPosterListJskk(id);
	
	document.getElementById("posterLisBox").innerHTML = result;
	document.getElementById("posterLisBox").style.display = "block";

}

function hidePosterList(id){
	document.getElementById("posterList_" + id).style.display = "none";
}
*/



/***************************/


function strReplace(str,strSearch){
	output = "";
	for (i=0;i<str.length;i++){
		aux = str.substring(i,(i+1));
		if (aux == strSearch) output += " ";
		else output += aux;
	}
	return output;
}

function showDestinosMes(codMes){
	BuscadorOfertas.showDestinosMes(codMes, callbackDestinosMes);
}

function showResultados(codDes, txtDes){

	document.getElementById("resultBox").style.display = "none";
	document.getElementById("boxPosters").style.display = "none";
	document.getElementById("cargandoBox").style.display = "block";
	
	if (txtDes.indexOf("+")) txtDes = strReplace(txtDes,"+");

	codMesSelect = document.getElementById("s_m");
	codOriSelect = document.getElementById("s_o");

	codMes = Number(document.getElementById("s_m").value);
	codOri = document.getElementById("s_o").value;
	desMes=document.getElementById("s_m").options[document.getElementById("s_m").selectedIndex].text;
	
	desOri = String(vCodOrigenes[document.getElementById("s_o").value]);

	origenStr = String(vCodOrigenes[document.getElementById("s_o").selectedIndex]);
	codOri = origenStr.substring(0,origenStr.indexOf(","));
	desOri = origenStr.substring(origenStr.indexOf(",")+1);

	maxPrice = document.getElementById("s_p").value;

	BuscadorOfertas.showResultados(codOri, codMes, codDes, desOri, txtDes, maxPrice, false, callbackShowResultados);

}

function muestraZonasDes(cod_des, cod_agz, desc_agz){

	destinoNew = cod_des;
	dia_seleccionado = "";
	dia_seleccionado = document.getElementById('fecini').value;
	
	document.paramForm.zonaTur_cod.value = cod_des;
	
	if (dia_seleccionado.length == 8) {
		dia = dia_seleccionado.substring(0,2);
		mes = parseInt(dia_seleccionado.substr(2,2),10) + 1;
		any = dia_seleccionado.substring(4);
	
		if (mes < 10) mes = "0" + mes;
		else mes = mes + "";
	
		dia_seleccionado = dia + mes + any;
		var resultado = InfoDestinosXML.recuperaZonasHTML(cod_des, cod_agz, desc_agz, dia_seleccionado, callbackMuestraZonasDes);
	} else {
		alert("Seleccione el día de entrada");
	}
	document.getElementById("calZona").style.display = 'none';
	document.getElementById("residentTxt").innerHTML = '';

}

function trOver(elem){
	aux = elem.className;
	
	if (aux.indexOf("last") == -1) elem.className = "trIn";
	else elem.className = "trIn last";
}

function trOut(elem){
	aux = elem.className;
	
	if (aux.indexOf("last") == -1) elem.className = "trOut";
	else elem.className = "trOut last";
}

//mostrar_poster_pdf
function showPoster(codofe) {
	
	directorio = "/estatico/";
	dominio = "http://www.soltour.es";
	
	codofe = dominio + "/ofertas/" + codofe;
	
	windowVar=window.open(codofe+".pdf","poster", "toolbar=yes,scrollbars=yes,resizable=yes");
	
	//document.getElementById("posterOn").value = 1;
}

function callBackGetFechaActualizacion(data){

	if (okFunction(data)) document.getElementById("actualizado").innerHTML = data;
	else showError(data);
	
}

function callBackGetComboMeses(data){

	if (okFunction(data))
		document.getElementById("s_mes").innerHTML = '<select id="s_m" onchange="showDestinosMes(this.options[this.selectedIndex].value)" style="desp_ofertas" style="width:150">'+ data +'</select>';
	else showError(data);

}

function callBackGetComboOrigenes(data){

	if (okFunction(data))
		document.getElementById("s_origen").innerHTML = '<select id="s_o" style="desp_ofertas" style="width:150">'+ data +'</select>';		
	else showError(data);

}

function callBackGetOrigenesMesVec(data){

	if (okFunction(data)) eval(data);
	else showError(data);
	
}

function callbackShowResultados(data){

	if (okFunction(data)){
	
		document.getElementById("resultBox").innerHTML = data;
		document.getElementById("cargandoBox").style.display = "none";
		document.getElementById("resultBox").style.display = "inline";
		
	} else showError(data);

}

function callbackDestinosMes(data){

	if (okFunction(data)){
	
		destinos = data.substring(0,data.indexOf("*"));
		vDestinoJs = data.substring(data.indexOf("*")+1);
		document.getElementById("buscadorOfertas").innerHTML = data;
		
	} else showError(data);

}

function okFunction(info){

	if (info.indexOf("ERROR") < 0) return true;
	else return false;

}

function showError(info){

	document.getElementById("boxParametros").style.display = "none";
	document.getElementById("boxError").style.display = "block";
	document.getElementById("boxError").innerHTML = info;
	
}

/*****Objeto posterCollection*****/
function posterCollection(){
	//atributos
	this.vecGlobal=new Array();
	
	//métodos
	this.addPosterList=addPosterList;		//añade una lista de posters a la coleccion
	this.showPosterListJskk=showPosterListJskk;		//muestra una lista de posters
}

//Añade una Lista de Posters a la Coleccion
function addPosterList(posterList){
	this.vecGlobal[this.vecGlobal.length]=posterList;
}

//Dado un Código de lista
//Muestra la tabla que se corresponde con la lista
function showPosterListJskk(codLista){
	
	aux = "";
	aux += "<table class='posterList' cellpadding='0' cellspacing='0'>";
	aux += "<caption>Posters</caption>";
	aux += "<thead>";
	aux += "	<th class='col1'></th>";
	aux += "	<th class='col2'></th>";
	aux += "</thead>";

	for (kk=0, exit=false; ((kk < this.vecGlobal.length) && (!exit)) ;kk++){
		codActual = this.vecGlobal[kk].getCodPosterList();
		if (codActual == codLista){
			aux += this.vecGlobal[kk].showList();
			exit = true;
		}
	}
	
	aux += "</table>";
	
	return aux;
	
}

/*****Objeto posterList*****/
function posterList(codPosterList){
	//atributos
	this.codPosterList=codPosterList
	this.vec=new Array();
	
	//métodos
	this.getCodPosterList=getCodPosterList;	//devuelve el código de la lista
	this.addPosterDef=addPosterDef;			//añade a la lista un poster pasando la definicion como parámetro
	this.addPoster=addPoster;				//añade un poster a la lista
	this.showList=showList;					//muestra una lista de posters
}

//Devuelve el código de la Lista de Posters
function getCodPosterList(){
	return this.codPosterList;
}

//Dados un:
//	*Código de poster
//	*Código de destino
//	*Descripción de destino
//Añade un nuevo poster a la Lista de posters
function addPosterDef(codPoster,codDestino,desDestino){
	newPoster = new poster(codPoster,codDestino,desDestino);
	this.vec[this.vec.length] = newPoster;
}

//Dado un poster
//Lo añade a la lista de Posters
function addPoster(poster){
	this.vec[this.vec.length]=poster;
}

//Muestra la lista de posters
function showList(){
	aux = "";
	
	for (i=0;i<this.vec.length;i++){
		aux += "<tr onclick=\"alert(\'" + this.vec[i].getCodPoster() + "\')\">";
		aux += "<td>" + this.vec[i].getDesDestino() + "</td><td>ico</td></tr>";
		aux += "</tr>";
	}
	
	return aux;

}

/*****Objeto poster*****/
function poster(codPoster,codDestino,desDestino){
	//atributos
	this.codPoster=codPoster;
	this.codDestino=codDestino;
	this.desDestino=desDestino;
	
	//métodos
	this.getPoster=getPoster;		//Devuelve la informacion del poster
	this.getCodDestino=getCodDestino;		//Devuelve el Destino del Poster
	this.getDesDestino=getDesDestino;		//Devuelve el Destino del Poster
	this.getCodPoster=getCodPoster;	//Devuelve el Código del Poster
}

//Devuelve el codigo
function getCodPoster(){
	return this.codPoster;
}

//Devuelve el Código Destino
function getCodDestino(){
	return this.codDestino;
}

//Devuelve la Descripción Destino
function getDesDestino(){
	return this.desDestino;
}

//Devuelve la informacion del poster
function getPoster(){
	aux = "";
	aux += "Codposter: " + this.codPoster + " // "; 
	aux += "CodDestino: " + this.codDestino + " // "; 
	aux += "DesDestino: " + this.desDestino;
	
	return aux;
}

function showListaPosters(elem){
	document.getElementById("posterOn").value = 1;
	
	var pantalla = document.body.clientWidth;
	var pos = (pantalla/2+50)-15;
	capaPosters = document.getElementById("boxPosters");
	capaPosters.style.left=(pos);
	capaPosters.style.top = 383 + (26 * (elem-1));
	capaPosters.style.display = "block";
	capaPosters.innerHTML = document.getElementById("postersTable_" + elem).innerHTML;	

}

function closePosterList(){
	document.getElementById("boxPosters").style.display = "none";
}

function overClose(elem){
	elem.className = "col2Over";
}

function outClose(elem){
	elem.className = "col2";
}