var vistaView = {
	/* variables */
	i:0,
	index:0,
	max:0,
	arrayimg:[],
	/** debut fonctions **/
	display: function() {
		$('tabedit').remove();
		// chargement des Rss		
		getRssVista();
		getRssVista.periodical(timerRefreshArticle);	
	}
}
var normalView = {
	/* variables */
	slideimg : [],
	slideindex : [],
	/** debut fonctions **/
	// chargement du template
	display: function() {
		try{
		
			/* FEEDVALUE */
			// no tracking of blog as the presentation page contains a blog version
			if(CWE.target!="blog")
				var fv = new FeedValue("FV-0016-01-0001",{platform:CWE.target,dontWaitOnload:true});
			
			// Tabbar's style : GOOGLE Campaign
			if(CWE.setTabBarStyle) CWE.setTabBarStyle('igoogle')		
			// onglet a propos
			CWE.setAbout($('divapropos'));
			if(!$('cloneheader')){
				var cloneH = $('header').clone().injectTop($('divapropos')).removeClass('header');
				cloneH.id = 'cloneheader';
			}
			var location = window.location.protocol+'//'+window.location.hostname;
			var url = racine.replace(/(http:\/\/)/g,"");
			url += "/";
			url = url.replace(/(\/)/g,"_cwe_slashes_");
			$('firefox').setProperty('onclick','javascript:window.sidebar.addPanel("'+document.title+'","'+location+'/index.php/cwe/ffsidebar/'+url+'","")');
			$('facebook').setProperty('href','http://apps.facebook.com/figaroscope');					
			$('iGoogle').setProperty('href','http://www.google.com/ig/adde?source=atgs&moduleurl=widget.scope.lefigaro.fr/google/figaroscope.xml');
			$('netvibes').setProperty('href','http://www.netvibes.com/subscribe.php?uwa='+location+'/index.php/cwe/uwa/'+url);
			$('vista').setProperty('href',location+'/index.php/cwe/desktop/vista?widget='+racine);
			$('iPhone').setProperty('href',location+'/index.php/cwe/iphone/'+url);
			// ajout d'action sur les images		
			$$('.fgimg').addEvent('click',function(){
				normalView.precedent(this.id);
			});
			$$('.fdimg').addEvent('click',function(){
				normalView.suivant(this.id);
			});			
			/*$$('.fdimg').each(function (el){
				el.addClass("isclickable");
			})*/
			$$('.fgimg').setStyle('opacity','0.3');			
			$$('.fdimg').setStyle('opacity','0.3');				
			// ajustement des elements
			if( window.ie6||window.ie7 && CWE.getPlateform()!="vista" ){
				$$('.fg').each(function (el){
					el.setStyles({
						'width':'32px'
					});
				});
				$$('.fd').each(function (el){
					el.setStyles({
						'width':'32px'
					});
				});
				$$('.divslide').each(function (el){
					el.setStyles({
						'padding-top':'5px'
					});
				});			
			}
			if( window.webkit ){
				$$('.slideinfo').each(function (el){
					el.setStyles({
						'width':'149px'
					});
				});
				$$('.slide').each(function (el){
					el.setStyles({
						'padding-top':'3px'
					});
				});
			}
			if( CWE.getPlateform()=='vista' ){
				$$('.slide').each(function (el){
					el.setStyles({
						'margin':'5px 0px 0px 10px'
					});
				});
			}
			if( CWE.getPlateform()=='iphone' ){
				$$('.slideinfo').each(function (el){
					el.setStyles({
						'width':'125px'
					});
				});
			}
			// chargement des Rss
			getRss();
			getRss.periodical(timerRefreshArticle);		 
		}catch (e){}
	},
	// naviguation des signes
	precedent: function(id){			
		var index = id.substring(2,id.length);
		if (!$('fg'+index).hasClass('isclickable')) return;
		normalView.slideindex[index].i = normalView.slideindex[index].i.toInt()-1;
		normalView.setImg(index);
	},
	suivant: function(id){
		var index = id.substring(2,id.length);
		if (!$('fd'+index).hasClass('isclickable')) return;
		normalView.slideindex[index].i = normalView.slideindex[index].i.toInt()+1;
		normalView.setImg(index);
	},
	// changement du signe
	setImg: function (index) {		
		if( normalView.slideindex[index].i > 0 ){
			$('fg'+index).setStyle('opacity', 1.0);
			$('fg'+index).addClass('isclickable')
		}else{
			$('fg'+index).setStyle('opacity', 0.3);
			$('fg'+index).removeClass('isclickable')
		}
		if( normalView.slideindex[index].i < normalView.slideimg[index].length-1 ){
			$('fd'+index).setStyle('opacity', 1.0);
			$('fd'+index).addClass('isclickable')
		}else{
			$('fd'+index).setStyle('opacity', 0.3);
			$('fd'+index).removeClass('isclickable')
		}
		
		if( CWE.getPlateform()!='iphone' ){
			normalView.smoothShow(index,500);
		}else{
			changeImg(index,normalView.slideindex[index].i);
		}				
	},
	smoothShow: function(index,delay){
		delay /= 2		
		
		var fx = new Fx.Style('slideinfo'+index,'opacity',{
			duration: delay,
			wait: false
		});
		
		var fx2 = new Fx.Style('slide'+index,'opacity',{
			duration: delay,
			wait: false
		});
		fx.start(0)
		fx2.start(0)
		fx.start.delay(delay,fx,1)
		fx2.start.delay(delay,fx2,1)
		changeImg.delay(delay,this,[index,normalView.slideindex[index].i]);
	}
}
