//generic prepare ajax links function
//revised 11/04/07
//now includes a class match, 
//for the links to be ajax'd the <a> needs class , this is set when the function is called
//also appends an ajax variable to the url string, this can be checked for at the front end
function prepareAjaxLinks(tagID, tagType, loadInTo, linkClass) {
  if (!document.getElementsByTagName) return false;
  if (!document.getElementById) return false;
  if (!document.getElementById(tagID)) return false;
  var ajaxLinks = document.getElementById(tagID);
  var links = ajaxLinks.getElementsByTagName(tagType);
  
  for ( var i=0; i < links.length; i++) {
    if (links[i].className.match(linkClass)) {
		links[i].onclick = function() {
		if(this.getAttribute('href').indexOf('.php?') != -1){
			//return alert(this.getAttribute('href'));
			return ajaxpage(this + "&ajax=1", loadInTo);
		} else {
			//return alert('no');
			return ajaxpage(this + "?ajax=1", loadInTo);
		}
	 //return ajaxpage(this, loadInTo);

	}
    links[i].onkeypress = links[i].onclick;
  } 
  }
}