/** 
* Formation à CWE, exemple 
**/
//PROXY = "proxy.php?url=";
//objet de configuration
config = {
   //activateall: true
   google: true,
   netvibes: true,
   firefoxsidebar: true,
   blog: true,
   facebook: false,
   vista:true,
   iphone:true
}


//when document is loaded
window.addEvent('domready', function () {
	//on charge notre contenu
		CWE.setUrlContent('./content.php');
   	// suppression des onglets		
		$('bookmark').remove();
		//$('mainbutton').remove();
});

window.addEvent('widgetload',function (){
   if(CWE.getPlateform()=="vista" ){   
   		CWE.addContainer({
	   		type: 'expand',
	   		view: normalView
   		});
   		CWE.addContainer({
   			type: 'default',
   			view: vistaView
   		});
   }else{	   
		CWE.addContainer({
			type: 'default',
			view: normalView
		});	
   }
   // replace url google
   CWE.setAdderButtonUrl('button_igoogle','http://www.google.com/ig/adde?source=atgs&moduleurl=pinup.widget-sexy.com/google/pinup.xml');
	 
   CWE.execute();
});

var vistaView = {
	nbImage : 0,
	rep : '',
	images : [],
	current: null,
	
	display: function (){		
		$('tabedit').remove();
		// reception des infos sur le signe
		rep = repWidget+repImage+repStar;
		new Ajax(path_html+'?rep='+rep,{
			'onComplete' : function (response){
				images = response.split("\n");
				nbImage = images.length-1;	
				
				vistaView.afficheImage();
				vistaView.afficheImage.periodical(iTimer);
			}			
		}).request();	
		
	},
	
	afficheImage: function (){
		var random = Math.floor(Math.random() * nbImage)+1;		
		var imgName = images[random];
		while (typeof (imgName) == 'undefined' || imgName == null || imgName == "") {
			random = Math.floor(Math.random() * nbImage)+1;		
			imgName = images[random];
		}
		if(vistaView.current){
			var fx = new Fx.Style(vistaView.current,'opacity',{duration: 900});
			fx.start(0.0);
			vistaView.current.remove.delay(905,vistaView.current);
		}		
		var img = new Element('img').setProperty('src',rep+'/'+imgName).setStyles({
			'margin-top':'2px',
			'margin-left' : '34px',
			'height': '78px',
			'width': '63px',
			'opacity': 0.0
		}).injectInside(CWE.getBody());
		var f = new Fx.Style(img,'opacity',{duration: 900, wait: true, transition: Fx.Transitions.Sine.easeIn});
		f.start.delay(907,f,1.0);
		vistaView.current=img;
	}
} 
 
var normalView = {
	display: function(){
		// taille div display
		var hdisplay = mondisplay; 
		if(window.gecko || window.webkit || window.opera) {
		 	hdisplay = mondisplay;				 	
		} else if(window.ie6 || window.ie7) {
		 	hdisplay = mondisplay-16;
		}				
		
		// affichage de l'iframe &
		// application de la taille contenu dans le fichier ./js/config.js		
		var h = hdisplay-3;
		var w = width;
		if(CWE.getPlateform()=="vista" ){
			hdisplay = 305;
			h = heightVista;
			w = widthVista;
		}else if(CWE.getPlateform()=="google" ){
			hdisplay -= 20;
		}else if(CWE.getPlateform()=="uwa" ){
			hdisplay -= 20;
		}
		
		$('mondisplay').setStyle('height', hdisplay+'px');	
		var date = new Date();
		$('mondisplay').setHTML('<iframe id="ifra" name="ifra" src="iframe.html?plateform='+CWE.getPlateform()+'" style="height:'+h+'px;width:'+w+'px;" frameborder="0"></iframe>');
	} 
}