// JavaScript Document
$(document).ready(function()
{


	//muestra u oculta el contenido de la capa "capamapa" al accionar los link "mostrar" u "ocultar"
	$("#capamapa").slideToggle("fast");
	$("#ocultarmapa").click(function(event){
    event.preventDefault();
    $("#capamapa").slideToggle("slow"); 
   });

   $("#mostrarmapa").click(function(event){
    event.preventDefault();
    $("#capamapa").slideToggle("slow"); 
   });

	//muestra u oculta el contenido de la capa "capavideo" al accionar los link "mostrar" u "ocultar"
	$("#capavideo").slideToggle("fast");
	$("#ocultarvideo").click(function(event){
    event.preventDefault();
    $("#capavideo").slideToggle("slow"); 
   });

   $("#mostrarvideo").click(function(event){
    event.preventDefault();
    $("#capavideo").slideToggle("slow"); 
   });

	//hace el fade del DIV con cabecera.gif, el DIV carga por defecto como hiden y aqui lo visualizamos con el fade
   $(document).ready(function(){  $(document).ready(function () {    $('#fotoinmo').fadeIn(3000);  });});

	//hace rollover a todos los graficos con la clase CSS "roll", el grafico dos tiene que ser ..._hover.gif
	//utilza el codigo de mas abajo
	peps.rollover.init();   

	//*** funcionamiento de los TABS
	if ($('#poralquiler').attr("value")=='SI') //control mio para mantener el TAB si es por alquiler
	{
		$(".tab_content").hide(); //Hide all content    
		$("ul.tabs li:#Tab2").addClass("active").show(); //Activate first tab    
		$(".tab_content:#tab2").show(); //Show first tab content    
	}
	else
	{
		$(".tab_content").hide(); //Hide all content    
		$("ul.tabs li:first").addClass("active").show(); //Activate first tab    
		$(".tab_content:first").show(); //Show first tab content    
	}

	//On Click Event    
	$("ul.tabs li").click(function() {        
		$("ul.tabs li").removeClass("active"); //Remove any "active" class        
		$(this).addClass("active"); //Add "active" class to selected tab        
		$(".tab_content").hide(); //Hide all tab content        
		
		var activeTab = $(this).find("a").attr("href"); //Find the href attribute value to identify the active tab + content        
		$(activeTab).fadeIn(); //Fade in the active ID content        
		return false;    
	});


});


//********* codigo para el rollover de graficos ************
peps = {};   
peps.rollover = {   
   init: function() {   
      this.preload();   
      $(".roll").hover(   
         function () { $(this).attr( 'src', peps.rollover.newimage($(this).attr('src')) ); },   
         function () { $(this).attr( 'src', peps.rollover.oldimage($(this).attr('src')) ); }   
      );   
   },   
preload: function(){   
      $(window).bind('load', function() {   
         $('.roll').each( function( key, elm ) { $('<IMG loaded="true" jQuery1286522289234="4">').attr( 'src', peps.rollover.newimage( $(this).attr('src') ) ); });   
      });   
   },   
   newimage: function( src ) {   
      return src.substring( 0, src.search(/(\.[a-z]+)$/) ) + '_hover' + src.match(/(\.[a-z]+)$/)[0];   
   },   
   oldimage: function( src ){   
      return src.replace(/_hover\./, '.');   
   }   
};





/* agregar sitio a favoritos */
function agregar(){
//Para internet explorer
if ((navigator.appName=="Microsoft Internet Explorer") && (parseInt(navigator.appVersion)>=4)) {
var url="http://www.urbanigloo.es/"; //Cambia esta dirección por la de tu web
var titulo="Urban IGLOO Inmobiliaria"; //Cambia esta nombre por el de tu web
window.external.AddFavorite(url,titulo);
}
//Para Netscape y Firefox
else {
if(navigator.appName == "Netscape")
alert ("Presione Crtl+D para agregar a este sitio en sus Favoritos");  //Puedes personalizar este mensaje
}
}




/* muestra fecha */
function mostrar_fecha()
{
	var fecha=new Date();
	var diames=fecha.getDate();
	var diasemana=fecha.getDay();
	var mes=fecha.getMonth() +1 ;
	var ano=fecha.getFullYear();
	
	var textosemana = new Array (7); 
	  textosemana[0]="Domingo";
	  textosemana[1]="Lunes";
	  textosemana[2]="Martes";
	  textosemana[3]="Miércoles";
	  textosemana[4]="Jueves";
	  textosemana[5]="Viernes";
	  textosemana[6]="Sábado";
	
	var textomes = new Array (12);
	  textomes[1]="Enero";
	  textomes[2]="Febrero";
	  textomes[3]="Marzo";
	  textomes[4]="Abril";
	  textomes[5]="Mayo";
	  textomes[6]="Junio";
	  textomes[7]="Julio";
	  textomes[8]="Agosto";
	  textomes[9]="Septiembre";
	  textomes[10]="Octubre";
	  textomes[11]="Noviembre";
	  textomes[12]="Diciembre";
	
	document.write(textosemana[diasemana] + " " + diames + " de " + textomes[mes] + " de " + ano + "<br>");
}

/* color fondo de celda al poner el cursos encima (ver llamada a esta funcion desde la celda en cuestion) */
function cambiacolor_over(celda)
{ celda.style.backgroundColor="#FBF7D2" } 

/* color fondo de celda al quitar el cursor de encima (ver llamada a esta funcion desde la celda en cuestion) */
function cambiacolor_out(celda)
{ celda.style.backgroundColor="#E8ECF7" }



