﻿function toggleMenu(mode) {
    var menu = document.getElementById('subMenuCon');
    var btn = document.getElementById('tabRev');
    if (mode == true) {
        menu.style.display = 'block';
    } else {
        menu.style.display = 'none';
        var aPath = window.location.href.split('/');
        if(aPath[aPath.length -1] != 'reverse.html') btn.className = 'topTab';
    }
}

function setupCalc() {
    var calc = document.getElementById('divCalculator');
    var tableW = 880;
    var windowW;
    var marginW;

    

    if (document.all) { windowW = document.body.offsetWidth; } else { windowW = window.innerWidth; }
    marginW = ((windowW - tableW) /2);
    calc.style.left = (marginW + tableW - 310) + 'px';
}

function getTestimony() {
    var aTest = new Array;
    var divTest = document.getElementById('divTestimony');
    var random = new Number;
    aTest.push('We have done several mortgages/refinances through Destiny Mortgage and have never had a problem. The staff is very professional and make the process as painless as possible. We always recommend Destiny to our family and friends.<p align="right"><i>Chris and Debbie Schultz</i></p>');
    aTest.push('Individually and as a team, you guys are outstanding.  From first contact, this was an incredibly smooth transaction and we are thrilled with the result.  We can only hope to work with such a competent team when we buy our next home.<p align="right"><i>Chris & Jody Berinato</i></p>');
    aTest.push('When it comes to mortgages or refinancing our knowledge is limited to say the least.   We knew we needed to refinance but needed someone we could both trust.   We found that in Destiny Mortgage Group.   Their team did a fantastic job explaining our best options and making sure everything was done correctly. We had zero problems and it was a joy to work with the entire Destiny team.  We highly recommend them!<p align="right"><i>Art and Marci Johnson</i></p>');

    
    random = (Math.floor((Math.random() * aTest.length)));
    divTest.innerHTML = '<div class="verticalSpacer" style="height:4px"></div><span class="testTitle">Testimonials</span><p>' + aTest[random] + '</p>';
}

function maskTel(f){
    tel='(';
    var val =f.value.split('');
    if (val[0] != tel && f.value != '') {
        for (var i = 0; i < val.length; i++) {
            if (i == 2) { val[i] = val[i] + ')' }
            if (i == 5) { val[i] = val[i] + '-' }
            tel = tel + val[i]
        }
        f.value = tel;
    } 
}

function forceNumeric(event, obj) {
    var code = (event.which) ? event.which : event.keyCode;
    var character = String.fromCharCode(code);
    //alert('Code: ' + code + '\nChar: ' + character)
    if ((code >= 48 && code <= 57)) { // check digits
        return true;
    } else if (code >= 37 && code <= 40) { // Allow directional arrows
        return true;
    } else if (code == 8 || code == 116 || code == 9 || code == 46 || code == 255) { // Allow backspace, F5
        return true;
    } else if (catchTAB(event,obj) == true) {return true;} //allow tab
    
    return false;
}


function catchTAB(evt, elem) {
    var TAB = 9;
    obj = elem;
    var keyCode;
    
    if ("which" in evt) {
        keyCode = evt.which; // NN4 & FF &amp; Opera
    } else if ("keyCode" in evt) {
        keyCode = evt.keyCode; // Safari & IE4+
    } else if ("keyCode" in window.event) {
        keyCode = window.event.keyCode; // IE4+
    } else if ("which" in window.event) {keyCode = evt.which;}

    if (keyCode == TAB) return true;
    return false;
}
