﻿function addOnLoadEvent(func) 
{
    var oldOnLoad = window.onload;

    if (typeof window.onload == 'function') 
    {
        window.onload = function() 
        {
            if (oldOnLoad) oldOnLoad();
            func();
        }
    }
    else 
    {
        window.onload = func;
    }
}

function replaceQuickSearchText(id, text) {

    var regions = document.getElementById("qs-regions");
    if (null != regions) {
        regions.firstChild.innerHTML = "Office";
    }

    var priceRange = document.getElementById("qs-pricerange");
    if (null != priceRange) {
        var labels = priceRange.getElementsByTagName("label");

        if (null != labels[0]) labels[0].innerHTML = "Price (Min)";
        if (null != labels[1]) labels[1].innerHTML = "Price (Max)";    
    }
}


function ieMenuHover(ulId, hoverClass) 
{
    navRoot = document.getElementById(ulId);
    if (null != navRoot) {
        for (i = 0; i < navRoot.childNodes.length; i++) {
            node = navRoot.childNodes[i];
            if (node.nodeName == "LI") {
                node.onmouseover = function() {
                    this.className += " over";
                }
                node.onmouseout = function() {
                    this.className = this.className.replace(" over", "");
                }
            }
        }
    }
}

function addIeHoverEvents()
{
    ieMenuHover("navMain", "over");
    ieMenuHover("offices", "over");
}


function cmsPopUp(editLink)
{
    if (! window.focus)return true;
    var href;
    if (typeof (editLink) == 'string')
        href = editLink;
    else
        href = editLink.href;
    window.open(href, 'cmsEdit', 'width=520,height=200,scrollbars=yes');
    return false;
}

addOnLoadEvent(replaceQuickSearchText);
addOnLoadEvent(addIeHoverEvents);

