
function demo()
{
	alert("Esto es un demo");
}
//Global script variables
var sWebFlow = '/posadasWebApp/application/commercewf';
//Browser Sniffing (sBrowser variable)
var sBrowser = navigator.userAgent; 
if ((sBrowser.indexOf("IE") > -1) && (navigator.platform == "Win32"))
{
	sBrowser = "IE";
} else 
{
	sBrowser = "nonIE";
}


//Cambiar de lenguaje
function changeLanguage(sLanguage)
{
	document.frmNavigation.action=document.frmNavigation.origin.value;
	document.frmNavigation.sLanguage.value=sLanguage;
	document.frmNavigation.sLeftArea.value=document.frmNavigation.sLeftAreaBefore.value;
	//Setting cookie language
	registerCookie("slanguage",sLanguage);
	document.frmNavigation.submit();
}


//Navegacion del sitio
function gotoPage(sMotivation,iMenuOption,iSubMenuOption,sMenuOption, sLeftArea, sOperationMode,sWebFlowOrigin,sWebFlowEvent)
{
	document.frmNavigation.sMotivation.value=sMotivation;
	if (iMenuOption != "") { document.frmNavigation.iMenuOption.value=iMenuOption; } 
	document.frmNavigation.sMenuOption.value=sMenuOption;
	if (iSubMenuOption != "") { document.frmNavigation.iSubMenuOption.value=iSubMenuOption; }
	document.frmNavigation.sLeftArea.value=sLeftArea;
	document.frmNavigation.sOperationMode.value=sOperationMode;
	if (sWebFlowOrigin != "") { document.frmNavigation.origin.value=sWebFlowOrigin; }
	if (sWebFlowEvent != "") { document.frmNavigation.event.value=sWebFlowEvent; }
	document.frmNavigation.submit();
}
function gotoPageSSL(sMotivation,iMenuOption,iSubMenuOption,sMenuOption, sLeftArea, sOperationMode,sWebFlowOrigin,sWebFlowEvent)
{
	document.frmNavigationSSL.sMotivation.value=sMotivation;
	if (iMenuOption != "") { document.frmNavigationSSL.iMenuOption.value=iMenuOption; } 
	document.frmNavigationSSL.sMenuOption.value=sMenuOption;
	if (iSubMenuOption != "") { document.frmNavigationSSL.iSubMenuOption.value=iSubMenuOption; }
	document.frmNavigationSSL.sLeftArea.value=sLeftArea;
	document.frmNavigationSSL.sOperationMode.value=sOperationMode;
	if (sWebFlowOrigin != "") { document.frmNavigationSSL.origin.value=sWebFlowOrigin; }
	if (sWebFlowEvent != "") { document.frmNavigationSSL.event.value=sWebFlowEvent; }
	document.frmNavigationSSL.submit();
}
function showDoc(sMotivation,iMenuOption,iSubMenuOption,sMenuOption, sLeftArea, sOperationMode,sWebFlowOrigin,sWebFlowEvent,sDocumentIdentifier,sTSectionSelected,sTBehindSection,sTBehindSectionWebFlow,sTBehindSectionNextSection,sTBehindSectionMenuOption,sTBehindSectionSubMenuOption)
{

	document.frmNavigation.sDocumentIdentifier.value=sDocumentIdentifier;
	document.frmNavigation.sTSectionSelected.value=sTSectionSelected;
	document.frmNavigation.sTBehindSection.value=sTBehindSection;
	document.frmNavigation.sTBehindSectionWebFlow.value=sTBehindSectionWebFlow;
	document.frmNavigation.sTBehindSectionNextSection.value=sTBehindSectionNextSection;
	document.frmNavigation.sTBehindSectionMenuOption.value=sTBehindSectionMenuOption;
	document.frmNavigation.sTBehindSectionSubMenuOption.value=sTBehindSectionSubMenuOption;
	gotoPage(sMotivation,iMenuOption,iSubMenuOption,sMenuOption, sLeftArea, sOperationMode,sWebFlowOrigin,sWebFlowEvent)
}


//Lanzar una ventana nueva (popup)
function popUpPage(sLink,iWidth,iHeight,iTop,iLeft)
{
	//Se agregaron estas 2 líneas el 06/Mayo para desplegar todos los pop-ups en la
	//esquina inferior derecha, no se quitaron los parametros de entrada iTop, iLeft
	//para no hacer cambios en todo el desarrollo, ya que este req. se dió hasta hoy.
	iTop=screen.availHeight - iHeight - 60 ;
	iLeft=screen.availWidth - iWidth - 20;
	if (sBrowser == "IE")
	{
		var displayWindow = window.open(strDomain+sLink,'displayWindow',"dependent=no,directories=no,height=" + iHeight + ",left=" + iLeft + ",location=no,menubar=no,resizable=no,scrollbars=yes,toolbar=no,top=" + iTop + ",width=" + iWidth);
	}
	else
	{
		var displayWindow = window.open(strDomain+sLink, 'displayWindow', 'alwaysRaised=yes,dependent=no,directories=no,hotkeys=no,location=no,menubar=no,personalbar=no,resizable=no,scrollbars=auto,toolbar=no');
		displayWindow.innerWidth=iWidth;
		displayWindow.innerHeight=iHeight;
		displayWindow.moveTo(iLeft,iTop); 
	}
}
//Lanzar una ventana nueva sin tamaño definido (popup)
function popUpPageNoWidth(sLink)
{
	if (sBrowser == "IE")
	{
		var displayWindow = window.open(sLink,'','');
	}
	else
	{
		var displayWindow = window.open(sLink,'', '');
	}
}


//Obtiene parametros de la forma (excepto origin y event)
function getFormFields()
{
	var sBrandCode = document.frmNavigation.sBrandCode.value;
	var sHotelCode = document.frmNavigation.sHotelCode.value;
	var sMotivation = document.frmNavigation.sMotivation.value;
	var iMenuOption = document.frmNavigation.iMenuOption.value;
	var sMenuOption = document.frmNavigation.sMenuOption.value;
	var iSubMenuOption = document.frmNavigation.iSubMenuOption.value;
	var sLeftArea = document.frmNavigation.sLeftArea.value;
	var sOperationMode = document.frmNavigation.sOperationMode.value;
	var sLanguage = document.frmNavigation.sLanguage.value;
	
	var sGetVariables = "&sBrandCode=" + sBrandCode + "&sHotelCode=" + sHotelCode + "&sMotivation=" + sMotivation + "&iMenuOption=" + iMenuOption + "&sMenuOption=" + sMenuOption + "&iSubMenuOption=" + iSubMenuOption + "&sLeftArea=" + sLeftArea + "&sOperationMode=" + sOperationMode + "&sLanguage=" + sLanguage;
	return sGetVariables;
}


//Lanzar una ventana nueva (popup)
function popUpPageGet(sWebFlowOrigin,sWebFlowEvent,iWidth,iHeight,iTop,iLeft)
{
	//Se agregaron estas 2 líneas el 06/Mayo para desplegar todos los pop-ups en la
	//esquina inferior derecha, no se quitaron los parametros de entrada iTop, iLeft
	//para no hacer cambios en todo el desarrollo, ya que este req. se dió hasta hoy.
	iTop=screen.availHeight - iHeight - 60 ;
	iLeft=screen.availWidth - iWidth - 20;
	var sURL = strDomain+sWebFlow + "?origin=" + sWebFlowOrigin + "&event=" + sWebFlowEvent + getFormFields();
	if (sBrowser == "IE")
	{
		var displayWindow = window.open(sURL,'displayWindow',"dependent=no,directories=no,height=" + iHeight + ",left=" + iLeft + ",location=no,menubar=no,resizable=no,scrollbars=yes,toolbar=no,top=" + iTop + ",width=" + iWidth);
	}
	else
	{
		var displayWindow = window.open(sURL, 'displayWindow', 'alwaysRaised=yes,dependent=no,directories=no,hotkeys=no,location=no,menubar=no,personalbar=no,resizable=no,scrollbars=auto,toolbar=no');
		displayWindow.innerWidth=iWidth;
		displayWindow.innerHeight=iHeight;
		displayWindow.moveTo(iLeft,iTop); 
	}
}

function popUpPageSSLGet(sWebFlowOrigin,sWebFlowEvent,iWidth,iHeight,iTop,iLeft)
{
	//Se agregaron estas 2 líneas el 06/Mayo para desplegar todos los pop-ups en la
	//esquina inferior derecha, no se quitaron los parametros de entrada iTop, iLeft
	//para no hacer cambios en todo el desarrollo, ya que este req. se dió hasta hoy.
	iTop=screen.availHeight - iHeight - 60 ;
	iLeft=screen.availWidth - iWidth - 20;
	var sURL = strSSLDomain+sWebFlow + "?origin=" + sWebFlowOrigin + "&event=" + sWebFlowEvent + getFormFields();
	if (sBrowser == "IE")
	{
		var displayWindow = window.open(sURL,'displayWindow',"dependent=no,directories=no,height=" + iHeight + ",left=" + iLeft + ",location=no,menubar=no,resizable=no,scrollbars=yes,toolbar=no,top=" + iTop + ",width=" + iWidth);
	}
	else
	{
		var displayWindow = window.open(sURL, 'displayWindow', 'alwaysRaised=yes,dependent=no,directories=no,hotkeys=no,location=no,menubar=no,personalbar=no,resizable=no,scrollbars=auto,toolbar=no');
		displayWindow.innerWidth=iWidth;
		displayWindow.innerHeight=iHeight;
		displayWindow.moveTo(iLeft,iTop); 
	}
}
//Capturar el evento ENTER (13) y darle submit a la 2a.forma en el docto.
function enterSubmit(e)
{
	var keyPressed="";
	var keyPressedAscii="";
	if (sBrowser == "IE")
	{
		keyPressed = String.fromCharCode(window.event.keyCode);
		keyPressedAscii = window.event.keyCode;
	}
	else
	{
		keyPressed = String.fromCharCode(e.which);
		keyPressedAscii = e.which;
	}
	if (keyPressedAscii == "13")
	{
		document.forms[1].submit();
	}
}

//Funcion para registrar la cookie, esta función será llamada desde las páginas.
function registerCookie(cookieName, cookieValue)
{
	var today = new Date();
	var expires = new Date();
	//El cookie expirará en 1 año a partir de hoy.
	expires.setTime(today.getTime() + 1000*60*60*24*365);
	setCookie(cookieName, cookieValue, expires)
}
//Funcion completo a "registerCookie"
function setCookie(name, value, expire)
{
	document.cookie = name + "=" + value + "; expires=" + expire.toGMTString() + "; path=/;";
	
}
//Funcion pare recuperar el valor del cookie
function getCookieValue(cookieName)
{
	var search = cookieName + "=";
	//Existen cookies en el cliente ?
	if (document.cookie.length > 0)
	{
		//Busqueda del cookie
		offset = document.cookie.indexOf(search);
		if (offset != -1)
		{
			//Obtener valor del cookie
			offset += search.length;
			end = document.cookie.indexOf(";", offset);
			if (end == -1) end = document.cookie.length;
			return document.cookie.substring(offset, end);
		}
	}
}



//Funcion que despliega la ventana de ayuda en linea, http://www.hellohelp.net
function popUpHelloHelp(sWebFlowOrigin,sWebFlowEvent,sLanguageId)
{
	var sURL = sWebFlow + "?origin=" + sWebFlowOrigin + "&event=" + sWebFlowEvent + "&sLanguageId=" + sLanguageId;
	popUpPage(sURL,'260','380','10','10');
}


//Funcion que despliega la ventana de empleos de Posadas
function popUpJobs(sWebFlowOrigin,sWebFlowEvent)
{
	var sURL = sWebFlow + "?origin=" + sWebFlowOrigin + "&event=" + sWebFlowEvent;
	popUpPage(sURL,'800','600','10','10');
}


//Funcion que despliega la ventana de Conversión de monedas, http://www.xe.com
function popUpCurrencyExchange(sWebFlowOrigin,sWebFlowEvent)
{
	var sURL = sWebFlow + "?origin=" + sWebFlowOrigin + "&event=" + sWebFlowEvent;
	popUpPage(sURL,'510','410','10','10');
}


//Funcion que despliega la ventana de travel net
function popUpTravelNet(sWebFlowOrigin,sWebFlowEvent)
{
	var sURL = sWebFlow + "?origin=" + sWebFlowOrigin + "&event=" + sWebFlowEvent;
	popUpPage(sURL,'800','600','10','10');
}
//Funcion que pasa los valores de promocion, desde la opcion "Mas informacion"
function promotionTracking(sLinkId,sPromotionCode){
   document.frmNavigation.sLinkId.value = sLinkId;
   document.frmNavigation.PCode.value = sPromotionCode;
}

//Funcion que pasa los valores de la promocion, desde la opción "Consulte disponibilidad"
function promotionAvailability(sPromotionCode,sDocumentId){
   document.frmNavigation.PCode.value = sPromotionCode;
   document.frmNavigation.sDocumentIdentifier.value = sDocumentId;
}

//Funcion que pasa los valores para buscar los hoteles en una promocion asi como sus datos, en la opcion "Buscar"
function detailPerDate(sDateValue,PCode){   
   document.frmNavigation.hiddenTxtFecha.value = sDateValue;
   document.frmNavigation.PCode.value = PCode;
}

function submitForma(sURL){
   document.frmNavigation.action=sURL;
   document.frmNavigation.event.value="link(avail)";
   document.frmNavigation.submit();
}
function submitFormaDetail(sURL){
   document.frmNavigation.action=sURL;
   document.frmNavigation.event.value="link(availDetail)";
   document.frmNavigation.submit();
}

function submitIndex(sIndex){
   document.frmNavigation.index.value=sIndex;
}

function setBrandEnv(){
   document.frmNavigation.sHotelCode.value = "none";
   document.frmNavigationSSL.sHotelCode.value = "none";
}