// JavaScript Document
function enviar(formulario) {
 formulario.submit();
}

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_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_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 selectVivienda(id, id_vivienda) {
	
  var viv_datos = id_vivienda.split("#");

  var obj_superficie = document.getElementById('viv_superf_'+id);
  var obj_precio     = document.getElementById('viv_precio_'+id);
  var obj_plano      = document.getElementById('viv_plano_'+id);

  if(id_vivienda == '') {
     obj_superficie.innerHTML = '---';
     obj_precio.innerHTML     = '---';
     obj_plano.innerHTML      = 'Ver plano';
  }
  else {
     obj_superficie.innerHTML = viv_datos[1];
     obj_precio.innerHTML     = viv_datos[2];

     var link_plano = 'Ver plano';
     if(viv_datos[3] != '') {
       link_plano = "<a href=\"#\" class=\"links\" onclick=\"window.open('../uploads/promociones/"+ viv_datos[3] +"', 'w_plano', 'menubar=no,location=no,resizable=yes,scrollbars=no,status=no,height=600,width=750');return false;\">Ver plano</a>";
     }
     obj_plano.innerHTML = link_plano;
     //alert(link_plano);
  }
}

function openDetalle(id, seccion) {
  var obj_num_habs = document.getElementById('num_habs_'+id);
  var hrefOpen = '../'+ seccion +'/?id='+ id +'&num_habs='+ obj_num_habs.value;
  //alert(hrefOpen);

  window.open(hrefOpen, 'w_detalle', 'menubar=no,location=no,resizable=no,scrollbars=no,status=no,height=400,width=600');
}
<!-- ------------------ -->
function ValidarConsulta(form)
{
  if (form.nombre.value == "")
  { alert("Por favor escriba su nombre"); form.nombre.focus(); return; }

  if (form.apellido1.value == "")
  { alert("Por favor escriba su apellido 1"); form.apellido1.focus(); return; }

  if (form.apellido2.value == "")
  { alert("Por favor escriba su apellido 2"); form.apellido2.focus(); return; }

  if (form.telefono.value == "")
  { alert("Por favor escriba su telefono"); form.telefono.focus(); return; }

  if (form.como.value == "")
  { alert("Por favor rellene el campo '¿Como nos ha conocido?'"); form.como.focus(); return; }

/*
  if (form.email.value == "")
  { alert("Por favor escriba su dirección de e-mail"); form.email.focus(); return; }
*/

  if(form.email.value != "") {
     if (form.email.value.indexOf('@', 0) == -1 ||
         form.email.value.indexOf('.', 0) == -1)
     { alert("Dirección de e-mail inválida"); form.email.focus(); return; }
  }

  form.submit();
}


//---------------------------------------------------------------
/* Noticias */
function move1(whichlayer) {
   tlayer=eval(whichlayer)
   if (tlayer.top>0&&tlayer.top<=5){
    tlayer.top=0
    setTimeout("move1(tlayer)",3000)
    setTimeout("move2(document.main.document.second)",3000)
    return
   }
   if (tlayer.top>=tlayer.document.height*-1){
    tlayer.top-=5
    setTimeout("move1(tlayer)",100)
   }
   else{
    tlayer.top=scrollerheight
    tlayer.document.write(messages[i])
    tlayer.document.close()
    if (i==messages.length-1) i=0
    else i++
   }
}

function move2(whichlayer){
   tlayer2=eval(whichlayer)
   if (tlayer2.top>0&&tlayer2.top<=5){
    tlayer2.top=0
    setTimeout("move2(tlayer2)",3000)
    setTimeout("move1(document.main.document.first)",3000)
    return
   }
   if (tlayer2.top>=tlayer2.document.height*-1){
    tlayer2.top-=5
    setTimeout("move2(tlayer2)",100)
   }
   else{
    tlayer2.top=scrollerheight
    tlayer2.document.write(messages[i])
    tlayer2.document.close()
    if (i==messages.length-1)
    i=0
    else
    i++
   }
}

function move3(whichdiv){
   tdiv=eval(whichdiv)
   if (tdiv.style.pixelTop>0&&tdiv.style.pixelTop<=5){
   tdiv.style.pixelTop=0
   setTimeout("move3(tdiv)",3000)
   setTimeout("move4(second2)",3000)
   return
   }
   if (tdiv.style.pixelTop>=tdiv.offsetHeight*-1){
   tdiv.style.pixelTop-=5
   setTimeout("move3(tdiv)",100)
   }
   else{
   tdiv.style.pixelTop=scrollerheight
   tdiv.innerHTML=messages[i]
   if (i==messages.length-1)
   i=0
   else
   i++
   }
}

function move4(whichdiv){
   tdiv2=eval(whichdiv)
   if (tdiv2.style.pixelTop>0&&tdiv2.style.pixelTop<=5){
   tdiv2.style.pixelTop=0
   setTimeout("move4(tdiv2)",3000)
   setTimeout("move3(first2)",3000)
   return
   }
   if (tdiv2.style.pixelTop>=tdiv2.offsetHeight*-1){
   tdiv2.style.pixelTop-=5
   setTimeout("move4(second2)",100)
   }
   else{
   tdiv2.style.pixelTop=scrollerheight
   tdiv2.innerHTML=messages[i]
   if (i==messages.length-1)
   i=0
   else
   i++
   }
}

function startscroll(){
   if (document.all){
      move3(first2);
      second2.style.top=scrollerheight;
      second2.style.visibility='visible';
   }
   else if (document.layers){
      document.main.visibility='show';
      move1(document.main.document.first);
      document.main.document.second.top=scrollerheight+5;
      document.main.document.second.visibility='show';
   }
}


<!--
function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);
//-->

<!--
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 nuevaventana(theURL,features) { //v2.0

  window.open(theURL,"",features);

}

//-->




function agregar(){ 
   if ((navigator.appName=="Microsoft Internet Explorer") && (parseInt(navigator.appVersion)>=4)) { 
      var url="http://www.gruponaru.es/"; 
      var titulo="NARU, inmobiliaria"; 
      window.external.AddFavorite(url,titulo); 
   } 
   else { 
      if(navigator.appName == "Netscape") 
         alert ("Presione Crtl+D para agregar este sitio en sus Bookmarks"); 
   } 
} 

//mapa google
//<![CDATA[
var map;
var mgr;
var espana;

function load() {
  if (GBrowserIsCompatible()) {
	map = new GMap2(document.getElementById("mapbueno"));
	if (map){
	map.addControl(new GLargeMapControl());
	map.addControl(new GMapTypeControl());
	map.setCenter(new GLatLng(39.740986,-4.306641), 5);
	espana="si";
	map.enableDoubleClickZoom();
	//36.712132,-4.26538836.712953
	//map.centerAndZoom(new GPoint (-4.161683, 36.791794), 18); HYBRID
	map.setMapType( G_MAP_TYPE );
	window.setTimeout(setupOfficeMarkers, 0);
	}
  }
}

function setupOfficeMarkers() {
  mgr = new GMarkerManager(map);
  for (var i in officeLayer) {
    var layer = officeLayer[i];
    var markers = [];
    for (var j in layer["places"]) {
      var place = layer["places"][j];
      var posn = new GLatLng(place["posn"][0], place["posn"][1]);
      markers.push(createMarker(posn, place["name"],place["enlace"]));
    }
    mgr.addMarkers(markers, layer["zoom"][0], layer["zoom"][1]);
  }
  mgr.refresh();
}

//funcion que crea las marcas
//------------
			function createMarker(point,texto,enlace) {
			var icon = getIcon();
			 var marki = new GMarker(point, { icon: icon });
			 //new GMarker(posn, { title: place["name"], icon: icon })
			 GEvent.addListener(marki, "click", function() {
				var center = map.getCenter();
				 //if ( espana == "si"){
					 map.setCenter(point, 16);
					 var labelinto = texto;
					 marki.openInfoWindowHtml( '<p class="promociones_parrafo"> ' + labelinto + '</p> <a href="#" ' + enlace + 'class="link_datos1">Mas Info</a>'
);
					 
				//	 espana="no";
				 //}else{
				//	map.setCenter(new GLatLng(39.740986,-4.306641), 5);
					
					//marki.closeInfoWindow();
				//	espana="si";
				// }
				});
				return marki;
			}
//------------
		
	function comprueba(){
		var mip = document.getElementById("mapbueno");
		if (mip){
			load();
			//GUnload();
		}
	}
	
	var icon;
	function getIcon() {
        icon = new GIcon();
        icon.image = "naru.gif";
		icon.shadow = "naru-shadow.gif";
        icon.iconSize = new GSize(10, 10);
		icon.shadowSize = new GSize (5,5);
		icon.iconAnchor = new GPoint(10, 10);
		icon.infoWindowAnchor = new GPoint(9, 2);
		icon.infoShadowAnchor = new GPoint(8, 5);
		//icon.shadow = "naru-shadow.png";
        //icon.shadowSize = new GSize(12, 12);
      return icon;
    }

	

//]]>
//---------------------------------------------------------------

