// JavaScript Document
$(function(){
	bindClickables();
});

function bindClickables(){
	if ($.browser.msie) {	
		$(":input[title]").unbind().tooltip({
				track: true,
				delay: 0,
				showURL: false,
				showBody: " - "
		});
	} else {
		$(":input[title]").unbind().tooltip({
				track: true,
				delay: 0,
				showURL: false,
				showBody: " - ",
				fade: 250
		});
	}
	$("input.tags").autocomplete("/ajax/typeahead_tags.php");
	$("input.requiredFunctions").autocomplete("/ajax/typeahead_functions.php");
	$("a.addNew").unbind().click(function(){
		if ($(this).parent().siblings().length > 10) {
			alert ("Please keep entries limited to 10 items");
			return false;		
		}
		var currentLink = $(this);
		$(this).parent().after($(this).parent().parent().find("div").filter(":first").html());
		$(this).end().end().remove();
		bindClickables();
		$(this).parent().next().find("input:first").focus();
		return false;
	});
	$("a.removeCurrent").unbind().click(function(){
		$(this).parent().remove();	
		return false;
	});
}