<!--
var google_conversion_id = 1033761018;
var google_conversion_language = "es";
var google_conversion_format = "1";
var google_conversion_color = "ffffff";
//-->

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 addToFavorites(valor)
{
	var pregunta=window.confirm(document.forms.frm.txtFraseAddToFavorites.value);
	if (pregunta) {
		document.forms.frm.addtofavorites.value = valor;
		document.forms.frm.submit();
	}
}

function movepic(img_src_name,img_name,img_src)
{
	document[img_name].src=img_src;	
	escala3(document.getElementById(img_src_name),390,520,document.getElementById("bigimg"));
}

function notLogged(valor)
{
	alert(valor);
}

function ShowTel(capa,capa1,capa2,capa3,capa4)
{
    
	fichainmueble.MostrarTelefono();
	document.getElementById(capa).style.display = '';
	document.getElementById(capa1).style.display = '';
	document.getElementById(capa2).style.display = 'none';
	document.getElementById(capa3).style.display = '';
	document.getElementById(capa3).innerHTML = document.getElementById(capa3).innerHTML + "<script language='JavaScript' type='text/javascript'><!--var google_conversion_label =\"RTq2CKbghgEQ-uH37AM\";//--></script>";
	document.getElementById(capa3).innerHTML = document.getElementById(capa3).innerHTML + "<script language='JavaScript' src='https://www.googleadservices.com/pagead/conversion.js'></script>";
	}

function ShowTelUsr(capa,capa1,capa2,capa3,capa4)
{
	accionesficha.MostrarTelefono();
	document.getElementById("ucpieficha_"+capa).style.display = '';
	document.getElementById("ucpieficha_"+capa1).style.display = '';
	document.getElementById("ucpieficha_"+capa2).style.display = 'none';
	document.getElementById("ucpieficha_"+capa3).style.display = '';
}

function Focus()
{
	document.getElementById("ucFormRecomendar_btnEnviar").focus();
	document.getElementById("ucFormRecomendar_txtAmigo").focus();
}

function ConsignarProponer(check) 
{
	if (document.getElementById("hdConsignarProponer").value == 0) 
	{
		document.getElementById("chkConsignar").checked = false;
		document.getElementById("chkProponer").checked = false;
		document.getElementById("dvTextoCondicionesUso").style.display = 'block';
		document.getElementById("hdCheckUsado").value = check;
	} 
}

function Contactficha()
{
	fichainmueble.ContactUsUnico();
}

function fichaUsUnico()
{
	fichainmueble.SetUsUnico();
}


function fichafotosUsUnico()
{
	fichafotos.SetUsUnico();
}

function fichavisitaUsUnico()
{
	
}

function Masinmuebles()
{
	fichainmueble.Masinmuebles();
}
function Errorcliente()
{
var xstr_otroerror = "";
 document.getElementById("ucFichainmueble_lbotroerror").style.display = "none";
 if (document.getElementById("ucFichainmueble_cbxMejoras").SelectedValue != "0")
    {
        if (document.getElementById("ucFichainmueble_cbxMejoras").SelectedValue == "5") 
            {
                document.getElementById("ucFichainmueble_lbotroerror").style.display = "";
            }
         else
            {
                xstr_otroerror = "";
               // fichainmueble.ReportarErrorCliente($get("ucFichainmueble_txtIdInmueble").value,xstr_otroerror,$get("ucFichainmueble_cbxMejoras").SelectedValue);
                fichainmueble.ReportarErrorCliente();
                document.getElementById("ucFichainmueble_lbAgradeceKO").style.display = "none";
                document.getElementById("ucFichainmueble_lbAgradece").style.display = "";
            }  
    }
 else 
    {
        document.getElementById("ucFichainmueble_lbAgradeceKO").style.display = "";
         document.getElementById("ucFichainmueble_lbAgradece").style.display = "none";
    }
 
}

function voi_cbxmejoraschange()
			{
				if(document.getElementById("ucFichainmueble_cbxMejoras") != null)
				{
					var xstr_valor;
					xstr_valor = str_obteneropcionselect(document.getElementById("ucFichainmueble_cbxMejoras"))
					
					if(xstr_valor == "5") //OTRO ERROR
					{
						document.getElementById("ta_otroerror").style.display = "";
					}
					else
					{
						document.getElementById("ta_otroerror").style.display = "none";
					}
				}
			}

function vermas()
{
	accionesficha.VerMasInmuebles();
}

function Enviaramigo(x)
{
    var IsValid = 0;
    var Action = 0;
    var IsUc = "";
  
  if (document.getElementById("ucFichainmueble_Ucformrecomendar2_lberrormail") != null)
    IsUc = "ucFichainmueble_";
  
  document.getElementById(IsUc + "Ucformrecomendar2_lberrormail").style.display = "none";
  document.getElementById(IsUc + "Ucformrecomendar2_lberrornombre").style.display = "none";
//          HAY QUE TRADUCIR ESTO PARA JVASCRIPT    
//    lberrornombre.Visible = (txtNombre.Value.Equals(string.Empty));
//			lberrormail.Visible = (txtEmail.Value.Equals(string.Empty));
//			if (!lberrormail.Visible)
//				lberrormail.Visible = !Validaciones.isValidEmail(txtEmail.Value);
//			//lberroramigos.Visible = (lstAmigos.Items.Count == 0);
//			if (lberroramigos.Visible)
//				if (txtAmigo.Value.Equals(string.Empty))
//					lberroramigos.Visible = true;
//				else
//					lberroramigos.Visible = !Validaciones.isValidEmail(txtAmigo.Value);
//			return (!lberrornombre.Visible) && (!lberrormail.Visible) && (!lberroramigos.Visible);
			
			
    if (IsValid == 0)
        {
            Action = FormRecomendar.EnviarRecomendacion(document.getElementById(IsUc + "Ucformrecomendar2_txtAmigo").value,document.getElementById(IsUc + "Ucformrecomendar2_txtNombre").value,document.getElementById(IsUc + "Ucformrecomendar2_txtEmail").value,document.getElementById(IsUc + "Ucformrecomendar2_txComentarios").value,window.location,document.getElementById(IsUc + "Ucformrecomendar2_hdIdanuncio").value);
            if (Action.value == "1") 
                {
            	//aviso.InnerHtml = aviso.InnerHtml.Replace("$EMail$", EMail);
                document.getElementById(IsUc + "Ucformrecomendar2_aviso").style.display = "";
                }
                else
                {
                alert('the other');
                }
        }
    
	if (x != 0)
	{
	fichainmueble.Enviaramigo();
	}
}


function fichamapaUsUnico()
{
	fichamapa.SetUsUnico();
}

function resultadosUsUnico()
{
	Migrated_resultados1.SetUsUnico();
	
}

function fichaplanosUsUnico()
{
	fichaplanos.SetUsUnico();
}

function fichamemoriaUsUnico(x)
{
	if (x == 0)
		fichainmueble.SetUsUnicoMem();
	if (x == 1)
		fichafotos.SetUsUnicoMem();
	if (x == 2)
		fichamapa.SetUsUnicoMem();
	if (x == 3)
		fichaplanos.SetUsUnicoMem();
	if (x == 5)
		accionesficha.SetUsUnicoMem();
	
}

function escala(img,boxh,boxw) 
{
 var imgH = img.clientHeight;
 var imgW = img.clientWidth;

 var scaleW = 0;
 scaleW = boxw / imgW;
 img.style.width = boxw + "px";
 img.style.height = Math.round(imgH * scaleW) + "px";
}

function escala2(img,boxh,boxw,img2) 
{
 var imgH = img.clientHeight;
 var imgW = img.clientWidth;
 var scaleW = boxw / imgW;
 img2.style.width = boxw + "px";
 img2.style.height = Math.round(imgH * scaleW) + "px";
}

function escala3(img,boxh,boxw,img2) 
{ 
 var imgH = img.clientHeight;
 var imgW = img.clientWidth;
 var scaleH = boxh / img.clientHeight; 
 var scaleW = 0;
 var factor = 0;
 var tamw = 0;
 var tamh = 0;
 
 scaleW = boxw / imgW;
 
 if(scaleH > scaleW)
	{	
	factor = scaleW;
	tamw = boxw;
	tamh = Math.round(imgH * factor);
	}
else
	{	
	factor = scaleH;
	tamw = Math.round(imgW * factor);
	tamh = boxh;
	}

//AFINAMOS EL SCRIPT, SI DESPUES DEL REDONDEO, NO SE CONSIGUE LA ALTURA POR 1 PIXEL (O LA ANCHURA)
if((boxh - tamh) <= 1)
	tamh = boxh;

if((boxw - tamw) <= 1)
	tamw = boxw;

img2.style.width = tamw + "px";    
img2.style.height = tamh + "px";    
}

function voi_centraimg(img, boxh)
{
 var imgH = img.clientHeight;
 
 var xint_dif;
 var xint_desp;
 if(boxh < imgH) //SI LA IMAGEN ES MAS ALTA QUE LA CAJA. LA CENTRAMOS EN ALTURA
	{
	xint_dif = imgH - boxh;
	xint_desp = parseInt(xint_dif / 2);
	
	img.style.position = "relative";
	img.style.top = "-" + xint_desp + "px";
	}
}
