// ---------------------------------- mostrar un archivo de una URL en un DIV ------------------------------

var destino = '';
var contenido = '';
//create the Cross-browser XMLHttpRequest object
// si lo llamo con dest='' retorna el html en la variable contenido
function getFile(pURL,dest) {
	destino=dest;
   document.getElementById(destino).innerHTML='<div style="text-align:center;"><br /><br /><br /><br /><br /><br /><br /><img src="imagenes/ajax-loader.gif" /></div>';
   
   if (window.XMLHttpRequest) { // code for Mozilla, Safari, etc 
      xmlhttp=new XMLHttpRequest();
      xmlhttp.onreadystatechange=postFileReady;
      xmlhttp.open("GET", pURL, true);
      xmlhttp.send(null);
   } else if (window.ActiveXObject) { //IE 
      xmlhttp=new ActiveXObject('Microsoft.XMLHTTP'); 
      if (xmlhttp) {
 		 xmlhttp.onreadystatechange=postFileReady;
         xmlhttp.open('GET', pURL, false);
         xmlhttp.send();
		 
      }
   }
   
}
//---------------------------------
function enviarEmail(dest) {
	destino=dest;
   document.getElementById(destino).innerHTML='<div style="text-align:center;"><br /><br /><br /><br /><br /><br /><br /><img src="imagenes/ajax-loader.gif" /></div>';
   var sendURL = 'consultas/enviar.php?nombre=' + document.formConsulta.nombre.value + '&email=' + document.formConsulta.email.value  + '&ciudad=' + document.formConsulta.ciudad.value + '&mensaje=' + document.formConsulta.mensaje.value ;
   //alert(sendURL);
   if (window.XMLHttpRequest) { // code for Mozilla, Safari, etc 
      xmlhttp=new XMLHttpRequest();
      xmlhttp.onreadystatechange=postFileReady;
      xmlhttp.open("GET", sendURL, true);
      xmlhttp.send(null);
   } else if (window.ActiveXObject) { //IE 
      xmlhttp=new ActiveXObject('Microsoft.XMLHTTP'); 
      if (xmlhttp) {
 		 xmlhttp.onreadystatechange=postFileReady;
         xmlhttp.open('GET', sendURL, false);
         xmlhttp.send();
		 
      }
   }
   
}
//-----------------------------
// function to handle asynchronous call
function postFileReady() {
   if (xmlhttp.readyState==4) { 
      if (xmlhttp.status==200) {
		  if (destino =='') {
			  contenido = xmlhttp.responseText; 
		  }else{
			  document.getElementById(destino).innerHTML=xmlhttp.responseText; 
			  destino='';
		  }
      }
   }
}

//------------------------------------------------------------------------------------
function colorear(idLink){
	document.getElementById(idLink).style.fontWeight = 'bold';
	document.getElementById(idLink).style.color ='#425e50';
//	alert('colorear');
}
function decolorear(idLink){
	if (actual != idLink){
		document.getElementById(idLink).style.fontWeight = 'normal';
		document.getElementById(idLink).style.color ='#3c6f68';
	};
//	alert('decolorear');	
}
//------------------------------------------------------------------------------
var actual = 'comienzo';
function selMenu(idLink){
	// lo primero que hago es actualizar el nuevo menu
	actual = idLink;
	// reseteo los colores
	decolorear('link_ubicacion');
	decolorear('link_habitaciones');
	decolorear('link_servicios');
	decolorear('link_precios');	
	decolorear('link_consultas');

	
	// le pongo el color de "over"
    if ('' != idLink){
	    document.getElementById(idLink).style.fontWeight = 'bold';
	    document.getElementById(idLink).style.color ='#425e50';
    }
}

//--------------------------------------------------------------------------------
function abrir(paguina){
	// lo primero que hago es poner el "cargando"
//	document.getElementById('contenido').innerHTML='<center><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><img src="imagenes/cargando.gif" /></center>';
	// y me muevo arriba del todo
//	scroll(0,0);
	
	
	//	document.getElementById('campoIframe').src = pagina + '.php';

	switch(paguina)
	{
	case 'ubicacion':		selMenu('link_ubicacion');
							getFile('seccion.php?cual=ubicacion','contenido');break;
                        	break;
	case 'habitaciones':	selMenu('link_habitaciones');
							getFile('seccion.php?cual=habitaciones','contenido');break;
                        	break;
	case 'servicios':		selMenu('link_servicios');
							getFile('seccion.php?cual=servicios','contenido');break;
                        	break;
	case 'precios':		selMenu('link_precios');
							getFile('seccion.php?cual=precios','contenido');break;
                        	break;	
	case 'consultas':		selMenu('link_consultas');
							getFile('seccion.php?cual=consultas','contenido');break;
                        	break;	
	case 'comienzo':		selMenu('');
							getFile('seccion.php?cual=comienzo','contenido');break;
                        	break;		
							
							
//	default: document.getElementById('contenido').innerHTML= '<br /><img src="imagenes/modulo.jpg"  usemap="#Map"/><map name="Map" id="Map"><area shape="rect" coords="0,0,406,215" /></map>';
	}	
}

//--------------------------------------------------------------------------------------------
var popUpWin=0;
function popUpWindow(imagen)
{
	var left	= 25; 
	var top		= 25;
	var width	= 100; 
	var height	= 50;
	  if(popUpWin)
	  {
		if(!popUpWin.closed){ popUpWin.close();}
	  }
	  popUpWin = open('popUpWin.php?img=' + imagen, 'popUpWin', 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,copyhistory=no,width='+width+',height='+height+',left='+left+', top='+top+',screenX='+left+',screenY='+top+'');
}

//--------------------------------------------------------------------------------------------

// simplePreload( '01.gif', '02.gif' ); 
function simplePreload()
{ 
  var args = simplePreload.arguments;
  document.imageArray = new Array(args.length);
  for(var i=0; i<args.length; i++)
  {
    document.imageArray[i] = new Image;
    document.imageArray[i].src = args[i];
  }
}


