
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 fncVolver()
{
  history.back();
}

function Limpiar( obj )//Recibe el objeto al que debe pasar el foco.
{
  obj.focus();
}

function fncCambiarMapeado(nuevoMapeado,ruta)
{
  obj = window.document.getElementById('mapa');
  obj.useMap = "#" + nuevoMapeado;
  window.location.href=ruta;
  
}


function esCorrecto()
{

	if (document.forms.empresa.value =="")
	{
		alert("Es necesario que rellene el campo Empresa");
		return false;
	}

	if (document.forms.provincia.value =="")
	{
		alert("Es necesario que seleccione la Provincia");
		return false;
	}

	if (document.forms.contacto.value =="")
	{
		alert("Es necesario que rellene el campo Contacto con su nombre");
		return false;
	}
	

	if  (document.forms.telefono.value =="")
	{
		alert("Es necesario que rellene el campo Teléfono");
		return false;
	}


	if (isNaN(document.forms.telefono.value))
	 {
		alert("Debe introducir un valor númerico en el campo Teléfono");
		document.forms.telefono.focus();
		return false;
	 }
	 
	 if (!validaTelefono(document.forms.telefono))
  	{
      		alert("Introduce un valor válido para el Teléfono. ")
  	  	return false;
  	
  	}

	if (document.forms.mail.value!=""){
		if (document.forms.mail.value.indexOf("@")==-1 || document.forms.mail.value.indexOf(".")==-1)
		{	
			alert("El formato de su E-mail no es correcto. Por favor vuelve a introducir tu E-mail");
			return false;
		}
	}


	//if (document.forms.cp.value==""){
	//		alert("Le agradeceriamos que nos indicara el CP");
	//		return false;
	//	}
		
	if (isNaN(document.forms.cp.value) && document.forms.cp.value!="")
	 {
		alert("Debe introducir un valor númerico en el C.P.");
		return false;
	 }
	
	 
   	//if (!(document.forms[18].checked) && !(document.forms[15].checked) && !(document.forms[16].checked) && !(document.forms[17].checked))
	//{
	//	alert("Es necesario que seleccione un Asunto");
	//	return false;
	//}

	document.forms.submit();

	return true;
}


function esCorrectoRevista()
{

	if (document.forms.empresa.value =="")
	{
		alert("Es necesario que rellene el campo Empresa");
		return false;
	}

	if (document.forms.provincia.value =="")
	{
		alert("Es necesario que seleccione la Provincia");
		return false;
	}

	if (document.forms.contacto.value =="")
	{
		alert("Es necesario que rellene el campo Contacto con su nombre");
		return false;
	}
	

	if  (document.forms.telefono.value =="")
	{
		alert("Es necesario que rellene el campo Teléfono");
		return false;
	}


	if (isNaN(document.forms.telefono.value))
	 {
		alert("Debe introducir un valor númerico en el campo Teléfono");
		document.forms.telefono.focus();
		return false;
	 }
	 
	 if (!validaTelefono(document.forms.telefono))
  	{
      		alert("Introduce un valor válido para el Teléfono. ")
  	  	return false;
  	
  	}

	if (document.forms.mail.value!=""){
		if (document.forms.mail.value.indexOf("@")==-1 || document.forms.mail.value.indexOf(".")==-1)
		{	
			alert("El formato de su E-mail no es correcto. Por favor vuelve a introducir tu E-mail");
			return false;
		}
	}

	
	if (isNaN(document.forms.cp.value) && document.forms.cp.value!="")
	 {
		alert("Debe introducir un valor númerico en el C.P.");
		return false;
	 }
	
	if (document.forms.edicion.value =="")
	{
		alert("Es necesario que seleccione la Edición de la revista");
		return false;
	}
	 
	document.forms.submit();

	return true;
}

function esCorrectoSoftwareInmobiliario()
{

	if (document.forms.empresa.value =="")
	{
		alert("Es necesario que rellene el campo Empresa");
		return false;
	}

	if (document.forms.provincia.value =="")
	{
		alert("Es necesario que seleccione la Provincia");
		return false;
	}

	if (document.forms.contacto.value =="")
	{
		alert("Es necesario que rellene el campo Contacto con su nombre");
		return false;
	}
	

	if  (document.forms.telefono.value =="")
	{
		alert("Es necesario que rellene el campo Teléfono");
		return false;
	}


	if (isNaN(document.forms.telefono.value))
	 {
		alert("Debe introducir un valor númerico en el campo Teléfono");
		document.forms.telefono.focus();
		return false;
	 }
	 
	 if (!validaTelefono(document.forms.telefono))
  	{
      		alert("Introduce un valor válido para el Teléfono. ")
  	  	return false;
  	
  	}
  	
	if (document.forms.cp.value==""){
			alert("Le agradeceriamos que nos indicara el CP");
			return false;
		}
		
	if (isNaN(document.forms.cp.value) && document.forms.cp.value!="")
	 {
		alert("Debe introducir un valor númerico en el C.P.");
		return false;
	 }


	if (document.forms.mail.value!=""){
		if (document.forms.mail.value.indexOf("@")==-1 || document.forms.mail.value.indexOf(".")==-1)
		{	
			alert("El formato de su E-mail no es correcto. Por favor vuelve a introducir tu E-mail");
			return false;
		}
	}

	document.forms.submit();
	return true;
}


function validaTelefono(telefono)
{
  if(telefono.value.length !== 9)
  {
    return(false);
  }
  if(isNaN(telefono.value))
  {
    return(false);
  }
  var caracter = telefono.value.charAt(0)
  if(caracter !== '9' && caracter !== '6' && caracter !== '8')
  {
    return(false);
  }
  return(true);
}


function ValidacionFormularioAyuda()
  {
    obj = window.document.getElementById("nombre")
    if(obj.value=='')
	{
	  alert('Sería conveniente que nos indicaras tu Nombre para poder contactar contigo');
          obj.focus();
          return(false);
		
	}
	    
    obj = window.document.getElementById("email")
    if(obj.value=='')
	{
	  alert('Sería conveniente que nos indicaras tu Email para poder contactar contigo');
          obj.focus();
          return(false);
		
	}
	
	if (obj.value.indexOf("@")==-1 || obj.value.indexOf(".")==-1)
		{	
			alert("El formato de su E-mail no es correcto. Por favor vuelve a introducir tu E-mail");
			 obj.focus();
			return false;
		}
		
    obj = window.document.getElementById("comentarios")
    if(obj.value=='')
    {
      alert('Sería conveniente que nos comentases algo');
      obj.focus();
      return(false);
    }
    	
    return(true);
  }
  
  function ValidacionFormularioSugerencias()
  {
    	
    obj = window.document.getElementById("comentario")
    if(obj.value=='')
    {
      alert('Sería conveniente que nos comentases algo');
      obj.focus();
      return(false);
    }
    	
    return(true);
  }