function wrap (text, color) {
    return '<span style="color: ' + color + ';">' + text + '</span>';
}

function openNewWindow(url) {
    window.open(url,"",'screenX="1", screenY="1", top="0", left="0", width=800, height=600, scrollbars=yes, resizable=yes');
}

function showresults(resulttype,foldername) {
    resultaddress = "framedresults.htm?pagewanted=" + resulttype + "&folderwanted=" + foldername;
    openNewWindow(resultaddress);
}

function showresults_nohead(resulttype,foldername) {
    resultaddress = "framedresults_nohead.htm?pagewanted=" + resulttype + "&folderwanted=" + foldername;
    openNewWindow(resultaddress);
}

function setdate() {
    ms_since_010170 = arguments[2];
    days_since_010170 = Math.floor((ms_since_010170 + 1000*60*60*6) / (1000*60*60*24));
    days_since_010104 = days_since_010170 - (34*365 + 7);
    four_years = 365*4 + 1;
    y4 = Math.floor((days_since_010104 - 1) / four_years);
    if ((days_since_010104 - y4*four_years) > 366) {
        leap = 0;
        y = Math.floor((days_since_010104 - y4*four_years - 367) / 365) + 1;
        }
    else {
        leap = 1;
        y = 0;
        }
    resultyear = 2004 + y4*4 + y;
    day_of_year = days_since_010104 - y4*four_years - y*365 - (1-leap);
    if (day_of_year <= 31) {
        resultmonth = "01";
        day_of_month = day_of_year;
        }
    else if (day_of_year <= (59+leap)) {
        resultmonth = "02";
        day_of_month = day_of_year-31;
        }
    else if (day_of_year <= (90+leap)) {
        resultmonth = "03";
        day_of_month = day_of_year-(59+leap);
        }
    else if (day_of_year <= (120+leap)) {
        resultmonth = "04";
        day_of_month = day_of_year-(90+leap);
        }
    else if (day_of_year <= (151+leap)) {
        resultmonth = "05";
        day_of_month = day_of_year-(120+leap);
        }
    else if (day_of_year <= (181+leap)) {
        resultmonth = "06";
        day_of_month = day_of_year-(151+leap);
        }
    else if (day_of_year <= (212+leap)) {
        resultmonth = "07";
        day_of_month = day_of_year-(181+leap);
        }
    else if (day_of_year <= (243+leap)) {
        resultmonth = "08";
        day_of_month = day_of_year-(212+leap);
        }
    else if (day_of_year <= (273+leap)) {
        resultmonth = "09";
        day_of_month = day_of_year-(243+leap);
        }
    else if (day_of_year <= (304+leap)) {
        resultmonth = "10";
        day_of_month = day_of_year-(273+leap);
        }
    else if (day_of_year <= (334+leap)) {
        resultmonth = "11";
        day_of_month = day_of_year-(304+leap);
        }
    else {
        resultmonth = "12";
        day_of_month = day_of_year-(334+leap);
        }
    resultday = day_of_month.toString();
    if (resultday.length < 2) {
        resultday = "0" + resultday;
        }

    foldername = resultyear + "-" + resultmonth + "-" + resultday;
    location.replace('pastresults.php?folderwanted=' + foldername + '&sectionwanted=none');
}

