function enableSend(param) {
    var btn = $('formSubmit');

    if (param == 1) {
        btn.disabled = false;
    } else {
 	btn.disabled = true;
    }
}


function FaqToggleBlock(containerId, elementId, iconId, openImage, closeImage, openText, closeText) {
    //effetti per la visualizzazione
    var objElement = $(elementId);
    var objOpenIco = $(iconId);

    Effect.toggle(objElement,'slide');

    if (objElement.visible()) {
        $(containerId).ancestors()[0].removeClassName('faqOpen');
        objOpenIco.writeAttribute({ title : openText });
        objOpenIco.update("<img src='" + openImage + "' alt='+' />");
    } else {
        $(containerId).ancestors()[0].addClassName('faqOpen');
        objOpenIco.writeAttribute({ title : closeText});
        objOpenIco.update("<img src='" + closeImage + "' alt='-' />");
    }

    return false;
}


function searchGlossarioEntry(currentLink,url) {
    var objElement = $('glossaryWrapper');

    new Ajax.Request(url, {
        method: 'post',
        onSuccess: function(transport) {
            objElement.fade({
	        duration: 1.0,
		afterFinish: function(){
                    objElement.update(transport.responseText);
                    //rimuovo la classe del link selezionato al vecchio link
                    $$(".currentCategory").each(function(el) {
                        el.removeClassName("currentCategory");
                    });
                    //aggiungo la classe del link selezionato
                    Element.addClassName(currentLink,"currentCategory");
		    objElement.appear({ duration: 1.0 });
		}
            });
        },
        onFailure: function(transport) {
            objElement.fade({
	        duration: 1.0,
		afterFinish: function(){
                    objElement.update("Si &egrave; verificato un errore durante l\'invio della richiesta.");
                    //rimuovo la classe del link selezionato al vecchio link
                    $$(".currentCategory").each(function(el) {
                        el.removeClassName("currentCategory");
                    });
                    //aggiungo la classe del link selezionato
                    Element.addClassName(currentLink,"currentCategory");
		    objElement.appear({ duration: 1.0 });
		}
            });
        }
    });

    return false;
}


function searchNewsByYear(currentFrm,url) {
    var objElement = $('newsWrapper');
    var objYear = $('query_formIdY');

    new Ajax.Request(url + '?query=' + objYear.value + '-', {
        method: 'post',
        parameters : Form.serialize(currentFrm,true),
        onSuccess: function(transport) {
            objElement.fade({
	        duration: 1.0,
		afterFinish: function(){
                    objElement.update(transport.responseText);
		    objElement.appear({ duration: 1.0 });
		}
            });
        },
        onFailure: function(transport) {
            objElement.fade({
	        duration: 1.0,
		afterFinish: function(){
                    objElement.update("Si &egrave; verificato un errore durante l\'invio della richiesta.");
		    objElement.appear({ duration: 1.0 });
		}
            });
        }
    });

    return false;
}

function searchNewsByKey(currentFrm,url) {
    var objElement = $('newsWrapper');


    new Ajax.Request(url, {
        method: 'post',
        parameters : Form.serialize(currentFrm,true),
        onSuccess: function(transport) {
            objElement.fade({
	        duration: 1.0,
		afterFinish: function(){
                    objElement.update(transport.responseText);
		    objElement.appear({ duration: 1.0 });
		}
            });
        },
        onFailure: function(transport) {
            objElement.fade({
	        duration: 1.0,
		afterFinish: function(){
                    objElement.update("Si &egrave; verificato un errore durante l\'invio della richiesta.");
		    objElement.appear({ duration: 1.0 });
		}
            });
        }
    });

    return false;
}


function searchGlossarioByKey(currentFrm,url) {
    var objElement = $('glossaryWrapper');

    new Ajax.Request(url, {
        method: 'post',
        parameters : Form.serialize(currentFrm,true),
        onSuccess: function(transport) {
            objElement.fade({
	        duration: 1.0,
		afterFinish: function(){
                    objElement.update(transport.responseText);
                    //rimuovo la classe del link selezionato al vecchio link
                    $$(".currentCategory").each(function(el) {
                        el.removeClassName("currentCategory");
                    });
		    objElement.appear({ duration: 1.0 });
		}
            });
        },
        onFailure: function(transport) {
            objElement.fade({
	        duration: 1.0,
		afterFinish: function(){
                    objElement.update("Si &egrave; verificato un errore durante l\'invio della richiesta.");
                    //rimuovo la classe del link selezionato al vecchio link
                    $$(".currentCategory").each(function(el) {
                        el.removeClassName("currentCategory");
                    });
		    objElement.appear({ duration: 1.0 });
		}
            });
        }
    });

    return false;
}


function searchPhotoGalleryByCat(url,category) {
    var objElement = $('photoGalleryWrapper');
    url = category != "" ? (url + '&query=Post.userDefined1 = "' + category + '"') : (url + '&query=');

    new Ajax.Request(url, {
        method: 'post',
        onSuccess: function(transport) {
            objElement.fade({
	        duration: 0.7,
		afterFinish: function(){
                    objElement.update(transport.responseText);
		    objElement.appear({ duration: 0.7 });
                    //reset shadowBox
                    Shadowbox.clearCache();
                    Shadowbox.setup();
		}
            });
        },
        onFailure: function(transport) {
            objElement.fade({
	        duration: 0.7,
		afterFinish: function(){
                    objElement.update("Si &egrave; verificato un errore durante l\'invio della richiesta.");
		    objElement.appear({ duration: 0.7 });
                    //reset shadowBox
                    Shadowbox.clearCache();
                    Shadowbox.setup();
		}
            });
        }
    });

    return false;
}


function ajaxRequest(goBackUrl,remoteUrl) {
    new Ajax.Request(remoteUrl, {
        method: 'get'
    });

    location.href = goBackUrl;
}
