<!-- *************************************** get actual browser height ********************************************* -->
function getHeight(){
  function iecompattest(){
    return (document.compatMode && document.compatMode!="BackCompat" && !window.opera)? document.documentElement : document.body;
  }
  if(iecompattest().clientHeight)
    return iecompattest().clientHeight;
  else  
    return null;
}
<!-- *************************************** get browser size ********************************************* -->
function get_browser_size(){
  // obtain the browser size in $_SESSION['browser_width'] and $_SESSION['browser_height'];
  var w = window.innerWidth || document.body.clientWidth;
  var h = getHeight();
  var o = (document.all ? document.all['size'] : document.getElementById('size'));
  o.src = "size.php?width="+w+"&height="+h;
 
}
<!-- *************************************** popup dialog ********************************************* -->
function show_popup(url) {
  // popup a window to show the given url
  var w = window.innerWidth || document.body.clientWidth;
  var h = getHeight();
  bw = document.body.offsetWidth;
  bh = document.body.offsetHeight;
  if (bh<h)
    bh=h;
  if (bh==0)
    bh=h;
  var o = (document.all ? document.all['popup'] : document.getElementById('popup'));
  o.style.width = "100%";
  o.style.height = bh +100+"px";
  o.style.position = "absolute";
  o.style.left = "0px";
  o.style.top = "0px";
  o.style.backgroundColor = "#808080";
  o.style.opacity = .8;
  o.style.filter = "alpha(opacity=80)";
  var o = (document.all ? document.all['ipopup'] : document.getElementById('ipopup'));
  o.style.width = "350px";
  o.style.height ="350px";
  o.style.position = "absolute";
  o.style.left = (w-350)/2+"px";
  if ((h-350)/2 >0)
    o.style.top = (h-350)/2+"px";
  else
    o.style.top = "0px";
  o.src = url;
 
  document.body.style.overflow = "hidden"; 
}
function hide_popup() {
  // hide the popup
  var o = (document.all ? document.all['popup'] : document.getElementById('popup'));
  o.style.width = "0px";
  o.style.height ="0px";
  o.style.position = "absolute";
  o.style.left = "-100px";
  o.style.top = "-100px";
  var o = (document.all ? document.all['ipopup'] : document.getElementById('ipopup'));
  o.style.width = "0px";
  o.style.height ="0px";
  o.style.position = "absolute";
  o.style.left = "-100px";
  o.style.top = "-100px";
  o.src = "";

  document.body.style.overflow = "auto"; 
}
function keyfilter(e){ 
  // disable key when popup
  var o = (document.all ? document.all['popup'] : document.getElementById('popup'));
  if (o.style.left == "0px")
    return false;
  return true;
}
<!-- *************************************** numeric input ********************************************* -->
function Numeric(e) { 

  var undefine;
  if (e.which == undefine){
    // ie
    k = e.keyCode;
  }
  else {
    // firefox netscape
    k = e.which;
  }
  if (k != 0){
    if ((k >= 48 && k <= 57) || (k == 8)){
    }
    else 
      e.preventDefault? e.preventDefault() : e.returnValue = false;       
  }

  disable_report();

} 
<!-- *************************************** no special char and enter input ********************************************* -->
function NoSpecialCharAndEnter(e) { 

  var undefine;
  if (e.which == undefine){
    // ie
    k = e.keyCode;
  }
  else {
    // firefox netscape
    k = e.which;
  }
  if (k != 0){
    if (k == 13)
      e.preventDefault? e.preventDefault() : e.returnValue = false; 
      
    if (k == 39 || k == 34 || k == 92 || k == 60 || k == 62 || k == 38){
      alert("Special character (' \" \\ < > &) not allowed");
      e.preventDefault? e.preventDefault() : e.returnValue = false; 
    }  
  }
  
  disable_report();
} 
<!-- *************************************** no special char input ********************************************* -->
function NoSpecialChar(e) { 

  var undefine;
  if (e.which == undefine){
    // ie
    k = e.keyCode;
  }
  else {
    // firefox netscape
    k = e.which;
  }
  if (k != 0){
    if (k == 39 || k == 34 || k == 92 || k == 60 || k == 62 || k == 38){
      alert("Special character (' \" \\ < > &) not allowed");
      e.preventDefault? e.preventDefault() : e.returnValue = false; 
    }  
  }
} 
<!-- *************************************** table row highlight effect ********************************************* -->
function trigger_init (id) {
 var undefined;

 var obj_table = (document.all ? document.all[id] : document.getElementById(id));
 if (obj_table != undefined) {
   for (var i = 2; i < obj_table.rows.length ; i++) {
    obj_table.rows[i].onmouseover = trigger_over;
    obj_table.rows[i].onmouseout = trigger_out;
    obj_table.rows[i].onfocus = trigger_over;
    obj_table.rows[i].onblur = trigger_out;
   }
 }

}
function trigger_over () {
    this.style.backgroundColor='#80ffff';
}
function trigger_out () {
    this.style.backgroundColor='transparent';
}
<!-- *************************************** cell highlight effect ********************************************* -->
function highlight (o) {
  o.style.backgroundColor='#80ffff';
}
function lowlight (o) {
  if (o.attributes['current']){
    if (o.attributes['current'].nodeValue == "selected")
      o.style.backgroundColor="LawnGreen";
    else
      o.style.backgroundColor="white";
  }
  else
    o.style.backgroundColor="white";
}
<!-- *************************************** resize iframe to body size ********************************************* -->
function resizeframe(id){
  var o = (parent.document.all ? parent.document.all[id] : parent.document.getElementById(id));
  var h = document.body.scrollHeight;
  o.style.height=h+"px";
}
<!-- *************************************** show message in iframe control message box ********************************************* -->
function msgbox(msg){
  var o = parent.document.getElementById('control');
  if ( o.contentDocument ) {
      var oo = o.contentDocument.getElementById('message');
  } else if ( o.contentWindow ) { 
      var oo = o.contentWindow.document.getElementById('message');
  }
  oo.innerHTML=msg;
}
<!-- *************************************** clear loading message ********************************************* -->
function message(msg){
  var o = (document.all ? document.all['loading'] : document.getElementById('loading'));
  o.innerHTML = msg;
}
<!-- *************************************** tooltips ********************************************* -->
var ole_showtip;
function showtip(o){
  var undefine;
  var tipobj=document.all? document.all["tip"] : document.getElementById? document.getElementById("tip") : ""
  tipobj.style.visibility="visible"
  if (o.innerHTML == "&nbsp;"){
    if (o.attributes['location'].nodeValue != 'NA')
      tipobj.innerHTML="Click/Highlight to book:<br>"+o.attributes['location'].nodeValue+"<br>"+o.attributes['periodname'].nodeValue;
    else
      tipobj.innerHTML="Click/Highlight to book:<br>"+o.attributes['periodname'].nodeValue;
    tipobj.style.backgroundColor='lightyellow';
  }
  else{
    if (o.attributes['location'] != undefine && o.attributes['location'].nodeValue != 'Outside School'){
      tipobj.innerHTML="Click to detail:<br>"+o.attributes['detail'].nodeValue;
      tipobj.style.backgroundColor='lightblue';
    }
    else{
      if (ole_showtip == 1){
        tipobj.innerHTML="Click to book:<br>OLE activity outside school";
        tipobj.style.backgroundColor='lightyellow';
      }
      else
        hidetip();
    }
  }
}

function positiontip(e){

  var tipobj=document.all? document.all["tip"] : document.getElementById? document.getElementById("tip") : ""
  if (tipobj.style.visibility == "visible") {

    var ie=document.all
    var ns6=document.getElementById && !document.all
    var offsetxpoint=5 
    var offsetypoint=15 

    ietruebody = (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
    var curX=(ns6)?e.pageX : event.clientX+ietruebody.scrollLeft;
    var curY=(ns6)?e.pageY : event.clientY+ietruebody.scrollTop;
    var rightedge=ie&&!window.opera? ietruebody.clientWidth-event.clientX-offsetxpoint : window.innerWidth-e.clientX-offsetxpoint-20
    var bottomedge=ie&&!window.opera? ietruebody.clientHeight-event.clientY-offsetypoint : window.innerHeight-e.clientY-offsetypoint-20

    var leftedge=(offsetxpoint<0)? offsetxpoint*(-1) : -1000

    if (rightedge<tipobj.offsetWidth)
      tipobj.style.left=ie? ietruebody.scrollLeft+event.clientX-tipobj.offsetWidth+"px" : window.pageXOffset+e.clientX-tipobj.offsetWidth+"px"
    else if (curX<leftedge)
      tipobj.style.left="5px"
    else
      tipobj.style.left=curX+offsetxpoint+"px"

    if (bottomedge<tipobj.offsetHeight)
      tipobj.style.top=ie? ietruebody.scrollTop+event.clientY-tipobj.offsetHeight-offsetypoint+"px" : window.pageYOffset+e.clientY-tipobj.offsetHeight-offsetypoint+"px"
    else
      tipobj.style.top=curY+offsetypoint+"px"
  }
}

function hidetip(){

  var tipobj=document.all? document.all["tip"] : document.getElementById? document.getElementById("tip") : ""
  tipobj.style.visibility="hidden"
  tipobj.style.left="-1000px"
  tipobj.style.top="-1000px"
  tipobj.innerHTML=""
  
}

<!-- *************************************** highlight ********************************************* -->
function hstart(o){
  var g=document.all? document.all["g1"] : document.getElementById? document.getElementById("g1") : ""
  if (g.attributes['h'].nodeValue != 1) {
    g.attributes['h'].nodeValue = 1;
    g.attributes['s'].nodeValue = o.attributes['id'].nodeValue;
  }
}

function hend(o){
  var g=document.all? document.all["g1"] : document.getElementById? document.getElementById("g1") : ""
  if (g.attributes['h'].nodeValue == 1) {
    g.attributes['e'].nodeValue = o.attributes['id'].nodeValue;
    // highlight the range
    var h = g.attributes['h'].nodeValue;
    var s = g.attributes['s'].nodeValue;
    var e = g.attributes['e'].nodeValue;
    var maxe = g.attributes['maxe'].nodeValue;
    var sr = parseInt(s.substr(1,3))-100;
    var er = parseInt(e.substr(1,3))-100;
    var maxe = parseInt(maxe);
    if (sr>er){
      i=sr;sr=er;er=i;
    }
    var c = s.substr(4,4);
    //check booked within the range
    for (i=sr;i<=er;i++){
      iid = "r" + (100+i) + c;
      var io=document.all? document.all[iid] : document.getElementById? document.getElementById(iid) : ""
      if (io.innerHTML != "&nbsp;") {
        er = i-1;
      }
    }
    // highlight cells
    for (i=1;i<=sr-1;i++){
      iid = "r" + (100+i) + c;
      var io=document.all? document.all[iid] : document.getElementById? document.getElementById(iid) : ""
      parent.lowlight(io);
      io.parentNode.cells[1].style.backgroundColor='white';
    }
    for (i=sr;i<=er;i++){
      iid = "r" + (100+i) + c;
      var io=document.all? document.all[iid] : document.getElementById? document.getElementById(iid) : ""
      parent.highlight(io);
      io.parentNode.cells[1].style.backgroundColor='#80ffff';
    }
    for (i=er+1;i<=maxe;i++){
      iid = "r" + (100+i) + c;
      var io=document.all? document.all[iid] : document.getElementById? document.getElementById(iid) : ""
      parent.lowlight(io);
      io.parentNode.cells[1].style.backgroundColor='white';
    }
  }
}

function hclick(o){
  var g=document.all? document.all["g1"] : document.getElementById? document.getElementById("g1") : ""
  if (g.attributes['h'].nodeValue == 1) {
    g.attributes['e'].nodeValue = o.attributes['id'].nodeValue;
    // highlight the range
    var h = g.attributes['h'].nodeValue;
    var s = g.attributes['s'].nodeValue;
    var e = g.attributes['e'].nodeValue;
    var sr = parseInt(s.substr(1,3))-100;
    var er = parseInt(e.substr(1,3))-100;
    if (sr>er){
      i=sr;sr=er;er=i;
    }
    var c = s.substr(4,4);
    //check booked within the range
    for (i=sr;i<=er;i++){
      iid = "r" + (100+i) + c;
      var io=document.all? document.all[iid] : document.getElementById? document.getElementById(iid) : ""
      if (io.innerHTML != "&nbsp;")
        er = i-1;
    }
    iid = "r" + (100+sr) + c;
    var io=document.all? document.all[iid] : document.getElementById? document.getElementById(iid) : ""
    book(sr,er,io.attributes['location'].nodeValue,io.attributes['wdate'].nodeValue);
  }
}

function ole_click(o){
  book(999,999,o.attributes['location'].nodeValue,o.attributes['wdate'].nodeValue);
}

var ole_current_date;
function ole_book(){
  book(999,999,'Outside School',ole_current_date);
}

function periodhighlight (o) {
  var g=document.all? document.all["g1"] : document.getElementById? document.getElementById("g1") : ""
  if (g.attributes['h'].nodeValue != 1) {
    highlight(o);
    o.parentNode.cells[1].style.backgroundColor='#80ffff';
  }
}
function periodlowlight (o) {
  var g=document.all? document.all["g1"] : document.getElementById? document.getElementById("g1") : ""
  if (g.attributes['h'].nodeValue != 1) {
    lowlight(o);
    o.parentNode.cells[1].style.backgroundColor='white';
  }
}
<!-- *************************************** book ********************************************* -->
function book(p1,p2,location,wdate){
  //show book screen
  parent.location.replace("index.php?action=book&param=p1="+p1+"?p2="+p2+"?location="+location+"?wdate="+wdate);
}
<!-- *************************************** disable text selection ********************************************* -->
function disableSelection(target){
  if (typeof target.onselectstart!="undefined") 
    target.onselectstart=function(){return false}
  else if (typeof target.style.MozUserSelect!="undefined") 
    target.style.MozUserSelect="none"
  else 
    target.onmousedown=function(){return false}
  target.style.cursor = "default"
}
<!-- *************************************** show url in the given iframe ********************************************* -->
function iframe_show(id,url){
  var o = (parent.document.all ? parent.document.all[id] : parent.document.getElementById(id));
//  o.src = url;
  if ( o.contentDocument ) {
      var oo = o.contentDocument;
  } else if ( o.contentWindow ) { 
      var oo = o.contentWindow.document;
  }
  oo.location.replace(url);
  
}
<!-- *************************************** select a date ********************************************* -->
function selectdate(tab,tag,val,psrc){

   var obj_table = (document.all ? document.all[tab] : document.getElementById(tab));
   for (var i = 0; i < obj_table.rows.length ; i++) {
      var obj_tr = obj_table.rows[i];
      for (var j = 0; j < obj_tr.cells.length ; j++) {
        if (obj_tr.cells[j].attributes[tag])
        if (obj_tr.cells[j].attributes[tag].nodeValue == val) {
          obj_tr.cells[j].attributes['current'].nodeValue = "selected";
          var y=obj_tr.cells[j].attributes['year'].nodeValue;
          var m=obj_tr.cells[j].attributes['month'].nodeValue;
          var d=obj_tr.cells[j].attributes['day'].nodeValue;
          parent.lowlight(obj_tr.cells[j]);
        }
      }
   }

   iframe_show('data',psrc+"?year="+y+"&month="+m+"&day="+d);
   parent.message("Loading...");

   ole_current_date1 = ((y * 100 + (m*1)) * 100 + (d*1)) + "tostring";
   ole_current_date = ole_current_date1.substring(0,4) + "-" + ole_current_date1.substring(4,6) + "-" + ole_current_date1.substring(6,8);
}
<!-- *************************************** unselect all cell ********************************************* -->
function unselectallcell(tab){
   var obj_table = (document.all ? document.all[tab] : document.getElementById(tab));
   for (var i = 0; i < obj_table.rows.length ; i++) {
      var obj_tr = obj_table.rows[i];
      for (var j = 0; j < obj_tr.cells.length ; j++) {
        if (obj_tr.cells[j].attributes['current'])
          obj_tr.cells[j].attributes['current'].nodeValue = "none";
        parent.lowlight(obj_tr.cells[j]);
      }
   }
}
<!-- *************************************** focus control ********************************************* -->
function gofocus(id){
  var o = (document.all ? document.all[id] : document.getElementById(id));
  o.focus();
}
<!-- *************************************** toggle the period input ********************************************* -->
function toggle(o){
  if (!readonly){
    inpid = o.attributes['inp'].nodeValue;
    var inpo = (document.all ? document.all[inpid] : document.getElementById(inpid));
    if (inpo.value == "Y"){
      inpo.value = "N";
      o.style.backgroundColor="white";
      o.attributes['current'].nodeValue = "none";
    }
    else {
      inpo.value = "Y";
      o.style.backgroundColor="LawnGreen";
      o.attributes['current'].nodeValue = "selected";
    }
  }
  disable_report();
}
<!-- *************************************** toggle all the day of the given weekday on the given month ********************************************* -->
function toggleweek(tid,col){
  var obj_table = (document.all ? document.all[tid] : document.getElementById(tid));
  if (col==0){ // toggle all the weekday, ie all days in that month
    toggleweek(tid,1);
    toggleweek(tid,2);
    toggleweek(tid,3);
    toggleweek(tid,4);
    toggleweek(tid,5);
    toggleweek(tid,6);
    toggleweek(tid,7);
  }
  else{ // toggle one weekday only
    for (var i = 2; i < obj_table.rows.length-1 ; i++) {
      o = obj_table.rows[i].cells[col];
      if (o.attributes['inp'])
        toggle(o);
    }
  }
}
<!-- *************************************** highlight all the day of the given weekday on the given month ********************************************* -->
function highlightweek(tid,col){
  var obj_table = (document.all ? document.all[tid] : document.getElementById(tid));
  if (col==0){ // toggle all the weekday, ie all days in that month
    highlightweek(tid,1);
    highlightweek(tid,2);
    highlightweek(tid,3);
    highlightweek(tid,4);
    highlightweek(tid,5);
    highlightweek(tid,6);
    highlightweek(tid,7);
  }
  else{ // toggle one weekday only
    for (var i = 2; i < obj_table.rows.length-1 ; i++) {
      o = obj_table.rows[i].cells[col];
      if (o.attributes['inp'])
        highlight(o);
    }
  }
}
<!-- *************************************** lowlight all the day of the given weekday on the given month ********************************************* -->
function lowlightweek(tid,col){
  var obj_table = (document.all ? document.all[tid] : document.getElementById(tid));
  if (col==0){ // toggle all the weekday, ie all days in that month
    lowlightweek(tid,1);
    lowlightweek(tid,2);
    lowlightweek(tid,3);
    lowlightweek(tid,4);
    lowlightweek(tid,5);
    lowlightweek(tid,6);
    lowlightweek(tid,7);
  }
  else{ // toggle one weekday only
    for (var i = 2; i < obj_table.rows.length-1 ; i++) {
      o = obj_table.rows[i].cells[col];
      if (o.attributes['inp'])
        lowlight(o);
    }
  }
}
<!-- *************************************** go to top ********************************************* -->
function scrolltotop(){
  parent.document.body.scrollTop=0;
}
<!-- *************************************** session timeout ********************************************* -->
function session_timeout(){
  alert('Session Timeout. Please try again');
  parent.location.replace('index.php');
}
<!-- *************************************** edit activity of the given id ********************************************* -->
function edit(o){
  var s_book_id=o.attributes['s_book_id'].nodeValue;
  parent.location.replace("index.php?action=edit&param="+s_book_id);
}
<!-- *************************************** no right to do ********************************************* -->
function no_right(){
  alert('Your role is not allowed to update booking');
  parent.location.replace('index.php');
}
<!-- *************************************** disable report button when changes not saved ********************************************* -->
function disable_report(){
  var undefined;
  var o = (document.all ? document.all['reportbbq'] : document.getElementById('reportbbq'));
  if (o != undefined){
    o.disabled = true;
  }
  var o = (document.all ? document.all['reportequip'] : document.getElementById('reportequip'));
  if (o != undefined){
    o.disabled = true;
  }
}

<!-- *************************************** show the div of given edit booking category ********************************************* -->
function editBooking(cat){
  var undefine;

  // refresh
  if (cat == 'summary'){
    refresh_summary();
    resizeframe('data');
  }
  
  // show it
  var o = (document.all ? document.all['activity'] : document.getElementById('activity'));
  o.style.position = "absolute";
  o.style.left = "-1000px";
  var o = (document.all ? document.all['period'] : document.getElementById('period'));
  o.style.position = "absolute";
  o.style.left = "-1000px";
  var o = (document.all ? document.all['location'] : document.getElementById('location'));
  o.style.position = "absolute";
  o.style.left = "-1000px";
  var o = (document.all ? document.all['equipment'] : document.getElementById('equipment'));
  o.style.position = "absolute";
  o.style.left = "-1000px";
  var o = (document.all ? document.all['date'] : document.getElementById('date'));
  if (o != undefine) {
    o.style.position = "absolute";
    o.style.left = "-1000px";
  }
  var o = (document.all ? document.all['summary'] : document.getElementById('summary'));
  o.style.position = "absolute";
  o.style.left = "-1000px";

  var o = (document.all ? document.all[cat] : document.getElementById(cat));
  o.style.position = "absolute";
  o.style.left = "174px";
  o.style.top = "28px";
  
  
  // color index
  var o = (document.all ? document.all['abookpage_activity'] : document.getElementById('abookpage_activity'));
  o.attributes['current'].nodeValue = ""
  o.style.backgroundColor='transparent';
  var o = (document.all ? document.all['abookpage_period'] : document.getElementById('abookpage_period'));
  o.attributes['current'].nodeValue = ""
  o.style.backgroundColor='transparent';
  var o = (document.all ? document.all['abookpage_location'] : document.getElementById('abookpage_location'));
  o.attributes['current'].nodeValue = ""
  o.style.backgroundColor='transparent';
  var o = (document.all ? document.all['abookpage_equipment'] : document.getElementById('abookpage_equipment'));
  o.attributes['current'].nodeValue = ""
  o.style.backgroundColor='transparent';
  var o = (document.all ? document.all['abookpage_date'] : document.getElementById('abookpage_date'));
  if (o != undefine) {
    o.attributes['current'].nodeValue = ""
    o.style.backgroundColor='transparent';
  }
  var o = (document.all ? document.all['abookpage_summary'] : document.getElementById('abookpage_summary'));
  o.attributes['current'].nodeValue = ""
  o.style.backgroundColor='transparent';

  var o = (document.all ? document.all['abookpage_'+cat] : document.getElementById('abookpage_'+cat));
  o.attributes['current'].nodeValue = "selected"
  o.style.backgroundColor="LawnGreen";
}

<!-- *************************************** toggle the given day on the given month ********************************************* -->
function selectday(tid,day){
  var obj_table = (document.all ? document.all[tid] : document.getElementById(tid));
  for (var i = 2 ; i < obj_table.rows.length-1 ; i++) {
    for (var col = 1 ; col <= 7 ;  col++) {
      o = obj_table.rows[i].cells[col];
      if (o.attributes['inp'])
        if (o.attributes['day'].nodeValue==day)
          toggle(o);
    }
  }
}

<!-- *************************************** highlight the given day on the given month ********************************************* -->
function highlightday(tid,day){
  var obj_table = (document.all ? document.all[tid] : document.getElementById(tid));
  for (var i = 2 ; i < obj_table.rows.length-1 ; i++) {
    for (var col = 1 ; col <= 7 ;  col++) {
      o = obj_table.rows[i].cells[col];
      if (o.attributes['inp'])
        if (o.attributes['day'].nodeValue==day)
          highlight(o);
    }
  }
}

<!-- *************************************** lowlight the given day on the given month ********************************************* -->
function lowlightday(tid,day){
  var obj_table = (document.all ? document.all[tid] : document.getElementById(tid));
  for (var i = 2 ; i < obj_table.rows.length-1 ; i++) {
    for (var col = 1 ; col <= 7 ;  col++) {
      o = obj_table.rows[i].cells[col];
      if (o.attributes['inp'])
        if (o.attributes['day'].nodeValue==day)
          lowlight(o);
    }
  }
}

<!-- *************************************** refresh summary content ********************************************* -->
function refresh_summary(){

  var o = (document.all ? document.all['summary_content'] : document.getElementById('summary_content'));
  content = "";
  var period_first = "<font color=black>";
  var loc_first = "<font color=black>";
  var equip_first = "<font color=black>";
  var date_first = "<font color=black>";
  var bookyear =0;
  var bookyear2 =0;
  var bookmonth =0;
  var bookmonth2 =0;
  var booknumday =0;
  var bookdate;
  var cat;

  function add_content(where,label){
    if (elem[i].name == where)
      content = content + "<strong>" + label + ":&nbsp;</strong>" + "<font color=blue>" + elem[i].value + "</font><br>";
  }

  function add_content_cat(where,label){
    if (elem[i].name == where){
      for (x=1;x<=combo_cat_total;x++){
        if (elem[i].value == combo_cat_id[x]){
          content = content + "<strong>" + label + ":&nbsp;</strong>" + "<font color=blue>" + combo_cat_descr[x] + "</font><br>";
          cat = combo_cat_descr[x];
        }
      }
    }
  }

  function add_content_type(where,label){
    if (elem[i].name == where){
      if (elem[i].value == "I")
        content = content + "<strong>" + label + ":&nbsp;</strong>" + "<font color=blue>" + "Internal" + "</font><br>";
      else
        content = content + "<strong>" + label + ":&nbsp;</strong>" + "<font color=blue>" + "External" + "</font><br>";
    }
  }

  function add_content_period(where,label){
    if (elem[i].name.substring(0,6) == where && elem[i].value == "Y"){
      id = elem[i].name.replace(where,"");
      if (cat == 'BBQ' || cat == 'BOARD'){
        if ((id*1) <= (booknumday*1)){
          bookdate = bookyear + "-" + bookmonth + "-" + id;
        }
        else {
          bookdate = bookyear2 + "-" + bookmonth2 + "-" + (id-booknumday);
        }
        content = content + "<strong>" + period_first + "Date" + ":</font>&nbsp;</strong>" + "<font color=blue>" + bookdate + "</font><br>";
        period_first = "<font color=white>";
      }
      else {
        for (x=1;x<=combo_period_total;x++){
          if (id == combo_period_id[x]){
            content = content + "<strong>" + period_first + label + ":</font>&nbsp;</strong>" + "<font color=blue>" + combo_period_descr[x] + "</font><br>";
            period_first = "<font color=white>";
          }
        }
      }
    }
  }

  function add_content_loc(where,label){
    if (elem[i].name.substring(0,3) == where && elem[i].value == "Y"){
      id = elem[i].name.replace(where,"");
      for (x=1;x<=combo_loc_total;x++){
        if (id == combo_loc_id[x]){
          content = content + "<strong>" + loc_first + label + ":</font>&nbsp;</strong>" + "<font color=blue>" + combo_loc_descr[x] + "</font><br>";
          loc_first = "<font color=white>";
        }
      }
    }
  }

  function add_content_equip(where,label){
    if (elem[i].name.substring(0,5) == where && elem[i].value != ""){
      id = elem[i].name.replace(where,"");
      for (x=1;x<=combo_equip_total;x++){
        if (id == combo_equip_id[x]){
          content = content + "<strong>" + equip_first + label + ":</font>&nbsp;</strong>" + "<font color=blue>" + combo_equip_descr[x] + " x " + elem[i].value + "</font><br>";
          equip_first = "<font color=white>";
        }
      }
    }
  }

  function add_content_net(where,label){
    if (elem[i].name == where){
      for (x=1;x<=combo_net_total;x++){
        if (elem[i].value == combo_net_id[x])
          content = content + "<strong>" + label + ":&nbsp;</strong>" + "<font color=blue>" + combo_net_descr[x] + "</font><br>";
      }
    }
  }

  function add_content_date(where,label){
    if (elem[i].name.substring(0,4) == where && elem[i].value == "Y"){
      content = content + "<strong>" + date_first + label + ":</font>&nbsp;</strong>" + "<font color=blue>" + elem[i].name.substring(4,8) + "-" + elem[i].name.substring(8,10) + "-" + elem[i].name.substring(10) + "</font><br>";
      date_first = "<font color=white>";
    }
  }

  var elem = document.getElementById('book').elements;
  for(var i = 0; i < elem.length; i++){

    if (elem[i].name == 'bookyear')
      bookyear = elem[i].value;
    if (elem[i].name == 'bookyear2')
      bookyear2 = elem[i].value;
    if (elem[i].name == 'bookmonth')
      bookmonth = elem[i].value;
    if (elem[i].name == 'bookmonth2')
      bookmonth2 = elem[i].value;
    if (elem[i].name == 'booknumday')
      booknumday = elem[i].value;

    add_content("eng_act_descr","English Title");
    add_content("chi_act_descr","Chinese Title");
    add_content_cat("l_act_id","Category");
    add_content('teacher_in_charge',"Teacher-in-charge");
    add_content('student_in_charge',"Student-in-charge");
    add_content('student_in_charge_class',"class");
    add_content('org',"Organization");
    add_content('remark',"Remarks");
    add_content_type("l_type","Type");
    add_content("l_ole","OLE");
    add_content_period("period","Period");
    add_content_loc("loc","Location");
    add_content_equip("equip","Equipment");
    add_content('other_equip',"Other Equipment");
    add_content_net('l_internet',"Internet");
    // debug only
    // content = content + elem[i].type + ":" + elem[i].name + "<br>" + "&nbsp;&nbsp;&nbsp;&nbsp;" + elem[i].value + "<br>";
  }

  var elem = document.getElementById('group_date_form').elements;
  for(var i = 0; i < elem.length; i++){
    add_content_date("date","Date");
  }
  
  o.innerHTML = content;
}

<!-- *************************************** group date variables into one ********************************************* -->
function group_date(){
  var elem = document.getElementById('group_date_form').elements;

  var v = "";
  for(var i = 0; i < elem.length; i++){
    if (elem[i].name.substring(0,4) == 'date' && elem[i].value == "Y"){
      if ( v == "")
        v = elem[i].name.replace('date',"");
      else
        v = v + "," + elem[i].name.replace('date',"");
    }
  }

  var o = (document.all ? document.all['group_date_value'] : document.getElementById('group_date_value'));
  o.value = v;
}


