// JavaScript Document
function getRef(obj) {
      if(typeof obj == "string")
         obj= document.getElementById(obj);
      return obj;
}
function resalta(obj) {
    anterior = getRef(obj).className;
	getRef(obj).className = "tdSelected";
}
function restore(obj) {
	getRef(obj).className = anterior;
}
function show(obj) {
	getRef(obj).className = "displayTrue";
}

function hide(obj) {
	getRef(obj).className = "displayFalse";
}

function vistrue(obj) {
	getRef(obj).className = "visibilityTrue";
}

function visfalse(obj) {
	getRef(obj).className = "visibilityFalse";
}

function openBrWindow(theURL,winName,features) { 
  window.open(theURL,winName,features);
}
function flow(text){
	document.getElementById('texto').innerHTML = "<strong>" + text + "</strong>";
}
function reset(){
	document.getElementById('texto').innerHTML = "<strong>Situe el rat&oacute;n sobre el icono para ver la leyenda</strong>";
}
function popup(url) { 
  window.open(url,'','scrollbars=yes,width=500,height=400');
}
//Popup que se ajusta a la imagen
function popup2(url,w,h){
	var width;
	var height;
	var s=false;
	if(w>screen.width){
		width=screen.width;
		s=true;
	}else{
		width=w;
	}
	if(h>screen.height){
		height=screen.height;
		s=true;
	}else{
		height=h;
	}
	
	if(s==true){
		opciones="width="+width+",height="+height+",scrollbars=yes";	
	}else{
		opciones="width="+width+",height="+height+",scrollbars=no";	
	}
	window.open(url, "imagen", opciones);
}

function getThumbnailImages() { 
	if (!document.getElementsByTagName) return; 
	var anchors = document.getElementsByTagName("a"); 
	for (var i=0; i<anchors.length; i++) { 
		var anchor = anchors[i]; 
		if (anchor.className == "thumbnail")  {
			anchor.onclick = doToggle;   
		}		
	} 
} 

function doToggle() {
	showPicture.toggle();
	objeto = this;
	setTimeout('changeImage(objeto)', 350);
	return false;
}

function changeImage(objeto){

	var actualImage = document.getElementById('image-holder');

	actualImage.onload=function(){
						showMooEffect();
					   }
	
	
	var actualSliceImage = (actualImage.src).split("/");
	
	var newThumbnail = actualSliceImage[0]+"//"+actualSliceImage[2]+"/"+actualSliceImage[3]+"/"+actualSliceImage[4]+"/"+actualSliceImage[5]+"/thumb_"+actualSliceImage[6];

	var newImage = objeto.href;
	
	oldImage = actualImage.src;
	actualImage.src = newImage;
	newLink = newImage.replace("mid/", "");
	actualImage.parentNode.href = newLink;

	//setTimeout('showMooEffect()', 500);

}

function showMooEffect(){
	if(hecho == 1){
		if(showPicture != null){
			showPicture.hide();
			showPicture.toggle();
		}
	}
	hecho = 1;
}

function swapSearch() { 
	if (!document.getElementsByTagName) return; 
	var anchors = document.getElementsByTagName("strong"); 
	for (var i=0; i<anchors.length; i++) { 
		var anchor = anchors[i]; 
		if (anchor.className == "triggerDrop")  {
			anchor.parentNode.nextSibling.style.display = "none";
			anchor.style.cursor = "pointer";
			anchor.onclick = function() {
				if (anchor.parentNode.nextSibling.style.display == "none") {
					anchor.parentNode.nextSibling.style.display = "block";   
				} else {
					anchor.parentNode.nextSibling.style.display = "none";   
				} // end if
			} // end function
		}		
	} 
} 

function checkMooTrigger() {
	if (!document.getElementsByTagName) return; 
	var anchors = document.getElementsByTagName("p"); 
	for (var i=0; i<anchors.length; i++) { 
		var anchor = anchors[i]; 
		if (anchor.className == "trigger")  {
		   //var newDestiny = eval(history.back())
			anchor.style.cursor = "pointer";
			anchor.title = "Pinche para desplegar los contenidos";
			anchor.innerHTML = anchor.innerHTML+" <span class='indicador'>[ + más ]</span>";
			anchor.onclick = function() {
				if (this.nextSibling.nodeName.toLowerCase() == "div") {
					Origen = this.nextSibling;
				} else {
					Origen = this.nextSibling.nextSibling;
				} // end if
				toggleTrigger = this.id;
				foo = toggleTrigger.split("-");
				textoInterior = Origen.innerHTML;
				textoInteriorMod = textoInterior+"<p id='algo"+foo[0]+"'><a href='#"+toggleTrigger+"' onclick='"+foo[0]+".toggle(); return true;'>&#094; Subir</a></p>";
				if (!document.getElementById("algo"+foo[0])) {
					Origen.innerHTML = textoInteriorMod;
				}
				eval(foo[0]).toggle();
			}
		}		
	} 
	var anchors = document.getElementsByTagName("h6"); 
	for (var i=0; i<anchors.length; i++) { 
		var anchor2 = anchors[i]; 
		if (anchor2.className == "trigger")  {
		   //var newDestiny = eval(history.back())
			anchor2.style.cursor = "pointer";
			anchor2.title = "Pinche para desplegar los contenidos";
			anchor2.onclick = function() {
				toggleTrigger = this.id;
				foo = toggleTrigger.split("-");
				eval(foo[0]).toggle();
			}
		}		
	} 
}

function addDOMLoadEvent(func){if(!window.__load_events){var init=function(){if(arguments.callee.done)return;arguments.callee.done=true;if(window.__load_timer){clearInterval(window.__load_timer);window.__load_timer=null}for(var i=0;i<window.__load_events.length;i++){window.__load_events[i]()}window.__load_events=null};if(document.addEventListener){document.addEventListener("DOMContentLoaded",init,false)}/*@cc_on @*//*@if (@_win32) document.write("<scr"+"ipt id=__ie_onload defer src=javascript:void(0)><\/scr"+"ipt>");var script=document.getElementById("__ie_onload");script.onreadystatechange=function(){if(this.readyState=="complete"){init()}};/*@end @*/if(/WebKit/i.test(navigator.userAgent)){window.__load_timer=setInterval(function(){if(/loaded|complete/.test(document.readyState)){init()}},10)}window.onload=init;window.__load_events=[]}window.__load_events.push(func)}

function checkIconCalendar() {
	if (!document.getElementsByTagName) return; 
	var anchors = document.getElementsByTagName("img"); 
	for (var i=0; i<anchors.length; i++) { 
		var anchor = anchors[i]; 
		if (anchor.className == "openCalendar")  {
		   //var newDestiny = eval(history.back())
			anchor.style.cursor = "pointer";
			anchor.previousSibling.readOnly = true;
			anchor.nextSibling.style.display = "none";
			anchor.onclick = launchCalendar;
		}		
	} 
}

function launchCalendar() {
	var Destination = this.previousSibling.id;
	var iLang = this.lang;
	CreateCal(Destination, iLang);
}
var iWindow = null;

function CreateCal(Destination, iLang) {
	var arTranslation = [
		["x"],
		[ "Solo un calendario a la vez."], 
		[ "Only one calender opens at a time."], 
		[ "---"]
	];
	if(iWindow != null){
		if(iWindow.closed){
			iWindow = window.open("/includes/calendar.php?casilla="+Destination, "", "menubar='no',resize='no',status=no,width=250,height=215, dependent=yes");
		} else {
			window.alert(arTranslation[iLang]);
		}
	} else {
		iWindow = window.open("/includes/calendar.php?casilla="+Destination, "", "menubar='no',resize='no',status=no,width=250,height=215, dependent=yes");
	}
}

//SE USA PARA EL BUSCADOR DE MAR INMOBILIARIA
function muestraEstado(){
	if (!document.getElementById("str_status")) return; 
	seleccion = document.getElementById("str_status");
	seleccion = seleccion.value;
	if(seleccion == 1){
		var costa = document.getElementById("costa");
		costa.className = "show";
		var zona = document.getElementById("zona");	
		zona.className = "hidden";
	} else {
		var zona = document.getElementById("zona");	
		zona.className = "show";
		var costa = document.getElementById("costa");
		costa.className = "hidden";
	}
}

function loadFlash(){
}

window.onload = function() {
	getThumbnailImages();
}