

function ControlaLongitud(_maximo, _object, e)
{
	var TextoActual = _object.value;
	
	if (TextoActual.length + 1 > _maximo)
	{
		event.returnValue = false;
	}
}

function CapaCaracteres(_maximo, _object)
{
	var TextoActual = _object.value;
	
	if (TextoActual.length > _maximo)
	{
		_object.value = TextoActual.substr(0, _maximo);
	}
}

function SoloNumeros(e)
{
		if ( ( event.keyCode < 48 ) || ( event.keyCode > 57 ) )
		{
			event.returnValue = false;
		}
		
}

function SoloLetras(e)
{
	if( ( event.keyCode < 57 ) && ( event.keyCode > 48 ) )
	{
		event.returnValue = false;
	}
}

function CampoNumerico(_textbox, _defaultvalue, _checkStringEmpty)
{
	if ( isNaN(_textbox.value) )
	{
		_textbox.value = _defaultvalue;
	}
	
	if ( _checkStringEmpty )
	{
		if ( _textbox.value == "" )
		{
			_textbox.value = _defaultvalue;
		}
	}
}



var strNombreControl;


//MNG 20061016 Cambios FireFox
function AnyadeOpcion(_strValor, _strTexto, _objCombo)
{
	var where = (document.all) ? -1 : null;
	var objNuevaOpcion = document.createElement("OPTION");
	objNuevaOpcion.value = _strValor;
	objNuevaOpcion.text = _strTexto;
	_objCombo.add(objNuevaOpcion, where);
	objNuevaOpcion = null;
}

function LimpiarCombo(_objCombo)
{
	for ( var i = _objCombo.length; i > 0; i-- )
	{
		_objCombo.remove(0);
	}
}


function CerrarVentana()
{
	window.close();
}


// función del recuperada frosfruciana
function ServPant(ValorInicial, Idioma)
{

		var Pos=0;
		if(ValorInicial)
		{
			if(ValorInicial.substr(ValorInicial.length-2,1)==".")
			{
				ValorInicial=ValorInicial+"0";
			}
			else
			{
				if(ValorInicial.substr(ValorInicial.length-3,1)!=".") 
				{ 
					ValorInicial=ValorInicial + ".00";
				}
			}
			for (var i=ValorInicial.length-1;i>=0;i--)
			{
				Pos++;
				if(ValorInicial.substr(i, 1)==".")
				{
					if(Idioma=="EN" || Idioma=="US")
					{
						ValorInicial = ValorInicial.substr(0,i) + "." + ValorInicial.substr(i+1,ValorInicial.length-i);
					}
					else
					{
						ValorInicial = ValorInicial.substr(0,i)+","+ValorInicial.substr(i+1,ValorInicial.length-i);
					}
					Pos=0;
				}
				if(Pos==3 && i>0)
				{
					if(Idioma=="EN" || Idioma=="US")
					{
						ValorInicial = ValorInicial.substr(0,i)+"," + ValorInicial.substr(i,ValorInicial.length-i);
					}
					else
					{
						ValorInicial = ValorInicial.substr(0,i) + "." + ValorInicial.substr(i,ValorInicial.length-i);
					}
					Pos=0;
				}
			}
			return ValorInicial;
		}
		else 
		{
			return 0;
		}
}

function Mouse_Over(obj)
{
	obj.style.cursor = "pointer";
}

function Mouse_Out(obj)
{
	obj.style.cursor = "default";
}

function Formatear_Fechas(_objFecha)
{
	var objFecha = new Date();
	objFecha = _objFecha;
	var intAnyo = objFecha.getFullYear();
    var intMes= objFecha.getMonth();
    intMes= intMes +1;
	var strAuxFecha = objFecha.toDateString();
	
	var index = 2;
	if (window.opera)
		index = 1;
		
	strDia = strAuxFecha.split(' ')[index];
	var strMes = intMes.toString();
	if (strDia.length == 1)
	{
		strDia = "0" + strDia; 
	}
	if (strMes.length == 1)
	{
		strMes = "0" + strMes;
	}
	var strFecha = intAnyo.toString() + strMes + strDia;	
	return strFecha;
}

function ClickLogin(event, _strNombreBoton)
{
	if (  event.keyCode == 13 )
		{
			document.getElementById(_strNombreBoton).click();
			event.returnValue = false;
		}

}

function Confirmacion(_Message)
{
	Page_BlockSubmit = !confirm(_Message);
	return !Page_BlockSubmit;
}

function Volver()
{
	history.back();
}

function AbrirPantallaCompleta(_strURL)
{
	var	strWidth = screen.availWidth;
	var	strHeight = screen.availHeight;
	window.open(_strURL ,"","left=0 , top =0, height =" + strHeight + " , width =  " + strWidth + ", resizable = yes, scrollbars=yes, location=yes , left = 0, top = 0, toolbar=yes, menubar=yes, titlebar=yes, status=yes", false);
}


/*****************************FIREFOX********************************************/

/* 
  Notes: 
    1. edge & help attributes do not work. 
    2. "height" & "width" must be entered before "center" 
    3. if you should choose to set "center=yes" do not put in "left" and "top" 
    4. Minimize button not hidden, but when clicked the window will not disappear 
    5. Aside from the aforementioned, all features should react the same *fingers crossed* 
    6. Still in the works, so don't expect miracles. Any problems/queries/complaints please don't hesitate. 
*/ 

dFeatures = 'dialogHeight: 450px; dialogWidth: 1049px; dialogTop: 646px; dialogLeft: 4px; edge: Raised; center: Yes; help: Yes; resizable: Yes; status: Yes;';//default features 

modalWin = ""; 
function xShowModalDialog( sURL, vArguments, sFeatures ) 
{ 
    if (sURL==null||sURL=='') 
    { 
        alert ("Invalid URL input."); 
        return false; 
    } 
    if (vArguments==null||vArguments=='') 
    { 
        vArguments=''; 
    } 
    if (sFeatures==null||sFeatures=='') 
    { 
        sFeatures=dFeatures; 
    } 
    if (window.navigator.appVersion.indexOf("MSIE")!=-1) 
    { 
        window.showModalDialog ( sURL, vArguments, sFeatures ); 
        return false; 
    } 
    sFeatures = sFeatures.replace(/ /gi,''); 

    aFeatures = sFeatures.split(";"); 
    sWinFeat = "directories=0,menubar=0,titlebar=0,toolbar=0,"; 
    for ( x in aFeatures ) 
    { 
        aTmp = aFeatures[x].split("="); 
        sKey = aTmp[0].toLowerCase(); 
        sVal = aTmp[1]; 
        switch (sKey) 
        { 
			case "scrollbars":
				sWinFeat += "scrollbars=" +sVal+",";
				break;
            case "dialogheight": 
                sWinFeat += "height="+sVal+","; 
                pHeight = sVal; 
                break; 
            case "dialogwidth": 
                sWinFeat += "width="+sVal+","; 
                pWidth = sVal; 
                break; 
            case "dialogtop": 
                sWinFeat += "screenY="+sVal+","; 
                break; 
            case "dialogleft": 
                sWinFeat += "screenX="+sVal+","; 
                break; 
            case "resizable": 
                sWinFeat += "resizable="+sVal+","; 
                break; 
            case "status": 
                sWinFeat += "status="+sVal+","; 
                break; 
            case "center": 
                if ( sVal.toLowerCase() == "yes" ) 
                { 
                    sWinFeat += "screenY="+((screen.availHeight-pHeight)/2)+","; 
                    sWinFeat += "screenX="+((screen.availWidth-pWidth)/2)+","; 
                } 
                break; 
        } 
    } 
    modalWin=window.open(String(sURL),"",sWinFeat); 
    if (vArguments!=null&&vArguments!='') 
    { 
        modalWin.dialogArguments=vArguments; 
    } 
} 

function checkFocus() 
    { 
    if (window.navigator.appVersion.indexOf("MSIE")==-1) 
        { 
        if (modalWin!=null && !modalWin.closed) 
        { 
            self.blur(); 
            modalWin.focus(); 
        } 
    } 
}

//Funcion que muestra el banner super ofertas de Barcelo
function SuperOfferShow(offerType) 
{
	if ( offerType == 19 )
		document.getElementById("imgNuevoHotel").style.display = "inline";

	if ( offerType == 38 )
		document.getElementById("imgSuperSummer").style.display = "inline";

	if ( offerType == 39 )
		document.getElementById("imgSuperMexico").style.display = "inline";

	if ( offerType == 40 )
		document.getElementById("imgWinterWarmer").style.display = "inline";
		
	if ( offerType == 42 )
		document.getElementById("imgBlueWaters").style.display = "inline";
} 

// Función para guardar la posición del scroll
function SaveScrollPositions(_posicionX, _posicionY) {
		var scrolly = typeof window.pageYOffset != 'undefined' ? window.pageYOffset : document.body.scrollTop;
		var scrollx = typeof window.pageXOffset != 'undefined' ? window.pageXOffset : document.body.scrollLeft;

		document.getElementById(_posicionX).value = scrollx;
		document.getElementById(_posicionY).value = scrolly;
}

// Función para aplicar la posición del scroll guardada
function GetScrollPositions(_posicionX, _posicionY)
{
	window.scrollTo(document.getElementById(_posicionX).value, document.getElementById(_posicionY).value);
}

/*
function validarFecha(_controlFechas)
{
	var controlMes = parent.document.getElementById(_controlFechas.id.replace('_DateSelector','_Months'));
	var controlDia = parent.document.getElementById(_controlFechas.id.replace('_DateSelector','_Days'));
	var IDtxtFecha = parent.document.getElementById(_controlFechas.id.replace('_DateSelector','_Fecha'));
	var IDtxtNoches = parent.document.getElementById(_controlFechas.id.split('_')[0] + "_txtNoches");
	var controlDiaSemana = parent.document.getElementById(_controlFechas.id.replace('_DateSelector','_WeekDay'));
	
	
	if ( controlMes.selectedIndex == 0 || controlDia.selectedIndex == 0 )
	{
		document.getElementById(IDtxtFecha).value = "";	
		_controlFechas.rows[0].cells[0].children[0].innerText = " ";
		
		return;
	}
	
	var datosMes = controlMes.options[controlMes.selectedIndex].value;
	
	if ( parseInt(datosMes.split("|")[0]) < parseInt(controlDia.options[controlDia.selectedIndex].text) )
	{
		if ( controlMes.selectedIndex < controlMes.length - 1 )
		{
			controlDia.selectedIndex = 1;
			controlMes.selectedIndex++;
		}
		else
		{
			controlDia.options[datosMes.split("|")[0]].selected = true;
		}
	}
	
	var diaSeleccionado = controlDia.value;
	var mesSeleccionado = controlMes.value.split("|")[1];
	var anyoSeleccionado = controlMes.value.split("|")[2];
	
	var fechaSeleccionada = new Date(anyoSeleccionado, mesSeleccionado - 1, diaSeleccionado);
	controlDiaSemana.innerText = dayNames[fechaSeleccionada.getDay()];
	
	
	if (!document.all)
	{
		if (IDtxtFecha)
		{
			alert(fechaSeleccionada);
			IDtxtFecha.value = formatearFecha(fechaSeleccionada);
			alert(IDtxtFecha.value);
			if (_controlFechas.id.indexOf("Entrada")!= -1)
			{	
				FechaEntrada_PerderFoco();
			}
			if (_controlFechas.id.indexOf("Salida")!= -1)
			{
				FechaSalida_PerderFoco();
			}
		}
	}
}

function SeleccionarValorDDL(_objetoID, _valor)
{	
	var objeto = parent.document.getElementById(_objetoID);

	var length = objeto.options.length;

	var i;
	for (i=0;i<length;i++)
	{
		if (objeto.options[i].value == _valor)
		{
			objeto.options[i].selected = true;
		}
	}
}*/
