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); }
}

Event.observe(window, 'load', function(){
	// dhtml
	InitMenus("nav");
	
	// tootips
	$$('a.pop').each(function(element){
    new Tip(element, $(element.rel).innerHTML, {
			effect:'appear',
			fixed:true,
			hideOn:false,
			hideAfter:.3,
			border:0,
			radius:0
		});
  });
});