var MSIEWidthObj;
var MSIEMinWidth;
var MSIEMaxWidth;
var MSIEAltWidth;

function MSIEWidth(id,maxwidth,minwidth,altwidth) {

    var agt=navigator.userAgent.toLowerCase();
    var is_major = parseInt(navigator.appVersion);
    var is_ie = ((agt.indexOf("msie") != -1) && (agt.indexOf("opera") == -1));
    var is_ie3 = (is_ie && (is_major < 4));
    var is_ie4 = (is_ie && (is_major == 4) && (agt.indexOf("msie 4")!=-1) );
    var is_ie5up  = (is_ie && !is_ie3 && !is_ie4);

    if (is_ie5up) {
        MSIEMaxWidth = maxwidth;
        MSIEMinWidth = minwidth;
        MSIEAltWidth = altwidth;
        MSIEWidthObj = document.getElementById(id);
        window.onbeforeprint=MSIESetPrintWidth;
        window.onafterprint=MSIESetNormalWidth;
        MSIESetNormalWidth();
    }

    return true;
}

function MSIESetNormalWidth() {
    MSIEWidthObj.style.width = (document.body.clientWidth>(MSIEMaxWidth+16) ? '990px' : (document.body.clientWidth>(MSIEMinWidth+16) ?  'auto' : MSIEMinWidth+'px' ));
    return true;
}

function MSIESetPrintWidth() {
    MSIEWidthObj.style.width = MSIEAltWidth;
    return true;
}
