jQuery.fn.highlight=function(b){function a(e,j){var l=0;if(e.nodeType==3){var k=e.data.toUpperCase().indexOf(j);if(k>=0){var h=document.createElement("span");h.className="highlight";var f=e.splitText(k);var c=f.splitText(j.length);var d=f.cloneNode(true);h.appendChild(d);f.parentNode.replaceChild(h,f);l=1}}else{if(e.nodeType==1&&e.childNodes&&!/(script|style)/i.test(e.tagName)){for(var g=0;g<e.childNodes.length;++g){g+=a(e.childNodes[g],j)}}}return l}return this.each(function(){a(this,b.toUpperCase())})};jQuery.fn.removeHighlight=function(){return this.find("span.highlight").each(function(){this.parentNode.firstChild.nodeName;with(this.parentNode){replaceChild(this.firstChild,this);normalize()}}).end()};

function down(min){
	$('#num_points').val(Math.max(min,parseInt($('#num_points').val())-1));
}

function up(max){
	$('#num_points').val(Math.min(max,parseInt($('#num_points').val())+1));
}

function keyup(min,max){
	var p = $('#num_points').val();
	if(/^\d+$/.test(p)){$('#num_points').val(Math.min(max,Math.max(min,p)));}
	else{$('#num_points').val(min);}
}

function fadeswap(from, to)
{
	$(from+":not("+to+")").fadeOut(function(){$(to).fadeIn();});
	return false;
}

function fadeswapscroll(from, to, scroll)
{
	$(from+":not("+to+")").fadeOut(function(){$(to).fadeIn(function(){$.scrollTo(scroll,1000);});});
	return false;
}

//For hover drop downs
$(document).ready(function() {
	$('li.selectable').hover(
		function () { $(this).children(".menu").show(); },
		function () { $(this).children(".menu").hide(); }
	);
	$('.tab-selected').click(function() { return false; });
	$('.unselectable').click(function() { return false; });
	$.fn.qtip.styles.hp = { width: 300, background: '#fff', padding: 10, color: 'black', textAlign: 'left', border: { width: 6, radius: 0, color: '#aaa' }, tip: 'bottomMiddle', name: 'dark' }
});