/*
* jQuery form values
*/
(function($){$.fn.example=function(text,args){var isCallback=$.isFunction(text);var options=$.extend({},args,{example:text});return this.each(function(){var $this=$(this);if($.metadata){var o=$.extend({},$.fn.example.defaults,$this.metadata(),options);}else{var o=$.extend({},$.fn.example.defaults,options);}if(!$.fn.example.boundClassNames[o.className]){$(window).unload(function(){$("."+o.className).val("");});$("form").submit(function(){$(this).find("."+o.className).val("");});$.fn.example.boundClassNames[o.className]=true;}if($.browser.msie&&!$this.attr("defaultValue")&&(isCallback||$this.val()==o.example)){$this.val("");}if($this.val()==""&&this!=document.activeElement){$this.addClass(o.className);$this.val(isCallback?o.example.call(this):o.example);}$this.focus(function(){if($(this).is("."+o.className)){$(this).val("");$(this).removeClass(o.className);}});$this.blur(function(){if($(this).val()==""){$(this).addClass(o.className);$(this).val(isCallback?o.example.call(this):o.example);}});});};$.fn.example.defaults={className:"example"};$.fn.example.boundClassNames=[];})(jQuery);

jQuery(document).ready(function($) {
	jQuery('article input.text').example('Mon nom');
	jQuery('article textarea.text').example('Ma grande idée en 120 caractères...');
	jQuery('body > footer').fadeIn(1000);
	
	if(jQuery("#pi").length>0){
		var idiot = parseInt(jQuery("#idiot").html());
		var contro = parseInt(jQuery("#controversial").html());
		var prog = parseInt(jQuery("#progressive").html());
		var obvious = parseInt(jQuery("#obvious").html());
		
		var numbers = new Array();
		var labels = new Array(); 
		if(idiot > 0){
			numbers.push(idiot);
			labels.push('Idiot ('+idiot+'%)');
		}
		if(contro > 0){
			numbers.push(contro);
			labels.push('Controversé ('+contro+'%)');
		}
		if(prog > 0){
			numbers.push(prog);
			labels.push('Progressiste ('+prog+'%)');
		}
		if(obvious > 0){
			numbers.push(obvious);
			labels.push('Évidente ('+obvious+'%)');
		}
		var pi = new RGraph.Pie('pi', numbers); // Create the pie object
	    pi.Set('chart.labels', labels);
	    pi.Set('chart.shadow', false);
	    pi.Set('chart.colors', ['#aaa','#bbb','#ccc','#ddd']);
	
	    pi.Set('chart.labels.sticks', true);
	    pi.Set('chart.linewidth', 3);
	    pi.Set('chart.highlight.style', '2d'); 
	    pi.Set('chart.text.font','Droid Sans');
	     
	    pi.Set('chart.title.vpos', 0);
		pi.Set('chart.title.hpos', 0);
	    pi.Draw();
	}
});


