function $(id) { return document.getElementById(id); }
var LH = { lineHeight  : 20,
           backColor   : "LemonChiffon"
		 };
		 
var CS = {
  normalBkColor    : 1,
  normalColor      : 2,
  activeBkColor    : 3,
  activeColor      : 4,
  selectedBkColor  : 5,
  selectedColor    : 6,
  arrowFontRules   : "font:16px arial; width:25px; margin-left:4px; display:inline-block; float:left;",
  textFontRules    : "font:12px verdana;width:200px;line-height:"+LH.lineHeight+"px;height:20px;display:inline-block; float:left;",
  colorScheme      : [LH.lineHeight+"px",LH.backColor, "dimgray", LH.backColor,"orangered", LH.backColor, "orange"],
  dummy : 0};  

 
function ob (items,                 // array of names
             idPrefix,              // id prefix
			 className,             // classname for each item
			 clrs,                  // colour scheme
			 divId                  // switch div id prefix
){

   this.divsPresent =  divId? true : false;;
   this.dispId = divId? divId : "";
   this.dispId = divId;
   this.x=idPrefix;
   this.y=className;
   this.nArrow = clrs.arrowFontRules+" background-color:"+clrs.colorScheme[1]+";color:"+clrs.colorScheme[1]+";"
   this.nText = clrs.textFontRules+" background-color:"+clrs.colorScheme[1]+";color:"+clrs.colorScheme[2]+";"
   this.aArrow = clrs.arrowFontRules+" background-color:"+clrs.colorScheme[3]+";color:"+clrs.colorScheme[3]+";"
   this.aText = clrs.textFontRules+" background-color:"+clrs.colorScheme[3]+";color:"+clrs.colorScheme[4]+";"
   this.sArrow = clrs.arrowFontRules+" background-color:"+clrs.colorScheme[5]+";color:"+clrs.colorScheme[6]+";"
   this.sText = clrs.textFontRules+" background-color:"+clrs.colorScheme[5]+";color:"+clrs.colorScheme[6]+";"
   this.strH = "";
   var i,k,strItem, elem;
   var m = items.length-1;
   var me = this;
   this.selected=0;
   
   k=0;
   for (i=1; i<=m; i++) {
   	  strItem = items[i];
	  if (strItem.substr(0,1) === "?") {
	     this.strH += "<p class='subH'>"+strItem.substr(1)+"</p>";
	  } else {
         ++k;
         this.strH += "<a id='__m"+k+"' class='item'>";
	     this.strH += "<q id='_q"+k+"' >&#9658;</q>";
	     this.strH += "<s id='_s"+k+"' >"+strItem+"</s>";
	     this.strH += "</a>";
	  }
   } 
   this.n=k;

 // methods:
 
   this.getIdNo = function(idx) {
      var reg = new RegExp(/(_s)(\d+)/);
	  if (reg.test(idx)) { return RegExp.$2; } else { return 0; }
  }
 
   this.highlight=function() {
	   var i=me.getIdNo (this.id) ;
	   if (i==me.selected) return;
	   $("_q"+i).style.cssText = me.aArrow;
	   $("_s"+i).style.cssText = me.aText;
   }
   
   this.choose=function(i) {
       if (i!==1) { i=me.getIdNo(this.id);  }
	   if (me.selected==i) { return; }
	   $("_q"+i).style.cssText = me.sArrow;
	   $("_s"+i).style.cssText = me.sText;
       if (me.divsPresent) { $(me.dispId+i).style.display ="block"; }
	   var j=me.selected;
	   if (j!==0) {
	     $("_q"+j).style.cssText = me.nArrow;
	     $("_s"+j).style.cssText = me.nText;
  	     if (me.divsPresent) { $(me.dispId+j).style.display ="none"; }
	   } 
	   me.selected = i;
   }
   
   this.unHighlight = function () {
	   var i=me.getIdNo (this.id) ;
	   if (i==me.selected) return;
	   $("_q"+i).style.cssText = me.nArrow;
	   $("_s"+i).style.cssText = me.nText;
   }

}

ob.prototype.doHTML = function(id) {
    var i,elem;
    $(id).innerHTML = this.strH;  
    for (i=1; i<=this.n; i++) {
       $("_q"+i).style.cssText = this.nArrow;
	   elem = $("_s"+i);
       elem.style.cssText = this.nText;
	   elem.onmouseover = this.highlight;
	   elem.onmouseout = this.unHighlight;
	   elem.onclick = this.choose;
	}   
}

ob.prototype.showHTML = function() {
   alert (this.strH);
}

function showBar(i) { 
     var elem = $("inDiv");
         elem.style.display="block";
         elem.innerHTML = "<span id='ss'>"+headsUp[i]+"</span>";
}

function hideBar() { $("inDiv").style.display="none";  }
function holdon () { PMC.vanB = false; } 
function vroom()   { 
       document.van.src = 'patMcrImages/van_ani.gif';
}

// ------------------------------------------------------------------------------------------------------------

