var initHelpers = function () {
	var theTips = $$("div.form-tip");
	var theForms = $$("form.huge");
	
	if(theForms.length > 0){
		theForms.each(function(theForm){
			if (theForm.hasClassName("hoverable")){
				theForm.removeClassName('hoverable');
			}
		});
		
		if(theTips.length > 0){
			buildTips(theTips);
			theTips[0].style.display = "block";
			theTips[0].up().select('input, textarea, select')[0].focus();
		}
	}	
}

var addHelpers = function(parent) {
	var theTips = parent.select("div.form-tip");
	buildTips(theTips);
}

var buildTips = function (theTips) {
	if(theTips.length > 0){
		theTips.each(function(theTip){
			if(theTip.hasClassName("permanent")){return false;}
			var theInputs = theTip.up().select('input, textarea, select');
	
			theInputs.each(function(theInput){
				if (theInput.tagName == "SELECT") {
					theTip.up().addClassName('shallow');
				}
				
				theInput.observe('focus', function(ev){
					theTip.style.display = "block";
				});
				
				theInput.observe('blur', function(ev){
					theTip.style.display = "none";
				});
			});
		});
	}
}

document.observe('dom:loaded', initHelpers);