/*
 *  Global Javascript
 */

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// global variables
// --------------------
/* google globals */
var gcal_base_href     = 'http://www.google.com/calendar/feeds/';
var gcal_tail_href     = '/public/basic';
var gcal_print_href    = 'http://www.google.com/calendar/print_preview?hl=en&ctz=America%2FNew_York&pgsz=letter&wkst=1&src=';
var gcal_event_uid     = 'j8cs0u26s813r0qh1ur90aslr0%40group.calendar.google.com';  // feed id for the events calendar feed
// build the google calendar urls
var gcal_events_url    = gcal_base_href  + gcal_event_uid   + gcal_tail_href;
var gcal_events_print  = gcal_print_href + gcal_event_uid;

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// time/date
// --------------------
var dayarray   = new Array("Sun","Mon","Tue","Wed","Thu","Fri","Sat");
var montharray = new Array("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec");

function pad_zero(n) {
  return (n < 10 ? '0' : '') + n;
}

function num_postfix(n) {
  // add the appropriate ending to the day
  var mn = "th";
  if (n == 1) { mn = "st"; }
    else if (n == 2)  { mn = "nd"; }
    else if (n == 3)  { mn = "rd"; }
    else if (n == 21) { mn = "st"; }
    else if (n == 22) { mn = "nd"; }
    else if (n == 23) { mn = "rd"; }
    else if (n == 31) { mn = "st"; }
  return n+mn;
}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// window open scripts
// --------------------
var win = null;

// Advanced window open - caller(in code, not user) has full control of the window
// NewWindow(url/page,title,width,height,allow-scrollbars(yes/no),resizable(yes/no),
//           toolbar(yes/no),locationbar(yes/no),directories(yes/no),
//           statusbar(yes/no),menubar(yes/no),copyhistory(yes/no));
//   ex. <a href="URL" onclick="NewWindow(this.href,'Logon','400','400','yes','yes','yes','yes','yes','yes','yes','yes');return false">Logon</a
function NewWindow(mypage,myname,wdt,hgt,scroll,resize,tool,loc,dir,stat,menub,hist){
  LeftPosition = (screen.width) ? (screen.width-wdt)/2 : 0;
  TopPosition = (screen.height) ? (screen.height-hgt)/2 : 0;
  settings = 'height='+hgt+',width='+wdt+',top='+TopPosition+',left='+LeftPosition+',scrollbars='+scroll+',resizable='+resize+',toolbar='+tool+',location='+loc+',directories='+dir+',status='+stat+',menubar='+menub+',copyhistory='+hist
  win = window.open(mypage,myname,settings)
}

// Simple window open
function openWindow(myurl){
  win = window.open(myurl)
}


//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// jquery calls
// --------------------
/* live date/time */
$(document).ready(
  function (){
    $('#date_time').jclock({
      format: '%a, %b %d, %Y | %I:%M:%S %P'
    });
});

