//********** declare variables **********//
var duty = new Array()        // declare and load array
	 duty[1]="Seneschal - Greetings, good gentles!  I am the spokesperson and legal representative for our shire for any legal issue that may arise.  I also act as 'officer in charge', coordinating all the other officers as necessary and soothing the troubled waters of conflicts.";
	 duty[2]="Reeve - I am Chancellor Of The Exchequer, and do with care keep good track of our shire's finances.  Nothing so base as a tax collector, but merely holder of the purse strings.";
	 duty[3]="Herald - Oyez! Oyez!  Good lords and ladies of the realm, I do hereby announce that I do gladly provide aide into the understanding of the gentle art of heraldry, and will use my knowledge to delve into the research of your persona's name and device (crest or shield).  I am also the voice of official announcements at events (forsooth, I am hard to miss).";
	 duty[4]="Minister of Arts and Sciences - I am the master of all the period arts and sciences practiced by the good people of our shire.  I do gladly share my hard-earned knowledge (or knowledge of the direction to look to further your own knowledge) of such crafts and skills as armor-making, woodworking, brewing and wine-making, cooking, bread making, clothing design and construction, weaving, embroidery, music, dancing, poetry, and a myriad of others.";
	 duty[5]="Marshal - I am the Master at Arms and well versed in the art of chivalric combat.  I do gladly train, and advise all the brave knights and fighters of our shire, endeavoring to ensure their safety and good fighting procedures.";
	 duty[6]="Sheriff - I do command the respect of all our good lords and ladies for I am the keeper of the peace, valiant in defense of the rules of good conduct among the gentle peoples of our shire.";
	 duty[7]="Minister Of Children - I do compassionately provide for the care and nurturing of our young future lords and ladies at shire meetings or events.  The young goslings under my wing find activities arranged for their amusement and enjoyment, whilst their parents are furthering their skills and knowledge, defending our realm, or otherwise mingling with other grown-up types.";
	 duty[8]="Chronicler - I do keep record of our good shire's activities and do skillfully compose and put forth for your learned selves our monthly newletter.";
	 duty[9]="Web Minister - I do valiantly battle with the mystic futuristic 'Page of the Web,' endeavoring to introduce the good gentles of our shire to newcomers, present our skills and knowledge to others, and keep record in this new and daring manner of the activities and events of our shire.";
	duty[10]="Archery Marshal - I am the master of archery, and do gladly share my knowledge of the worthy skill of combat archery and the gentle art of target shooting.  I will help advise our brave archers and aide in training, weapon maintenance and inspections, and the conduct of archery activities at events.";
	duty[11]="Chirurgeon - Look to me, brave gentles, should you find yourselves sore wounded.  I do with care provide first aid and take charge of any medical response should an injury occur at shire meetings, fighter practices, or events.";
	duty[12]="Chatelaine - To all you newcomers who do not yet understand our society nor yet speak the gentle tongue of our good lords and ladies, come to me.  I will help show you around, introduce you to the people in our shire, and give you some tips on fitting into our wonderful medieval world.";
	duty[13]="Historian - I do keep the ancient scrolls of our good shire in order, providing a record of past events, activities, glories, and honors that our gentle knights, craftsmen, artists, lords, and ladies once reveled in, for reference, for reminiscence, and for remembrance.";
	duty[14]="Persona Developer - I am well versed in knowledge of the middle ages' custom, dress, and manner.  I do gladly aid you in developing your own unique character, that you may plunge fully into our medieval world as you join us in our wondrous recreation of those bygone times.";
	duty[15]="Equestrian - Look unto me for all things relating to your gentle steeds.  I am master of equestrian combat, training, and events.";
	duty[16]="Minister of the Lists - What do I do again?";
var w_y, w_x, dutybox, boxheight, boxwidth;
var ishover=false;
var isloaded=false;

//********** Utility Functions **********//
function getwindowdims(){
   w_y=(NS4||NS6)? window.innerHeight : (IE5||IE4)? document.body.clientHeight : 0;
   w_x=(NS4||NS6)? window.innerWidth : (IE5||IE4)? document.body.clientWidth : 0;
}

function getboxwidth(){
   if(NS4)boxwidth=(dutybox.document.width)? dutybox.document.width : dutybox.clip.width;
   if(IE5||IE4)boxwidth=(dutybox.style.pixelWidth)? dutybox.style.pixelWidth : dutybox.offsetWidth;
   if(NS6)boxwidth=(dutybox.style.width)? parseInt(dutybox.style.width) : parseInt(dutybox.offsetWidth);
}

function getboxheight(){
   if(NS4)boxheight=(dutybox.document.height)? dutybox.document.height : dutybox.clip.height;
   if(IE4||IE5)boxheight=(dutybox.style.pixelHeight)? dutybox.style.pixelHeight : dutybox.offsetHeight;
   if(NS6)boxheight=parseInt(dutybox.offsetHeight);
}

function movebox(x,y){
   if(NS4)dutybox.moveTo(x,y);
   if(W3C||IE4){
      dutybox.style.left=x+'px';
      dutybox.style.top=y+'px';
   }
}

function getpagescrolly(){
   if(NS4||NS6)return window.pageYOffset;
   if(IE5||IE4)return document.body.scrollTop;
}

function getpagescrollx(){
   if(NS4||NS6)return window.pageXOffset;
   if(IE5||IE4)return document.body.scrollLeft;
}

function writeindiv(text){
   if(NS4){
      dutybox.document.open();
      dutybox.document.write(text);
      dutybox.document.close();
   }
   if(W3C||IE4)dutybox.innerHTML=text;
}

function moveobj(evt){
   if(isloaded && ishover){
      margin=(IE4||IE5)? 1 : 23;
      if(NS6)if(document.height+27-window.innerHeight<0)margin=15;
      if(NS4)if(document.height-window.innerHeight<0)margin=10;
      if(NS4){
         mx=evt.pageX
         my=evt.pageY
      }
      else if (NS6){
         mx=evt.clientX
         my=evt.clientY
      }
      else if (IE5){
         mx=event.clientX
         my=event.clientY
      }
      else if (IE4){
         mx=0
         my=0
      }
      if(NS4){
         mx-=getpagescrollx();
         my-=getpagescrolly();
      }
      xoff=mx+5;
      yoff=(my+boxheight+20-getpagescrolly()+margin>=w_y)? -15-boxheight: 20;
      movebox( Math.min(w_x-boxwidth-margin , Math.max(2,xoff))+getpagescrollx() , my+yoff+getpagescrolly());
      if(NS4)dutybox.visibility="show";
      if(W3C||IE4)dutybox.style.visibility="visible";
   }
}

window.onload=function(){
  dutybox=(NS4)? document.layers['dutybox'] : (IE4)? document.all['dutybox'] : (W3C)? document.getElementById('dutybox') : null;
  getboxwidth();
  getboxheight();
  getwindowdims();
  isloaded=true;
  if(W3C)dutybox.style.padding='4px';
}

window.onresize=getwindowdims;
if(NS4)document.captureEvents(Event.MOUSEMOVE);
document.onmousemove=moveobj;

function showduties(text){
   if(isloaded){
      if(text!=0){
         ishover=true;
         if(NS4)text='<div class="officerdutybox">'+text+'</div>';
         writeindiv(text);
         getboxheight();
      }else{
         if(NS4)dutybox.visibility="hide";
         if(IE4||W3C){
            dutybox.style.visibility="hidden";
         }
         writeindiv('');
         ishover=false;
      }
   }
}
