
	


	//preps a file name minus #anchors and the path from webroot
	url = document.URL;
	lastpos = (url.lastIndexOf("#")!=-1) ? url.lastIndexOf("#") : url.length;
	docname = url.substring(url.lastIndexOf("\/")+1,lastpos);



 	/*Ajax.Responders.register({
		onCreate: function(){
			$("pageStatus").show();
		},
		onComplete: function(){
			$("pageStatus").hide();
		}
	});*/
	
	
	function CheckRequiredFields(form){
		
		var review = new Array("fname","lname","dept","class","comments");
		var reviewReadable = new Array("Author's First Name","Author's Last Name","Department","Class","Comments");
  		var	book = new Array("price","email","condition","dept","class");
		var	bookReadable = new Array("Price","Email","Condition","Deptartment","Class");
		var fields = null;

		if(form == "book"){
			fields = book;
		} else {
			fields = review;
		}

		for(var i=0; i < fields.length;i++){
			//alert(fields[i]);
			if(document.getElementById(fields[i]).value == ""){
				alert("Please fill out the '" + eval(form + "Readable[i]") + "' field.");
				return false;
			}
		}
	
		return true;
	}

	


	function fillForm(item){
	
		text = item.innerHTML;
		var comma = text.indexOf(",");
		var car1 = text.indexOf("<");
		var car2 = text.indexOf(">");
		var car3 = text.indexOf("<",car2);
	
		var fn = text.slice(comma+2,car1);
		var ln = text.slice(0,comma);
		var id = text.slice(car2+1,car3);
	
		if(fn.substr(0,1) == ' '){
			fn = fn.slice(1,fn.length);
		}
	
 		$('fname').value=fn;
		$('lname').value=ln;


		$('exists').value=id;
		location=docname+"#step2";
	}

	last = null;

	function showProfs(x){
	
		if(docname.search("professors")!=-1){
			document.getElementById("prof_reviews").innerHTML = "";
		}
	
		if(eval(last)){
			last.display = "none";
			last.height = "0";
		}
		
		
		
		var x = document.getElementById("as_"+x.toUpperCase()).style;
		x.display = "block";
		x.height = "auto";
	
		last = x;
	
		location=docname+"#step1";
	}
	
	//review
	
	last_p=null;

	function getReview(prof,id){
		
		new Ajax.Updater('prof_reviews', 
						'ajax_reviews.php', 
			{
				parameters: {pid: id},
				onSuccess:function(){
					$("loading").style.display="none";
					$("loading").style.height="20px;"
				}
			}
		);
		if(last_p!=null){$(last_p).removeClassName('selected');}
		$(prof).addClassName('selected');
		last_p = prof;
		
		$("loading").style.display="block";
	}
	
	
	

		
	
	