// By using this JavaScript, you are acknowledging that the author,
// Stuart Price, can not be held responsible for any damage to hardware
// or software; spelling mistakes; tardiness; or waking your mother at
// 3:00 a.m. because the JavaScript said it was 3:00 p.m. in Denver.
//
//                                        http://www.4est.com/
// Script borrowed and the output made pretty by Ken Baldwin

// Is it currently DST?  This will not update automatically.  
// You'll have to change it twice a year.  Sorry.
var dst = 'yes' // change this to no when DST ends

// get the date and change it to GMT string
var date = new Date();
var timegmt = date.toGMTString();

// split the GMT string at spaces
time_string = timegmt.split(' ');

// assign variables
week = time_string[0];
day = time_string[1];
mon = time_string[2];
year = time_string[3];
hms = time_string[4];

// split the time part on colon
hms_string = hms.split(':');

// assign variables
var hour = hms_string[0] - 0;
var min = hms_string[1];

// convert day-of-week variables to numbers
if (week == 'Sun,') {
   week = 1
   }
if (week == 'Mon,') {
   week = 2
   }
if (week == 'Tue,') {
   week = 3
   }
if (week == 'Wed,') {
   week = 4
   }
if (week == 'Thu,') {
   week = 5
   }
if (week == 'Fri,') {
   week = 6
   }
if (week == 'Sat,') {
   week = 7
   }

// fix mac version communicator bug
function checkOS() {
          if (navigator.appVersion.indexOf("Mac") > 0) return "Macintosh";
          else return "other";
}
var check = checkOS();
    if (check == "Macintosh") {
    week -= 1
   }

// make array for days of week
weekly = new Array("Saturday", "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday");

// assign +- hour for San Francisco
var sf_hour = hour - 8;
if (dst == 'yes') {
 sf_hour = hour - 7;
}
var sf_week = week;
var sf_ampm = " a.m.";
if (sf_hour < 0) {
   sf_hour += 24
   sf_week -= 1
   }
if (sf_hour > 11) {
    sf_ampm = " p.m."
    }
if (sf_hour > 12) {
   sf_hour -= 12
   }
if (sf_hour == 0) {
   sf_hour = 12
   }

// assign +- hour for Denver
var den_hour = hour - 7;
if (dst == 'yes') {
 den_hour = hour - 6;
}
var den_week = week;
var den_ampm = " a.m.";
if (den_hour < 0) {
   den_hour += 24
   den_week -= 1
   }
if (den_hour > 11) {
    den_ampm = " p.m."
    }
if (den_hour > 12) {
   den_hour -= 12
   }
if (den_hour == 0) {
   den_hour = 12
   }      

// assign +- hour for Memphis
var mem_hour = hour - 6;
if (dst == 'yes') {
 mem_hour = hour - 5;
}
var mem_week = week;
var mem_ampm = " a.m.";
if (mem_hour < 0) {
   mem_hour += 24
   mem_week -= 1
   }
if (mem_hour > 11) {
    mem_ampm = " p.m."
    }
if (mem_hour > 12) {
   mem_hour -= 12
   }
if (mem_hour == 0) {
   mem_hour = 12
   }

// assign +- hour for New York
var ny_hour = hour - 5;
if (dst == 'yes') {
 ny_hour = hour - 4;
}
var ny_week = week;
var ny_ampm = " a.m.";
if (ny_hour < 0) {
   ny_hour += 24
   ny_week -= 1
   }
if (ny_hour > 11) {
    ny_ampm = " p.m."
    }
if (ny_hour > 12) {
   ny_hour -= 12
   }
if (ny_hour == 0) {
   ny_hour = 12
   }

// assign +- hours for London
var lon_hour = hour + 0;
if (dst == 'yes') {
 lon_hour = hour + 1;
 }
var lon_week = week;
var lon_ampm = " a.m.";
if (lon_hour > 24) {
   lon_hour -= 24
   lon_week += 1
   }
if (lon_hour > 11) {
    lon_ampm = " p.m."
    }
if (lon_hour > 12) {
   lon_hour -= 12
   }
if (lon_hour == 0) {
   lon_hour = 12
   }

// assign +- hours for Paris
var par_hour = hour + 1;
if (dst == 'yes') {
 par_hour = hour + 2;
 }
var par_week = week;
var par_ampm = " a.m.";
if (par_hour > 24) {
   par_hour -= 24
   par_week += 1
   }
if (par_hour > 11) {
    par_ampm = " p.m."
    }
if (par_hour > 12) {
   par_hour -= 12
   }
if (par_hour == 0) {
   par_hour = 12
   }

// assign +- hours for Moscow
var mos_hour = hour + 3;
if (dst == 'yes') {
 mos_hour = hour + 4;
 }
var mos_week = week;
var mos_ampm = " a.m.";
if (mos_hour > 24) {
   mos_hour -= 24
   mos_week += 1
   }
if (mos_hour > 11) {
    mos_ampm = " p.m."
    }
if (mos_hour > 12) {
   mos_hour -= 12
   }
if (mos_hour == 0) {
   mos_hour = 12
   }

// assign +- hours & minutes for Delhi
var num_min = min - 0;
var del_hour = hour + 5;
var del_min = num_min + 30;
if (del_min > 60) {
    del_min -= 60
    del_hour += 1
    }
if (del_min < 10) {
   del_min = '0' + del_min
}
var del_week = week;
var del_ampm = " a.m.";
if (del_hour > 24) {
   del_hour -= 24
   del_week += 1
   }
if (del_hour > 11) {
    del_ampm = " p.m."
    }
if (del_hour > 12) {
   del_hour -= 12
   }
if (del_hour == 0) {
   del_hour = 12
   }
   
// assign +- hours for Bangkok
var ban_hour = hour + 7;
var ban_week = week;
var ban_ampm = " a.m.";
if (ban_hour > 24) {
   ban_hour -= 24
   ban_week += 1
   }
if (ban_hour > 11) {
    ban_ampm = " p.m."
    }
if (ban_hour > 12) {
   ban_hour -= 12
   }
if (ban_hour == 0) {
   ban_hour = 12
   }

   // assign +- hours for Tokyo
var tok_hour = hour + 9;
if (dst == 'yes') {
 tok_hour = hour + 9;
}
var tok_week = week;
var tok_ampm = " a.m.";
if (tok_hour > 24) {
   tok_hour -= 24
   tok_week += 1
   }
if (tok_hour > 11) {
    tok_ampm = " p.m."
    }
if (tok_hour > 12) {
   tok_hour -= 12
   }
if (tok_hour == 0) {
   tok_hour = 12
   }
      
// assign +- hours for Sydney
var syd_hour = hour + 11;
if (dst == 'yes') {
 syd_hour = hour + 10;
}
var syd_week = week;
var syd_ampm = " a.m.";
if (syd_hour > 24) {
   syd_hour -= 24
   syd_week += 1
   }
if (syd_hour > 11) {
    syd_ampm = " p.m."
    }
if (syd_hour > 12) {
   syd_hour -= 12
   }
if (syd_hour == 0) {
   syd_hour = 12
   }
