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();
}

/*
 Funcion creada para ser usada en caso de que la busqueda sea pedida desde un sitio alianzado.
 En este caso, estamos compartiendo nuestro motor de busqueda y la ventana
 se tiene que re acomodar segun lo que el sitio tenga configurado.
*/
function resize_to(v_width,v_height)  
{
	if (window.resizeTo)
	{
		self.resizeTo(v_width,v_height);
		if (window.moveTo && screen.width )
		{
			var winl = (screen.width - v_width)/2;
			var wint = (screen.height - v_height)/2;
			self.moveTo(winl,wint);
		} 
	}
	
	//window.menubar.visible = false;
}

function openSelectDatePopup(opener_field, call, context_path) {
	month = eval('document.' + opener_field + '_month.value');
	year = eval('document.' + opener_field + '_year.value');
	openCenteredWindow(context_path + '/popup_fechas.php?opener_field=' + opener_field + '&call=' + call + '&month=' + month + '&year=' + year, 'popup_fechas', 200, 200, 'scrollbars=no')
}


/* 
Funcion temporal: problemas con la seguridad del IE. Con la seguridad predeterminada
no cambia la sesion del idioma...
Cuando se encuentre una mejor solucion, eliminar esta funcion y grabar el idioma que el usuario
seleccion en la sesion en lugar de pasarlo por parametro.
*/ 
function openSelectDatePopupLang(opener_field, call, context_path, lang) {
	month = eval('document.' + opener_field + '_month.value');
	year = eval('document.' + opener_field + '_year.value');
	openCenteredWindow(context_path + '/popup_fechas.php?opener_field=' + opener_field + '&call=' + call + '&lang='+ lang +'&month=' + month + '&year=' + year, 'popup_fechas', 200, 200, 'scrollbars=no')
}



function openHotelPopup(context_path, id, can_reserve) {
	openCenteredWindow(context_path + '/popups/hotel/index.php?id=' + id + '&cr=' + can_reserve, 'hotel_popup', 700, 550, 'scrollbars=no')
}

function openHotelPopupInPolitics(context_path, id) {
	openCenteredWindow(context_path + '/popups/politicas/politicas.php?id=' + id, 'cancel_popup', 400, 400, 'scrollbars=no')
}

function openNewsPopup(id) {
	openCenteredWindow('popups/adonde_ir/index.php?id=' + id, 'adonde_ir_popup', 400, 431, 'scrollbars=no')
}

function openForgetUserPopup(context_path) {
	openCenteredWindow(context_path + '/popups/olvido_su_clave/index.php?type=user', 'olvido_popup', 257, 175, 'scrollbars=no')
}

function openForgetHotelPopup(context_path) {
	openCenteredWindow(context_path + '/popups/olvido_su_clave/index.php?type=hotel', 'olvido_popup', 257, 175, 'scrollbars=no')
}

function openForgetAlliancePopup(context_path) {
	openCenteredWindow(context_path + '/popups/olvido_su_clave/index.php?type=alliance', 'olvido_popup', 257, 175, 'scrollbars=no')
}

function openRecomendarPopup(context_path) {
	openCenteredWindow(context_path + '/popups/recomendar/index.php', 'recomendar_popup', 287, 275, 'scrollbars=no')
}

function openSugerenciasPopup(context_path) {
	openCenteredWindow(context_path + '/popups/contactenos/index.php', 'recomendar_popup', 287, 275, 'scrollbars=no')
}