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

  # Written by:             Gino Bossetto
  # Of:                     www.stellaritsolutions.com
  # On:                     10-12-2004
  # Last update:            03-21-2009

  # Purpose:                Various common website tools
  #
  # Copyright (c) 2004-2009 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(/staff.html$/) != -1
            || section == 'about' && links[i].href.search(/staff2.html$/) != -1
            || section == 'how' && links[i].href.search(/philosophy.html$/) != -1
            || section == 'how' && links[i].href.search(/team.html$/) != -1
            || section == 'how' && links[i].href.search(/faq.html$/) != -1
            || section == 'how' && links[i].href.search(/partners.html$/) != -1
            || section == 'testimonials' && links[i].href.search(/testimonials.html$/) != -1
            || section == 'contact' && links[i].href.search(/contact.html$/) != -1
            || section == 'projects' && links[i].href.search(/bathroom1.html$/) != -1
            || section == 'projects' && links[i].href.search(/bathroom2.html$/) != -1
            || section == 'projects' && links[i].href.search(/bathroom3.html$/) != -1
            || section == 'projects' && links[i].href.search(/bathroom4.html$/) != -1
            || section == 'projects' && links[i].href.search(/bathroom5.html$/) != -1
            || section == 'projects' && links[i].href.search(/bathroom6.html$/) != -1
            || section == 'projects' && links[i].href.search(/bathroom7.html$/) != -1
            || section == 'projects' && links[i].href.search(/bathroom8.html$/) != -1
            || section == 'projects' && links[i].href.search(/house1.html$/) != -1
            || section == 'projects' && links[i].href.search(/house2.html$/) != -1
            || section == 'projects' && links[i].href.search(/house3.html$/) != -1
            || section == 'projects' && links[i].href.search(/house4.html$/) != -1
            || section == 'projects' && links[i].href.search(/kitchen1.html$/) != -1
            || section == 'projects' && links[i].href.search(/kitchen2.html$/) != -1
            || section == 'projects' && links[i].href.search(/kitchen3.html$/) != -1
            || section == 'projects' && links[i].href.search(/kitchen4.html$/) != -1
            || section == 'projects' && links[i].href.search(/kitchen5.html$/) != -1
            || section == 'projects' && links[i].href.search(/kitchen6.html$/) != -1
            || section == 'projects' && links[i].href.search(/kitchen7.html$/) != -1
            || section == 'projects' && links[i].href.search(/kitchen8.html$/) != -1
            || section == 'projects' && links[i].href.search(/special1.html$/) != -1
            || section == 'projects' && links[i].href.search(/special2.html$/) != -1
            || section == 'projects' && links[i].href.search(/special3.html$/) != -1
            || section == 'projects' && links[i].href.search(/special4.html$/) != -1
            || section == 'projects' && links[i].href.search(/details1.html$/) != -1
            || section == 'projects' && links[i].href.search(/details2.html$/) != -1
            || section == 'projects' && links[i].href.search(/details3.html$/) != -1
            || section == 'projects' && links[i].href.search(/details4.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;
  }

  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++) {
        document.imgstore[j] = new Image;
        document.imgstore[j].src = args[i];
        j++;
      }
    }
  }


