function right(e) {
   if (navigator.appName == 'Netscape' && 
      (e.which == 3 || e.which == 2))
      return false;
   else if (navigator.appName == 'Microsoft Internet Explorer' && 
      (event.button == 2 || event.button == 3)) 
   {
      alert("");
      return false;
   }
   return true;
}

function disable_rclick()
{
   document.onmousedown=right;
   document.onmouseup=right;
   if (document.layers) window.captureEvents(Event.MOUSEDOWN);
   if (document.layers) window.captureEvents(Event.MOUSEUP);
   window.onmousedown=right;
   window.onmouseup=right;
}

function check_login_form()
{
   var form_obj = document.getElementById('login_form');
   if (is_empty(form_obj.email, 'Please enter your email address.')) return false;
   //if (!check_email_address(form_obj.email)) return false;
   if (is_empty(form_obj.password, 'Please enter your password.')) return false;
   return true;
}



function is_empty(obj, mesg)
{
   if (obj.value == '')
   {
      alert(mesg);
      obj.focus();
   }
   return (obj.value == '');
}

function check_email_address(field)
{

   // Note: The next expression must be all on one line...
   //       allow no spaces, linefeeds, or carriage returns!
   var good = false;
   var goodEmail = field.value.match(/\b(^(\S+@).+((\.com)|(\.net)|(\.edu)|(\.mil)|(\.gov)|(\.org)|(\..{2,2}))$)\b/gi);
   if (goodEmail){
      good = true;
   } else {
      alert('Please enter a valid email address.');
      field.focus();
      field.select();
      good = false;
   }
   return good;   
}

function set_minor(obj)
{
   var sel_idx = obj.selectedIndex;
   var catid = obj.options[sel_idx].value;
   var cat_html = minor_dhtml[catid];
   cat_html = '<select class="frontdd" name="minor_cat" onchange="set_sub(this);"><option value="0">and all minor categories</option>' + cat_html + '</select>';
   document.getElementById('minor_cat_dhtml').innerHTML = cat_html;  
   
}

function set_sub(obj)
{
   var sel_idx = obj.selectedIndex;
   var catid = obj.options[sel_idx].value;
   var cat_html = sub_dhtml[catid];
   cat_html = '<select class="frontdd" name="sub_cat"><option value="0">and all sub categories</option>' + cat_html + '</select>';
   document.getElementById('sub_cat_dhtml').innerHTML = cat_html;
   
}

function search(type)
{
   var form_obj = document.getElementById('search_form');
   if (type && is_empty(form_obj.string, 'Please enter your search term.')) return;
   if (type && form_obj.string.value.length < 4) { alert ('Your search term must be longer than 3 characters.'); return; }
   form_obj.type.value = (type)?'keyword':'browse';
   form_obj.submit();
}

function img(data)
{
   window.location = '/info.php?data=' + data;
}