function openCenteredWindow(url, name, width, height, features) {
  if(screen.width){
	  var winl = (screen.width-width)/2;
	  var wint = (screen.height-height)/2;
  } else {
		winl = 0;
		wint =0;
  }
  if (winl < 0) winl = 0;
  if (wint < 0) wint = 0;
  var settings = 'height=' + height + ',';
  settings += 'width=' + width + ',';
  settings += 'top=' + wint + ',';
  settings += 'left=' + winl + ',';
  settings += features;
  win = window.open(url, name, settings);
  win.window.focus();
}

function openViajePopup(context_path, name) {
	openCenteredWindow(context_path + '/popups/viaje.php?name=' + name, 'viaje_popup', 656, 400, 'scrollbars=yes')
}

function openLegalPopup(context_path) {
	openCenteredWindow(context_path + '/popups/legal.php', 'legal_popup', 400, 400, 'scrollbars=no')
}

function openPrivacyPopup(context_path) {
	openCenteredWindow(context_path + '/popups/privacidad.php', 'privacy_popup', 400, 400, 'scrollbars=no')
}

function openGalleryPopup(context_path, id) {
	openCenteredWindow(context_path + '/popups/galeria.php?id=' + id, 'gallery_popup', 400, 400, 'scrollbars=no')
}

function openSelectDatePopup(opener_field, call, context_path) {
	month = eval('document.' + opener_field + '_month.value');
	year = eval('document.' + opener_field + '_year.value');
	openCenteredWindow(context_path + '/popups/calendario.php?opener_field=' + opener_field + '&call=' + call + '&month=' + month + '&year=' + year, 'popup_fechas', 200, 220, 'scrollbars=no')
}

function openFormPopup() {
	openCenteredWindow('/popups/form.php', 'form_popup', 420, 400, 'scrollbars=yes')
}