﻿function supportAvailable(DST,isTest,isDJ) {
    // tell us that support is available when it's available or tell us when it will be if it's not
    if (DST) 
    var EasternTimeGMToffset = 5  // change to 5 when not Daylight savings, change to 4 for DST
if (DST) { EasternTimeGMToffset = 4; } else { EasternTimeGMToffset = 5; }
    var crlf = "<br \>" + "\n" // line break(html)  and new line (source)
    var msg = "";
    
    var dtNow = new Date;
    // 
    var dtUTC = Date.UTC(dtNow.getUTCFullYear(), dtNow.getUTCMonth(), dtNow.getUTCDate(), dtNow.getUTCHours(), dtNow.getUTCMinutes(), dtNow.getUTCSeconds(), dtNow.getUTCMilliseconds());
    // dtUTC is now in milliseconds but it is still in browser timezone    
    // Boston is UTC - 5 hours
    // set dtNow is UTC in milliseconds - 5 hours
   // document.write((dtNow.getTimezoneOffset()) + "<br />");
    dtNow.setTime(dtUTC + ((dtNow.getTimezoneOffset()) * 60 * 1000) - (EasternTimeGMToffset * 60 * 60 * 1000));
    // setup for test if support should be open
    var isMondayToFridayOpen = false;
    var isSaturdayOpen = false;
    //var isTest = true;
    var isHoliday = false;

    // is stat holiday jan=0
    // December 24 - early close
    // December 31 - early close
    // thanksgiving 2009
    // july 24
   
// New Years Day
    isHoliday =
     ((dtNow.getMonth() == 0) && (dtNow.getDate() == 1));
// December 24 Leaving Early  
     isHoliday = isHoliday ||
     ((dtNow.getMonth() == 11) && (dtNow.getDate() == 24))
       && (dtNow.getHours() >= 15); // 3:00 pm
// Christmas Day
     isHoliday = isHoliday ||
     ((dtNow.getMonth() == 11) && (dtNow.getDate() == 25));
// New Years Eve Leaving Early     
     isHoliday = isHoliday ||
     ((dtNow.getMonth() == 11) && (dtNow.getDate() == 31)
       && (dtNow.getHours() >= 17)); // 5:00 pm
// Thanksgiving 2009
     isHoliday = isHoliday ||
    ((dtNow.getFullYear() == 2009)&& (dtNow.getMonth() == 10) && (dtNow.getDate() == 26));
    
//  july 4 - Independence Day
         isHoliday = isHoliday ||
     ((dtNow.getMonth() == 06) && (dtNow.getDate() == 4));
     
// september 7 - labour day
         isHoliday = isHoliday ||
     ((dtNow.getMonth() == 08) && (dtNow.getDate() == 7));

     
// test
    //isHoliday = (dtNow.getMonth() == 11) && (dtNow.getDate() == 4);

    if (isTest) {
        document.write("isHoliday = " + isHoliday + " dtNow.getMonth() = " + dtNow.getMonth() + " dtNow.getDate()= " + dtNow.getDate() + " <br />");
        document.write("<br /> EasternTimeGMToffset = " + EasternTimeGMToffset + "<br />");
    } 
    // Monday to Friday 8:30 AM to 9:00 PM Eastern Standard Time
    if ((dtNow.getDay() >= 1) && (dtNow.getDay() <= 5)) {
     //   document.write(dtNow.getHours() + "<br />");
        if ((dtNow.getHours() == 8) && (dtNow.getMinutes() >= 30) 
        || (dtNow.getHours() >= 9) 
        && (dtNow.getHours() < 21)) {
       // if ((dtNow.getHours() >= 1) && (dtNow.getHours() <= 21)) {
            isMondayToFridayOpen = true;
        }
    }
    // Saturday 9:00 AM to 5:00 PM Eastern Standard Time
    if (dtNow.getDay() == 6) {
        if ((dtNow.getHours() >= 9) && (dtNow.getHours() < 17)) {
            isSaturdayOpen = true;
        }
    }

    if (isMondayToFridayOpen || isSaturdayOpen || isTest) {
        var closingTime;
        if (isMondayToFridayOpen) {
        closingTime= "9:00 PM";
        } else {
        closingTime = "5:00 PM";
        }

        /* holiday exceptions */
        if ((dtNow.getMonth() == 11) && (dtNow.getDate() == 24)) { closingTime = " 3:00 PM"; }
        if ((dtNow.getMonth() == 11) && (dtNow.getDate() == 31)) { closingTime = " 5:00 PM"; }

        msg += crlf + "<b>Bose L1 support is available today ";
        msg += " until " + closingTime + "&nbsp;ET</b>";
        msg += "&nbsp;in the US & Canada. ";
        if (isDJ==false){
    msg += crlf + "<div style=\"font-size:8pt;\">Staffed by Bose employee-musicians</div>"
    }
    msg += "  Call toll-free <b>1-877-335-2673</b>";
    // msg += "Phone support will be available today until
    // msg += "&nbsp;" + closingTime + "&nbsp;Eastern Time";
    } else {
    msg += "Call Bose L1 support at 1-877-335-2673 (U.S. and Canada only)"
        + crlf + "Monday-Friday: 8:30 AM - 9:00 PM ET"
        + crlf + "Saturday 9:00 AM - 5:00 PM ET" ;
//        + crlf + "Currently no support available on Sunday";
}
if (isHoliday) {
// nextBusinesDay
var daysA = new Array("Monday", "Tuesday", "Wednesday"
	     , "Thursday", "Friday", "Saturday", "Monday")
var nextBusinesDay=daysA[dtNow.getDay()]


    msg = "Bose<sup>®</sup> L1<sup>®</sup> Support "
        + " " + "is closed now for the holiday but will be open on " + nextBusinesDay ;
    msg += crlf + "&nbsp; in the US & Canada. Call <b>1-877-335-2673</b>";


    msg += crlf + "Monday-Friday: 8:30 AM - 9:00 PM ET"
        + crlf + "Saturday 9:00 AM - 5:00 PM ET";
        


    }

if     (((dtNow.getMonth() == 11) && (dtNow.getDate() >= 20)))
// || ((dtNow.getMonth() == 0) && (dtNow.getDate() < 1)))
{
       msg += crlf + "Except as noted below.";
       msg +=  "<br /><b>Special Holiday hours</b>: (all times Eastern) ";
       if ((dtNow.getDate() <= 24)) {
           msg += crlf + "December 24: 8:30 am - 3:00 pm (closing early)";
       }
       if ((dtNow.getDate() < 25)) {
           msg += crlf + "December 25: Closed for holiday";
       }
       if ((dtNow.getDate() < 26)) {
           msg += crlf + "December 26: 9:00am - 5:00pm (Normal Saturday hours)";
       }
       if ((dtNow.getDate() < 27)) {
           msg += crlf + "December 27: Closed for Sunday";
       }
       if ((dtNow.getDate() < 28)) {
           msg += crlf + "December 28: 8:30am - 9:00pm (Normal business hours)";
       }
       if ((dtNow.getDate() < 29)) {
           msg += crlf + "December 29: 8:30am - 9:00pm (Normal business hours)";
       }
       if ((dtNow.getDate() < 30)) {
           msg += crlf + "December 30: 8:30am - 9:00pm (Normal business hours)";
       }
              
       if ((dtNow.getDate() <= 31)) {
           msg += crlf + "December 31: 8:30 am - 5:00 pm (closing early)";
       }
       msg += crlf + "January &nbsp;1 &nbsp;&nbsp;&nbsp;&nbsp;: Closed for holiday";

}

// msg += crlf + "<b>Note: L1 Support will be closed on <a href='http://www.dol.gov/opa/aboutdol/laborday.htm' title='Labor Day Holiday in the US and Canada' >Labor Day - Monday September 7<sup>th</sup>, 2009</a></b>";

//msg += crlf + "<b>Note: L1 Support will be closed on <a href='http://en.wikipedia.org/wiki/Thanksgiving_%28United_States%29' title='Thanksgiving Day in the US' >Thanksgiving Day</a></b><br /> - Thursday November  26<sup>th</sup>, 2009";

    return msg;
	
	
}

//document.write(supportAvailable(true));

	
	