function addEvent(obj, evType, fn) { 
  if (obj.addEventListener){ 
    obj.addEventListener(evType, fn, false); 
    return true; 
  }
  else if (obj.attachEvent){ 
    var r = obj.attachEvent("on"+evType, fn); 
    return r; 
  }
  else { 
    return false; 
  } 
}


var init_timer = function() {
	if(document.getElementById('current_time')) {
		window.setInterval('update_time()', 60*1000);
	}
}

var update_time = function() {
	if(!document.getElementById) return; 
	var a_p;
	
	// find the time, and stringify
	var the_date = new Date();
	var raw_hour = (the_date.getUTCHours() - 8);
	var the_hour = (raw_hour % 12) + 1;
	var the_mins = the_date.getUTCMinutes();
	if(raw_hour > 12 || raw_hour < 0) { a_p = 'PM'; }
	else { a_p = 'AM'; }
	var the_time_string = the_hour + ':';
	if(the_mins < 10) { the_time_string = the_time_string + '0'; }
	the_time_string = the_time_string + the_mins + ' ' + a_p + ' PST';
	
	// insert
	var the_destination = document.getElementById('current_time');
	the_destination.firstChild.data = the_time_string;	
	
}


var NewWindow = {
  init: function(att,val) {
    if (!document.getElementById || !document.createElement || !document.appendChild) { return; }
    var strAtt   = ((typeof att == 'undefined') || (att == null)) ? 'class' : att;
    var strVal   = ((typeof val == 'undefined') || (val == null)) ? 'non-html' : val;
    var arrLinks = document.getElementsByTagName('a');
    var oRegExp  = new RegExp("(^|\\s)" + strVal + "(\\s|$)");
    var oLink;
    for (var i = 0; i < arrLinks.length; i++) {
      oLink = arrLinks[i];
      if ((strAtt == 'class') && (oRegExp.test(oLink.className)) || (oRegExp.test(oLink.getAttribute(strAtt)))) {
        oLink.onclick = NewWindow.openWin;
      }
    }
    oWarning = null;
  },
  openWin: function(e) {
    var event = (!e) ? window.event : e;
    if (event.shiftKey || event.altKey || event.ctrlKey || event.metaKey)
	    return true;
    else {
      var oWin = window.open(this.getAttribute('href'), '_blank');
      if (oWin) {
        if (oWin.focus) { oWin.focus(); return false; }
      }
      oWin = null;
      return true;
    }
  }
};  // end NewWindow


addEvent(window, 'load', init_timer);
addEvent(window, 'load', function(){ NewWindow.init('rel', 'external'); });
