var dimX = Number(screen.width);
var dimY = Number(screen.height);

function abrirVentana(url,ancho,alto,scroll,ventana)
{
	if (ventana == "") ventana = "ventana";
	LeftPosition = (screen.width)?(screen.width-ancho)/2:0;
	TopPosition = (screen.height)?(screen.height-alto)/2:0;
	settings = "width="+ancho+",height="+alto+",top="+TopPosition+",left="+LeftPosition+",scrollbars="+scroll+",resizable=yes";
	window.open(url,ventana,settings);
}

function verImagen(num,hotel)
{
	abrirVentana("verImagen.asp?imagen="+num+"&hotel="+hotel,520,405,"no");
}

function escribirCapa(id,texto,capaReferencia)
{
	var ie4 = document.all;
	var ns4 = document.layers;
	var capa;

	if (ns4)	{
		if (capaReferencia)
			capa = eval ('document.'+capaReferencia+'.document.'+id+'.document');
		else {
			capa = document.layers[id].document;
			capa.open();
			capa.write(texto);
			capa.close();
		}
	} else {
		if (ie4) 
			document.all[id].innerHTML = texto;
	}
}

function irURL(url,target,cerrar)
{
	if (target == "_blank")
		window.open(url,target);
	else
		window.location = url;
}

function verOferta(id)
{
	abrirVentana("/MagicCostablanca/common/asp/promociones/index.asp?IDPortada=94",500,490,"yes","Promociones");
}

function verCapa(campo)
{
	if (opCapa == 1)  {
		opCapa = 2;
		document.getElementById(campo).style.display = "";
	} else {
		opCapa = 1;
		document.getElementById(campo).style.display = "none";
	}
}

function cambiarImagen(nombre,imagen)
{
	document.images[nombre].src = imagen;	
}

function abrirVentanaModal(ancho,alto,url)
{
	capa = "ventanaModal";	
	aux1 = (dimX-ancho)/2;
	aux2 = (dimY-alto)/6;
	aux3 = document.getElementById("paginaPrincipal").offsetHeight;	
	if (document.getElementById("pie_cierra"))
		aux3 = aux3+document.getElementById("pie_cierra").offsetHeight+20;
	document.getElementById(capa).style.width = ancho+"px";
	document.getElementById(capa).style.height = (30+alto)+"px";
	document.getElementById(capa).style.left = aux1+"px";
	document.getElementById(capa).style.top = aux2+"px";	
	document.getElementById("fade").style.display = "block";
	document.getElementById("fade").style.height = aux3+"px";	
	window.location = "#TOP";
	document.getElementById("ventanaModal2").width = ancho;
	document.getElementById("ventanaModal2").height = alto;
	if (top.frames["principalCALC"])
		top.frames["principalCALC"].frames["ventanaModal2"].location = url;	
	else if (top.frames["agencias"])	
		top.frames["agencias"].frames["ventanaModal2"].location = url;		
	else if (top.frames["webExt"])	
    top.frames["webExt"].frames["ventanaModal2"].location = url;		
	else
		top.frames["ventanaModal2"].location = url;
	document.getElementById(capa).style.display = "block"
	if (document.getElementById("flashOfertas"))
		document.getElementById("flashOfertas").style.display = "none";
}

function abrirVentanaModal2(ancho,alto,url,ventana)
{
  if (ventana == "") ventana = "ventana";
  LeftPosition = (screen.width)?(screen.width-ancho)/2:0;
	TopPosition = (screen.height)?(screen.height-alto)/2:0;
	settings = "width="+ancho+",height="+alto+",top="+TopPosition+",left="+LeftPosition+",scrollbars=yes,resizable=yes";
	window.open(url,ventana,settings);
}

function cerrarVentanaModal()
{
	capa = "ventanaModal";
	if (top.frames["principalCALC"])	
		top.frames["principalCALC"].frames["ventanaModal2"].location = "about:blank";		
	else if (top.frames["agencias"])	
		top.frames["agencias"].frames["ventanaModal2"].location = "about:blank";		
	else
		top.frames['ventanaModal2'].location = "about:blank";	
	document.getElementById("fade").style.display = ""	
	document.getElementById(capa).style.display = "none"
	if (document.getElementById("flashOfertas"))
		document.getElementById("flashOfertas").style.display = "";
}
