function CheckSearch(search) {
  if (search==""){
    alert('Please enter a search term!');
    return false;
  }
  else{
    return true;
  }
}

function ClearMatch(x,y,z) {
  if (z==1){
    document.searchform.match1[x].checked=false;
    document.searchform.match1[y].checked=false;
  }
  if (z==2){
    document.searchform.match2[x].checked=false;
    document.searchform.match2[y].checked=false;
  }
  if (z==3){
    document.searchform.match3[x].checked=false;
    document.searchform.match3[y].checked=false;
  }
}

function ClearField(x,y) {
  if(x){
    document.searchform.field1[x].checked=false;
  }

  if(y){
    document.searchform.field1[y].checked=false;
  }
}

function ClearFieldExcept(x) {
  for (i=0; i < 8; i++){
    if (x != i){
      document.searchform.field1[i].checked=false;
    }
  }
}

function add_title() {
  var iframeObj = document.getElementById('selected_titles');
  iframeObj.src = './search_within?thing=title&id=' + document.searchform.within_dropdown.value;
}

function setCheckedValue(radioObj, newValue) {
  if(!radioObj) return;

  var radioLength = radioObj.length;

  if(radioLength == undefined) {
    radioObj.checked = (radioObj.value == newValue.toString());
    return;
  }

  for(var i = 0; i < radioLength; i++) {
    radioObj[i].checked = false;
    if(radioObj[i].value == newValue.toString()) {
      radioObj[i].checked = true;
    }
  }
}

function add_treesubject(field,depth) {
  //the form our data is in
  var theForm = document.forms["searchform"];

  //array to hold our results
  var things = new Array();

  //loop over each drop-down
  for ( var d=0; d<depth; d++) {
    //because this loop counts from 0 and we don't ;o
    var r = d+1;
    var fieldname = field+'_'+r;

    //if this field is the one we've been passed
    for( var i=0; i<theForm.elements.length; i++) {
      if(theForm.elements[i].name==fieldname) {
        if (theForm.elements[i].selectedIndex>=0) {
          var value = theForm.elements[i].options[theForm.elements[i].selectedIndex].value;
          if (value) {
            things[d] = value;
          }
        }
      }
    }
  }

  last = things.length - 1;

  if(things[last]>0) {
    var iframeObj = document.getElementById('selected_'+field);
    iframeObj.src = './search_within?thing='+field+'&id='+things[last];
  }
}

function TestURL(url) {
  if (url != '') {
    var newwindow = window.open(url, 'test', 'width=400, height=300, resizable=yes, scrollbars=yes, toolbar=0');      
    newwindow.focus();
  }

  return false;
}

function ColorPicker(form,name,hex,lf) {
  // we need to remove the # from hex
  element = hex.split("#");              
  var newhex = element[0]+element[1];

  var url = './colorpicker?form='+form+'&locallf='+lf+'&id='+name+'&hex='+newhex;
  window.open(url, 'colorpicker', 'width=350, height=350, resizable=yes, scrollbars=yes, toolbar=0');
  return false;
}

function RevertColor(name,orig) {
  name.value = orig;
  return false;
}

function ResetLNF() {
  if (confirm('Any changes you have made will be lost, are you sure?')) {
    return true;
  }
  else{
    return false;
  }
}

function Resize(dimension,table,field) {
  // work out number of cols - note if undefined then a normal text field
  var changeby = 2;

  if (dimension == "thinner" || dimension == "shorter") {
    changeby = -2;
  }

  var formObj = document.getElementById(field); //eval('document.'+table+'.\''+field+'\';');

  if(formObj.type.toLowerCase() == "text" || formObj.type.toLowerCase() == "password" || formObj.type.toLowerCase() == "file") {
    // text field
    if (dimension == "taller" || dimension == "shorter") {
      // can't change the height of a text box!
    }
    else {
      var size = formObj.size;
      size = size + changeby;
      if (size < 1) {
        size = 1;
      }
      formObj.size = size;
    }
  }
  else if (formObj.type.toLowerCase() == "textarea") {
    // text area
    if (dimension == "taller" || dimension == "shorter") {
      var size = formObj.rows;
      size = size + changeby;
      if (size < 1) {
        size = 1;
      }
      formObj.rows = size;
    }
    else {
      var size = formObj.cols;
      size = size + changeby;
      if (size < 1) {
        size = 1;
      }
      formObj.cols = size;
    }
  }
}

function set_background_color(hex) {
  document.bgColor=hex;
}

function doIt(idOfDiv) {
  var oH = getRefToDivMod( idOfDiv ); if( !oH ) { return false; }

  if (self.innerWidth) {
    frameWidth = self.innerWidth;
    frameHeight = self.innerHeight;
  }
  else if (document.documentElement && document.documentElement.clientWidth) {
    frameWidth = document.documentElement.clientWidth;
    frameHeight = document.documentElement.clientHeight;
  }
  else if (document.body) {
    frameWidth = document.body.clientWidth;
    frameHeight = document.body.clientHeight;
  }
  else return;

  newHeight = frameHeight;
  newWidth = frameWidth;

  newHeight = oH.clip ? oH.clip.height : oH.offsetHeight; if( !oH ) { return false; }

  if (document.layers) {
    tmp1 = parent.outerWidth - parent.innerWidth;
    tmp2 = parent.outerHeight - parent.innerHeight;
    newWidth -= tmp1;
    newHeight -= tmp2;
  }

  this.window.resizeTo(frameWidth,newHeight);
}

function getRefToDivMod( divID, oDoc ) {
  if( !oDoc ) { oDoc = document; }

  if( document.layers ) {
    if( oDoc.layers[divID] ) { return oDoc.layers[divID]; } 
    else {
      for( var x = 0, y; !y && x < oDoc.layers.length; x++ ) {
        y = getRefToDivNest(divID,oDoc.layers[x].document); 
      }
      return y; 
    } 
  }

  if( document.getElementById ) { return oDoc.getElementById(divID); }
  if( document.all ) { return oDoc.all[divID]; }
  return document[divID];
}  

function resizeWinTo( idOfDiv ) {
  var oH = getRefToDivMod( idOfDiv ); if( !oH ) { return false; }
  var oW = oH.clip ? oH.clip.width : oH.offsetWidth;
  var oH = oH.clip ? oH.clip.height : oH.offsetHeight; if( !oH ) { return false; }
  var x = window; x.resizeTo( oW + 200, oH + 200 );
  var myW = 0, myH = 0, d = x.document.documentElement, b = x.document.body;
  if( x.innerWidth ) { myW = x.innerWidth; myH = x.innerHeight; }
  else if( d && d.clientWidth ) { myW = d.clientWidth; myH = d.clientHeight; }
  else if( b && b.clientWidth ) { myW = b.clientWidth; myH = b.clientHeight; }
  if( window.opera && !document.childNodes ) { myW += 16; }
  x.resizeTo( oW + ( ( oW + 200 ) - myW ), oH + ( (oH + 200 ) - myH ) );
}

function changelocation(url,anchor)
{
  var now = new Date();
  var milli = now.getTime();
  var finalurl = url + "&timestamp=" + milli;
  
  if (anchor != "undefined") {
    finalurl = finalurl + "#" + anchor;
  }

  window.location = finalurl;
}

// this just does a get for the URL but does nothing with it
function markitems(url) {
  var randnum = Math.floor(Math.random()*99999999); 
  image1 = new Image();
  image1.src = url+"&zdc="+randnum.toString();
}

function ref_popup(mylink, windowname) {
  if (! window.focus) {
    return true;
  }

  var href;

  var browHeight, browWidth;
  browHeight = (screen.height*(1/8));
  browWidth = (screen.width*(6/8));

  if (typeof(mylink) == 'string') {
     href=mylink;
  }
  else {
     href=mylink.href;
  }

  newwindow=window.open(href, windowname, 'height=' + browHeight + ',width=' + browWidth +',resizable=yes,dependent=yes,left='+((1/8)*screen.width)+',top='+((6/8)*screen.height)+',scrollbars=yes');

  newwindow.focus();

  return false;
}

function popup(url,target,width,height) {
  if (width == "undefined"){
    width = 550;
  }

  if (height == "undefined"){
    height = 600;
  }

  var leftVal = (screen.width - width) / 2;
  var topVal = (screen.height - height) / 2;

  var popupwindow = window.open(url, target, 'alwaysRaised=1,dependent=yes,innerWidth='+width+',innerHeight='+height+',menubar=0,resizable=1,scrollbars=yes,screenX='+leftVal+',left='+leftVal+',screenY='+topVal+',top='+topVal+',status=0,toolbar=0');

  popupwindow.focus;
}

function openPopup(url,target,width,height) {
  if (!width) width = 600;
  if (!height) height = 400;
  var leftVal = (screen.width - width) / 2;
  var topVal = (screen.height - height) / 2;
  var myPopup = window.open(url,target,'width='+width+',height='+height+',status=no,toolbar=no,menubar=no,resizable=yes,scrollbars=yes,screenX='+leftVal+',left='+leftVal+',screenY='+topVal+',top='+topVal+'');
  if (!myPopup.opener) myPopup.opener = self;
  myPopup.focus;
}

function UseImage(name, subsection) {
  var url = './register~mode=lnf~popup=true~useimage=true~form='+subsection+'~name='+name;
  window.open(url, 'useimage', 'width=540, height=600, resizable=yes, scrollbars=yes, toolbar=0');      
  return false;
}

function read_phrase() {
  if (!domData.isClippable) {
    return false;
  }

  var text = "";

  if (domData.isNN4) {
    text = document.getSelection(); 
  }
  else if (domData.isIE4up) {
    text = document.selection.createRange().text; 
  }
  else if (domData.isNN6up) {
    text = window.getSelection();
  }

  return text;
}

function search_phrase() {
  if (!domData.isClippable){
    return false;
  }

  var word = read_phrase();

  if (word=="") { 
    void(word = prompt('Enter text to search on using this site. You can also highlight a word on this web page before clicking search.',''));
  }

  if (word){
    window.location = "./search?submit=true&first=1&term1="+word;
  }
}

function search_google_scholar() {
  if (!domData.isClippable){
    return false;
  }

  var word = read_phrase();

  if (word=="") { 
    void(word = prompt('Enter text to search on using Google Scholar. You can also highlight a word on this web page before clicking search.',''));
  }

  if (word){
    window.location = "http://scholar.google.com/scholar?q="+word;
  }
}

startList = function() {
  if (document.all && document.getElementById) {
    navRoot = document.getElementById("nav");

    if(navRoot){
      for (i=0; i<navRoot.childNodes.length; i++) {
        node = navRoot.childNodes[i];

        if (node.nodeName=="LI") {
          node.onmouseover=function() {
            this.className+=" over";
          }

          node.onmouseout=function() {
            this.className=this.className.replace(" over", "");
          }
        }
      }
    }
  }
}

window.onload=startList;

function domDetect() {
  this.wvlong = parseFloat(navigator.appVersion);
  this.wvshort = parseInt(navigator.appVersion);
  this.wagent = navigator.userAgent;
  this.wplatform = navigator.platform;
  this.wbrowser = navigator.appName;
  
  this.isMac = (this.wplatform.indexOf("Mac") != -1);
  this.isWin = (this.wplatform.indexOf("Win") != -1);
  this.isLinux = (this.wplatform.indexOf("Linux") != -1);
  this.isNN = (this.wbrowser == "Netscape");
  this.isIE = (this.wbrowser.indexOf("Microsoft") != -1);
  this.isK = (this.wbrowser.indexOf("Konqueror") != -1);

  this.isNN4 = (this.wvshort == 4) && (this.isNN);  
  this.isNN6up = (this.wvshort >= 5) && (this.isNN);
  this.isIE4up = (this.wvshort >= 4) && (this.isIE);
  this.isIE5Mac = (this.isIE4up) && (this.wagent.indexOf("5.0") != -1) && (this.isMac);
  this.isIE6 = (this.wagent.indexOf("MSIE 6.0") != -1);
  this.isOther = (!this.isNN4) && (!this.isIE4up) && (!this.isNN6up) && (!this.isK);
  this.isClippable = ((this.isIE4up) || (this.isNN6up)) && (!this.isMac) && (!this.isK);
} 

domData = new domDetect();

// functions used by the marked list add/remove links
var lastVisibleLayer;
function view(layername,evt) {
  if (lastVisibleLayer == layername) {
    //already visible
    return;
  }

  if (lastVisibleLayer) {
    hide(lastVisibleLayer);
    lastVisibleLayer = "";
  }

  lastVisibleLayer = layername;

  var thislayer = new getObject(layername);

  if (evt) {
    var x = findXCoord(evt);
    thislayer.style.left = (x-5)+"px";
    var y = findYCoord(evt);
    thislayer.style.top = y+"px";
  }

  checkLayerOnScreen(layername);
  thislayer.style.visibility = 'visible';
}

function hide(layername) {
  if (lastVisibleLayer == layername) {
    lastVisibleLayer = "";
  }
  var x = new getObject(layername);
  x.style.visibility = 'hidden';
}

function getObject(name) {
  if (document.getElementById) {
    this.obj = document.getElementById(name);
    if (this.obj != null) {
      this.style = document.getElementById(name).style;
    }
  }
  else if (document.all) {
    this.obj = document.all[name];
    if (this.obj != null) {
      this.style = document.all[name].style;
    }
  }
  else if (document.layers) {
    this.obj = document.layers[name];
    if (this.obj != null) {
     this.style = document.layers[name];
    }
  }
}

function findXCoord(evt) {
  if (evt.x) return evt.x;
  if (evt.pageX) return evt.pageX;
}

function findYCoord(evt) {
  if (evt.y) return evt.y;
  if (evt.pageY) return evt.pageY;
}

function divPopulate(divname,data) {
  if (document.getElementById) {
    document.getElementById(divname).innerHTML = data;
  }
  else if (document.all) {
    document.all[divname].innerHTML = data;
  }
  else if (document.layers) {
    var d = document.layers[divname]; 
    d.document.open();
    d.document.writeln(data);
    d.document.close();
  }
}

function openerDivPopulate(divname,data) {
  if (opener.document.getElementById) {
    opener.document.getElementById(divname).innerHTML = data;
  }
  else if (opener.document.all) {
    opener.document.all[divname].innerHTML = data;
  }
  else if (opener.document.layers) {
    var d = opener.document.layers[divname]; 
    d.document.open();
    d.document.writeln(data);
    d.document.close();
  }
}

function openerGetDivContents(divname) {
  if (opener.document.getElementById) {
    var c = opener.document.getElementById(divname).innerHTML;
    return c;
  }
  else if (opener.document.all) {
    var c = opener.document.all[divname].innerHTML;
    return c;
  }
  else if (opener.document.layers) {
    var d = opener.document.layers[divname]; 
    d.document.open();
    was = d.document.readln();
    d.document.close();
    return was;
  }
}

function SetAllCheckBoxes(FormName, FieldName, CheckValue) {
  if(!document.forms[FormName])
    return;

  var objCheckBoxes = document.forms[FormName].elements[FieldName];

  if(!objCheckBoxes) return;

  var countCheckBoxes = objCheckBoxes.length;

  if(!countCheckBoxes)
    objCheckBoxes.checked = CheckValue;
  else
    // set the check value for all check boxes
    for(var i = 0; i < countCheckBoxes; i++)
      objCheckBoxes[i].checked = CheckValue;
}

function mouseLeaves (element, evt) {
  if (typeof evt.toElement != 'undefined' && evt.toElement && typeof element.contains != 'undefined') {
    return !element.contains(evt.toElement);
  }
  else if (typeof evt.relatedTarget != 'undefined' && evt.relatedTarget) {
    return !contains(element, evt.relatedTarget);
  }
}

function contains (container, containee) {
  while (containee) {
    if (container == containee) {
      return true;
    }
    containee = containee.parentNode;
  }
  return false;
}

// functions for showing/hiding layers using the "style.visibility" method
function toggleLayerVisibility(layername,showhide,focus) {
  var thislayer = new getObject(layername);

  if (showhide) {
    thislayer.style.visibility = showhide;
  }
  else if ((thislayer.style.visibility == 'hidden') || (thislayer.style.visibility == 'hide')) {
    thislayer.style.visibility = 'visible';
  }
  else {
    thislayer.style.visibility = 'hidden';  
  }

  if (focus) {
    eval("document."+focus+".focus();");
  }
}

function makeLayerInvisible(layername,focus) {
  toggleLayerVisibility(layername,'hidden',focus);
}

function makeLayerVisible(layername,focus) {
  toggleLayerVisibility(layername,'visible',focus);
}

function HideLayer(layername) {
  var thislayer = new getObject(layername);
  thislayer.style.display = 'none';
}

// functions for showing/hiding layers using the "style.display" method
var currenttimeout = null;
function toggleLayerDisplay(layername,showhide,focus,autohide) {
  //clear any existing timeout
  if ((currenttimeout != null) && (autohide>0)) {
    clearTimeout(currenttimeout);
    currenttimeout = null;
  }

  var thislayer = new getObject(layername);

  if (thislayer.obj != null) {
    if (showhide == 'hide') {
      thislayer.style.display = 'none';  
    }
    else if (showhide == 'show') {
      thislayer.style.display = '';
      if (autohide>0) {
        currenttimeout = setTimeout("HideLayer('"+layername+"')",autohide);
      }  
    }
    else {
      var thislayer = new getObject(layername);
      if (thislayer.style.display == 'none') {
        thislayer.style.display = '';
        if (autohide>0) {
          currenttimeout = setTimeout("HideLayer('"+layername+"')",autohide);
        }  
      }
      else {
        thislayer.style.display = 'none';  
      }
    }

    // if layer in view and we have a focus, set it
    if (focus) {
      if (thislayer.style.display == '') {
        eval("document."+focus+".focus();");
      }
    }
  }
}

// functions for showing/hiding popup items on main menu
function ShowLoginBox() {
  toggleLayerDisplay('loginboxbar',0,'quicklogin.username');
}

function ShowMyDekkerMenu() {
  toggleLayerDisplay('quickloginbox','hide');
//  checkLayerOnScreen('mydekker');
  toggleLayerDisplay('mydekker');
  return false;
}

// Functions for working out size of browser window, scroll postions and repostioning layers on screen
function getBrowserWindowScrollXY() {
  var scrOfX = 0, scrOfY = 0;

  if( typeof( window.pageYOffset ) == 'number' ) {
    //Netscape compliant
    scrOfY = window.pageYOffset;
    scrOfX = window.pageXOffset;
  }
  else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) {
    //DOM compliant
    scrOfY = document.body.scrollTop;
    scrOfX = document.body.scrollLeft;
  }
  else if( document.documentElement &&
    ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) {
    //IE6 standards compliant mode
    scrOfY = document.documentElement.scrollTop;
    scrOfX = document.documentElement.scrollLeft;
  }

  return [ scrOfX, scrOfY ];
}

function getBrowserWindowSizeXY() {
  var myWidth = 0, myHeight = 0;

  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myWidth = window.innerWidth;
    myHeight = window.innerHeight;
  }
  else if( document.documentElement &&
    ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    myWidth = document.documentElement.clientWidth;
    myHeight = document.documentElement.clientHeight;
  }
  else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
      //IE 4 compatible
    myWidth = document.body.clientWidth;
    myHeight = document.body.clientHeight;
  }
  return [ myWidth, myHeight ];
}

function findCursorXYCoordinates(evt) {
  var x = 0, y = 0;

  if (evt.x) {
    x = evt.x;
    y = evt.y;
  }
  else if (evt.pageX) {
    x = evt.pageX;
    y = evt.pageY;
  }

  return [ x, y ];
}

function getLayerSizeXY(layername) {
  var height = 0, width = 0;

  if (document.getElementById) {
    height = document.getElementById(layername).offsetHeight;
    width = document.getElementById(layername).offsetWidth;
  }
  else if (document.all) {
    height = document.all[layername].clientHeight;
    width = document.all[layername].clientWidth;
  }
  else if (document.layers) {
    height = document.layers[layername].document.height;
    width = document.layers[layername].document.width;
  }

  return [width, height];
}

function checkLayerOnScreen(layername) {
  var thislayer = new getObject(layername);
  var layersizexy = getLayerSizeXY(layername);
  var browsersizexy = getBrowserWindowSizeXY();
  var scrollxy = getBrowserWindowScrollXY();
  var layerx = parseInt(thislayer.style.left);
  var layery = parseInt(thislayer.style.top);

  // check the x pos
  // Is it off the right?
  var layerright = layerx + layersizexy[0];

  if (layerright > browsersizexy[0]) {
    var newx = browsersizexy[0] - layersizexy[0] - 5;
    // take in to account the scroll position
    // note, Netscape takes scroll pos in to account in the cursor pos so no need to do it here for Netscape
    if (navigator.appName != "Netscape") {
      newx += scrollxy[0];
    }
    // set the x coordinate
    thislayer.style.left = newx
  }

  // Is it off the left?
  if (layerx < scrollxy[0]) {
    var newx = scrollxy[0] + 5;
    // set the x coordinate
    thislayer.style.left = newx
  }


  // check the y pos
  // Is it off the bottom?
  var layerbottom = layery + layersizexy[1];

  if (layerbottom > browsersizexy[1]) {
    var newy = browsersizexy[1] - layersizexy[1] - 5;
    // take in to account the scroll position
    // note, Netscape takes scroll pos in to account in the cursor pos so no need to do it here for Netscape
    if (navigator.appName != "Netscape") {
      newy += scrollxy[1];
    }
    // set the y coordinate
    thislayer.style.top = newy
  }

  // Is it off the top?
  if (layery < scrollxy[1]) {
    var newy = scrollxy[1] + 5;
    // set the y coordinate
    thislayer.style.top = newy
  }
}

function moveLayerToCursor(layername,evt) {
  var cursorxy = findCursorXYCoordinates(evt);
  var layersizexy = getLayerSizeXY(layername);
  var browsersizexy = getBrowserWindowSizeXY();
  var thislayer = new getObject(layername);
  var scrollxy = getBrowserWindowScrollXY();
  var cursoroffset = 5; // how many pixels way from cursor to postion layer

  // work out new x coordinate
  var newx = cursorxy[0] + cursoroffset;

  // check not off the right of page
  var layerright = newx + layersizexy[0];

  if (layerright > browsersizexy[0]) {
    newx = newx - layersizexy[0] - (2 * cursoroffset);
    // take in to account the scroll position
    // note, Netscape takes scroll pos in to account in the cursor pos so no need to do it here for Netscape
    if (navigator.appName != "Netscape") {
      newx += scrollxy[0];
    }
  }
  // set the x coordinate
  thislayer.style.left = newx

  // work out y coordinate
  var newy = cursorxy[1] - layersizexy[1] - cursoroffset;

  // take in to account the scroll position
  // note, Netscape takes scroll pos in to account in the cursor pos so no need to do it here for Netscape
  if (navigator.appName != "Netscape") {
    newy += scrollxy[1];
  }

  // check not off the top of the screen
  if (newy < scrollxy[1]) {
    newy = cursorxy[1] + cursoroffset;
    if (navigator.appName != "Netscape") {
      newy += scrollxy[1];
    }
  }

  // set the y coordinate
  thislayer.style.top = newy;
}

function SubmitIfEnterPressed(e,form,thisvalue) { 
  if (thisvalue != "") {
    if (!e) {
      var e = window.event;
    }

    var key;
    if (e.keyCode) {
      key = e.keyCode;
    } 
    else if (e.which) {
      key = e.which;
    }

    if (key == 13) {
      eval('document.'+form+'.submit();');
    }
  }
}

function SelectAll(formname,groupname,allname) {
  // see what setting now is
  var ischecked = eval('document.'+formname+'.'+allname+'.checked');
  newstatus = "";

  if (ischecked == true) {
    newstatus = "true";
  }

  var numboxes = eval('document.'+formname+'.'+groupname+'.length');

  if (numboxes == undefined) {
    eval('document.'+formname+'.'+groupname+'.checked = newstatus');
  }
  else {
    for (i=0; i<numboxes; i++) {
      eval('document.'+formname+'.'+groupname+'[i].checked = newstatus');
    }
  }

  eval('document.'+formname+'.allup.checked = newstatus');
  eval('document.'+formname+'.alldown.checked = newstatus');
}

function CheckAllBoxes(formname,ischecked) {
  if (ischecked != true) {
    eval('document.'+formname+'.alldown.checked = \'\'');
    eval('document.'+formname+'.allup.checked = \'\'');
  }
}

function toggleBranchDisplay(layername,showhide,focus) {
  var thislayer = new getObject('bit'+layername);
  if ( ((thislayer.style.display == 'none') || (showhide == 'show')) && (showhide != 'hide') ){
    thislayer.style.display = '';
    divPopulate('link'+layername,"<img src=\"/images/minus.png\" alt=\"Contract\" class=\"b_expand\" />");
  }
  else {
   thislayer.style.display = 'none';  
    divPopulate('link'+layername,"<img src=\"/images/plus.png\" alt=\"Expand\" class=\"b_expand\" />");
  }
}

function toggleBranchDisplayABES(layername,showhide,focus) {
  var thislayer = new getObject('bit'+layername);
  if ( ((thislayer.style.display == 'none') || (showhide == 'show')) && (showhide != 'hide') ){
    thislayer.style.display = '';
    divPopulate('link'+layername,"<img src=\"/images/abe/expand_down_down.gif\" alt=\"Contract\" class=\"b_expand\" />");
  }
  else {
   thislayer.style.display = 'none';  
    divPopulate('link'+layername,"<img src=\"/images/abe/expand_right.gif\" alt=\"Expand\" class=\"b_expand\" />");
  }
}

function populateElement(selector, defvalue) {
    if($(selector).attr('value') == null) {
      $(selector).attr('value', defvalue);
    }
  
    $(selector).focus(function() {
      if($(selector).attr('value') == defvalue) {
        $(selector).attr('value','' );
      }
    });
    
    $(selector).blur(function() {
        if($(selector).attr('value') == null || $(selector).attr('value') == "") {
            $(selector).attr('value', defvalue);
        }
    });
 }

