var normalView = {

        display: function (){

                CWE.setUrlContent('./widget.html');

                window.addEvent('widgetload',function (){

                        normalView.correctFooter()

                        $('ongletsoiree').setStyles({

                                'opacity': 1.0,

                                'float' : 'left'

                        })

                        $('ongletactus').setStyles({

                                'opacity': 0,

                                'float' : 'left'

                        })

                        CWE.currentPane = new Element('div');

                        $('mainbutton').remove();

                        CWE._smoothShow($('ongletactus'),200);

                        CWE._smoothShow($('ongletsoiree'),200);

                        $('menusoiree').addClass('active');

                        $$("#menu span").each(function (bouton){

                            //pour les bouton du mini menu, on va afficher les onglets correspondants

                            bouton.addEvent('click',function (){                   

                                    $$('#menuactus,#menusoiree').removeClass('active');

                                    $(bouton).addClass('active'); 

                                    var id = bouton.id.replace('menu','onglet');

                                    //console.debug($(id))

                                    CWE._smoothShow($(id),200);

                            })

                        })



                        CWE.displayReader();

                        $('smenologo').setStyle('cursor','pointer').addEvent('click',function (){

                                window.open('http://www.instantanet-expo.com/')	

                        })



                        var a = '<p>Widget : <a href="http://www.instantanet-expo.com/">Instantanet</a> <br />R&eacute;alisation: <a href="http://www.kreactive-technologies.com">Kreactive Technologies.com</a></p>';



                        var ab = new Element('div').addClass('apropos').setHTML(a);

                        CWE.setAbout(ab);

                        $('aboutboxbutton').injectInside('myabout').setStyles({

                                'margin' : '0',

                                'padding': '2px', 

                                'cursor': 'pointer',

                                'clear': 'none', 

                                'display': 'inline', 

                                'background': 'transparent',

                                'text-decoration' : 'underline'

                        })

                        $('aboutpanel').setStyle('background','#FFF')

                        

                        

                        //trick

                        $$('div').each(function (div){

                                if(div.getStyle('width')=='99%'){

                                        console.debug(div)

                                        div.setStyle('width','100%')

                                }

                        })

                        

                });

                

                

                window.addEvent('widgetrssreaderdisplayed',function (RSS){

                        var colec = "#"+RSS.name+' ';

                        try{

                                $$(colec+'.rssitem .itemenclosure').setStyle('float','left');

                                $$(colec+'.rssitem .itemenclosure').setStyle('width','50px');

                                $$(colec+'.rssitem .itemenclosure img').setStyle('width','47px');

                                $$(colec+'.rssitem .itemlink a').each(function(link){

	                                var t = link.getParent().getParent().getElementsBySelector('.itemtitle')[0];

	                                var d = t.getParent().getElementsBySelector('.itemdate')[0];

	                                var img = t.getParent().getParent().getParent().getElementsBySelector('.itemenclosure img')[0];

	                                img.addEvent('click',function (){

		                                window.open(link)

	                                })

	                                img.setStyle('cursor','pointer')



	                                var date = new Element('div').setHTML(d.getText());

	                                d.remove();

	                                var tt = t.getText()

	                                t.empty();

	                                link.injectTop(t).setText(tt);

	                                date.injectInside(t);

                                })

                        }catch(e){

                                console.log(e)

                        }



                        try{

                                //console.log(RSS.feeds)

                                $$(colec+'.itemdescription').each( function (elem,i){

                                        //console.debug(i)		

                                        normalView.truncate(elem,150,RSS.feeds[i].link);

                                })

                        }catch(e){

                         //console.log(e)

                        }

                });

 

        },

        truncate: function (p,len,link){

                var trunc = p.innerHTML;

                if (trunc.length > len) {

                        trunc = trunc.substring(0, len);

                        trunc = trunc.replace(/\w+$/, '');

                }    

                trunc  += "... " +'<a href="'+link+'" target="_blank">Lire la suite</a>'

                p.innerHTML = trunc;

        },

        

        correctFooter: function (){

                $('shareformular').getParent().setStyles({

                        'overflow': '',

                        'height':'',

                        'background' :'#FFF'

                }).injectAfter('ongletactus');

                

                                

                if(CWE.getPlateform()) {

                        $('sharePanel').setStyles({

                                'overflow':'',

                                'background' :'#FFF'                                

                        }).setStyle('height','').injectAfter('ongletactus');

                }

                //$('footer').getParent().injectAfter($('shareformular').getParent());

                

        }

}


