// Utils
function getBusy(name) {
    busy_element = $(".busy[for='" + name +"']");
    if (!(busy_element.length > 0)) {
        $("input[name='" + name +"']").after("<label for='" + name +"' class='busy'></label>");
        busy_element = $(".busy[for='" + name +"']");
    }
    return busy_element;
}

function showBusy(name) {
    getBusy(name).show();
}

function hideBusy(name) {
    getBusy(name).remove();
}

function showDefaultAjaxError(name, validator) {
    errors = new Array()
    errors[name] = "Error, please try again.";
    
    hideBusy(name);
    validator.showErrors(errors);
}

// All forms
function bindForm() {
	$(".shift > input").focus(function () {
        var container = $(this).parent();
        container.css({'background-position' : '0px -33px'});
	    $(this).css({'color' : '#292929'});
	});
	$(".shift > input").blur(function () {
        var container = $(this).parent();
        container.css({'background-position' : '0px 0px'});
	    $(this).css({'color' : '#fff'});
	});
    $(".shift input").keydown(function () {
        error_label = $("label[class='error'][for='" + $(this).attr("id") + "']");
        if (error_label.length > 0)
            error_label.remove();
	});
}
