   window.defaultStatus = "Association of Professional Engineers And Geoscientists of Manitoba";
   window.onload = window.onresize = SetContentHeight;
   var APEGMOffset = 115;
   function SetContentHeight(){
      var content_div = document.getElementById('ContentArea');
      var screen_height;
   	if (self.innerHeight){ screen_height = self.innerHeight; }
      else if (document.documentElement && document.documentElement.clientHeight){
   	   APEGMOffset = 125; screen_height = document.documentElement.clientHeight;
      }
      else if (document.body){ screen_height = document.body.clientHeight; }
      else return;
      content_div.style.height = (screen_height - APEGMOffset) + "px";
      ScrollIfNeeded();
      buildsubmenus_horizontal();
   }
   function ScrollIfNeeded()
   {
      if( typeof( ScrollToID ) != "undefined" )  
      {
         ScrollTo(ScrollToID);
      }
      else if( location.hash )
      {
         ScrollTo(location.hash.substring(1));
      }
   }
   function ScrollTo( ObjID ) { ScrollToObj(document.getElementById(ObjID)); }
   function ScrollToObj( Obj )
   {
      if( Obj )
      {
         document.getElementById("ContentArea").scrollTop = getVerticalScrollPos( Obj );
      }
   }
   function getVerticalScrollPos(obj)
   {   var curtop = 0;
	   if (obj.offsetParent) {
		   curtop = obj.offsetTop;
		   while (obj = obj.offsetParent) {
			   curtop += obj.offsetTop;
		   }
	   }
	   return curtop - APEGMOffset;
   }
   function buildsubmenus_horizontal(){
      var ultags = document.getElementById("treemenu1").getElementsByTagName("ul");
      for (var t = 0; t < ultags.length; t++){
	      if (ultags[t].parentNode.parentNode.id == "treemenu1")
	      {  ultags[t].style.top = ultags[t].parentNode.offsetHeight+"px"; }
	      else
	      {  ultags[t].style.left = (ultags[t-1].getElementsByTagName("a")[0].offsetWidth)+"px"; }
         ultags[t].parentNode.onmouseover=function(){ this.getElementsByTagName("ul")[0].style.visibility="visible"; }
         ultags[t].parentNode.onmouseout=function(){ this.getElementsByTagName("ul")[0].style.visibility="hidden"; }
      }
   }
   function FormatDate(dateField)
   {
      var a_months = new Array('Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec');
      var a_days = new Array('Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday');
      var date_d = new Date(dateField.value);
      if( date_d.toDateString() != "Invalid Date" && date_d.toDateString() != "NaN")
      {
         dateField.value = a_months[date_d.getMonth()] + " " + date_d.getDate() + ", " + date_d.getFullYear();
         dateField.title = a_days[date_d.getDay()];   // gives 'day of week' in a tool tip
      }
      else
      {
         if( dateField.value.toLowerCase() == 'today' )
         {  var new_d = new Date();
            dateField.value = a_months[new_d.getMonth()] + " " + new_d.getDate() + ", " + new_d.getFullYear();
            dateField.title = a_days[new_d.getDay()];
         }
         else { dateField.value = ""; }
      }
   }
   function CheckLength(field, length)
   {
      var MaxLength = new Number(length);
      if( field.value.length > MaxLength )
      {
         field.value = field.value.substring(0, MaxLength);
         alert("Max: " + length + " characters");
      }
   }
   function FormatMoney(moneyField)
   {
      var Value_s = moneyField.value;
      var Number_s = "";
      var Char_n;
      var Int_n;
      for( i = 0; i < Value_s.length; i++ )
      {
         Char_n = Value_s.substr(i, 1);
         Int_n = parseInt(Char_n);
         if( !isNaN(Int_n) ) Number_s += Char_n;
      }
      var Num_val = Number_s; //Copy before destruction
      var formatted_s = "";
      while( Num_val.length > 3 )
      {
         formatted_s = Num_val.substr(Num_val.length - 3, 3) + formatted_s;
         formatted_s = "," + formatted_s;
         Num_val = Num_val.substr(0, Num_val.length - 3);
      }
      moneyField.value = "$" + Num_val + formatted_s;
   }
   function SetFirstInputFocus( Container )
   {
      var boxes = document.getElementById(Container).getElementsByTagName('input');
      if( boxes[0] != null ) boxes[0].focus();
   }
   function ToggleInput(LinkID, DivID)
   {
      if( document.getElementById(LinkID).style.display == 'none' )
      {
         document.getElementById(LinkID).style.display = '';
         document.getElementById(DivID).style.display = 'none';
      }
      else
      {
         document.getElementById(DivID).style.display = '';
         document.getElementById(LinkID).style.display = 'none';
         SetFirstInputFocus(DivID);
      }
   }