  /*
  ###############################################################################
  # comjav.js               version 1.0.0

  # Written by:             Gino Bossetto
  # Of:                     www.stellaritsolutions.com
  # On:                     10-12-2004
  # Last update:            06-21-2009

  # Purpose:                Various common website tools
  #
  # Copyright (c) 2004-2009 Stellar IT Solutions
  ###############################################################################
  */

  var addthis_pub="mathedleaders";

  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
            || (dochref.search(/about\/awards/) != -1 && links[i].href.search(/about\/awards/) != -1 && linklist != 'submenu')
            || (dochref.search(/about\/board/) != -1 && links[i].href.search(/about\/board/) != -1 && linklist != 'submenu')
            || (dochref.search(/about\/elections/) != -1 && links[i].href.search(/about\/elections/) != -1 && linklist != 'submenu')
            || (dochref.search(/about\/history/) != -1 && links[i].href.search(/about\/history/) != -1 && linklist != 'submenu')
            || (dochref.search(/events\/conferences\/IN/) != -1 && links[i].href.search(/events\/conferences/) != -1 && linklist != 'submenu')
            || (dochref.search(/events\/conferences\/SD/) != -1 && links[i].href.search(/events\/conferences\/index\.html/) != -1 && linklist != 'submenu')
            || (dochref.search(/events\/conferences\/DC/) != -1 && links[i].href.search(/events\/conferences\/index\.html/) != -1 && linklist != 'submenu')
            || (dochref.search(/events\/academy2009\.html/) != -1 && links[i].href.search(/events\/conferences\/index\.html/) != -1 && linklist != 'submenu')
            || (dochref.search(/events\/academy2008\.html/) != -1 && links[i].href.search(/events\/conferences\/index\.html/) != -1 && linklist != 'submenu')
            || (dochref.search(/events\/academy2007\.html/) != -1 && links[i].href.search(/events\/conferences\/index\.html/) != -1 && linklist != 'submenu')
            || (dochref.search(/events\/academy2006\.html/) != -1 && links[i].href.search(/events\/conferences\/index\.html/) != -1 && linklist != 'submenu')
            || (dochref.search(/events\/fallseminars2009\.html/) != -1 && links[i].href.search(/events\/conferences\/index\.html/) != -1 && linklist != 'submenu')
            || (dochref.search(/resources\/journals/) != -1 && links[i].href.search(/resources\/periodicals/) != -1 && linklist != 'submenu')
            || (dochref.search(/resources\/newsletters/) != -1 && links[i].href.search(/resources\/periodicals/) != -1 && linklist != 'submenu')
            || (dochref.search(/resources\/podcasts/) != -1 && links[i].href.search(/resources\/podcasts.html/) != -1 && linklist != 'submenu')
            || (dochref.search(/partners\/sponsor-/) != -1 && links[i].href.search(/partners\/meetsponsors.html/) != -1 && linklist != 'submenu')
          ) {
            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(/about\/index.html$/) != -1
            || section == 'networks' && links[i].href.search(/networks\/index.html$/) != -1
            || section == 'events' && links[i].href.search(/events\/index.html$/) != -1
            || section == 'resources' && links[i].href.search(/resources\/index.html$/) != -1
            || section == 'join' && links[i].href.search(/join\/index.html$/) != -1
            || section == 'partners' && links[i].href.search(/partners\/index.html$/) != -1
          ) {
            links[i].className = markclass;
            break;
          }
        }
      }
    }
  }

  function fixflash(containerID){
    var msie = ((navigator.appVersion.indexOf('MSIE') != -1) && ! window.opera) ? true : false;
    if (msie) {
      var flashContainer = document.getElementById(containerID);
      var flashMovie = document.createElement('div');
      flashMovie.innerHTML = flashContainer.innerHTML.replace(/</g, '<').replace(/>/g, '>');
      flashContainer.parentNode.insertBefore(flashMovie, flashContainer);
      flashContainer.parentNode.removeChild(flashContainer);
      flashMovie.setAttribute('id',containerID);
    }
  }

  function getimages() {
    if (document.images) {
      if (!document.imgstore) {
        document.imgstore = new Array();
      }
      var j = document.imgstore.length;
      var args = getimages.arguments;
      for(var i=0; i<args.length; i++) {
        if (args[i].indexOf("#") != 0) {
          document.imgstore[j] = new Image;
          document.imgstore[j].src = args[i];
          j++;
        }
      }
    }
  }

  function validateemail(e) {

    var a = e.indexOf('@');
    var d = e.indexOf('.');
    var l = e.length;

    if (a < 1 || a == l || d < 1 || d == l || e.indexOf('@',(a+1)) != -1 || e.substring(a-1,a) == '.' || e.substring(a+1,a+2) == '.' || e.indexOf('.',(a+2)) == -1 || e.indexOf(' ') != -1) {
      alert('Please enter a valid email address');
      return false;
    }

    return true;
  }

  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].name == 'email' && inputs[i].value) {
        validateemail(inputs[i].value);
      }
      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('select');
    for (var i=0; i<inputs.length; i++) {
      if (inputs[i].className=='required' && ! inputs[i].value) {
        req = req + '\n\t' + inputs[i].getAttribute('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 {
      submitted = true;
      return true; 
    }
  }

  function showtoc(id) {
    if (toc = document.getElementById('toc1')) toc.style.display = "none";
    if (toc = document.getElementById('toc2')) toc.style.display = "none";
    if (toc = document.getElementById('toc3')) toc.style.display = "none";
    if (toc = document.getElementById('toc4')) toc.style.display = "none";
    elem = document.getElementById(id);
    elem.style.display = "block";
  }

  function hidetoc(id) {
    elem = document.getElementById(id);
    elem.style.display = "none";
  }

  var popwin;

  function popopen(title,width,height,content) {

    if ( !popwin || popwin.closed ) {
      popwin=window.open('','pophelp','width=' + width +',height=' +height + ',resizable=yes,scrollbars=yes,top=50,left=10');
    }

    popwin.document.clear();
    popwin.document.writeln('<html> <head> <title>' + title + '</title> <style> .photo { border: 1px solid black; } </style> </head>');
    popwin.document.writeln('<body style="font-size: 80%; font-family: Arial, Helvetica, sans-serif;">');
    popwin.document.writeln(content);
    popwin.document.writeln('</body> </html>');
    popwin.document.close();
    popwin.focus();
  }

  function popclose() {
    if (popwin && !popwin.closed) {
      popwin.close();
    }
  }


/**************Old Stuff**************/


