Array.prototype.in_array = function(search_term) {
  var i = this.length;
  if (i > 0) {
	 do {
		if (this[i] === search_term) {
		   return true;
		}
	 } while (i--);
  }
  return false;
}

//function to call prototype ajax for each subject load
function callAjaxUpdater(parent, subjectId){
	
	var elements = parent.getElementsByTagName('ol');
	if(elements.length){
		var removed = $('ajaxed').remove();
	} else {

		if(document.getElementById('ajaxed')){
			var removed = $('ajaxed').remove();
		}

		//use the prototype ajax methods to insert a new list item
		var container = parent;
		var url = 'get_items_by_subject.php?subject='+subjectId;

		new Ajax.Updater(container, url, {
			insertion: Insertion.Bottom	
		});

	}

	return false;
}

//show other essays in this category
function changeToggleLink(){
	var heading = document.getElementById('explore_other_heading');
	if(heading.className =="smaller close"){
		new_class = "smaller open";
	} else {
		new_class = "smaller close";
	}

	heading.className = new_class;
}
function showEssays(){
	if(Effect){
		Effect.toggle('other_essay_holder', 'slide', {afterFinish:changeToggleLink});
		return false;
	} else {
		return true;
	}
}

function thisMovie(movieName) {
	var isIE = navigator.appName.indexOf("Microsoft") != -1;
	return (isIE) ? window[movieName] : document[movieName];
}


