//$Id: tag_detail.js 1758 2007-08-15 12:20:17Z star000s $   
function show_forum_form(user_logged_in, current_url) {
   if (user_logged_in == 1) {
      show('tag_forum_form');
   }
   else {
      location.href="http://" + location.hostname + "/user_admin.php?d=user_login&url=" + current_url;
   }
}  
function update_forum(section) {
   var topic = document.getElementById("topic").value;
   topic = new String(topic);
   topic = topic.replace( /^\s+/g, "" );// strip leading
   if (topic == "") {
      alert("Please enter a topic.");
      document.getElementById("topic").focus();
      return false;
   }
   else {
      var poststr = "tag_id=" + encodeURI( document.getElementById("tag_id").value ) +
      "&topic=" + encodeURIComponent( document.getElementById("topic").value ) +
      "&forum_response=" + encodeURIComponent( document.getElementById("forum_response").value ) +
      "&goto_page=" + encodeURIComponent( document.getElementById("goto_page").value ) +
      "&d=update_forum";
      if (section) {
         poststr = poststr + "&section=" + section;

      }
      makePOSTRequest('tag_detail.php', poststr, 'tag_forum_content');
      document.post_topic.topic.value='';
      document.post_topic.forum_response.value='';
   }
}
function show_content(tag_id, d) {
   url = 'http://' + location.hostname + '/tag_detail.php?d=' + d + '&tag_id=' + tag_id;
   loadDoc(url, "tag_content");
}
function show_your_content(user_logged_in, current_url, tag_id) {
   if (user_logged_in == 1) {
      url = 'http://' + location.hostname + '/tag_detail.php?d=your_content' + '&tag_id=' + tag_id;
      loadDoc(url, "tag_content");
   }
   else {
      location.href="http://" + location.hostname + "/user_admin.php?d=user_login&url=" + current_url;
   }
}
function show_wiki_content(tag_id, d) {
   url = 'http://' + location.hostname + '/tag_detail.php?d=' + d + '&tag_id=' + tag_id;
   //loadDoc(url, "tag_wiki");
   loadDoc(url, "tag_wiki_content");
}
function show_forum_content(tag_id, d) {
   url = 'http://' + location.hostname + '/tag_detail.php?d=' + d + '&tag_id=' + tag_id;
   loadDoc(url, "tag_forum_content");
}
function view_tag_wiki(id) {
   url = 'http://' + location.hostname + '/tag_detail.php?d=view_wiki&id=' + id;
   loadDoc(url, "tag_wikis");
}
function revert_to_this(id, user_logged_in, current_url) {
   if (user_logged_in == 1) {
      url = 'http://' + location.hostname + '/tag_detail.php?d=revert&id=' + id;
      loadDoc(url, "tag_wikis");
   }
   else {
      location.href="http://" + location.hostname + "/user_admin.php?d=user_login&url=" + current_url;
   }
}
function show_wiki_form(user_logged_in, current_url) {
   if (user_logged_in == 1) {
      show('tag_wiki_form');
      hide('tag_wiki');
   }
   else {
      location.href="http://" + location.hostname + "/user_admin.php?d=user_login&url=" + current_url;
   }
}
function show_response_form(tag_forum_id, user_logged_in, current_url) {
   if (user_logged_in == 1) {
      url = 'http://' + location.hostname + '/tag_detail.php?d=response_form&tag_forum_id=' + tag_forum_id;
      loadDoc(url, "tag_forum_content");
   }
   else {
      location.href="http://" + location.hostname + "/user_admin.php?d=user_login&url=" + current_url;
   }
}
function update_wiki(user_logged_in, current_url) {
   if (user_logged_in == 1) {
      var wiki_text = document.getElementById("wiki_text").value;
      wiki_text = new String(wiki_text);
      wiki_text = wiki_text.replace( /^\s+/g, "" );// strip leading
      if (wiki_text == "") {
         alert("Please add wiki content.");
         document.getElementById("wiki_text").focus();
         return false;
      }
      else {
         var poststr = "wiki_id=" + encodeURI( document.getElementById("wiki_id").value ) +
                 "&tag_id=" + encodeURI( document.getElementById("tag_id").value ) +
                 "&wiki_text=" + encodeURIComponent( document.getElementById("wiki_text").value ) +
                 "&d=update_wiki";
         makePOSTRequest('tag_detail.php', poststr, 'tag_wiki_content');
      }
   }
   else {
      location.href="http://" + location.hostname + "/user_admin.php?d=user_login&url=" + current_url;
   }
}
function update_forum_response() {
   var forum_response = document.getElementById("forum_response").value;
   forum_response = new String(forum_response);
   forum_response = forum_response.replace( /^\s+/g, "" );// strip leading
   if (forum_response == "") {
      alert("Please add forum response.");
      document.getElementById("forum_response").focus();
      return false;
   }
   else {
      var poststr = "tag_id=" + encodeURI( document.getElementById("tag_id").value ) +
                 "&tag_forum_id=" + encodeURI( document.getElementById("tag_forum_id").value ) +
                 "&forum_response=" + encodeURIComponent( document.getElementById("forum_response").value ) +
                 "&d=update_forum_response";
      makePOSTRequest('tag_detail.php', poststr, 'tag_forum_content');
   }
}
function view_responses(forum_id) {
   url = 'http://' + location.hostname + '/tag_detail.php?d=view_responses&tag_forum_id=' + forum_id;
   loadDoc(url, "tag_forum_content");
}
