/**
	 * devuelve en texto el tipo de suplemento que es
	 *
	 * Tipos de suplementos:
	 * 0 -> por porcentaje (precio_base*precio/100)
	 * 1 -> por pasajero (precio*n_pasajeros)
	 * 2 -> por pasajero y noche (precio*n_pasajeros*n_noches)
	 * 3 -> por habitación (precio*n_habitaciones)
	 * 4 -> por habitación y noche (precio*n_habitaciones*n_noches)
	 * 5 -> por adulto (precio*n_adultos)
	 * 6 -> por adulto y noche (precio*n_adultos*n_noches)
	 **/
function getTipoSupl (tipo, moneda)
{	var rtdo_mon = "€";
	if (moneda == "P") rtdo_mon = "pts.";
	var rtdo = "";
	if (tipo == "0") rtdo = " % persona";
	else if (tipo == "1") rtdo = rtdo_mon + " persona";
	else if (tipo == "2") rtdo = rtdo_mon + " persona/noche";
	else if (tipo == "3") rtdo = rtdo_mon + " habitación";
	else if (tipo == "4") rtdo = rtdo_mon + " hab./noche";
	else if (tipo == "5") rtdo = rtdo_mon + " adulto";
	else if (tipo == "6") rtdo = rtdo_mon + " adulto/noche";

	return rtdo;
}
/**
	 * devuelve en texto el tipo de des/sup que es
	 *
	 * Tipos de descuentos/suplemento Ind.:
	 * 0 -> por porcentaje (precio_base*precio/100)
	 * 1 -> por habitación y noche (precio*n_habitaciones*n_noches)
	 * 2 -> por pasajero y noche (precio*n_pasajeros*n_noches)
	 * 4 -> por habitación y noche (precio*n_habitaciones*n_noches)
	 **/
function getTipoDescSuplInd (tipo, moneda, tipoPrecio)
{	var rtdo_mon = "€";
	if (moneda == "P") rtdo_mon = "pts.";
	var rtdo = "";
	if (tipo == "0") rtdo = " %";
	else if (tipo == "1" || tipo == "4")
		 {	if (tipoPrecio == "2" || tipoPrecio == "3")//  .../paquete
				rtdo = rtdo_mon + " persona";
			else // .../noche
				rtdo = rtdo_mon + " persona/noche";
		 }else if (tipo == "2") rtdo = rtdo_mon + " persona/noche";

	return rtdo;
}

function f_imp (importe, tipo_moneda)
{	var lc;
	if (tipo_moneda == "E")// euro
	{	lc = new nf_locale(",", ".", 2);
	}else // pts.
	{	lc = new nf_locale(",", ".", 0);
	}
	return nf_formatNum(importe, lc);
}

/**
 * funciones de numberformat
 */
function nf_locale(decimalPoint, thousandSep, fracDigits)
{	this.decimalPoint = new String(decimalPoint);
	this.thousandSep = new String(thousandSep);
	this.fracDigits = fracDigits;
}
function nf_roundFloat(num, fracDigits)
{	var factor = Math.pow(10, fracDigits);
	return(Math.round(num*factor)/factor);
}
function nf_toLcString(num, lc)
{	var str = new String(num);
	var aParts = str.split(".");
	aParts[0]=nf_thousands(aParts[0],lc); // alejandro
	return(aParts.join(lc.decimalPoint));
}
function nf_formatNum(num, lc)
{	var sNum = new String(nf_roundFloat(num, lc.fracDigits));
	if(lc.fracDigits>0)
	{	if(sNum.indexOf(".")<0)
	  		sNum = sNum+".";
		while(sNum.length < 1+sNum.indexOf(".")+lc.fracDigits)
		sNum = sNum+"0";
	}
	return(nf_toLcString(sNum, lc));
}
function nf_parseLcNum(str, lc)
{	var sNum = new String(str);
	var aParts = sNum.split(lc.thousandSep);
	sNum = aParts.join("");
	aParts = sNum.split(lc.decimalPoint);
	return(parseFloat(aParts.join(".")));
}
// alejandro
function nf_thousands (sNum,lc)
{	var num = parseInt (sNum);
	var str = (Math.abs (num)).toString ();
	var pos = str.length;
	pos -= 3;
	while (pos > 0)
	{	str = str.substring(0,pos) + lc.thousandSep + str.substring(pos);
		pos -= 3;
	}
	return (num>=0?"":"-") + str;
}
/**
 * fin funciones de numberformat
 */
 
 
// jon  Incluyo ver_oficinas
function ver_oficinas ()
{	var wnd_oficinas = window.open ("/viajeseroski/servlet/genVuelosOficinas?campo=entrega_oficina","winoficinas","width=500,height=400,toolbar=0,statusbar=0,scrollbars=1");
	wnd_oficinas.focus ();
}

/**
 * Resalta un TR al pasar sobre el
 *
 * @param   object    the table row
 * @param   interger  the row number
 * @param   string    the action calling this script (over, out)
 * @param   string    the default background color
 * @param   string    the color to use for mouseover
 *
 * @return  boolean  whether pointer is set or not
 */
function setPointer(theRow, theRowNum, theAction, theDefaultColor, thePointerColor)
{    var theCells = null;
    // 1. Pointer and mark feature are disabled or the browser can't get the
    //    row -> exits
    if (thePointerColor == '' || typeof(theRow.style) == 'undefined')
    {	return false;
    }
    // 2. Gets the current row and exits if the browser can't get it
    if (typeof(document.getElementsByTagName) != 'undefined')
    {	theCells = theRow.getElementsByTagName('td');
    }else
    	if (typeof(theRow.cells) != 'undefined')
    	{	theCells = theRow.cells;
    	}else
    	{	return false;
    	}
    // 3. Gets the current color...
    var rowCellsCnt  = theCells.length;
    var domDetect    = null;
    var currentColor = null;
    var newColor     = null;
    // 3.1 ... with DOM compatible browsers except Opera that does not return
    //         valid values with "getAttribute"
    if (typeof(window.opera) == 'undefined' && typeof(theCells[0].getAttribute) != 'undefined')
    {	currentColor = theCells[0].getAttribute('bgcolor');
        domDetect    = true;
    }else // 3.2 ... with other browsers
    {   currentColor = theCells[0].style.backgroundColor;
        domDetect    = false;
    } // end 3
    // 4. Defines the new color
    // 4.1 Current color is the default one
    if (currentColor == '' || currentColor.toLowerCase() == theDefaultColor.toLowerCase())
    {	if (theAction == 'over' && thePointerColor != '')
    	{	newColor = thePointerColor;
        }
    }else // 4.1.2 Current color is the pointer one
    	 if (currentColor.toLowerCase() == thePointerColor.toLowerCase())
    	 {	if (theAction == 'out')
    	 	{	newColor = theDefaultColor;
        	}
    	}
     // 5. Sets the new color...
    if (newColor)
    {	var c = null;
        // 5.1 ... with DOM compatible browsers except Opera
        if (domDetect)
        {	for (c = 0; c < rowCellsCnt; c++)
        	{	theCells[c].setAttribute('bgcolor', newColor, 0);
            } // end for
        }else// 5.2 ... with other browsers
        {	for (c = 0; c < rowCellsCnt; c++)
        	{	theCells[c].style.backgroundColor = newColor;
            }
        }
    } // end 5
    return true;
} // end of the 'setPointer()' function

//Funciones llamadas desde el menu, que antes estaban en 'menu.js'
function nv(url)
{	var wnd = window.open (url, 'VENTANA');
	wnd.focus();
}

//*** Función de quita espacios en blanco de delante y detrás, ademas de eliminar los espacios duplicados. ***
// XII - Octubre 2009
function jsTrim(JSvalue){
	var JStemp = JSvalue;
	var JSobj = /^(\s*)([\W\w]*)(\b\s*$)/;
	//Elimina los espacios iniciales y finales
	if (JSobj.test(JStemp))
		 JStemp = JStemp.replace(JSobj, '$2')
	//Elimina los espacios duplicados
	var JSobj = / +/g;
	JStemp = JStemp.replace(JSobj, " ");
	if (JStemp == " ")
		JStemp = "";
	//devolvemos la cadena limpia
	return JStemp;
}
