var _documentElement = null;

function body_Scroll() {
    if (_documentElement == null) {
        if (document.documentElement && !isNaN(document.documentElement.scrollTop)) {
            _documentElement = eval(document.documentElement);
        }
        else if (document.body && !isNaN(document.body.scrollTop)) {
            _documentElement = eval(document.body);
        }
    }

    if (_documentElement != null) {
        document.forms[0].__SCROLLLOC.value = _documentElement.scrollTop;
    }
}

function setScrollLocation(scrollValue) {
    if (_documentElement == null) {
        if (document.documentElement && !isNaN(document.documentElement.scrollTop)) {
            _documentElement = eval(document.documentElement);
        }
        else if (document.body && !isNaN(document.body.scrollTop)) {
            _documentElement = eval(document.body);
        }
    }

    if (_documentElement != null && !isNaN(scrollValue)) {
        _documentElement.scrollTop = scrollValue;
        document.forms[0].__SCROLLLOC.value = scrollValue;
    }
}

function putFlash(src, width, height, FlashVars) {
    var s = "<object classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" "
            + "codebase=\"http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0\" "
            + "width=\"" + width + "\" height=\"" + height + "\">"
                + "<param name=\"movie\" value=\"" + src + "\" />"
                + "<param name=\"quality\" value=\"high\" />";

    if (FlashVars && FlashVars != "") {
        s += "<param name=\"FlashVars\" value=\"" + FlashVars + "\" />";
    }

    s += "<embed src=\"" + src + "\" quality=\"high\" "
            + "pluginspage=\"http://www.macromedia.com/go/getflashplayer\" "
            + "type=\"application/x-shockwave-flash\" ";

    if (FlashVars && FlashVars != "") {
        s += "FlashVars=\"" + FlashVars + "\" ";
    }

    s += "width=\"" + width + "\" height=\"" + height + "\" /></object>";

    document.write(s);
}

function putFlashSsl(src, width, height, FlashVars) {
    var s = "<object classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" "
            + "codebase=\"https://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0\" "
            + "width=\"" + width + "\" height=\"" + height + "\">"
                + "<param name=\"movie\" value=\"" + src + "\" />"
                + "<param name=\"quality\" value=\"high\" />";

    if (FlashVars && FlashVars != "") {
        s += "<param name=\"FlashVars\" value=\"" + FlashVars + "\" />";
    }

    s += "<embed src=\"" + src + "\" quality=\"high\" "
            + "pluginspage=\"https://www.macromedia.com/go/getflashplayer\" "
            + "type=\"application/x-shockwave-flash\" ";

    if (FlashVars && FlashVars != "") {
        s += "FlashVars=\"" + FlashVars + "\" ";
    }

    s += "width=\"" + width + "\" height=\"" + height + "\" /></object>";

    document.write(s);
}

function putFlashTransparent(src, width, height, FlashVars) {
    var s = "<object classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" "
            + "codebase=\"http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0\" "
            + "width=\"" + width + "\" height=\"" + height + "\">"
                + "<param name=\"movie\" value=\"" + src + "\" />"
                + "<param name=\"wmode\" value=\"transparent\" />"
                + "<param name=\"quality\" value=\"high\" />";

    if (FlashVars && FlashVars != "") {
        s += "<param name=\"FlashVars\" value=\"" + FlashVars + "\" />";
    }

    s += "<embed src=\"" + src + "\" quality=\"high\" "
            + "pluginspage=\"http://www.macromedia.com/go/getflashplayer\" "
            + "type=\"application/x-shockwave-flash\" "
            + "wmode=\"transparent\" ";

    if (FlashVars && FlashVars != "") {
        s += "FlashVars=\"" + FlashVars + "\" ";
    }

    s += "width=\"" + width + "\" height=\"" + height + "\" /></object>";

    document.write(s);
}

function putFlashSslTransparent(src, width, height, FlashVars) {
    var s = "<object classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" "
            + "codebase=\"https://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0\" "
            + "width=\"" + width + "\" height=\"" + height + "\">"
                + "<param name=\"movie\" value=\"" + src + "\" />"
                + "<param name=\"wmode\" value=\"transparent\" />"
                + "<param name=\"quality\" value=\"high\" />";

    if (FlashVars && FlashVars != "") {
        s += "<param name=\"FlashVars\" value=\"" + FlashVars + "\" />";
    }

    s += "<embed src=\"" + src + "\" quality=\"high\" "
            + "pluginspage=\"https://www.macromedia.com/go/getflashplayer\" "
            + "type=\"application/x-shockwave-flash\" "
            + "wmode=\"transparent\" ";

    if (FlashVars && FlashVars != "") {
        s += "FlashVars=\"" + FlashVars + "\" ";
    }

    s += "width=\"" + width + "\" height=\"" + height + "\" /></object>";

    document.write(s);
}

function putHeader(FlashVars) {
    putFlashTransparent("/flash/header.swf", 766, 305, FlashVars);
}

function putHeaderSsl(FlashVars) {
    putFlashSslTransparent("/flash/header.swf", 766, 305, FlashVars);
}

function formatCurrency(num) {
    num = num.toString().replace(/\$|\,/g,'');
    if (isNaN(num)) {
        num = "0";
    }

    sign = (num == (num = Math.abs(num)));
    num = Math.floor(num*100+0.50000000001);
    cents = num%100;
    num = Math.floor(num/100).toString();

    if (cents < 10) {
        cents = "0" + cents;
    }

    for (var i = 0; i < Math.floor((num.length-(1+i))/3); i++) {
        num = num.substring(0,num.length-(4*i+3))+','+
                num.substring(num.length-(4*i+3));
    }

    return (((sign) ? '' : '-') + '$' + num + '.' + cents);
}
