/*
Copyright (C) 2001 - Linkto.org
*/
function generalAjaxHandler(field,message,onErrorFunction,onSuccessFunction) {
    if (req.readyState == 4 && req.status == 200) {
        var res = req.responseText;
        if (res.indexOf("OK") != -1) {
            onSuccessFunction();
        } else {
            if (onErrorFunction == null) {
		warnField(field);
		alert(message);

            } else {
                onErrorFunction();
		 warnField(field);
		if(message != null) alert(message);
            }
        }
    }
}
function loading(){
	toggleDiv('loadDiv');
	toggleDiv('formSubmit');
}

function validate(string, regexp, err, fieldName) {
    if (string.match(regexp) == null) {
	warnField(fieldName);
	alert(err);
        return false;
    }
    return true;
}

function isValidEmail(a)
{
        var at = a.indexOf("@");
        var name = a.substring(0, at);
        var isp = a.substring(at + 1, a.length);
        var dot = a.lastIndexOf(".");
        if (at == -1 || at == 0 || name == "" || isp == "" || dot == -1 ||
dot== (a.length - 1))
        {
                return false;
        }
        return true;
}

function controllaLunghezzaCampo(text,textLength){
	if(text.length > textLength ){
		return false;
	}
	return true;
}


