// openWindow function for online charges
function openPopUp(aux) {
	popupWin = window.open(aux,'Details', 'top=5,left=5,width=627,height=600,buttons=no,scrollbars=yes,location=no,menubar=no,resizable=yes,status=no,directories=no,toolbar=no')
}

function openCustomPopUp(aux, iwidth, iheight) {
	popupWin = window.open(aux,'Details', 'top=5,left=5,width=' + iwidth + ',height=' + iheight + ',buttons=no,scrollbars=yes,location=no,menubar=no,resizable=yes,status=no,directories=no,toolbar=no')
}

function openGallery(aux) {
	popupWin = window.open(aux,'ImageGallery', 'top=5,left=5,width=700,height=550,buttons=no,scrollbars=no,location=no,menubar=no,resizable=no,status=no,directories=no,toolbar=no')
}

// hide-show elements using display
function changeDisplayElement(element, display) {
	document.getElementById(element).style.display=display;
}

//
function topicOnChange(){
	var index;
	index = document.getElementById("Subject").selectedIndex;
	changeDisplayElement("rTbl", "none");
	changeDisplayElement("rPropertyInfo", "none");
	changeDisplayElement("rBookConf", "none");
	if (index == "00") {
		changeDisplayElement("rPropertyInfo", "");
	} else if (index == "01") {
		changeDisplayElement("rTbl", "");
	} else if (index == "02") {

	} else if (index == "03") {

	}
}

function topicBlock(iIndex){
	var control;
	control = document.getElementById("Subject");
	control.selectedIndex = iIndex;
	control.disabled = true;
	//control = document.getElementById("Property");
	//control.disabled = true;
}

function topicReservation(){
	var control;
	control = document.getElementById("Subject");
	control.selectedIndex = 01;
	control.disabled = true;
	control = document.getElementById("Hotel");
	control.disabled = true;
}

function openRatesMC() {
	var src;
	src= 'http://www.e-travelsolution.com.mx/Partners/Reservations/Hotels/list.aspx?asoc=mexcar&Idioma=ING&moneda=US&destino=' + document.forma.Destino.value + '&dia_desde=' + document.forma.dia_desde.value + '&mes_desde=' + document.forma.mes_desde.value + '&anio_desde=' + document.forma.anio_desde.value + '&dia_hasta=' + document.forma.dia_hasta.value + '&mes_hasta=' + document.forma.mes_hasta.value + '&anio_hasta=' + document.forma.anio_hasta.value;
	popupWin = window.open(src,'Print', 'top=50,left=50,width=850,height=600,buttons=no,scrollbars=yes,location=no,menubar=no,resizable=no,status=yes,directories=no,toolbar=no');
}

function t1msnDestinos()
{
	var error=0;
	var errorMsg=""
	if (document.forma.Destino.value == ""){
		errorMsg+="Please select Destination.\n";
		error=1;
	}
	var sArrivalDate=document.forma.anio_desde.value+"-"+document.forma.mes_desde.value+"-"+document.forma.dia_desde.value;
	var sDepartureDate=document.forma.anio_hasta.value+"-"+document.forma.mes_hasta.value+"-"+document.forma.dia_hasta.value;
	var dToday = new Date();
	var dArrivalDate = new Date(document.forma.anio_desde.value,document.forma.mes_desde.value-1,document.forma.dia_desde.value);
	var dDepartureDate = new Date(document.forma.anio_hasta.value,document.forma.mes_hasta.value-1,document.forma.dia_hasta.value);
	if (isNaN(dArrivalDate)) {
		errorMsg+="Check In is not a valid date.\n";
		error=1;
	}
	if (isNaN(dDepartureDate)) {
		errorMsg+="Check Out is not a valid date.\n";
		error=1;
	}
	if ((dArrivalDate-dToday)/(24*60*60*1000)<-0.99999){
		errorMsg+="Check In is not a valid date.\n";
		error=1;
	}
	if ((dDepartureDate-dArrivalDate)/(24*60*60*1000)<1){
		errorMsg+="Check Out is not a valid date. Check Out must be at least one day after Check In.\n";
		error=1;
	}
	if (error) {
		alert(errorMsg);
		return false;
	} else {
		return true;
	}
}

