$(window).load(function() {
	$('#dialog').hide();
	
	if ($('#illustration img').attr('src')=='img/suivre-mon-budget.png') {
		$('#suivre').liquidCanvas("[border{color:rgba(34, 148, 165, 0.95); width:1} gradient{from:rgba(34, 148, 165, 0.95); to:rgba(77, 45, 91, 0.95);}] => roundedRect{radius:10}");
	} else {
		$('#suivre').liquidCanvas("[gradient{from:rgba(34, 148, 165, 0.95); to:rgba(77, 45, 91, 0.95);}] => roundedRect{radius:10}");
	}
	if ($('#illustration img').attr('src')=='img/maitriser-mon-budget.png') {
		$('#maitriser').liquidCanvas("[border{color:rgba(170, 202, 43, 1.0); width:1} gradient{from:rgba(170, 202, 43, 1.0); to:rgba(77, 45, 91, 0.95);}] => roundedRect{radius:10}");
	} else {
		$('#maitriser').liquidCanvas("[gradient{from:rgba(170, 202, 43, 1.0); to:rgba(77, 45, 91, 0.95);}] => roundedRect{radius:10}");
	}
	if ($('#illustration img').attr('src')=='img/corriger-mon-budget.png') {
		$('#corriger').liquidCanvas("[border{color:rgba(186, 70, 240, 1.0); width:1} gradient{from:rgba(186, 70, 240, 1.0); to:rgba(77, 45, 91, 0.95);}] => roundedRect{radius:10}");
	} else {
		$('#corriger').liquidCanvas("[gradient{from:rgba(186, 70, 240, 1.0); to:rgba(77, 45, 91, 0.95);}] => roundedRect{radius:10}");
	}
	if (!$.browser.safari) $('#suivre').children('ul').fadeOut(0);
	if (!$.browser.safari) $('#maitriser').children('ul').fadeOut(0);
	if (!$.browser.safari) $('#corriger').children('ul').fadeOut(0);
	$('#suggestion').liquidCanvas("[border{color:rgba(255, 255, 255, 0.5); width:1} fill{color:rgba(255, 255, 255, 0.1)}] => roundedRect{radius:10}");
	$('#liens').liquidCanvas("[border{color:rgba(255, 255, 255, 0.5); width:1} fill{color:rgba(255, 255, 255, 0.1)}] => roundedRect{radius:10}");
	$('#nav-gauche').liquidCanvas("[border{color:rgba(255, 255, 255, 0.5); width:1} fill{color:rgba(255, 255, 255, 0.1)}] => ecken{tl:10; bl:10; br:0; tr:0}");
	$('#nav-droite').liquidCanvas("[border{color:rgba(255, 255, 255, 0.5); width:1} fill{color:rgba(255, 255, 255, 0.1)}] => ecken{tl:0; bl:0; br:10; tr:10}");
	$('#cigale-ou-fourmi').liquidCanvas("[border{color:rgba(255, 255, 255, 0.5); width:1} fill{color:rgba(255, 255, 255, 1.0)}] => roundedRect{radius:10}");
	$('#cadre').liquidCanvas("[border{color:rgba(255, 255, 255, 0.3); width:2} fill{color:rgba(255, 255, 255, 0.5)}] => roundedRect{radius:10}");
	$('.intro').liquidCanvas("[border{color:rgba(255, 204, 102, 0.8); width:1} fill{color:rgba(255, 204, 102, 0.1)}] => roundedRect{radius:5}");
	$('#nav-gauche').hover(
	   function(){
	   		$(this).stop().animate({right: '10px'},{queue: false, duration: 350});
	}, function(){
	   		$(this).stop().animate({right: '0px'},{queue: false, duration: 0});
	});
	$('#nav-droite').hover(
	   function(){
	   		$(this).stop().animate({left: '10px'},{queue: false, duration: 350});
	}, function(){
	   		$(this).stop().animate({left: '0px'},{queue: false, duration: 0});
	});
	$('#suivre').hover(
    	function(){
    	//$('.dummy').hide();
    	$(this).css('cursor','pointer');
        $(this).stop().animate(
            {height: '192px'},
            {queue: false,
            duration: 300,
            easing: 'easeOutBounce'});
        if (!$.browser.safari) $(this).children('ul').fadeIn(1500);
	}, function(){
    	//$('.dummy').hide();
        $(this).stop().animate(
            {height: '12px'},
            {queue: false,
            duration: 600,
            easing: 'easeOutBounce'});
        if (!$.browser.safari) $(this).children('ul').fadeOut(25);
	});

	$('#maitriser').hover(
    	function(){
    	//$('.dummy').hide();
    	$(this).css('cursor','pointer');
        $(this).stop().animate(
            {height: '324px'},
            {queue: false,
            duration: 300,
            easing: 'easeOutBounce'});
        //$(this).children('ul')
        if (!$.browser.safari) $(this).children('ul').fadeIn(1500);
	}, function(){
    	//$('.dummy').hide();
        $(this).stop().animate(
            {height: '12px'},
            {queue: false,
            duration: 600,
            easing: 'easeOutBounce'});
        if (!$.browser.safari) $(this).children('ul').fadeOut(25);
	});
	
	$('#corriger').hover(
    	function(){
    	//$('.dummy').hide();
    	$(this).css('cursor','pointer');
        $(this).stop().animate(
            {height: '444px'},
            {queue: false,
            duration: 300,
            easing: 'easeOutBounce'});
        if (!$.browser.safari) $(this).children('ul').fadeIn(1500);
	}, function(){
    	//$('.dummy').hide();
        $(this).stop().animate(
            {height: '12px'},
            {queue: false,
            duration: 600,
            easing: 'easeOutBounce'});
        //$(this).children('ul').hide(0)
        if (!$.browser.safari) $(this).children('ul').fadeOut(25);
	});
});
   
// This script uses jQuery to retrieve the news XML file and display the contents
$(document).ready(function(){
	$("#accordion").accordion({ autoHeight: false, active: false, clearStyle: true, collapsible: true, fillSpace: true });
	
	$.ajax({
	    type: "GET",
		url: "lexique.xml",
		dataType: "xml",
		success: function(xml) {
			$(xml).find('item').each(function(){
				var comments = $(this).find('comments').text();
				var title = $(this).find('title').text();
				var description = $(this).find('description').text();
				
				var selector=".bulle[rel='"+comments+"']";
				
				$(selector).qtip({
				   content: {
				   	text: description
				   },
				   show: 'mouseover',
				   hide: 'mouseout', 
				   style: { 
				   	name: 'cream', 
				   	tip: true 
				   }
				});							
			});
		}
	});
				
	$('#rubrique a[rel=lightbox]').lightBox();
	$('#rubrique a[rel=lightbox2]').lightBox();
	
	$("a[href^='http://']").not("a[href^='http://budget.fastt.org']").not("a[href^='http://www.fastt.org']").not("a[href^='http://fastt.org']").click(function(){ 
		window.open(this.href,'external'); 
		return false; 
	});
	$("a[href^='https://']").click(function(){ 
		window.open(this.href,'external'); 
		return false; 
	});
});

function dialogue(titre, message, largeur, hauteur) {
	if (!largeur) largeur = 320;
	if (!hauteur) hauteur = 150;
	$('#dialog').dialog({
		bgiframe: true,
		width: largeur, 
		height: hauteur,
		modal: true,
		title: titre, 
		close: function() {$(this).dialog('destroy')}
	});	
	if (message.length>0) $("#dialog").text(message);
	$("#dialog").dialog('open');
}
