//##############################################################################
//##############################################################################
function openWindow(){
  //alert('Opening a popup to put sign up into!')
  Modalbox.show('/signup.asp?mode=form', {title: 'Sign up for Updates', width: 400});
}
var valid = true;
//##############################################################################
//##############################################################################
function validate(form_id) {
  valid = true;
  
  validateInput('name', 'not-empty');
  validateInput('email', 'not-empty');
  validateInput('address', 'not-empty');
  validateInput('city', 'not-empty');
  validateInput('zip', 'not-empty');
  validateInput('phone', 'not-empty');
  
  if(valid) {
    new Ajax.Request('/signup.asp?mode=log', {
      method: 'get',
      parameters: $(form_id).serialize(true),
      onSuccess: function(transport) {
        $('MB_content').update(transport.responseText);
        Modalbox.resizeToContent();
      }
    });
  }
}
//##############################################################################
//##############################################################################
function validateInput(id, vtype) {
  switch(vtype) {
    case 'not-empty':
      if($(id).value == '') {
        valid = false;
        $(id+'_error').update('Required!');
        $(id+'_error').addClassName('error');
      }
      if(valid) { clearErrors(id) }
      break;
  }
}
//##############################################################################
//##############################################################################
function clearErrors(id) {
  $(id+'_error').update();
  $(id+'_error').removeClassName('error');
}
//##############################################################################
//##############################################################################
//##  User Handler Functions												  ##
//##############################################################################
function externalLinks() {
  if (!document.getElementsByTagName) return;
  var anchors = document.getElementsByTagName("a");
  for (var i=0; i<anchors.length; i++) {
    var anchor = anchors[i];
    if ((anchor.getAttribute("href")) && (anchor.getAttribute("rel") == "external"))
     anchor.target = "_blank";
 }
}
//##############################################################################
//##############################################################################