function getAjax(url,pars,idSucess){
    var ajax = new  Ajax.Updater(
    {
        success: idSucess
    },
    url,
    {
        method: 'post',
        parameters: pars,
        onLoading: cargando(idSucess),
        onFailure: errorAjax,
        evalScripts: true
    });
}

function cargando(idSucess){
    document.getElementById(idSucess).innerHTML = 'Cargando...';
}

function errorAjax(){
    alert('Se produjo un error al cargar, intente nuevamente.');
}

var anchoModal = 580;
function getAjaxModal(url, pars, ancho){
	anchoModal = ancho;
    var myAjaxModal = new  Ajax.Updater(
    {
        success: 'msjModal'
    },
    url,
    {
        method: 'post',
		parameters: pars,
        onLoading: cargandoModal,
        onFailure: errorAjax,
        onComplete: cargadoModal,
        evalScripts:true
    });
}

function cargandoModal(){
    document.getElementById("imagenMapa").style.cursor='wait';
}

function cargadoModal(){
    tiempoEspera = true;
    document.getElementById("imagenMapa").style.cursor='pointer';
    tiempoEspera = false;
    openDialog('msjModal', anchoModal);
}

function getAjaxDiv(url,pars,idSucess){
    var myAjax = new  Ajax.Updater(
    {
        success: idSucess
    },
    url,
    {
        method: 'post',
        evalScripts:true,
        parameters: pars,
        onLoading: cargandoDiv(idSucess),
        onFailure: errorAjax()
    });
}

function cargandoDiv(idSucess){
    document.getElementById(idSucess).innerHTML = '<img src="../img/ajax-loader.gif">';
}

function getAjaxHTML(idSucess, html){
    var myAjax = new  Ajax.Updater(
    {
        success: idSucess
    },
    '',
    {
        method: 'post',
        evalScripts:true,
        onLoading: cargandoHTML(idSucess),
        onComplete: cargadoHTML(idSucess, html),
        onFailure: errorAjax
    });
}

function cargandoHTML(idSucess){
    document.getElementById(idSucess).innerHTML = '<img src="./img/ajax-loader.gif"> Cargando...';
}

function cargadoHTML(idSucess, html){
    document.getElementById(idSucess).innerHTML = html;
}

