// -------------------
// SelDestacat CATALÀ
// -------------------

function SelDestacatCAT(id){
	switch (id) {
		case "1":
			 window.open('promocions.asp','_self');
			 break
		case "2":
			 window.open('golf.asp','_self');
			 break
		case "3":
			 window.open('platja.asp','_self');
			 break
		case "4":
			 window.open('cultura.asp','_self');
			 break
		case "5":
			 window.open('empreses.asp','_self');
			 break
		case "6":
			 window.open('portaventura.asp','_self');
			 break
		case "0":
			break
		}
	}


// -------------------
// SelDestacat
// -------------------
function SelDestacat(id){
  switch (id) {
    case "1":
      window.open('promociones.asp','_self');
      break
    case "2":
      window.open('golf.asp','_self');
      break
    case "3":
      window.open('playa.asp','_self');
      break
    case "4":
      window.open('cultura.asp','_self');
      break
    case "5":
      window.open('empresas.asp','_self');
      break
    case "6":
      window.open('portaventura.asp','_self');
      break
    case "0":
      break
  }
}

// -------------------
// SelDestacatENG
// -------------------
function SelDestacatENG(id){
  switch (id) {
    case "1":
      window.open('weekends.asp','_self');
      break
    case "2":
      window.open('golf.asp','_self');
      break
    case "3":
      window.open('beach.asp','_self');
      break
    case "4":
      window.open('cultura.asp','_self');
      break
    case "5":
      window.open('companies.asp','_self');
      break
    case "6":
      window.open('portaventura.asp','_self');
      break
    case "0":
      break
  }
}

// -------------------
// SelDestacatFR
// -------------------
function SelDestacatFR(id){
  switch (id) {
    case "1":
      window.open('weekends.asp','_self');
      break
    case "2":
      window.open('golf.asp','_self');
      break
    case "3":
      window.open('plage.asp','_self');
      break
    case "4":
      window.open('culture.asp','_self');
      break
    case "5":
      window.open('entreprises.asp','_self');
      break
    case "6":
      window.open('portaventura.asp','_self');
      break
    case "0":
      break
  }
}

// -------------------
// MM_openBrWindow
// -------------------
function MM_openBrWindow(theURL,winName,features, myWidth, myHeight, isCenter) { //v3.0
  if(window.screen)if(isCenter)if(isCenter=="true"){
    var myLeft = (screen.width-myWidth)/2;
    var myTop = (screen.height-myHeight)/2;
    features+=(features!='')?',':'';
    features+=',left='+myLeft+',top='+myTop;
  }
  window.open(theURL,winName,features+((features!='')?',':'')+'width='+myWidth+',height='+myHeight);
}


// -------------------
// getObjDoc
// -------------------
function getObjDoc(name) {

  if (document.getElementById) {
    return document.getElementById(name);
  }
  else if (document.all) {
    return document.all[name];
  }
  else if (document.layers) {
    return document.layers[name];
  }
  else
    return false;
}


// -------------------
// checkDate
// -------------------
function checkDate() {

  var month_days = new Array();
  var today = new Date();
  var year_max = today.getFullYear() + 2;

  var day = eval(getObjDoc('txtDay').value);
  var month = eval(getObjDoc('txtMonth').value);
  var year = eval(getObjDoc('txtYear').value);
  var nights = eval(getObjDoc('cmbNights').value);

  var day2;
  var month2;
  var year2;

  month_days[1] = 31;
  month_days[2] = (year % 4) ? 28 : 29;
  month_days[3] = 31;
  month_days[4] = 30;
  month_days[5] = 31;
  month_days[6] = 30;
  month_days[7] = 31;
  month_days[8] = 31;
  month_days[9] = 30;
  month_days[10] = 31;
  month_days[11] = 30;
  month_days[12] = 31;

  if ((month > 12) || (month <= 0)) {
    alert("Ha de introducir un número del 1 al 12 en la casilla del mes.");
  	getObjDoc('txtMonth').focus();
  	getObjDoc('txtMonth').select();
    return;
  }

  if ((month_days[month] < day) || (day <= 0)) {
    alert('Ha de introducir un número del 1 al ' + month_days[month] + ' en la casilla del día.');
  	getObjDoc('txtDay').focus();
  	getObjDoc('txtDay').select();
    return;
  }

  if (year < today.getFullYear()) {
    alert("No es posible realizar reservas en años posteriores al año " + today.getFullYear() + ".");
    getObjDoc('txtYear').focus();
  	getObjDoc('txtYear').select();
    return;
	}

  if (year > year_max || (year + (((month_days[month] - day - nights) < 0 && month == 12) ? 1 : 0) > year_max)) {
    alert('Solo es posible realizar reservas hasta el año ' + year_max + '.');
  	getObjDoc('txtYear').focus();
  	getObjDoc('txtYear').select();
    return;
  }

  if ((month_days[month] - day - nights) < -1) {
    day2 = nights - month_days[month] + day - 1;
    month2 = month + 1 - ((month == 12) ? 12 : 0);
    year2 = year + ((month == 12) ? 1 : 0);
  }
  else if ((month_days[month] - day - nights) == -1) {
    day2 = month_days[month];
    month2 = month;
    year2 = year;
  }
  else {
    day2 = day + nights - 1;
    month2 = month;
    year2 = year;
  }

	if ((month >= 1) && (month <= 9)) {
    month = '0' + month;
	}

  if ((month2 >= 1) && (month2 <= 9)) {
    month2 = '0' + month2;
	}
	
  if ((day >= 1) && (day <= 9)) {
    day = '0' + day;
	}
	
  if ((day2 >= 1) && (day2 <= 9)) {
    day2 = '0' + day2;
	}

  window.location = 'https://www.sercotelhoteles.com/web/ES/FPW/22_Reserva_Anadir_Producto.ASP?v=39757&pfi=' + day + '/' + month + '/' + year + '&pff=' + day2 + '/' + month2 + '/' + year2;
}