jQuery.noConflict(); // Oh prototype, you served us well but are no longer the best.

// Makes a case insensative verions of ":contains"
jQuery.extend(jQuery.expr[':'], {
	"icontains"	: "(a.innerText||a.innerHTML).toUpperCase().indexOf(m[3].toUpperCase())>=0"
}); 

// Stuff to do when the DOM is ready
jQuery(document).ready(function(){
	var jq = jQuery; // Less to type = good

	//sort the survey links
	jq('#surveys a').sort(mySortAlpha).appendTo('#surveys');	
	
	// let them filter easier onload
	jq('#survey-filter').focus();

	// filter for survey links
	jq("#survey-filter").keyup(function() {
		jq("#surveys")
			.find("a").hide().end()
			.find("a:icontains('"+ jq("#survey-filter").val() +"')").show();
	});
	
	//Print page links
	jq("a.print-link")
		.attr("href", "#")
		.click(function() {
			window.print()
		});



 
}); // document.ready

jQuery.fn.sort = function() {
	   return this.pushStack( [].sort.apply( this, arguments ), []);
	 };
	
function mySortAlpha(a,b){
		//console.log(a.innerHTML.innerHTML);
		return a.innerHTML > b.innerHTML ? 1 : -1;
};