// Version ID: @(#) 401kComLib.js [@@/main/ff_phase_2/1]>

function getEvent(evt) {
    return (evt ? evt : window.event);
}

function getEventTarget(evt) {
    return (evt.target ? ((evt.target.nodeType == 3) ? evt.target.parentNode : evt.target) : evt.srcElement);
}

// var background = getElementStyle("total", "background", "background");
function getElementStyle(id, ieProp, w3cProp) {
    var style = null;
    var elem = document.getElementById(id);
    if (elem) {
        if (elem.currentStyle) {
            style = elem.currentStyle[ieProp];
        } else {
            var computedStyle = window.getComputedStyle(elem, "");
            style = computedStyle.getPropertyValue(w3cProp);
        }
    }
    return style;
}

function trueFn() {
    return true;
}

function falseFn() {
    return false;
}

function nullFn() {
    return null;
}

function isBlank(s) {
    return ((s.length == 0) || /^\s+$/.test(s));
}

function isPercent(s) {
    return ((s == "0") || (s == "100") || /^[1-9]\d?$/.test(s));
}

function setVisible(id, isVisible) {
    var elem = document.getElementById(id);
    if (typeof elem.origVisibility == "undefined") {
        elem.origVisibility = elem.style.visibility;
    }

    if (isVisible) {
        elem.style.visibility = elem.origVisibility;
    } else {
        elem.style.visibility = "hidden";
    }
}

function setDisplay(id, isDisplayed) {
    var elem = document.getElementById(id);
    if (typeof elem.origDisplay == "undefined") {
        elem.origDisplay = elem.style.display;
    }

    if (isDisplayed) {
        elem.style.display = elem.origDisplay;
    } else {
        elem.style.display = "none";
    }
}

function reloadNav() {
    if (top.frames["401k_emp_nav"]) {
        top.frames["401k_emp_nav"].location.reload();
    }
}

function reloadHeader() {
    if (top.frames["401k_emp_header"]) {
        top.frames["401k_emp_header"].location.reload()
    }
}

function force_openhelp(this_spot) {
    //
    // this is a custom sized window...
    //
    var help_window = window.open(this_spot,
                                  "help_window",
                                  "toolbar=no,resizable=yes,location=no,menubar=yes,scrollbars=yes,width=500,height=550");
    if (help_window != null) {
        help_window.focus()
    }
} 

function openWindow(url, thisTitle, args) {
    var w = window.open(url, thisTitle, ('"' + args + '"'));
    w.focus();
}

function printScreen() {
    window.print();
}

function goBack() {
    history.back()
}

function menuFocus() {
    window.top.opener.focus();
}

function resetAllInputs() {
    var elements = document.forms[0].elements;
    var numElements = elements.length;
    var elem = null;
    for (var i = 0; i < numElements; i++) {
        elem = elements[i];
        if (elem.type == "text") {
            elem.value = "";
        } else if (elem.type == "checkbox") {
            elem.checked = "";
        } else if (elem.type == "radio") {
              elem.checked = "";
        }
    }
    return false;
}      

function totalPCTs() {
    //Creates a running total for the percentages entered.
    var nTotalPercents = 0;
    var form = document.forms[0];
    var sPercent = "";

    for (var x = 0; x < form.newpctSize.value; x++)  {
        sPercent = form.elements["newpct[" + x + "]"].value;
        if ((sPercent != null) && (sPercent != "") && (!isNaN(parseInt(sPercent))) && (!hasDecimalPt(sPercent)))  {
            nTotalPercents += parseInt(sPercent);
        } else {
            nTotalPercents += 0;
        }
    }
    form.total.value = nTotalPercents;
}

function hasDecimalPt(thePercent) {
    var sPercent = new String(thePercent);

    for ( var i = 0; i < sPercent.length; i++ ) {
        if ( sPercent.charAt(i) == '.' )
            return true;
    }

    return false;
}


function retirementCalcHelpWindow(aBase,aItem) {  
    doOpenRemote(aBase + aItem,'help','580','640','scrollbars','form'); 
}


function doOpenRemote(aURL, newName, aHEIGHT, aWIDTH, aFeatures, orgName) { 
    if (aHEIGHT == "*"){ aHEIGHT = (screen.availHeight - 80) }; 
    if (aWIDTH == "*"){ aWIDTH = (screen.availWidth - 30) };
    var features = "toolbar=no,resizable=yes,location=no "; 
    var newFeatures = features + "height=" + aHEIGHT + ",innerHeight=" + aHEIGHT; 
    newFeatures += ",width=" + aWIDTH + ",innerWidth=" + aWIDTH; 
    if (window.screen){ var ah = (screen.availHeight - 30); 
    var aw = (screen.availWidth - 10); 
    var xc = (( aw - aWIDTH ) / 2); var yc = (( ah - aHEIGHT ) / 2); 
    newFeatures += ",left=" + xc + ",screenX=" + xc; 
    newFeatures += ",top=" + yc + ",screenY=" + yc; 
    newFeatures += "," + aFeatures }; 
    openWin(aURL, newName, newFeatures, orgName); 
} 


function openWin(newURL, newName, newFeatures, orgName) { 
    var help_window = window.open(newURL, newName, newFeatures); 
    if (help_window != null) 
    { 
        help_window.focus() 
    }   
} 

function openPrivacyPage() {
    var w = open("http://www.paychex.com/payroll/privacy.html",
                 "privacy",
                 "toolbar=no,resizable=yes,location=no,menubar=yes,scrollbars=yes,width=400,height=450,top=10,left=10");

    if (w != null) {
        w.top.focus();
    }

    return false;
}

function renderPrivacyLink(mode) {
    if (mode == 1) {
        document.write('<br><font size="-1"><a href="javascript:void(0)" onclick="return openPrivacyPage()">Privacy Statement</a></font>')
    } else if (mode == 2) {
        document.write('<font size="-1"><a href="javascript:void(0)" onclick="return openPrivacyPage()">Privacy Statement</a></font>')
    } else if (mode == 3) {
        document.write('<center><a href="javascript:void(0)" onclick="return openPrivacyPage()">Privacy Statement</a></center>')
    }
}

function viewFundSlick(fundSlickPdf) {
    var url = "http://" + window.location.host + "/fundslicks/" + fundSlickPdf;
    var fundSlick =
        window.open(url,
                    "fundslick",
                    "toolbar=0,location=0,directories=0,status=0,menubar=1,scrollbars,resizable=1,width=640,height=480");
}

function viewSdbaProvider(url) {
    var sdbaProvider =
        window.open(url,
                    "sdbaProvider",
                    "toolbar=0,location=0,directories=0,status=0,menubar=1,scrollbars,resizable=1,width=640,height=480");
}

function viewHelp(url) {
    var help =
        window.open(url,
                    "help",
                    "toolbar=0,location=0,directories=0,status=0,menubar=1,scrollbars,resizable=1,width=640,height=480");
}

function menuFocus() {
    top.opener.focus()
    return false
}

function contact_us(branch, client, usemail) {
    var info_tag = "BRANCH="+branch+"&CLIENT="+client+"&EMAIL="+usemail+"&CANCEL=close&PRODUCT=401&USE_800=401"
    var the_rfi = "/cgi-bin/menu/contact"
    the_rfi += "?" + escape(info_tag)
    force_contact_us(the_rfi)
}

function force_contact_us(this_spot) {
    contact_us_window = start_cons(this_spot, "con_window")
    contact_us_window.focus()
}

function start_cons(str, winname) {
    var the_window = null
    the_window = open(str, winname, "status=no,resizable=no,toolbar=no,location=no,menubar=no,scrollbars=yes,top=10,left=10,width=560,height=700")
    return the_window
}

function printScreen() {
    window.print()
}

function goBack() {
    history.back()
}

function gcConfirmation() {
    return window.confirm("Guided SavingsTM is a free service offered by GuidedChoiceTM that provides you with professional assistance to help you determine how much to save for retirement and where to invest your 401(k) contributions.  For a small fee, GuidedChoice can implement, manage, and periodically rebalance your account for you. Click OK to learn more about how GuidedSavings can help you achieve your retirement goals.");
}
