
$.fn.antispam = function() {

	// loop through each matched selector  
	this.each(function() {
		$(this).html(
			$(this).html().replace(/\[AT\]/,"@").replace(/\[DOT\]/,".")
			);
		if ($(this).attr('href')) {
		  $(this).attr("href",$(this).attr("href").replace(/\[AT\]/,"@").replace(/\[DOT\]/,"."));
		}
		});  
	return $(this);  
}


$(document).ready(function() {
  $(".email").antispam();

  // setup search-box
  var searchobj = document.getElementById("search");

  // get the search string from the html
  // alert("Have text = "+searchtext);
  

  if (searchobj) {
  var label = searchobj.parentNode.getElementsByTagName("label")[0];
  var searchtext = $(label).text();

  if ((searchobj.value == "")||(searchobj.value==searchtext)) {
  searchobj.className = "dimmed";
  searchobj.value = searchtext;
  }
  searchobj.onclick = function() {
  var thisobj = document.getElementById("search");
  if (thisobj.className=="dimmed") {
  thisobj.value = "";
  thisobj.className = "";
  }
  }
  searchobj.onblur = function() {
  var thisobj = document.getElementById("search");
  if (thisobj.value=="") { // return to dimmed
    thisobj.className = "dimmed";
    thisobj.value = searchtext;
  }
  }
  }

  $(".showpop").click(function() {
      $(this).parent().find(".popblock").css("visibility","visible");

      });
  $(".closepop").click(function() {
      $(this).parents(".popblock").css("visibility","hidden");
      });

  $("#download-link").click(function() {
      
     if ( $("#download-form").length == 0 ) {
        return true;
      }
      if ( $("#download-form").css("display") == "none" ) {
        $("#download-form").css("display", "block");
      } else {
        $("#download-form").css("display", "none");
      }
      return false;
  });

});



