SelecteurCanal.prototype = {
    setOnClick: function() {
	var courant = this;
	this.canal.onclick = function() {
	    if(document.getElementById('widgetblog')){
		var element = document.getElementById('widgetblog');
		document.getElementById('page').removeChild(document.getElementById('widgetblog'));
	    };
	    courant.createLecteurRSS(courant.idCanal, courant.nomCanal,'TXT');
	};
    },

    createLecteurRSS: function(idCanal, nom, type){
	new LecteurRSS(idCanal, nom, type);
    }
}

function SelecteurCanal(idCanal, nom){
    this.canal = document.getElementById(idCanal);
    this.idCanal = idCanal;
    this.nomCanal = nom;
    this.canal.style.cursor = "pointer";
    this.setOnClick();
}

SelecteurCanal.prototype.constructor = SelecteurCanal;

LecteurRSS.prototype = {
    createHTMLBox: function() {
	this.parent = document.getElementById("page");
	this.boite = document.createElement("div");
	this.boite.id = "widgetblog";
	this.header = document.createElement("div");
	this.header.innerHTML = this.nomCanal;
	this.body = document.createElement("div");
	this.body.className = "corps";
        this.boite.appendChild(this.header);
	this.boite.appendChild(this.body);
	this.parent.appendChild(this.boite);
    },

    populateLecteur: function(){
	this.header.className = "entete";
	this.askCanal(this.body, this.type);
    },

    askCanal: function(visualisateur, type){
	moteur = new Moteur("idElement="+encodeURIComponent("blog")+"&type="+encodeURIComponent("Widgets")+"&idURL="+this.id+"&typeRep="+encodeURIComponent(type), visualisateur, type);
    }    
}

function LecteurRSS(idCanal, nom, type){
    this.id = idCanal.replace('fil_','');
    this.nomCanal = nom;
    this.type = type || 'TXT';
    this.createHTMLBox();
    this.populateLecteur();
    new BoxComplete("widgetblog");
}

LecteurRSS.prototype.constructor = LecteurRSS;
