   function switchButton(elementId, currentState) {
      if(currentState == "off") {
         if(document.getElementById(elementId).src.indexOf("graybg") > 0)
		 document.getElementById(elementId).src = "/images/more_button_on_graybg.gif";
	 else
	    document.getElementById(elementId).src = "/images/more_button_on.gif";
      }
      else {
	 if(document.getElementById(elementId).src.indexOf("graybg") > 0)
	    document.getElementById(elementId).src = "/images/more_button_off_graybg.gif";
         else
	    document.getElementById(elementId).src = "/images/more_button_off.gif";
      }
   }
   function switchOnOffButton(element) {
      if(element.src.indexOf("off") > 0) {
         element.src = element.src.replace(/_off/, "_on");
      }
      else {
         element.src = element.src.replace(/_on/, "_off");
      }
   }
   function highlightOn(elementId) {
      elementId.style.backgroundColor="#f9f9f9";
      elementId.style.color="#1a94d3";
   }
   function highlightOff(elementId) {
      elementId.style.backgroundColor="#ffffff";
      elementId.style.color="#1a94d3";
   }
   function gotoPosting(articleId) {
      location.href="http://www.vegtaste.com/php/posting?articleId=" + articleId;
   }
   //function showArticle(param, value) {
      // delete this one after new site is done.
      //if(param == "userId") {
         //location.href="http://www.vegtaste.com/php/archive.php?userId="+value;
      //}
   //}
   function gotoArticle(param, value) {
      // delete this one after new site is done.
      if(param == "userId") {
         location.href="http://www.vegtaste.com/main/archive.php?userId="+value;
      }
   }

   function searchUser(userId) {
      if(userId != "") {
         location.href="http://www.vegtaste.com/main/archive.php?userId="+userId;
      }
   }

   function search() {
      if($('searchInput').value != "") {
         location.href="http://www.vegtaste.com/main/archive.php?searchInput=" + $('searchInput').value;
      }
   }

   function searchArticle() {
      if($('searchInput').value != "") {
         location.href="http://www.vegtaste.com/pages/search.php?searchInput=" + $('searchInput').value;
      }
   }

   function submitSearch() {
      document.searchForm.submit();
   }

   var articleIdToBeRemoved = "";
   function deleteFavorite(articleId) {
      articleIdToBeRemoved = articleId;
      new Ajax.Request("/php/ajax/removeFromFavorites.php", {parameters:'articleId='+articleId, onSuccess:favoritesRemoveHandler, onFailure:errFunc});
   }
   
   function errFunc(t) {
      alert(t);
   }

   function favoritesRemoveHandler(t) {
      alert(t.responseText);
      if(t.responseText.indexOf("Successfully deleted") >= 0) {
         Effect.Fade('article_'+articleIdToBeRemoved);
      }
   }
   function getXmlBlock(stack, needle) {
      var firstIndex = stack.indexOf("<" + needle + ">");
      var secondIndex = stack.indexOf("</" + needle + ">");
      return stack.substring(firstIndex+2+needle.length, secondIndex);
   }
   function gotoURL(url) {
      location.href=url;
   }
   
   function addImgToElement(elementId, url, articleId) {
      document.getElementById(elementId).innerHTML += "<div style='text-align:center;float:left;width:50px;'><a href='/php/uploads/" + url + "' rel='lightbox' title='Full Size Image'><img src='/php/uploads/" + url + "' width='40' height='40' /></a><br /><a href='/pages/posting.php?articleId=" + articleId + "' style='color:#ffffff;' title='Go to article'><img src='/images/spark/blackButton_off.gif' onmouseover='switchOnOffButton(this)' onmouseout='switchOnOffButton(this)' /></a></div>";
   } 


