window.addEvent('domready', function() {
	
	// insertion de l'animation flash
	
	var obj = new Swiff('images/mailcube.swf', {
		id: 'filmNexes',
		width: 580,
		height: 420,
		container: "anim-mailcube",
		params: {
			wmode: 'transparent'
		}
	});
	
	
	
	// calculateur du coût annuel du spam en entreprise
	
	function Calc(){
		I01 = $('nb-employes').get('value');
		I02 = $('salaire').get('value');
		I03 = $('nb-emails').get('value');
		I04 = $('pourcent-spams').get('value');
		
		HYPO1 = 5;  	//temps pour supprimer un spam (secondes)
		HYPO2 = 0.001;  //probabilité de tentation
		HYPO3 = 1200;	//temps perdu lors d'une tentation (secondes)
		HYPO4 = 230;	//nb de jours ouvrés
		HYPO5 = 8;	//nb d'heures dans une journée
		HYPO6 = 0.01;	//coût informatique d'un spam
		
		if (I04>100) { I04 = 100; }
		
		C01 = (I04*I03*HYPO1*HYPO4)/(100*3600);
		$('perte-annuelle-employe').set('text', round2(C01)+' heures');
		
		C011 = (I04*I03*HYPO2*HYPO3*HYPO4)/(100*3600);
		$('effet-tentation').set('text', round2(C011)+' heures');
		
		C0111 = C01+C011;
		$('perte-totale-annuelle-employe').set('text', round2(C0111)+' heures');
		
		C01111 = ((I01*I02)/(HYPO4*HYPO5))*C0111;
		$('cout-perte-productivite').set('text', round2(C01111)+' €');
		
		
		C05 = (I03*I04*HYPO6*HYPO4)/100;
		$('cout-info-employe').set('text', round2(C05)+' €');
		
		C06 = C05*I01;
		$('cout-info-total').set('text', round2(C06)+' €');
		C07 = C01111+C06;
		$('total-calculateur').set('text', round2(C07)+' €');
		
		
		$('pourcent-spams').set('value', I04);
	}
	
	function round2(X){
		var T, S = new String(Math.round(X*100))
		while(S.length<3)
		S = '0' + S
		return S.substr(0, T=(S.length-2)) + '.' + S.substr(T, 2)
	}
	
	
	
	$('form-calculateur').addEvent('submit', function(e) {
		e.stop();
		Calc();
		$('resultats-calculateur').setStyle("display", "block");
	});
	
	
});