﻿<!--
var ListName=new String('');
var newLocation=new String('');

function findPosX(obj)
{
	var curleft=0;
	if (obj.offsetParent)
	{
		while (obj.offsetParent)
		{
			curleft += obj.offsetLeft
			obj = obj.offsetParent;
		}
	}
	else if (obj.x) curleft += obj.x;
	return curleft;
}

function findPosY(obj)
{
	var curtop=0;
	if (obj.offsetParent)
	{
		while (obj.offsetParent)
		{
			curtop += obj.offsetTop
			obj = obj.offsetParent;
		}
	}
	else if (obj.y)
		curtop += obj.y;
	return curtop;
}

function SetMenu(location)
{    
    try
    {
        for(i=0;i<MenuArray.length;i++)
        {
            var s,g='1',a='1',p;
    	    var properties=MenuArray[i].split(';');
		    switch(properties[1])
		    {
			    case '1':
				    s = properties[7];
				    g = '1';
				    a = '1';
				    break;
			    case '2':
			        for (j=i;j>=0;j--)
			        {
			            p=MenuArray[j].split(';');
			            if (p[1]=='1')
			            {
			                s=p[7];
			                break;
			            }
			        }
			        g = properties[7];
				    a = '1';
				    break;
			    case '3':
				    for (j=i;j>=0;j--)
			        {
			            p=MenuArray[j].split(';');
			            if (p[1]=='2') g=p[7];
			            if (p[1]=='1')
			            {
			                s=p[7];
			                break;
			            }
			        }
				    a = properties[7];
				    break;
		    }
		    var pg=new String('');
		    if (properties[5]=='1')
		    {
		        pg='page_redirect.aspx?IdSection=' + s + '&IdGroup=' + g + '&IdDetail=' + a;
		    }
		    else
		    {
		        if ((properties[1]=='1') && (properties[6] !=''))
		        {
		            pg='page_redirect.aspx?IdSection=' + s + '&IdGroup=' + properties[6] + '&IdDetail=' + a;
		        }		
		        if ((properties[1]=='2') && (properties[6] !=''))
		        {
		            pg='page_redirect.aspx?IdSection=' + s + '&IdGroup=' + g + '&IdDetail=' + properties[6];
		        }
		    }
		    if (location.indexOf(pg)>=0)
		    {
		        document.getElementById('ctl00_tbMenuState').value=i;
		        document.getElementById('ctl00_tbPage').value=location;
                __doPostBack('ctl00$tbMenuState','');
		        break;
		    }
		}
    }
    catch(e)
    {
        alert(e.description);
    }
}

function ResizeToContent()
{
    if (document.body.scrollHeight<607)
    {
        document.getElementById('menu').style.height=474;
        document.getElementById('RightCell').style.height=455;
    }
}

function ShowList(tbName,lstName)
{
    try
    {
        HideList(1);
        SetListName(lstName);
        var cLeft=0,cTop=0;
	    var obj=document.getElementById(tbName);
	    var h=obj.offsetHeight;
	    var w=obj.offsetWidth;
	    if (obj.offsetParent)
	    {
		    while (obj.offsetParent)
		    {
			    cLeft+=obj.offsetLeft
			    obj=obj.offsetParent;
		    }
	    }
	    else if (obj.x) curleft+=obj.x;
	    obj=document.getElementById(tbName);
        if (obj.offsetParent)
	    {
		    while (obj.offsetParent)
		    {
			    cTop+=obj.offsetTop
			    obj=obj.offsetParent;
		    }
	    }
	    else if (obj.y) cTop+=obj.y;
	    var lst=document.getElementById(lstName);
	    lst.style.width=w+20;
        lst.style.left=cLeft;
        lst.style.top=cTop+h-1;
        lst.style.display='inline';
        if(lst.offsetHeight>300) lst.style.height=300;
        if (lst.clientHeight<=15) lst.style.display='none';
    }
    catch(e)
    {
        alert(e.description);
    }
}

function HideList(FromCode)
{
    try
    {
        if (FromCode==1)
        {
            document.getElementById(ListName).style.display='none';
            return -1;
        }
        if (event.srcElement.id.indexOf('img')>=0) return -1;
        document.getElementById(ListName).style.display='none';
    }
    catch (e)
    {
        //NOP
    }
}

function SetListName(NewName)
{
    ListName=NewName;
}

function CambiarTextosHome()
{
    try
    {
        if (ImgArr.length==0) return false;
        PreloadImages();
        var p=ImgArr[CurrentImg].split(';');
        var imgL=document.getElementById('imgHomeLeft');
        var imgR=document.getElementById('imgHomeRight');
        if (p[2]=='L')
        {
            document.getElementById('tdLogo').style.textAlign='right';
            imgL.src=Img[CurrentImg].src;
            imgL.style.display='inline';
            imgR.style.display='none';
        }
        else
        {
            document.getElementById('tdLogo').style.textAlign='left';
            imgR.src=Img[CurrentImg].src;
            imgL.style.display='none';
            imgR.style.display='inline';
        }
        document.getElementById('textCentral').innerHTML=p[1];
        CurrentImg+=1;
        if (CurrentImg>=ImgArr.length) CurrentImg=0;
        setTimeout('CambiarTextosHome()', Interval);
    }
    catch(e)
    {
        //alert(e.toString());
    }
}

function PreloadImages()
{
    try
    {
        for(i=0;i<ImgArr.length;i++)
        {
            Img[i]=new Image();
            Img[i].src=ImgArr[i].split(';')[0];
        }
    }
    catch(e)
    {
        alert(e.description);
    }
}

function CheckAll(DataGridName,ControlName)
{
    var checkVal=event.srcElement.checked;
    var i=2;
    var k=true;
    while (k)
    {
	    try
	    {
		    i++;
		    document.getElementById(DataGridName + '__ctl' + i + '_' + ControlName).checked=checkVal;
	    }
	    catch (e)
	    {
		    k=false;
	    }
    }
}

function AddLink()
{
    try
    {
	    var b='';
	    b=rtbDetalle_x5.document.selection.createRange();
	    if (b.text=='') b=rtbDetalle1_x5.document.selection.createRange();
	    if (b.text=='') b=rtbDetalle2_x5.document.selection.createRange();
	    if (b.text=='') b=rtbResumen_x5.document.selection.createRange();
	    if (b.text=='') return 1;
	    txt=b.text;
	    t=b.htmlText;
	    t=t.replace(/&amp;/gi,"_");
	    t=t.replace(/#/gi,"/");
	    document.getElementById("txt1").value=t;
	    var sFeatures;
	    sFeatures = "dialogHeight:200px;dialogWidth:750px;help:no;scroll:no;status:no;resizable:1";
	    var sNewLink;
	    sNewLink = window.showModalDialog('createLinks.aspx', self, sFeatures);
		
		    if (sNewLink != "" && sNewLink!=undefined)
		    {
			    oSelection = b;
			    sNewLink = sNewLink + oSelection.text + "</a>";
			    sNewLink = sNewLink.replace(" </a>", "</a> ");
			    oSelection.pasteHTML(sNewLink);
		    }
    }
    catch (e)
    {
        //NOP
    }
}

function SubmitForm()
{
    var sLink;
    sLink = "";
    if (document.getElementById("txtUrl").value != "")
    {
    var objchk=document.getElementById('chk1');
    if (objchk.checked == true) sLink = '<a id="an1" target=pages href="' + document.getElementById("txtUrl").value + '"';
    else sLink = '<a id="an1" target=blank href="' + document.getElementById("txtUrl").value + '"';
    sLink = sLink + '>';
    }
    window.returnValue = sLink;
    window.close();
	
}

function SelectType (iOption)
{
    window.returnValue = "";
    document.getElementById("lstType").selectedIndex = iOption;
    document.getElementById("txtUrl").value = document.getElementById("lstType").value;
    document.getElementById("txtUrl").focus();
}

function selMenu()
{
    document.getElementById("CmbMenu").selectedIndex=document.getElementById("CmbMenu").selectedIndex;
    document.getElementById("txtUrl").value=document.getElementById("CmbMenu").value;
    var a=document.getElementById("CmbMenu").value;
    var b=a.split("/");
    document.getElementById("txtUrl").value='page_redirect.aspx?IdSection=' + b[0] + '&IdGroup=' + b[1] + '&IdDetail=' + b[2];
}

function GetAnchor()
{
	if (window.dialogArguments) window.opener = window.dialogArguments;
	txtlinku.innerHTML='<b>Texto:</b> ' + opener.document.Form1.txt1.value;
	var c=txtlinku.innerHTML;
	var t=c.replace(/_/gi,'&');
	t=t.replace(/page&redirect/gi,'page_redirect');
	txtlinku.innerHTML=t;
}

function ConfigPG()
{
	try
	{
		var x=document.getElementById("CmbMenu");
		var k=0;
		var textu=new String(txtlinku.innerHTML);
		for (i=0;i<x.length;i++)
		{
			var n=x.options[i].value.split("/");
			var t='page_redirect.aspx?IdSection=' + n[0]+ '&amp;IdGroup=' + n[1] + '&amp;IdDetail=' + n[2];
			if (textu.indexOf(t)>0) k=i;
		}
		
		if (k>0)
			{
				x.selectedIndex=k;
				document.getElementById('CmbMenu').style.display='inline';
				document.getElementById('tbLink').style.visibility='hidden';
				document.getElementById('chk1').checked=true;
			}
		else
			{
			document.getElementById('txtUrl').value=document.getElementById('an1').href;
			document.getElementById('tbLink').style.visibility='visible';
			document.getElementById('CmbMenu').style.display='none';
			}
	}   
	catch (e)
	{
	    //NOP
	}
}

function Enlarge()
{
	var strSrc = event.srcElement.src;
	var img=new Image();
	img.src=strSrc;
	var w = img.width + 8;
	var h = img.height + 47;
	window.showModelessDialog(strSrc,'','dialogHeight:' + h + 'px;dialogWidth:' + w + 'px;resizable:1;');
}

function ContenidoHeightSet()
{
	try
	{
		if (parent.frames('frameContenido').location.href!='')
		{
			var old=parent.parent.document.frames('pages').document.body.scrollHeight;
			var h=parent.document.frames('frameContenido').document.body.scrollHeight
			var l=parent.parent.document.frames('left').document.body.scrollHeight;
			parent.document.getElementById('frameContenido').height = h;
			if (l>=h + old + 20) parent.parent.document.getElementById('pages').height=l;
			else parent.parent.document.getElementById('pages').height = h + old + 20;
		}
	}
	catch(e)
	{
		//NOP
	}
}


CurrentPos = 0;

function TextFinder(theSearch)
{
try
	{
	if (theSearch == "")
		{
		return false;
		}

	var theSearchL = theSearch.toLowerCase();
	var theText = document.body.innerHTML;
	var theTextL = theText.toLowerCase();
	var theArray = theTextL.split(theSearchL);
	var theNewText = "";

	for (var i = 0; i < theArray.length; i++)
		{
		var tempStr = new String('');
		
		for (var j = 0; j <= i; j++) 
			{
			tempStr += theArray[j];
			}
		
		var posLT = tempStr.lastIndexOf('<');
		var posGT = tempStr.lastIndexOf('>');
		var posAmp = tempStr.lastIndexOf('&');
		var posComa = tempStr.lastIndexOf(';');
		
		if ((posGT < posLT) || (posComa < posAmp))
			{
			theNewText += theText.substr(CurrentPos, theArray[i].length) + theText.substr(CurrentPos + theArray[i].length, theSearch.length);
			}
		else
			{
			theNewText += theText.substr(CurrentPos, theArray[i].length) + "<span style='background-color: red; color: white;'>" + theText.substr(CurrentPos + theArray[i].length, theSearch.length) + "</span>";
			}
		
		CurrentPos += theArray[i].length + theSearch.length;
		}

		document.body.innerHTML = theNewText;
	}
catch (ex)
	{
	//do something;
	}
}


function ImageView(Seccion, Idioma, Grupo, Apartado, Img, Width, Height)
{
try
	{
	var rnd = Math.floor(Math.random() * 201)
	window.showModelessDialog('image_view.aspx?Seccion='+ Seccion +'&Idioma=' + Idioma + '&Grupo=' + Grupo + '&Apartado=' + Apartado + '&img=' + Img + '&large=1&rnd=' + rnd,'','dialogHeight:' + Height + 'px;dialogWidth:' + Width + 'px;resizable:1;status:0;');
	}
catch (ex)
	{
	alert('Error view image');
	}
}

function MostrarDetallesInmueble(CodigoProducto)
{
    try
    {
        try
        {
            document.getElementById('DivBuscador').className='DivMinimized';
        }
        catch (ex1)
        {
            //
        }
        try 
        {
            document.getElementById('DivSloganOfertas').className='DivMinimized';
        } 
        catch (ex2)
        {
            //
        }
        try
        {
            document.getElementById('DivDetalles').className='DivMaximized';
        }
        catch (ex3)
        {
            //
        }
        try
        {
            document.getElementById('frmDetalles').src='DetallesInmueble.aspx?c=' + CodigoProducto;
        }
        catch (ex4)
        {
            //
        }
    }
    catch(ex)
    {
        //NOP;
    }
}

function MostrarBuscador()
{
    try
    {
        try
        {
            parent.document.getElementById('DivBuscador').className='DivMaximized';
        }
        catch (ex1)
        {
            //
        }
        try
        {
            parent.document.getElementById('DivSloganOfertas').className='DivMaximized';
        }
        catch (ex2)
        {
            //
        }
        try
        {
            parent.document.getElementById('DivDetalles').className='DivMinimized';
        }
        catch (ex3)
        {
            //
        }
        return false;
    }
    catch(ex)
    {
        alert(ex.description);
    }
}
-->