//$Id: apply_tag.js 940 2006-11-13 15:11:11Z star000s $
function noenterkey(id, objType) {
   if (window.event) {
      if ( window.event.keyCode == 13) {
         apply_tag(id, objType);
         document.getElementById('tg_'+id).value='';
         document.getElementById('tg_'+id).focus();
         return false;
      }
   }
}
function apply_tag(id, objType) {
   tag_string = encodeURIComponent(document.getElementById('tg_'+id).value);
   var url;
   var underscoreIndex = id.indexOf('_');
   var obj_id = id;
   if (underscoreIndex >= 1) {
      obj_id = id.substring(0,underscoreIndex);
   }
   if (objType == "E") {
      url  = 'http://' + location.hostname + '/tag.php?d=tag&event_id=' + obj_id + '&tag=' + tag_string;
   }
   else if (objType == "V") {
      url  = 'http://' + location.hostname + '/tag.php?d=tag&venue_id=' + obj_id + '&tag=' + tag_string;
   }
   else if (objType == "L") {
      url  = 'http://' + location.hostname + '/tag.php?d=tag&list_id=' + obj_id + '&tag=' + tag_string;
   }
   else if (objType == "G") {
      url  = 'http://' + location.hostname + '/tag.php?d=tag&guide_id=' + obj_id + '&tag=' + tag_string;
   }
   loadDoc(url, "tag_" + id);
}
function show_tags(id, objType, user_logged_in, current_url) {
   if (user_logged_in == 1) {
      var url;
      var underscoreIndex = id.indexOf('_');
      var obj_id = id;
      if (underscoreIndex >= 1) {
         obj_id = id.substring(0,underscoreIndex);
      }
      if (objType == "E") {
         url  = 'http://' + location.hostname + '/tag.php?d=show_tags&event_id=' + obj_id;
      }
      else if (objType == "V") {
         url  = 'http://' + location.hostname + '/tag.php?d=show_tags&venue_id=' + obj_id;
      }
      else if (objType == "L") {
         url  = 'http://' + location.hostname + '/tag.php?d=show_tags&list_id=' + obj_id;
      }
      else if (objType == "G") {
         url  = 'http://' + location.hostname + '/tag.php?d=show_tags&guide_id=' + obj_id;
      }
      show ('t_' + id);
      loadDoc(url, "tag_" + id);
   }
   else {
      location.href="http://" + location.hostname + "/user_admin.php?d=user_login&url=" + current_url;
   }
}

