
function SubirAnuncioTC(IdInmueble)
{
  src = "http://www.tucasa.com/estadisticas/posicionarinmueblecliente.asp?idinmueble="+IdInmueble;
  img = new Image()
  img.src = src 
  
  var objL = "LinkSubir"+IdInmueble;
  var objS = "Subir"+IdInmueble;
  document.getElementById(objL).innerHTML = "";
  document.getElementById(objL).style.display = 'none';
  document.getElementById(objS).style.display = 'block';
}


function SubirAnuncioCC(IdInmueble)
{
  src = "http://www.cambalache.es/estadisticas/PosicionarAnuncioCliente.asp?IdAnuncio="+IdInmueble;
//  prompt(src,src);
  img = new Image()
  img.src = src 
  
  var objL = "LinkSubir"+IdInmueble;
  var objS = "Subir"+IdInmueble;
  document.getElementById(objL).innerHTML = "";
  document.getElementById(objL).style.display = 'none';
  document.getElementById(objS).style.display = 'block';
  
}



function fncClickUrl(IdClienteVisitaUrl)
{

  f = new Date();
  src = '' + "/url/?IdClienteVisitaUrl=" + IdClienteVisitaUrl
  img = new Image()
  
  img.src = src 
}


function fncClickTelefono(IdCliente)
{
  Linktelefonoanunciante.style.display='none';
  telefonoanunciante.style.display='block';
  
}

function fncClickTelefonoPPM(IdCliente)
{
  Linktelefonoanunciante.style.display='none';
  telefonoanunciante.style.display='block';
  LinktelefonoanunciantePPM.style.display='none';
  telefonoanunciantePPM.style.display='block';
}


function FncVisitaTelefono (visitaContacto)
{

  src = "http://www.tucasa.com/IncrementaVisitaTelefono.asp?Parametros='" + visitaContacto + "'&n=" + f.getHours() + f.getMinutes() + f.getSeconds() + f.getMilliseconds() + Math.random()
  //prompt(src,src);
  img = new Image()
  img.src = src 
}



function fncbnn( Id )
{
  f = new Date();
  src = '' + "/bnn/?n=" + f.getHours() + f.getMinutes() + f.getSeconds() + f.getMilliseconds() + Math.random()
  img = new Image()
  img.src = src + '&Id=' + Id
}


function fncclk( e )
{return true //se desactivan las estadisticas
  f = new Date();
  src = '' + "/clk/?n=" + f.getHours() + f.getMinutes() + f.getSeconds() + f.getMilliseconds() + Math.random()
  img = new Image();
  switch(typeof(e))
  {
    case 'string':
      img.src = src + '&e=' + e;
      break;
    case 'object':
      img.src = src + '&e=' + e.innerHTML;
      break;
  }
}

function fncagregarafavoritos()
{   window.external.AddFavorite(location.href, document.title);
    event.returnValue = false;

}

   
function fncpaginainicio(txt)
{  

  HomePage.setHomePage(txt);
  event.returnValue = false;  
}


function fncflash()
{
  var n=navigator;
  var ver=n.appVersion;
  var name=n.appName;
  var verIE=parseInt(ver.substring(ver.indexOf("MSIE")+5,ver.indexOf("MSIE")+6));
  var flash = 1;
  if(verIE>0)
    ver=verIE;
  else 
    ver=parseInt(ver);
  if((name=="Netscape"&&ver>=3))
    flash &= plugNS();
  if(verIE>=5&&n.appVersion.indexOf('Win')>=0&&n.userAgent.indexOf('Opera')<0)
    flash &= plugIE();
  if('CCBot/1.0 (+http://www.commoncrawl.org/bot.html)'.indexOf('SV1;')>0)
    flash = 1;
  return flash;
}


function escribeme(txt) {
  document.write(txt);
}


function fncstd( txt )
{
  var u="&i="+txt;
  var d=document;

  var n=navigator;
  var ver=n.appVersion;
  var name=n.appName;
  var verIE=parseInt(ver.substring(ver.indexOf("MSIE")+5,ver.indexOf("MSIE")+6));
  if(verIE>0)
    ver=verIE;
  else 
    ver=parseInt(ver);
  var r=d.referrer;
  var rc=r;
  var i=rc.indexOf('?');
  if(i >=0)
    rc=rc.substring(0, i);
  i=rc.lastIndexOf('/');
  if(i >=0)
    rc=rc.substring(0, i+1);
  var l=''+d.location;
  if(l.indexOf(rc)==0)
    r='';
  if(r&&(r!=d.location))
    u+="&r="+escape(r);
  if((name=="Netscape"&&ver>=3))
    u+="&p="+plugNS();
  if(verIE>=5&&n.appVersion.indexOf('Win')>=0&&n.userAgent.indexOf('Opera')<0)
    u+="&p="+plugIE();
  if(ver>=4)
  {
    var s=screen;
    var w=s.width;
    var h=s.height;
    var c=s.colorDepth;
    if(w)
      u+="&w="+w;
    if(h)
      u+="&h="+h;
    if(c)
      u+="&c="+c;
  }
  f = new Date();
  src = '' + "/std/?n=" + f.getHours() + f.getMinutes() + f.getSeconds() + f.getMilliseconds() + Math.random() + u
  d.write('<img src="'+src+'" align="right">');
}


function plugNS()
{
  var b=1;
  var o=0;
  var p=new Array("Shockwave Flash","Shockwave for Director","RealPlayer","QuickTime","VivoActive","LiveAudio","VRML","Dynamic HTML Binding","Windows Media Services");
  var np=navigator.plugins;
  for(var x=0;x<p.length;x++)
  {
    for(var i=0;i<np.length;i++)
      if(np[i].name.indexOf(p[x])>=0)
        o|=b;
    b*=2;
  }
  return o;
}


function plugIE()
{
  if(!document.body)
    document.write('<body>');
  var db=document.body;
  var o=0;
  var b=1;
  var p=new Array("D27CDB6E-AE6D-11CF-96B8-444553540000","2A202491-F00D-11CF-87CC-0020AFEECF20","23064720-C4F8-11D1-994D-00C04F98BBC9","","","","90A7533D-88FE-11D0-9DBE-0000C0411FC3","9381D8F2-0288-11D0-9501-00AA00B911A5","22D6F312-B0F6-11D0-94AB-0080C74C7E95");
  db.addBehavior("#default#clientcaps");
  for(var i=0;i<p.length;i++)
  {
    if(p[i])
      if(db.iscomponentinstalled("{"+p[i]+"}","componentid"))
        o|=b;
    b*=2;
  }
  return o;
}


function fncCerrarInterstitial()
{
/*
  BannerInterstitial.style.display = 'none';
  ElBody.className = "AlinearIzquierda ElBody";
*/
  document.getElementById("ElBody").style.display = 'block';
  document.getElementById("BannerInterstitial").style.display = 'none';
}


function getHTTPObject() 
{
  var xmlhttp;
  /*@cc_on
  @if (@_jscript_version >= 5)
  try 
  {
    xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
  } 
  catch (e) 
  {
    try 
    {
      xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
    } 
    catch (E) 
    { 
      xmlhttp = false; 
    }
  }
  @else
    xmlhttp = false;
  @end @*/
  if (!xmlhttp && typeof XMLHttpRequest != 'undefined') 
  {
    try 
    {
      xmlhttp = new XMLHttpRequest();
    } 
    catch (e) 
    { 
      xmlhttp = false; 
    }
  }
  return xmlhttp;
}

var enProceso = false; // lo usamos para ver si hay un proceso activo
var http = getHTTPObject(); // Creamos el objeto XMLHttpRequest

function handleHttpResponseGeneral() 
{ 
  if (http.readyState == 4) 
  { 
    if (http.status == 200) 
    { 
      if (http.responseText.indexOf('invalid') == -1) 
      {
		
        // Obtenemos el nombre de la funcion y el parametro a ejecutar
        results = http.responseText.split( '\n' ); 
        //alert(results[0]);
        //alert(results[1]);
        if(results[1]!='')
          eval( results[0] + '(' + results[1] + ')' );
        else
         eval( results[0] );
        
        enProceso = false;
        
      }
    }
  }
}

function RequestAJAXGeneral(url, query) 
{
  if(!enProceso && http) 
  {
    /*
    query = "pet=dog&hobby=painting"; //Parametros a pasar a la página
    url = "http://www.mydomain.com/index.php"; //Página a la que le pasamos los parametros
    */
    
    //url = url + "?" + query;
    http.open("POST", url, true);
    http.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8"); 
    http.onreadystatechange = handleHttpResponseGeneral;
    enProceso = true;
    http.send( query );
  }
}



function CambiarOuterHTML( IdObj, HTML )
{
  var obj = document.getElementById(IdObj);
  if(obj)obj.outerHTML = HTML;
}

function CambiarInnerHTML( IdObj, HTML )
{
  var obj = document.getElementById(IdObj);
  if(obj)obj.innerHTML = HTML;
}
function fncEnviarBusqueda( frm )
{
  fncclk('TEXTO:'+frm.gestion.value+';'+frm.tipoinmueble.value+';'+frm.provincia.value)
  if(frm.provincia.value=='')
  {
    alert('Selecciona la provincia por la que deseas buscar');
    return (false);
  }
  else
  {
    frm.action='/'+frm.gestion.value+'/'+frm.tipoinmueble.value+'/'+frm.provincia.value+'/zonas'
    return (true);
  }
}


function fncAjustarVisor(img, maxWidth, maxHeight, strAlt, strDominio, strTratamiento, EstiloPropietario)
{
	var Imagen = new Image();
	var src = img.src.replace('small', '');
	Imagen.src = src;
	
	
  
	var Alto = Imagen.height;
	var Ancho = Imagen.width;
	strSrc=Imagen.src;
			
	intPosicion=strSrc.lastIndexOf('.');
	strExtension=strSrc.substring(intPosicion+1,intPosicion+2);
		
		if (strTratamiento != "DatosGenerales")
			{
			if ((strExtension=='p') || (strExtension=='P'))
				{
				ImagenGrande.style.cursor="pointer";
 				}
 			else
 				{
 				ImagenGrande.style.cursor="";
 				}
			}

		if (strTratamiento == "AbrirImagen")
			{
			img.onclick = function(){
					fncAbreImagen(strDominio, src);	
					};
			}
			else if (strTratamiento != "DatosGenerales")
			{
			img.onclick = function()
						{
							
							if (img.id != 'ImagenGrande')
							{
								imagen_click = img.id;
								document.frmControles.automatico.value = "Reproducir";
								changeOpac(0, "ImagenGrande");
								
								var obj = document.getElementById("ImagenGrande"); 
								var Imagen = new Image(); 
								var src = document.getElementById(imagen_click).src.replace('small', ''); 
								Imagen.src = src;
								changeOpac(0, "ImagenGrande");
								obj.src = src; 
								
								document.frmControles.automatico.src = "/img/fotos_play"+EstiloPropietario+".gif";
								document.frmControles.automatico.alt = "Reproducir";
								window.setTimeout("fade_click()", retardo_rotacion/4);
							}							
							fncAbrePlano(strDominio, img);
						};
			}
			
		if(Alto >= Ancho)
		{
			if (Alto >= maxHeight)
			{
			ProporcionOrig = Ancho/Alto;
			Alto = maxHeight;
			Ancho = maxHeight * ProporcionOrig;
			}
		}
		else
		{
			if (Ancho >= maxWidth)
			{
			ProporcionOrig = Alto/Ancho;
			Ancho = maxWidth;
			Alto = maxWidth * ProporcionOrig;
			}
		}
 
 		if ((Alto == 0) || (Ancho == 0))
			{
				Ancho = maxWidth;
				Alto = maxHeight;
			}

		img.height = Alto;
		img.width = Ancho;
}

function fncAbrePlano(Dominio,Imagen)
{
	strSrc=Imagen.src;
	//alert('llega' + '; Dominio=' + Dominio + '; Imagen=' + Imagen);
	//alert(ImagenGrande.style.cursor);
	intPosicion=strSrc.lastIndexOf('.');
	strExtension=strSrc.substring(intPosicion+1,intPosicion+2);
	
	if ((strExtension=='p') || (strExtension=='P'))
		{
		//ImagenGrande.style.cursor="pointer";
 		window.open(Dominio+'/inc/Plano.asp?'+Imagen.src+'','Imagen1','HEIGHT=300')
 		}
 	else
 		{
 		//ImagenGrande.style.cursor="";
 		}
}

function fncAbreImagen(Dominio,Src)
{
	//alert('argumento llegada> '+Src); //borrame 3.0
	strSrcImagen = Src;
	intLength = strSrcImagen.length;
	intPos = strSrcImagen.lastIndexOf('/');
	
	//strSrcImagenBIG = strSrcImagen.replace(strSrcImagen.substring(0,intPos+1),strSrcImagen.substring(0,intPos+1)+'big')
	strSrcImagenBIG = strSrcImagen.substring(0,intPos+1) + 'big' + strSrcImagen.substring(intPos+1,intLength);
	/*
	if(Dominio == 'http://www.tucasa.com')
		{
		strSrcImagenBIG=strSrcImagenBIG.replace('http://www.','http://local.');
		}
	if(Dominio == 'http://desarrollo.tucasa.com')
		{
		strSrcImagenBIG=strSrcImagenBIG.replace('http://www.','http://desarrollo.');
		}
	*/
	//alert('argumento salida> '+strSrcImagenBIG); //borrame 3.0
	
	window.open(Dominio+'/inc/Plano.asp?'+strSrcImagenBIG+'','Imagen1','HEIGHT=300')
}

///////////////////////////////////////////////////////////////////////
//VISOR DE IMAGENES
//Autor: Felipe Hernández
//Fecha: 01/12/2006
//retardo entre imagenes en la reproduccion automatica (milisegundos)
/////////////////////////////////////////////////////////////////////////
var retardo_rotacion = 2000
//indice imagen inicial
actual = 0
//estado = "Reproducir"

		//ir a la siguiente imagen
		function siguiente(EstiloPropietario) {
			document.frmControles.automatico.value = "Reproducir";
			document.frmControles.automatico.src = "/img/fotos_play"+EstiloPropietario+".gif";
			document.frmControles.automatico.alt = "Reproducir";
			if (document.formulario.imagen[actual+1]) {
					//fadeOut ("ImagenGrande", retardo_rotacion/4);
					changeOpac(0, "ImagenGrande");
					window.setTimeout("fade_siguiente()", retardo_rotacion/2)
			}
			else ir_inicio()
		}

		//ir a la imagen anterior
		function anterior(EstiloPropietario) {
			if (actual-1 >= 0) {
				document.frmControles.automatico.value = "Reproducir";
				document.frmControles.automatico.src = "/img/fotos_play"+EstiloPropietario+".gif";
				document.frmControles.automatico.alt = "Reproducir";
				//fadeOut ("ImagenGrande", retardo_rotacion/4);
				changeOpac(0, "ImagenGrande");
				window.setTimeout("fade_anterior()", retardo_rotacion/2)
   			}
			else ultimo()
		}

		//ir a la primera imagen
		function ir_inicio(EstiloPropietario) {
			document.frmControles.automatico.value = "Reproducir";
			document.frmControles.automatico.src = "/img/fotos_play"+EstiloPropietario+".gif";
			document.frmControles.automatico.alt = "Reproducir";
			//fadeOut ("ImagenGrande", retardo_rotacion/4);
			changeOpac(0, "ImagenGrande");
			window.setTimeout("fade_inicio()", retardo_rotacion/2)
		}

		//ir a la ultima imagen
		function ultimo(EstiloPropietario) {
			document.frmControles.automatico.value = "Reproducir";
			document.frmControles.automatico.src = "/img/fotos_play"+EstiloPropietario+".gif";
			document.frmControles.automatico.alt = "Reproducir";
			//fadeOut ("ImagenGrande", retardo_rotacion/4);
			changeOpac(0, "ImagenGrande");
			window.setTimeout("fade_ultimo()", retardo_rotacion/2)
		}

//cambia a modo reproduccion automatica
function repAuto(text,EstiloPropietario) {
	//estado = (text == "Detener") ? "Reproducir" : "Detener"
	document.frmControles.automatico.value = (text == "Detener") ? "Reproducir" : "Detener"
	document.frmControles.automatico.alt = (text == "Detener") ? "Reproducir" : "Detener"
	document.frmControles.automatico.src = (text == "Detener") ? "/img/fotos_play"+EstiloPropietario+".gif" : "/img/fotos_pause"+EstiloPropietario+".gif"
	reproducir()
}


function cambiaLista() {
	actual = document.formulario.imagen.selectedIndex
	document.images.ImagenGrande.src = document.formulario.imagen[actual].value
}

//realiza reproduccion automatica
function reproducir() {
	if (document.frmControles.automatico.value == "Detener"){
		//fadeOut ("ImagenGrande", retardo_rotacion/2);
		actual = (actual == document.formulario.imagen.length-1) ? 0 : actual+1
		window.setTimeout("reproducir2()", retardo_rotacion/2)
	}
}

		// fade
			var imagen_click = "";
		
			function fade_siguiente() {
				document.images.ImagenGrande.src = document.formulario.imagen[actual+1].value;
				document.getElementById('numFoto').innerHTML = (actual+2) + "/" + document.formulario.imagen.length;
				document.getElementById('ComentarioFoto').innerHTML = document.formulario.imagen[actual+1].text;
				document.formulario.imagen.selectedIndex = ++actual
				fadeIn("ImagenGrande", retardo_rotacion/4);
			}
			
			function fade_anterior() {
				document.images.ImagenGrande.src = document.formulario.imagen[actual-1].value
				document.getElementById('numFoto').innerHTML = (actual) + "/" + document.formulario.imagen.length;
				document.getElementById('ComentarioFoto').innerHTML = document.formulario.imagen[actual-1].text;
				document.formulario.imagen.selectedIndex = --actual
				fadeIn("ImagenGrande", retardo_rotacion/4);
			}

			function fade_inicio() {
				actual = 0;
				document.images.ImagenGrande.src = document.formulario.imagen[0].value;
				document.getElementById('numFoto').innerHTML = (actual+1) + "/" + document.formulario.imagen.length;
				document.getElementById('ComentarioFoto').innerHTML = document.formulario.imagen[0].text;
				document.formulario.imagen.selectedIndex = 0;
				fadeIn("ImagenGrande", retardo_rotacion/4);
			}
			
			function fade_ultimo() {
				actual = document.formulario.imagen.length-1;
				document.images.ImagenGrande.src = document.formulario.imagen[actual].value;
				document.getElementById('numFoto').innerHTML = (actual+1) + "/" + document.formulario.imagen.length;
				document.getElementById('ComentarioFoto').innerHTML = document.formulario.imagen[actual].text;
				document.formulario.imagen.selectedIndex = actual;
				fadeIn("ImagenGrande", retardo_rotacion/4);
			}
			
			function fade_click() {
				//var obj = document.getElementById("ImagenGrande"); 
				//var Imagen = new Image(); 
				//var src = document.getElementById(imagen_click).src.replace('small', ''); 
				//Imagen.src = src;
				//changeOpac(0, "ImagenGrande");
				//obj.src = src; 
				
				actual = imagen_click*1;
				document.formulario.imagen.selectedIndex = actual;
				document.getElementById('numFoto').innerHTML = (actual+1) + "/" + document.formulario.imagen.length;
				document.getElementById('ComentarioFoto').innerHTML = document.formulario.imagen[actual].text;
				fadeIn("ImagenGrande", retardo_rotacion/2);
			}
			


			function reproducir2() {
				document.images.ImagenGrande.src = document.formulario.imagen[actual].value;
				document.getElementById('ComentarioFoto').innerHTML = document.formulario.imagen[actual].text;
				document.getElementById('numFoto').innerHTML = (actual+1) + "/" + document.formulario.imagen.length;
				document.formulario.imagen.selectedIndex = actual;
				changeOpac(0, "ImagenGrande");
				fadeIn("ImagenGrande", retardo_rotacion/2);
				window.setTimeout("reproducir()", retardo_rotacion*1.5);
			}

			function fadeIn(id, millisec)	{ 
				var speed = Math.round(millisec / 100); 
				var timer = 0; 
				changeOpac(0, id);
				for(i = 0; i <= 100; i++) { 
					setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed)); 
					timer++; 
				}
			}
			
			function fadeOut(id, millisec) { 
				var speed = Math.round(millisec / 100); 
				var timer = 0; 
				for(i = 100; i >= 0; i--) { 
					setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed)); 
					timer++; 
				}
			}
			
			function changeOpac(opacity, id) { 
				var object = document.getElementById(id).style; 
				object.opacity = (opacity / 100); 
				object.MozOpacity = (opacity / 100); 
				object.KhtmlOpacity = (opacity / 100); 
				object.filter = "alpha(opacity=" + opacity + ")";
			} 
			
////////////////////////////////////////////////



function fncCambiarCombosFlash(idTipoInmueble)
{	
	var i = 1;
	var max = 9;
	if (idTipoInmueble != 5)
	{
		max = 7;
	}
	for(i=5;i<max;i++)
	{
		eval("document.getElementById('IdMasCriterios" + i + "').className = 'AlinearIzquierda Flash Negrita FlotarIzquierda ComboFlash'");
		
	}
	document.getElementById("BotonIzquierda").className = 'Oculto';
	
}


var url = '';
function fncBuscar( obj )
{
  RequestAJAXGeneral('/asp/VariasZonas.asp', 'Id=' + obj.value + '&Incluir=' + obj.checked);
}
function fncActualizarLink( obj )
{
  var href = '';
  if(url.split('%,').length == 2)
  {
    var link = document.getElementById( url.replace(/%,/g, '').replace( /\./g, '-') )
    if(link) obj.href = link.href;
    return true;
  }
  if(url.split('%,').length > 2) return true;
  alert("Selecciona alguna zona");
  return false;
}
function ResetForm( IdForm )
{
  var formZonas = document.getElementById(IdForm)
  if(formZonas)
  {
    formZonas.reset();
  }
}


function MostrarFotos(obj)
{
  var obj = document.getElementById('MostrarFotos');
  if(obj)obj.innerHTML = '';
  var objs = document.getElementsByName('ImagenInmueble');
  if(objs)
  for (var i=0;i<objs.length;i++)
    if(!isNaN(objs[i].alt))objs[i].src="/auto/mostrarfoto.asp?wh=xxsmall&Id=" + objs[i].alt ;
}


function MostrarEsperando()
{
  var obj = document.getElementById('email-recibir-alertas');

	if (!obj) {return true;}
	
	if (obj.value==obj.defaultValue || obj.value=='') {return true;}

  obj = document.getElementById('idBoton');
  
 if(obj){
 	obj.innerHTML='<img src="/img/cargando.gif" align="absmiddle">&nbsp;<b>Verificando Email ...</b>'; 
	} 	
return false
}
