/**
 * Appel du coeur de JSON.
 */
document.write('<script type="text/javascript" src="/scripts-v57/view/json/jsonrpc_ah.js"></script>');


var core = Array();
//********************************************************************************
// Cette fonctionnalite permet de charger des objets javascripts, declares dans
// des fichiers annexes, et qui s'ajoutent au tableau core.
// Sur le onload le tableau est parcouru, et les methode getBeans, initJSON, 
// Et rewrite sont appelee.
// Les objets ajoutes dans le core doivent avoir le prototype suivant:
// var MyJsonObject = {
//     variable: null,
//     
//     getBeans: function() {
//         return "MyViewBeanObject;";
//     },
//     
//     initJSON: function() {
//         var num;
//     	try {
//         	for( num in beans){
//                 if("MyViewBeanObject" == beans[num].nom) {
//                     variable = beans[num].bean;
//             	}
//             }
//         } catch(e) {
//     		alert(e);
//     	}
//     }, 
//     
//     //
//     // Dear agencies, Write your code here.
//     //
//     rewrite: function() {
//         // Your code here ...
//     }
// }
// 
// core.push(MyJsonObject);
//********************************************************************************

      Event.observe(window, 'load', function () {pushOnLoad();});      
      Event.observe(document, 'rewrite:load', function () {pushOnLoad();});

function pushOnLoad() {    
    if(core.length>0) {
        var beanNames = "";
        for(var i=0;i<core.length;i++) {
            beanNames=beanNames+core[i].getBeans()+";";
        }        
        initBeanList(beanNames);
        updateView(null, "", beanToLoad);
    }
}

//********************************************************************************
// Cette methode est appelee lors de la mise a jour du JSON par la methode
// updateView().
//********************************************************************************
function rewriteView() {
    for(var i=0;i<core.length;i++) {
        core[i].initJSON();
        core[i].rewrite();  
    }
}

function Bean(nom, bean) {
    this.nom = nom;
    this.bean = bean;
}
