﻿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 2010
     isHoliday = isHoliday ||
    ((dtNow.getFullYear() == 2010)&& (dtNow.getMonth() == 10) && (dtNow.getDate() == 25));
    
//  july 4 - Independence Day
         isHoliday = isHoliday ||
     ((dtNow.getMonth() == 06) && (dtNow.getDate() == 4));
     
// september 6 2010 - labour day
         isHoliday = isHoliday ||
     ((dtNow.getMonth() == 08) && (dtNow.getDate() == 6));

// February 15 2010 - President's day
         isHoliday = isHoliday ||
     ((dtNow.getMonth() == 01) && (dtNow.getDate() == 15));

// May 30 2011 - Memorial day
         isHoliday = isHoliday ||
     ((dtNow.getMonth() == 04) && (dtNow.getDate() == 30));

     
// 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"; }
// easter
		if ((dtNow.getMonth() == 3) && (dtNow.getDate() == 22)) { closingTime = " 7: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() >= 21)))

//    || ((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 - <b>3:00 pm</b> (closing early)";
       }
       
/*        if ((dtNow.getDate() <= 25)) {
           msg += crlf + "December 25: <b>Closed for Sunday</b> ";
       }
      if ((dtNow.getDate() <= 26)) {
           msg += crlf + "December 26: Closed for holiday";
       }
*/      /* if ((dtNow.getDate() < 27)) {
           msg += crlf + "December 27: 8:30am - 9:00pm (Normal business hours)";
       }
       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 27-30: 8:30am - 9:00pm (Normal business hours)";
       }
              
       if ((dtNow.getDate() <= 31)) {
           msg += crlf + "December 31: 8:30 am - <b>5:00 pm</b> (closing early)";
       }
       msg += crlf + "January &nbsp;1 &nbsp;&nbsp;&nbsp;&nbsp;: <b>Closed for holiday</b> ";
*/
}

// 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";
// msg += crlf + "<b>Note: L1 Support will be closed on <a href='http://en.wikipedia.org/wiki/Memorial_Day' title='Memorial Day' >Memorial Day</a></b><br /> - Monday May 31<sup>st</sup>, 2010";

//msg += crlf + "<b>Monday Service Interruption Monday June 7, 2010:<br />This site will be unavailable for up to four hours, sometime between 2 PM and midnight Pacific Time on June 7th</b>. This a scheduled maintenance event and this as close as we can get to predicting when it will happen. Thank you for your understanding.";

if ( (dtNow.getFullYear() == 2011) && ((dtNow.getMonth() == 10) && (dtNow.getDate() <= 25) && (dtNow.getHours() <=24))){
 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' >Thursday November 24th, "+dtNow.getFullYear()+"<br/>Thanksgiving Day</a></b>";
//msg += crlf + "<b>Scheduled Service Interruption Tuesday August 31, 2010 System improvements between 1 AM August 31th and 3AM September 1st </b>: <br />This site will be unavailable for up to 30 minutes<br />Sorry for the inconvenience.";
}


if ( (dtNow.getFullYear() == 2011) &&   ((dtNow.getMonth() == 3) && (dtNow.getDate() <= 22) && (dtNow.getHours() <=24))){
 msg += crlf + "<b>Note: L1 Support will be open 9:00 AM to 7:00 PM Friday April 22, 2011<br/>Easter Good Friday</b>";
}

if ( (dtNow.getFullYear() == 2011) &&  ((dtNow.getMonth() == 3) && (dtNow.getDate() <= 22) && (dtNow.getHours() <=24))){
 msg += crlf + "<b>Note: L1 Support will be open 9:00 AM to 7:00 PM Friday April 22, 2011<br/>Easter Good Friday</b>";
}

if ( (dtNow.getFullYear() == 2011) &&  ((dtNow.getMonth() == 4) && (dtNow.getDate() <= 30) && (dtNow.getHours() <=24))){
 msg += crlf + "<b>Note: L1 Support will be closed on Monday May 30, 2011<br/>Memorial Day</b>";
}

if ( (dtNow.getFullYear() == 2011) &&  ((dtNow.getMonth() == 6) && (dtNow.getDate() <= 4) && (dtNow.getHours() <=24))){
 msg += crlf + "<b>Note: L1 Support will be closed on Monday July 4th, 2011<br/><a href=\"http://en.wikipedia.org/wiki/Independence_Day_%28United_States%29\">Independence Day</a></b>";
}

if ( (dtNow.getFullYear() == 2011) &&  ((dtNow.getMonth() == 11) && (dtNow.getDate() <= 15) && (dtNow.getHours() <=23))){

msg+= crlf +  "We have a scheduled maintenance event coming up on Thursday night and will be offline for up to four hours between Thursday December 15th 11:00 pm (Eastern Time) and 7:00 am the following morning. Sorry for the inconvenience."
}

    return msg;	
}

//document.write(supportAvailable(true));

	
	
