﻿var sBasePath = '/';
var sActiveNav = '';
var sScriptOnload = '';
var sScriptUnload = '';
var activeImage = 1;
var fadeLoop = 1;
var fadeActive = 1;
      
var sCiphClean = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-.\'@0123456789';
var sCiphCrypt = 'fghijklmnopqrstuvwxyz-.\'@0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcde';

/* Elimintate Frame Nesting */
if(top.frames.length!=0){self.location.href = 'http://www.realmpro.com/fwd/';};

/* Elimintate Cache View */
if (location.href.indexOf("q=cache") != -1){window.location.href="http://www.realmpro.com";} 

function pageLoad()
{    
    if(sScriptOnload != '')
    {
        setTimeout(sScriptOnload,0);
    }    
}
function pageUnload()
{
    if(sScriptUnload != '')
    {
        setTimeout(sScriptUnload,0);
    }    
}

function setNav(mNavName)
{
    sActiveNav = mNavName;
    mOff(mNavName);
}
function mOn(mNavName)
{
    if(sActiveNav == mNavName)
    {
        document.getElementById("Nav"+mNavName+"Img").setAttribute('src',sBasePath+'theme/images/nav_'+mNavName+'_active.gif');
    } else {
        document.getElementById("Nav"+mNavName+"Img").setAttribute('src',sBasePath+'theme/images/nav_'+mNavName+'_on.gif');
    }
    fadeActive = 0;
}
function mOff(mNavName)
{
    if(sActiveNav == mNavName)
    {
        document.getElementById("Nav"+mNavName+"Img").setAttribute('src',sBasePath+'theme/images/nav_'+mNavName+'_active.gif');
    } else {
        document.getElementById("Nav"+mNavName+"Img").setAttribute('src',sBasePath+'theme/images/nav_'+mNavName+'_off.gif');
    }
    fadeActive = 1;
}
function mAct(mNavName)
{
    if(sActiveNav != '')
    {
        document.getElementById("Nav"+sActiveNav+"Img").setAttribute('src',sBasePath+'theme/images/nav_'+sActiveNav+'_off.gif');
    }
    document.getElementById("Nav"+mNavName+"Img").setAttribute('src',sBasePath+'theme/images/nav_'+mNavName+'_active.gif');
}
function sendEmail(inAddr)
{
    var outAddr = '';
    for (i = 0; i <= inAddr.length - 1; i++)
    {
       outAddr = outAddr + sCiphClean.substring(sCiphCrypt.indexOf(inAddr.substring(i,i+1)),sCiphCrypt.indexOf(inAddr.substring(i,i+1))+1);
    }
    document.location.href = 'mailto:'+outAddr+'?subject=REALM Professionals Web Site Response';
}
function startCycle()
{
    setTimeout('cycleImages();',4000);
}
function stopCycle()
{
    fadeActive = 0;
    fadeLoop = 0;
}
function cycleImages()
{
    if(fadeActive == 1)
    {
        activeImage = activeImage + 1;
        crossfade(document.getElementById('FeatureImage'), '/Images/Home/Feature-'+activeImage+'.jpg', '1', '');
        if(activeImage == 3)
        {
            activeImage = 0;
        }
    }  
    if(fadeLoop == 1)
    {  
        if(document.getElementById('FeatureImage'))
        {
            setTimeout('cycleImages();',7000);
        }
    }
}




var hdnMyListings = 'ctl00_PageContentPanel_hdnMyListings';
function clearListings()
{
    var where_to= confirm("Do you wish to clear your MyREALM Listings?");

    if (where_to== true)
     {
        document.getElementById('ActiveListings').innerHTML = '';
        document.getElementById('MyREALMResponse').src = '/MyREALM/Active/update-listings.aspx?';
        document.location.href = '/PropertySearch/Results/?';
     }
    else
     {
      return false;
      }   
}
function buildProp(sRef, sMLSTag, sImgLnk, sStreet, sBeds, sBath, sBathHalf, sPrice)
{
    var processAdd = 1;
    if(document.getElementById(hdnMyListings))
    {
        var oListings = document.getElementById(hdnMyListings);
        if(oListings.value.indexOf(sMLSTag) > -1)
        {
            processAdd = 0;
        }                
        if(processAdd == 1)
        {
            if(document.getElementById('NoListingsMsg'))
            {
                document.getElementById('NoListingsMsg').className = 'PanelHide';
            }
            var newProp = '';
            newProp = newProp + '<div class="PropertyPanel" id="QuickPanel' + sMLSTag + '">';
            newProp = newProp + '    <div class="ImagePanel"><img src="' + sImgLnk + '" width="60" height="45" alt=""/></div>';
            newProp = newProp + '    <span class="PropertyTitle">' + sStreet + '</span><br />Newly Added Listing<br />List: $'+sPrice;
            newProp = newProp + '</div>';  
        
            document.getElementById('ActiveListings').innerHTML = document.getElementById('ActiveListings').innerHTML + newProp;
            
            if(oListings.value.length > 0)
            {
                oListings.value = oListings.value + '-';
            }
            oListings.value = oListings.value + sMLSTag;
            if(document.getElementById(sRef))
            {
                document.getElementById(sRef).className = 'ActiveListing';
            }
        } else {
        
            
            
            var aListings = oListings.value.split('-');
            var newListings = '';
            if(aListings.length > 0)
            {
                for (var x = 0; x < aListings.length; x++)
                {
                    if(aListings[x] != sMLSTag)
                    {
                        if(newListings.length > 0)
                        {
                            newListings = newListings + '-';
                        }
                        newListings = newListings + aListings[x];
                    }
                }  
                oListings.value = newListings;
            }
            
            if(document.getElementById('NoListingsMsg'))
            {
                if(oListings.value.length = 0)
                {
                    document.getElementById('NoListingsMsg').className = 'PanelShow';
                }
            }
            
            if(document.getElementById('QuickPanel'+sMLSTag))
            {
                document.getElementById('QuickPanel'+sMLSTag).className = 'PanelHide';
            }
            if(document.getElementById(sRef))
            {
                document.getElementById(sRef).className = 'NotListed';
            }
        }
        document.getElementById('MyREALMResponse').src = '/MyREALM/Active/update-listings.aspx?'+oListings.value;
    }
   
}