// JavaScript Document

//Para el buscador
NS4 = (document.layers) ? true : false;

function checkEnter(event,forma)
{ 	
	var code = 0;
	
	if (NS4)
		code = event.which;
	else
		code = event.keyCode;
	if (code==13){
		eval('enviaBusqueda()');
	}
}

function enviaBusqueda(){

	if(document.formaBusqueda.cd.value==document.formaBusqueda.cd.defaultValue && document.formaBusqueda.hotel.value==document.formaBusqueda.hotel.defaultValue){
		alert('Favor de Ingresar una busqueda');
		document.formaBusqueda.hotel.focus();
	}else if(document.formaBusqueda.cd.value==document.formaBusqueda.cd.defaultValue){
		document.formaBusqueda.cd.value='';
		document.formaBusqueda.submit();
	}else if(document.formaBusqueda.hotel.value==document.formaBusqueda.hotel.defaultValue){
		document.formaBusqueda.hotel.value='';
		document.formaBusqueda.submit();
	}else {
		document.formaBusqueda.submit();
	}
}

function enviaBusquedaCiudad(link){

	if(document.formaBusqueda.cd.value!=document.formaBusqueda.cd.defaultValue){
		document.formaBusqueda.submit();
		link.href='#';
	}
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function clearText(thefield){
if (thefield.defaultValue==thefield.value)
thefield.value = ""
}

function Otra_VentanaEnviaMensaje(desktopURL){
window.open( desktopURL, '_blank', 'height=780,width=650,toolbar=false,location=no,status=no,menubar=no,resizable=no,scrollbars=no,directories=no');
}

function Otra_VentanaComercial(desktopURL){
window.open( desktopURL, '_blank', 'height=700,width=970,toolbar=false,location=no,status=no,menubar=no,resizable=no,scrollbars=yes,directories=no');
}

function Otra_Ventanaturi(desktopURL){
window.open( desktopURL, '_blank', 'height=340,width=540,toolbar=false,location=no,status=no,menubar=no,resizable=no,scrollbars=yes,directories=no');
}

function Otra_Ventanamapa(desktopURL){
window.open( desktopURL, '_blank', 'height=640,width=640,toolbar=false,location=no,status=no,menubar=no,resizable=no,scrollbars=yes,directories=no');
}

var mapaEdo;
function Otra_VentanamapaEdo(desktopURL){
	document.mapaEdo=window.open( desktopURL, 'mapaEdo', 'height=680,width=690,toolbar=false,location=no,status=no,menubar=no,resizable=no,scrollbars=yes,directories=no');
	document.mapaEdo.focus();
}

var pop_paquete;
function ventana_paquete(desktopURL){
	document.pop_paquete=window.open( desktopURL, 'pop_paquete', 'height=440,width=690,toolbar=false,location=no,status=no,menubar=no,resizable=no,scrollbars=yes,directories=no');
	document.pop_paquete.focus();
}

var mapaChico;
var mapaGrande;

function Otra_VentanamapaChico(desktopURL){
	document.mapaChico = window.open( desktopURL, 'mapaChico', 'height=700,width=680,toolbar=false,location=no,status=no,menubar=no,resizable=no,scrollbars=yes,directories=no');
	document.mapaChico.focus();
}
function Otra_VentanamapaChicoGoogle(desktopURL){
	document.mapaChicoGoogle = window.open( desktopURL, 'mapaChicoGoogle', 'height=700,width=680,toolbar=false,location=no,status=no,menubar=no,resizable=no,scrollbars=yes,directories=no');
	document.mapaChicoGoogle.focus();
}
function Otra_VentanamapaGrande(desktopURL){
	mapaGrande = window.open( desktopURL, 'mapaGrande', 'height=900,width=830,toolbar=false,location=no,status=no,menubar=no,resizable=no,scrollbars=yes,directories=no');
	mapaGrande.focus();
}
function Otra_VentanamapaGrandeGoogle(desktopURL){
	mapaGrandeGoogle = window.open( desktopURL, 'mapaGrandeGoogle', 'height=900,width=830,toolbar=false,location=no,status=no,menubar=no,resizable=no,scrollbars=yes,directories=no');
	mapaGrandeGoogle.focus();
}
function Otra_VentanaVImpresa(desktopURL){
window.open( desktopURL, '_blank', 'height=620,width=760,toolbar=false,location=no,status=no,menubar=no,resizable=no,scrollbars=yes,directories=no');
}

function Otra_VentanaInfoTurismo(desktopURL){
window.open( desktopURL, '_blank', 'height=450,width=540,toolbar=false,location=no,status=no,menubar=no,resizable=no,scrollbars=no,directories=no');
}

function Otra_VentanaOrdena(desktopURL){
window.open( desktopURL, '_blank', 'height=370,width=540,toolbar=false,location=no,status=no,menubar=no,resizable=no,scrollbars=no,directories=no');
}

function Otra_VentanaGaleria(desktopURL){	
		galeria=window.open( desktopURL, 'galeria', 'height=290,width=350,toolbar=false,location=no,status=no,menubar=no,resizable=no,scrollbars=no,directories=no');	
		galeria.focus();	
	
}

var convenciones;
function Otra_VentanaConvenciones(desktopURL){	
		convenciones=window.open( desktopURL, 'convenciones', 'height=600,width=950,toolbar=false,location=no,status=no,menubar=no,resizable=yes,scrollbars=yes,directories=no');	
		convenciones.focus();	
	
}

function AbreGaleria(desktopURL){
	galeria=window.open( desktopURL, '_blank', 'height=280,width=350,toolbar=false,location=no,status=no,menubar=no,resizable=no,scrollbars=no,directories=no');
}
function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

function Otra_VentanaCadena(desktopURL){
window.open( desktopURL, '_blank', 'height=700,width=540,toolbar=false,location=no,status=no,menubar=no,resizable=no,scrollbars=yes,directories=no');
}

function Otra_VentanaAmigoHotel(desktopURL){
window.open( desktopURL, '_blank', 'height=715,width=670,toolbar=false,location=no,status=no,menubar=no,resizable=no,scrollbars=no,directories=no');
}

function Otra_VentanaAmigo(desktopURL){
window.open( desktopURL, '_blank', 'height=480,width=670,toolbar=false,location=no,status=no,menubar=no,resizable=no,scrollbars=no,directories=no');
}

function Otra_VentanaContacto(desktopURL){
window.open( desktopURL, '_blank', 'height=500,width=620,toolbar=false,location=no,status=no,menubar=no,resizable=no,scrollbars=no,directories=no');
}

function Otra_VentanaVImpresa(desktopURL){
window.open( desktopURL, '_blank', 'height=620,width=760,toolbar=false,location=no,status=no,menubar=no,resizable=no,scrollbars=no,directories=no');
}

function Otra_VentanaEco(desktopURL,width,height){
window.open( desktopURL, '_blank', 'height='+height+',width='+width+',toolbar=false,location=no,status=no,menubar=no,resizable=no,scrollbars=no,directories=no');
}

var emailPaquete;

function Otra_VentanaEMail(desktopURL){
	document.emailPaquete = window.open( desktopURL, '', 'height=100,width=200,toolbar=false,location=no,status=no,menubar=no,resizable=no,scrollbars=no,directories=no');
	setTimeout('document.emailPaquete.close()',1000);
}

function refrescarPadre(url){
	
	//window.onerror=refrescarVentana(url);
	if(window.opener){
		if(url!='')
			window.opener.location=url;	
		else window.opener.history.go(0);
		window.opener.focus();
	}else {
		refrescarVentana(url);
	}
}

function refrescarVentana(url){
	if(url!='')
		window.location=url;	
	else window.history.go(0);
}

var visa;

function Otra_VentanaVisa(desktopURL){
visa=window.open( desktopURL, 'visa','height=360,width=500,toolbar=false,location=no,status=no,menubar=no,resizable=no,scrollbars=no,directories=no');
}

var viaTelefono;
function ventana_telefono(desktopURL){
	document.viaTelefono = window.open( desktopURL, 'viaTelefono', 'height=300,width=390,toolbar=false,location=no,status=no,menubar=no,resizable=no,scrollbars=yes,directories=no');
	document.viaTelefono.focus();
}

//-para el listado 
function simple_overlay(nombre,visible,imagen,event,parent_obj_id){
	var size=get_size();
	var elemento=document.getElementById(nombre);
	var parent_object=document.getElementById(parent_obj_id);
	
	//alert(findPosX(parent_object));
	//alert(findPosY(parent_object));
	
	//-para las x!
	var x=findPosX(parent_object) - 223;
	
	//-para las y!	
	var y = findPosY(parent_object)-172;
	
	var estilo=new Array('display: none; position: absolute; z-index: 10000; left: '+x+'px; top: '+y+'px; visibility: hidden; opacity: 0; width: 254px; height: 79px;','display: block; position: absolute; z-index: 10000; left: '+x+'px; top: '+y+'px; visibility: visible; opacity: 1;');
	var cssString = estilo[visible];
		
	if(!elemento){
		return false;
	}
	//si trae el nombre d la imagen!
	if(imagen!=''){
		document.images['imagen_overlay'].src='http://www.zonaturistica.com/newlook/pix.gif';
		document.images['imagen_overlay'].src=imagen;
	}
	
	elemento.style.cssText = cssString;
	elemento.setAttribute('style',cssString);
}

function findPosX(obj) {
	var curleft = 0;
	if(obj.offsetParent)
	    while(1) 
	    {
	      curleft += obj.offsetLeft;
	      if(!obj.offsetParent)
	        break;
	      obj = obj.offsetParent;
	    }
	else if(obj.x)
	    curleft += obj.x;
	return curleft;
}

function findPosY(obj) {
	var curtop = 0;
	if(obj.offsetParent)
	    while(1)
	    {
	      curtop += obj.offsetTop;
	      if(!obj.offsetParent)
	        break;
	      obj = obj.offsetParent;
	    }
	else if(obj.y)
	    curtop += obj.y;
	return curtop;
}

function get_size() {
  var myWidth = 0, myHeight = 0;
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myWidth = window.innerWidth;
    myHeight = window.innerHeight;
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    myWidth = document.documentElement.clientWidth;
    myHeight = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    myWidth = document.body.clientWidth;
    myHeight = document.body.clientHeight;
  }
  
  var size=new Array(myWidth,myHeight);
  return size;
}

function showBoxLite(width_src,height_src){
	
	var tmp_light=document.getElementById('light');
	var tmp_fade=document.getElementById('fade');
	
	if(!tmp_light || !tmp_fade)
		return false;
	
	var width = document.documentElement.clientWidth + document.documentElement.scrollLeft;

    if (document.body.clientWidth > width)
        width = document.body.clientWidth;
	
	tmp_fade.style.position = 'absolute';
	tmp_fade.style.top = '0px';
	tmp_fade.style.left = '0px';
	tmp_fade.style.height = document.documentElement.scrollHeight + 'px';
	tmp_fade.style.width = width + 'px';
	tmp_fade.style.backgroundColor = 'black';
	tmp_fade.style.opacity = '.6';
	tmp_fade.style.filter += ("progid:DXImageTransform.Microsoft.Alpha(opacity=60)");
	tmp_fade.style.display='block';
	
	tmp_light.style.position = 'absolute';
	tmp_light.style.top = '250px';
	tmp_light.style.left = (width / 2) - (400 / 2) + 'px';
	tmp_light.style.height = height_src + 'px';
	tmp_light.style.width = width_src +'px';
	tmp_light.style.display='block';
	
}
function hideBoxLite(){

	var tmp_light=document.getElementById('light');
	var tmp_fade=document.getElementById('fade');
	
	if(!tmp_light || !tmp_fade)
		return false;
	
	tmp_light.style.display='none';
	tmp_fade.style.display='none';
}

function showBox(width_src,height_src,text_src){
	var width = document.documentElement.clientWidth + document.documentElement.scrollLeft;

	
    if (document.body.clientWidth > width)
        width = document.body.clientWidth; 
	
	var layer = document.createElement('div');
	layer.style.zIndex = 2;
	layer.id = 'layer';
	layer.style.position = 'absolute';
	layer.style.top = '0px';
	layer.style.left = '0px';
	layer.style.height = document.documentElement.scrollHeight + 'px';
	layer.style.width = width + 'px';
	layer.style.backgroundColor = 'black';
	layer.style.opacity = '.6';
	layer.style.filter += ("progid:DXImageTransform.Microsoft.Alpha(opacity=60)");
	document.body.appendChild(layer);

	var div = document.createElement('div');
	div.style.zIndex = 3;
	div.id = 'box';
	div.style.position = (navigator.userAgent.indexOf('MSIE 6') > -1) ? 'absolute' : 'fixed';
	div.style.position = 'absolute';
	div.style.top = '200px';
	div.style.left = (width / 2) - (400 / 2) + 'px';
	div.style.height = height_src + 'px';
	div.style.width = width_src +'px';
	div.style.backgroundColor = 'white';
	div.style.border = '2px solid silver';
	div.style.padding = '20px';
	document.body.appendChild(div);

	var p = document.createElement('p');
	p.innerHTML = text_src;
	div.appendChild(p);

	var a = document.createElement('a');
	a.innerHTML = 'Cerrar ventana';
	a.href = 'javascript:void(0)';
	a.onclick = function()
	{
		document.body.removeChild(document.getElementById('layer'));
		document.body.removeChild(document.getElementById('box'));
	};

	div.appendChild(a);
}

function load_fb_share_script(){
	var head= document.getElementsByTagName('head')[0];
	var script= document.createElement('script');
	script.type= 'text/javascript';
	script.language= 'javascript';
	script.src= 'http://static.ak.fbcdn.net/connect.php/js/FB.Share';
	head.appendChild(script);
}

function Otra_Ventanaturist(desktopURL){
window.open( desktopURL, '_blank', 'height=700,width=540,toolbar=false,location=no,status=no,menubar=no,resizable=no,scrollbars=yes,directories=no');
}
function Otra_VentanaFiestas(desktopURL){
window.open( desktopURL, '_blank', 'height=540,width=540,toolbar=false,location=no,status=no,menubar=no,resizable=no,scrollbars=<?php echo $scrollFerias; ?>,directories=no');
}
function ventanaMensajeGolf(desktopURL){
window.open( desktopURL, '_blank', 'height=600,width=600,toolbar=false,location=no,status=no,menubar=no,resizable=no,scrollbars=no,directories=no');
}
