function jsSubmitProposeDestino(pFormName)
{
// jsHome_ProposeForm = pFormName;
var oForm = document.getElementById(pFormName);
//--- Valida el Formulario
if (!jsValidateProposeDestino(oForm))
return;

$.ajax( { url: oForm.action,
type: "POST",
data: "txtProposeDestino=" + document.getElementById("txtProposeDestino").value + "&txtProposeEMail=" + document.getElementById("txtProposeEMail").value + "&hidIdiomaId=" + IdiomaId,
success : jsHandleProposeDestino,
error : jsGbl_AJAX_HandleError
//parameters : Form.serialize(oForm)
});
}


function jsValidateProposeDestino(pForm)
{
var varMsgs = new jsGbl_MsgSummary();

var valDestino = document.getElementById("txtProposeDestino").value;
var valEMail = document.getElementById("txtProposeEMail").value;

if (jsGbl_IsEmpty(valDestino))
varMsgs.AddMsg("Nombre del Destino que no encuentra.");
if (!jsGbl_IsEmpty(valEMail) && !jsGbl_IsEMail(valEMail))
varMsgs.AddMsg("E-mail válido.");

if (!varMsgs.IsEmpty())
{
varMsgs.ShowSummary();
return false;
}

return true;
}

function jsValidateProposeHotel(pForm)
{
var varMsgs = new jsGbl_MsgSummary();
varMsgs.AddMsgTitle("Por favor, ingrese el/los siguiente/s datos:");


var valHotel = $("#txtProposeHotel",$("#"+pForm.id)).val();
var valEMail = $("#txtProposeEMail",$("#"+pForm.id)).val();

if (jsGbl_IsEmpty(valHotel))
varMsgs.AddMsg("Nombre del hotel que no encuentra.");
if (!jsGbl_IsEmpty(valEMail) && !jsGbl_IsEMail(valEMail))
varMsgs.AddMsg("E-mail válido.");

if (!varMsgs.IsEmpty())
{
varMsgs.ShowSummary();
return false;
}

return true;
}


function jsSubmitProposeHotel(pFormName)
{
// jsHome_ProposeForm = pFormName;
var oForm = document.getElementById(pFormName);
//--- Valida el Formulario
if (!jsValidateProposeHotel(oForm))
return;


$.ajax( { url: oForm.action,
type: "POST",
data: "txtProposeHotel=" + $("#txtProposeHotel", $("#" + oForm.id)).val() + "&txtProposeEMail=" + $("#txtProposeEMail", $("#" + oForm.id)).val() + "&hidIdiomaId=es",
success : jsHandleProposeHotel,
error : jsGbl_AJAX_HandleError
});
}
function jsGbl_MsgSummary()
{
this.Messages = "";
this.Title = "";
this.IsEmpty = jsGbl_MsgSummary_IsEmpty;
this.GetTable = jsGbl_MsgSummary_GetTable;
this.AddMsg = jsGbl_MsgSummary_AddMsg;
this.ShowSummary = jsGbl_MsgSummary_ShowSummary;
this.AddMsgTitle = jsGbl_MsgSummary_AddMsgTitle;
}
function jsGbl_MsgSummary_IsEmpty()
{
if (this.Messages=="")
return true;
return false;
}
function jsGbl_MsgSummary_AddMsgTitle(pstrText)
{
this.Title += "<tr><td align=left>"+pstrText+"</td></tr>";
}

function jsGbl_MsgSummary_AddMsg(pstrText)
{
this.Messages += "<tr><td align=left><b>¦</b> "+pstrText+"</td></tr>";
}
function jsGbl_MsgSummary_GetTable()
{
return "<table style=\"height: 60px;\">"+this.Title+this.Messages+"</table>";
}
function jsGbl_MsgSummary_ShowSummary()
{
jsGbl_MsgBox(this.GetTable(),"Errores de validación:",jscteGbl_Icon_Error);
}

function jsGbl_IsEMail(value)
{
apos=value.indexOf("@")
dotpos=value.lastIndexOf(".")
if (apos<1||dotpos-apos<2)
return false;
return true;
}
function jsGbl_IsEmpty(value)
{
if(value==null||value=='')
return true;
return false;
}

function jsHandleProposeDestino(pobjResponse)
{
jsGbl_AJAX_HandleResponse(pobjResponse,true);
}

function jsGbl_AJAX_HandleResponse(pobjResponse,pbolShowMsg)
{
var oxmlDoc = pobjResponse;
return jsGbl_XML_HandleResponse(oxmlDoc,pbolShowMsg);
}


function jsGbl_XML_HandleResponse(pxmlResponse,pbolShowMsg)
{
var oxmlHeader = null;
var oxmlBody = null;
var strStatus = "";
var strMsg = "";
var strMsgDetail = "";

if ($.browser.msie)
{
oxmlHeader = pxmlResponse.selectSingleNode("/response/header");
oxmlBody = pxmlResponse.selectSingleNode("/response/body");
strStatus = oxmlHeader.selectSingleNode("status").text;
strMsg = oxmlHeader.selectSingleNode("msg").text;
strMsgDetail = oxmlHeader.selectSingleNode("msg_detail").text;
}
else
{
oxmlHeader = pxmlResponse.getElementsByTagName("header");
oxmlBody = pxmlResponse.getElementsByTagName("body")[0];
strStatus = pxmlResponse.getElementsByTagName("status")[0].firstChild.nodeValue;
var oxmlAuxi = pxmlResponse.getElementsByTagName("msg")[0];
if (oxmlAuxi.firstChild!=null)
strMsg = oxmlAuxi.firstChild.nodeValue;
var oxmlAuxi = pxmlResponse.getElementsByTagName("msg_detail")[0];
if (oxmlAuxi.firstChild!=null)
strMsgDetail = oxmlAuxi.firstChild.nodeValue;

}
var strIcon = jscteGbl_Icon_Information;
var bolOK = false;

//--- Almacena el BODY
jsGbl_AJAX_Body = oxmlBody;

if (strStatus==jscteGbl_Status_ERROR)
strIcon = jscteGbl_Icon_Error;
else if (strStatus==jscteGbl_Status_INFO)
strIcon = jscteGbl_Icon_Exclamation;
else if (strStatus==jscteGbl_Status_OK)
{
strIcon = jscteGbl_Icon_Information;
bolOK = true;
}

//--- Verifica si debe mostrar los Mensajes
if (pbolShowMsg)
{
if (strMsg!="")
jsGbl_MsgBox(strMsg,"Mensaje de Ejecución",strIcon);
}

//--- Almacena el Resultado de la ejecución
jsGbl_AJAX_ExecuteOK = bolOK;
return bolOK;
}


var jsGbl_AJAX_ExecuteOK = false;
var jsGbl_AJAX_Body = null;
var jscteGbl_Images_MsgBox = "/images/msgbox/";
var jscteGbl_Icon_Information = "Information.gif";
var jscteGbl_Icon_Exclamation = "Exclamation.gif";
var jscteGbl_Icon_Question = "Question.gif";
var jscteGbl_Icon_Error = "Error.gif";
var jscteGbl_Status_OK = "OK";
var jscteGbl_Status_INFO = "INFO";
var jscteGbl_Status_ERROR = "ERROR";


function jsGbl_AJAX_HandleError(pobjResponse)
{
ClearForm();

if (pobjResponse.status==200)
{
jsGbl_MsgBox(pobjResponse.responseText,
"Error en ejecución:",jscteGbl_Icon_Error);
}
else
{
if (pobjResponse.status==404)
{
jsGbl_MsgBox("Lo sentimos, no fue posible procesar su solicitud.",
"Error en ejecución:",jscteGbl_Icon_Error);
}
}
}

function jsGbl_MsgBox(pstrText,pstrTitle,pstrIcon)
{
var divMsgBox = document.getElementById('modalMessage');
var divMsgTitle = document.getElementById('modalMessageTitle');
var divMsgFooter = document.getElementById('modalFooter');


divMsgBox.innerHTML = pstrText;
divMsgTitle.innerHTML = pstrTitle;
divMsgFooter.innerHTML = '<input type="button" class="mainSprite button" value="Cerrar" id="cerrar" onClick="javascript:popupModalHide();"/>'

popupModalShow()
scroll(0,0)
}

function popupModalShow()
{
if (document.getElementById('iframemodal'))
document.getElementById('iframemodal').style.display = "block";
}

function popupModalHide()
{
if (document.getElementById('iframemodal'))
document.getElementById('iframemodal').style.display = "none";

jsCloseCalifPanel('divRankingCalifHoteles_Container');
jsCloseCalifPanel('ifrmRankingCalifHoteles');
jsCloseCalifPanelBusqDestino('chkNOBusquedaDestino','divBusquedaDestino_NewDestino','ifrmBusquedaDestino_NewDestino');
jsCloseCalifPanel('ifrmBusquedaDestino');
jsCloseCalifPanel('divBusquedaDestino_NewDestinoShadowContainer');

}


function jsGbl_RaiseClick(pElement)
{
if ($.browser.msie)
{
pElement.click();
}
else
{
var evt = document.createEvent("MouseEvents");
evt.initMouseEvent("click", true, true, window, 0, 0, 0, 0, 0, false, false, false, false, 0, null);
var canceled = !pElement.dispatchEvent(evt);
}
}

function jsSetiFrame(div,iframe)
{
div.style.display = "block";

iframe.className= div.className;
iframe.style.height = 120;
iframe.style.display = "block";
}

function jsCloseCalifPanelBusqDestino(pCHECK,pDIV,pIFRAME)
{
var iframe = $("#" + pIFRAME);
var div = $("#" + pDIV);
var checkbox = $("#" + pCHECK);

if ($.browser.msie)
{
iframe[0].style.display = "none";
}
div.hide();
}

function jsCloseCalifPanel(divName)
{
var divPanel = $("#" + divName);
divPanel.hide();
}
