
function changeContent(id, content) {
   document.getElementById(id).firstChild.nodeValue = content;
}


function changeBgColor(id, newColor) {
   document.getElementById(id).style.backgroundColor = newColor;
}

function changeBorderColor(id, newColor) {
   document.getElementById(id).style.borderColor = newColor;
}

function changeUri(uri) {
   window.location.href = uri;
}


function toggleDisplay(id) {

   var display = document.getElementById(id).style.display;

   if(display == 'none' || display == '') {
      document.getElementById(id).style.display = 'block';
   }
   if(display == 'block') {
      document.getElementById(id).style.display = 'none';
   }

}


function toggleButton(id) {

   src = document.getElementById(id).src;

   basename = src.substring(0,src.lastIndexOf('_'));
   appendix = src.substring(src.lastIndexOf('_'), src.lastIndexOf('.'));
   extension = src.substring(src.lastIndexOf('.'));

   if(appendix == '_closed') {
      document.getElementById(id).src = basename + '_open' + extension;
   }

   if(appendix == '_open') {
      document.getElementById(id).src = basename + '_closed' + extension;
   }

}


function setValue(id, value) {
   if(document.getElementById(id)) {
      document.getElementById(id).value = value;
   }
}
function changeColor(id, newColor) {
   if(document.getElementById(id)) {
      document.getElementById(id).style.color = newColor;
   }
}

function changeBgColor(id, newColor) {
   if(document.getElementById(id)) {
      document.getElementById(id).style.backgroundColor = newColor;
   }
}

function changeBorderColor(id, newColor) {
   if(document.getElementById(id)) {
      document.getElementById(id).style.borderColor = newColor;
   }
}


function openPopupCentered(uri, width, height) {

   var left = (screen.width) ? (screen.width-width)/2 : 0;
   var top = (screen.height) ? (screen.height-height)/2 : 0;


   if(window.screenLeft) {
      left  = left + window.screenLeft;
   }

   
   ref = window.open(uri, '_blank', "toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,width="+width+",height="+height+",top="+top+",left="+left);
   
   ref.focus();
   return ref;

}

function openNewWindow(uri) {
   ref = window.open(uri, '_blank', 'width=600,height=400,resizable=1');
}



function changeUri(uri) {
   window.location.href = uri;
}

function changeDisplay(id,newDisplay) {
   if(document.getElementById(id)) {
      document.getElementById(id).style.display = newDisplay;
   }
}

function changeDisplayName(name, newDisplay) {
   var arr = document.getElementsByName(name);
   for (i=0;i<arr.length;i++) {
      arr[i].style.display = newDisplay;
   }
}


function changeVisibility(id,newVisibility) {
   if(document.getElementById(id)) {
      document.getElementById(id).style.visibility = newVisibility;
   }
}

function changeVisibilityName(name, newVisibility) {
   var arr = document.getElementsByName(name);
   for (i=0;i<arr.length;i++) {
      arr[i].style.visibility = newVisibility;
   }
}

function toggleDisplay(id) {
   var display = document.getElementById(id).style.display;
   if(display == 'none' || display == '') {
      document.getElementById(id).style.display = 'block';
   }
   if(display == 'block') {
      document.getElementById(id).style.display = 'none';
   }
}

function toggleButton(id) {
   src = document.getElementById(id).src;
   basename = src.substring(0,src.lastIndexOf('_'));
   appendix = src.substring(src.lastIndexOf('_'), src.lastIndexOf('.'));
   extension = src.substring(src.lastIndexOf('.'));

   if(appendix == '_closed') {
      document.getElementById(id).src = basename + '_open' + extension;
   }

   if(appendix == '_open') {
      document.getElementById(id).src = basename + '_closed' + extension;
   }
}


function highlightButton(id, event) {
   src = document.getElementById(id).src;
   basename = src.substring(0,src.lastIndexOf('_'));
   appendix = src.substring(src.lastIndexOf('_'), src.lastIndexOf('.'));
   extension = src.substring(src.lastIndexOf('.'));

   if(event == 'over') {
      document.getElementById(id).src = basename + '_hi' + extension;
   }

   if(event == 'out') {
      document.getElementById(id).src = basename + '_norm' + extension;
   }
}
