  /*
  ###############################################################################
  # comjav.js               version 1.0.0

  # Written by:             Gino Bossetto
  # Of:                     www.stellaritsolutions.com
  # On:                     10-12-2004
  # Last update:            12-11-2008

  # Purpose:                Various common website tools
  #
  # Copyright (c) 2004-2008 Stellar IT Solutions
  ###############################################################################
  */

  function em(acct,dom,tld) {
    document.write('<a href="mailto:' + acct + '@' + dom + '.' + tld + '">' + acct + '@' + dom + '.' + tld + '</a>');
  }

  function marklink(markclass,linklist) {
    var dochref = document.location.href;
    if (document.getElementById) {
      var listelement = (linklist) ? document.getElementById(linklist) : document;
      if (listelement) {
        var links = listelement.getElementsByTagName('A');
        for(var i=0; i<links.length; i++){
          if(links[i].href == dochref) {
            links[i].className = markclass;
            break;
          }
        }
      }
    }
  }

  function marksection(markclass,linklist,section) {
    if (document.getElementById) {
      var listelement = (linklist) ? document.getElementById(linklist) : document;
      if (listelement) {
        var links = listelement.getElementsByTagName('A');
        for(var i=0; i<links.length; i++){
          if(section == 'home' && links[i].href.search(/\/$/) != -1
            || section == 'home' && links[i].href.search(/index.html$/) != -1
            || section == 'about' && links[i].href.search(/background.html$/) != -1
            || section == 'projects' && links[i].href.search(/laddition.html$/) != -1
            || section == 'together' && links[i].href.search(/services.html$/) != -1
            || section == 'informed' && links[i].href.search(/green.html$/) != -1
            || section == 'contact' && links[i].href.search(/contact.html$/) != -1
          ) {
            links[i].className = markclass;
            break;
          }
        }
      }
    }
  }

  function check_required(form) {
    var req = '';
    var hasValue = new Object;
    var inputs = document.getElementsByTagName('input');
    for (var i=0; i<inputs.length; i++) {
      if (inputs[i].className == 'required') {
        if (inputs[i].type == 'radio') {
          if (inputs[i].checked) {
            hasValue[inputs[i].name] = 'true';
          } else {
            if (hasValue[inputs[i].name] != 'true') {
              hasValue[inputs[i].name] = 'false';
            }
          }
        } else {
          if (! inputs[i].value) {
            hasValue[inputs[i].name] = 'false';
          }
        }
      }
    }
    for (var name in hasValue) {
      if (hasValue[name] == 'false') {
        req = req + '\n\t' + name;
      }
    }
    var inputs = document.getElementsByTagName('textarea');
    for (var i=0; i<inputs.length; i++) {
      if (inputs[i].className=='required' && ! inputs[i].value) {
        req = req + '\n\t' + inputs[i].getAttribute('name');
      }
    }
    if (req) {
      alert('Values for these fields are required:\n' + req);
      return false;
    } else {
      return true; 
    }
  }

  function changepic(picid,picpath,textid,message) {
    document.getElementById(picid).src = picpath;
    document.getElementById(textid).innerHTML = message;
  }

  function unhideinput(trigger,value,input) {
    var e = document.getElementById(input);
    if (document.getElementById(trigger).value == value) {
      e.style.display = 'block';
      e.focus();
      e.select();
    } else {
      e.style.display = 'none';
    }
  }

