var ie5 = false;
var ns6 = false;
var moz = false;
var mac = false;

agent = navigator.userAgent.toLowerCase();
ie5   = (document.all && document.getElementById)  ? true : false;
ns6   = (document.getElementById && !document.all) ? true : false;
moz   = (document.getElementById && !document.all) ? true : false;
mac   = (agent.indexOf("mac")!=-1);

function safemail(name, domain, display, css, subject) {
  css       = (css)     ? ' class="' + css + '"' : '';
  subject   = (subject) ? '?subject=' + subject : '';
  displayed = (display) ? display : name + '@' + domain;
  mailto    = name + '@' + domain + subject;
  document.write('<a href="mailto:' + mailto + '"' + css + '>' + displayed + '</a>');
}
function Popup(title,filename,w,h,scroll,resizable,menubar) {
  title     = (title == '')         ? 'popup' : title;
  scroll    = (scroll == 'scroll')  ? 'yes'   : 'no';
  resizable = (resizable == 'lock') ? 'no'    : 'yes';
  menubar   = (menubar == 'menu')   ? 'yes'   : 'no';
  
  winOptions = eval("'width="+w+",height="+h+",toolbar=no,location=no,directories=no,status=no,menubar="+menubar+",scrollbars="+scroll+",resizable="+resizable+",copyhistory=no'");
  window.open(filename,title,winOptions);
  return;
}
function PopWindow(title, url, width, height) {
  BuildWindow({id:'popwindow', title:title, url:url, width:width, height:height});
}
function SetFocus(fieldname,formname){if (formname == ''){ formname = 'form'; }if (eval("document."+formname+".elements[fieldname].value == ''")){ eval("document."+formname+".elements[fieldname].focus();"); }}
function SpellCheck() {
	var speller = new spellChecker();
	speller.spellCheckAll();
}
function DisableButtonImg(obj) {
  obj.src          = '/images/loading.gif';
  obj.disabled     = true;
  obj.style.border = 'none';
}
function DisableButtonTxt(obj) {
  obj.value        = 'Processing...';
  obj.disabled     = true;
  obj.style.border = 'none';
}
function SubmitForm(obj, form_action) {
  // disable button
  DisableButtonTxt(obj);
  
  // get elements
  var frm = document.forms[obj.form.name];
  var act = frm.elements['form_action'];
  
  // set form action
  act.value = form_action;
  
  // submit form
  frm.submit();
}
function HideOutput() {
  // check for previous reponses/errors
  if ($('flash')) { Element.hide('flash'); }
}
function ToggleElement(id) {
  if ($(id)) { Element.toggle(id); }
}
function SetCookie(name, value, days) {
  if (days) {
    var date = new Date();
    date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000));
    var expires = '; expires=' + date.toGMTString();
  } else {
    var expires = '';
  }
  document.cookie = name + '=' + value + expires + '; path=/';
}
function SetStyle(name) {
  // change body class
  $('body').className = name;
  
  // set cookie
  SetCookie('style', name, 365);
  
  // update links
  var list  = $('header-links').getElementsByTagName('a');
  var nodes = $A(list);
  nodes.each(
    function(node) {
      if (node.id == name) {
        Element.addClassName(node, 'on');
      } else {
        Element.removeClassName(node, 'on');
      }
    }
  );
}
window.onload = function() {
  
}
window.onresize = function() {
  
}
