﻿function autoFill(id, v) {
    $(id).css({ color: "#b2adad" }).attr({ value: v }).focus(function() {
        if ($(this).val() == v) {
            $(this).val("").css({ color: "#333" });
        }
    }).blur(function() {
        if ($(this).val() == "") {
            $(this).css({ color: "#b2adad" }).val(v);
        }
    });

}

function openLink(url, title, width, height) {
    window_width = (width == null || width == '') ? 700 : width;
    window_height = (height == null || height == '') ? 460 : height;
    if (title = null) { title = '_blank' }
    window.open(url, title, 'alwaysRaised=yes,width=' + window_width + ',height=' + window_height + ',location=no,menubar=yes,resizable=yes,titlebar=yes,toolbar=no,scrollbars=yes,left=20,top=20')
}

function MortgageCalc(mlsId, mlNum) { openLink('/calculators/mortgagecalculatorbasic.aspx?mls=' + mlsId + '&m=' + mlNum, 'MortgageCalc', 275, 350); }
function CMARequest(profileId) { openLink('/forms/default.aspx?F=10&PR=' + profileId, 'CMARequest', 530, 600); }
function AgentRequest() { openLink('/forms/default.aspx?F=4', 'AgentRequest', 530, 600); }
function FLAgentRequest() { openLink('/forms/default.aspx?F=38', 'AgentRequest', 530, 600); }
function ContactAgent(profileId, mlsid, mlnum) { openLink('/forms/default.aspx?F=1&PR=' + profileId + '&MLS=' + mlsid + '&M=' + mlnum, 'ContactAgent', 530, 600); }
function GetNHAgent() { openLink('/forms/default.aspx?F=6', 'FranchiseInfo', 530, 600) }
function ContactNHAgent(profileId, subid) { openLink('/forms/default.aspx?F=3&PR=' + profileId + '&S=' + subid, 'ContactAgent', 530, 600); }
function ScheduleAppt(profileId, mlsid, mlnum) { openLink('/forms/default.aspx?F=7&MLS=' + mlsid + '&M=' + mlnum + '&PR=' + profileId, 'ScheduleAppt', 530, 600); }
function ScheduleNHAppt(profileId, subid) { openLink('/forms/default.aspx?F=9&PR=' + profileId + '&S=' + subid, 'ScheduleAppt', 530, 600); }
function GetPropInfo(mlsid, mlnum) { openLink('/forms/default.aspx?F=13&MLS=' + mlsid + '&M=' + mlnum, 'GetPropInfo', 530, 600); }
function GetPreQual(profileId, estmortgage) { openLink('/forms/default.aspx?F=16&EM=' + estmortgage + '&PR=' + profileId, 'PreQual', 530, 600); }
function ContactHSC(hsc) { openLink('/forms/default.aspx?F=30&E=' + hsc, 'ContactHSC', 530, 600); }
function Email2AFriend(mlsid, mlnum) { openLink('/forms/default.aspx?F=28&MLS=' + mlsid + '&M=' + mlnum, 'EmailToAFriend', 530, 600); }
function SendTextMessage(profileId, mlsid, mlnum) { openLink('/forms/default.aspx?F=37&PR=' + profileId + '&MLS=' + mlsid + '&M=' + mlnum, 'SendTM', 530, 600); }
function ContactHUD() { openLink('/forms/default.aspx?F=29', 'ContactForm', 525, 450) }
function NationalReloForm(state) { openLink('/forms/default.aspx?F=26&ST=' + state, 'RELO', 525, 450) }
function ContactHS() { openLink('/forms/default.aspx?F=30', 'ContactUs', 530, 600) }
function HSReg() { openLink('/forms/default.aspx?F=34', 'HSReg', 530, 600) }
function HSVendorInq() { openLink('/forms/default.aspx?F=31', 'HSVendorInq', 530, 600) }
function ContactCorporate() { openLink('/forms/default.aspx?F=22', 'ContactUs', 530, 600) }
function ContactStaff(empID) { openLink('/forms/default.aspx?F=33&E=' + empID, 'ContactStaff', 530, 600) }
function ContactManager(empID) { openLink('/forms/default.aspx?F=39&E=' + empID, 'ContactManager', 530, 600) }
function GeneralInquiry() { openLink('/forms/default.aspx?F=14', 'GeneralInquiry', 530, 600) }
function CareerDayReg(sessionID) { openLink('/forms/default.aspx?F=15&SID=' + sessionID, 'CareerDayReg', 530, 600) }
function ContactCC() { openLink('/forms/default.aspx?F=23', 'ContactCC', 530, 600) }
function WebsiteFeedback() { openLink('/forms/default.aspx?F=41', 'WebsiteFeedback', 530, 600) }
function AssessmentCheck() { openLink('/forms/default.aspx?F=44', 'AssessmentCheck', 530, 600) }
function RentalInfo() { openLink('/forms/default.aspx?F=45', 'RentalInfo', 530, 600) }
function FranchiseInfo() { openLink('/forms/default.aspx?F=46', 'FranchiseInfo', 530, 600) }
//function PCCareerDayReg() { openLink('/forms/default.aspx?F=48&RegionID=2', 'CareerDayReg', 530, 600) }
//function PCContactCC() { openLink('/forms/default.aspx?F=49', 'ContactCC', 530, 600) }
function CorpPerkReg() { openLink('/forms/default.aspx?F=50', 'CorpPerkReg', 530, 600) }


function SetUniqueRadioButton(groupName, current) {
    re = new RegExp(groupName);
    for (i = 0; i < document.forms[0].elements.length; i++) {
        elm = document.forms[0].elements[i]
        if (elm.type == 'radio') {
            if (re.test(elm.name)) {
                elm.checked = false;
            }
        }
    }
    current.checked = true;
}

// BEGIN IE 5.5 & 6 MENU FIX
var hiding = false;
var cNav = '';
uHover = function() {
    if (navigator.userAgent.indexOf('MSIE') >= 0 && parseFloat(navigator.userAgent.substring(navigator.userAgent.indexOf('MSIE') + 5)) < 7) {
        if (!document.getElementsByTagName) return false;
        var uEls = $get("navNoth").getElementsByTagName("li");
        for (var i = 0; i < uEls.length; i++) {
            if (uEls[i].id != '') {
                uEls[i].onmouseover = function() {
                    $get('shim').style.display = 'none';
                    hiding = false;
                    cNav = this.id;
                    var menus = $get("navNoth").getElementsByTagName("li");
                    for (var i = 0; i < menus.length; i++) {
                        if (menus[i].className.indexOf('uhover') >= 0)
                            menus[i].className = menus[i].className.replace(new RegExp(" uhover\\b"), "");
                    }
                    if (this.id != "" && $get('shim').style.display != 'block') {
                        this.className += " uhover";
                        var iframe = $get('shim');
                        iframe.style.display = 'block';
                        iframe.style.width = '142px';
                        iframe.style.top = '100px';
                        if (this.offsetParent)
                            iframe.style.left = findLeft(this);
                        var subs = this.getElementsByTagName("li");
                        iframe.style.height = parseInt((subs.length * 24) + 2) + 'px';
                    }
                }
                uEls[i].onmouseout = function() {
                    cNav = '';
                    if ($get('shim').style.display != 'none') {
                        hiding = true;
                        setTimeout("hideShim('" + this.id + "')", 50);
                    }
                }
            }
        }
        setTimeout('cleanup()', 500);
    }
}
function cleanup() {
    var menus = $get("navNoth").getElementsByTagName("li");
    for (var i = 0; i < menus.length; i++) {
        if (menus[i].className.indexOf('uhover') >= 0 && menus[i].id != cNav)
            menus[i].className = menus[i].className.replace(new RegExp(" uhover\\b"), "");
    }
    setTimeout('cleanup()', 500);
}
function hideShim(obj) {
    if (hiding) {
        $get(obj).className = $get(obj).className.replace(new RegExp(" uhover\\b"), "");
        $get('shim').style.display = 'none';
    }
}
function findLeft(obj) {
    var curleft = 0;
    if (obj.offsetParent) {
        curleft = obj.offsetLeft;
        while (obj = obj.offsetParent) { curleft += obj.offsetLeft; }
    }
    return curleft + 15;
}
if (window.attachEvent) window.attachEvent("onload", uHover);
// END IE 5.5 & 6 MENU FIX

