//
//------------------------------------------------------------------------------------
// Modifications :
//****************
//
// 20/09/2009 par punglas - fonction qui affiche les boites modales avec appel Ajax
// 14/10/2009 par pascal: Ajout du script pour créer un objet console bidon si
//                        celui pour Firebug n'est pas présent.
//------------------------------------------------------------------------------------
//

var trace_evo_active = false;

//
// Crée un objet console bidon si celui pour Firebug n'est pas présent.
// Ca permet de laisser dans le code JS des traces pour Firebug sans se soucier
// de la configuration du navigateur.
//
if (!window.console || !console.firebug)
{
    var names = ["log", "debug", "info", "warn", "error", "assert", "dir", "dirxml",
    "group", "groupEnd", "time", "timeEnd", "count", "trace", "profile", "profileEnd"];

    window.console = {};
    for (var i = 0; i < names.length; ++i)
        window.console[names[i]] = function() {}
}

function trace(message)
{
    if (trace_evo_active)
        console.log(message);
}

// $() is a css selector. First I choose what triggers the event. In this case when  
// you CLICK on a LINK with the js-ajax CLASS. I changed the example to use the live() 
// function so that any javascript-generated html will be binded too instead of click(). 
$('a.js-ajax').live('click', function() { 
    // Now we simply make the ajax call. load($url) will pull the url's VIEW and put it  
    // into ther innerhtml of whatever tag you called load on. In this case, I want to fill  
    // up my #overlayer div with the results of the ajax. 
    document.getElementById("overlayer").innerHTML = 'Chargement en cours';
    $('#overlayer').dialog({
			bgiframe: true,
			height: 140,
			modal: true
		});
    $('#overlayer').load( 
        // Here is the tricky part. Instead of hard-coding a url to pass, I just had jquery  
        // go look at what the link (from the outside scope, .click() part) was already going  
        // to (href) and used that as the argument. 
        $(this).attr('href') 
    , function () { 
        // This is a callback, after the ajax gets loaded, the #overlayer div gets faded in at 300 miliseconds. 
        //$(this).fadeIn(300); 
        $('#overlayer').dialog('destroy');
        $('#overlayer').dialog({
					bgiframe: true,
					modal: true,
					width : 700
				});
        
    }); 
    // And finally to prevent actually making the link go anywhere 
    return false; 
});

$('a.js-ajax-log_window').live('click', function() { 
    // Now we simply make the ajax call. load($url) will pull the url's VIEW and put it  
    // into ther innerhtml of whatever tag you called load on. In this case, I want to fill  
    // up my #overlayer div with the results of the ajax. 
    document.getElementById("overlayer").innerHTML = 'Chargement en cours';
    $('#overlayer').dialog({
			bgiframe: true,
			height: 140,
			modal: true
		});
    $('#overlayer').load( 
        // Here is the tricky part. Instead of hard-coding a url to pass, I just had jquery  
        // go look at what the link (from the outside scope, .click() part) was already going  
        // to (href) and used that as the argument. 
        $(this).attr('href') 
    , function () { 
        // This is a callback, after the ajax gets loaded, the #overlayer div gets faded in at 300 miliseconds. 
        //$(this).fadeIn(300); 
        $('#overlayer').dialog('destroy');
        $('#overlayer').dialog({
					bgiframe: true,
					modal: true,
					width : 700,
					height : 700
				});
        
    }); 
    // And finally to prevent actually making the link go anywhere 
    return false; 
});


