$(window).load(function() {
	$('#dialog').hide();
	$("img[name^='dessin']").each(function(){
		$(this).addClass($(this).attr('name').substr(7, 6));
		$(this).css("width",$('#accordion').width()*0.5);
	});
	if ($('#illustration img').attr('src')=='img/louerunlogement.rechercher.png') {
		$('#rechercher').liquidCanvas("[border{color:rgba(255, 255, 255, 0.95); width:2} gradient{from:rgba(38, 177, 290, 0.95); to:rgba(30, 65, 127, 0.95);}] => roundedRect{radius:10}");
	} else {
		$('#rechercher').liquidCanvas("[border{color:rgba(255, 255, 255, 0.5); width:1} gradient{from:rgba(38, 177, 290, 0.95); to:rgba(30, 65, 127, 0.95);}] => roundedRect{radius:10}");
	}
	if ($('#illustration img').attr('src')=='img/louerunlogement.signer-le-bail.png') {
		$('#signer-le-bail').liquidCanvas("[border{color:rgba(255, 255, 255, 0.95); width:2} gradient{from:rgba(38, 177, 290, 0.95); to:rgba(30, 65, 127, 0.95);}] => roundedRect{radius:10}");
	} else {
		$('#signer-le-bail').liquidCanvas("[border{color:rgba(255, 255, 255, 0.5); width:1} gradient{from:rgba(38, 177, 290, 0.95); to:rgba(30, 65, 127, 0.95);}] => roundedRect{radius:10}");
	}
	if ($('#illustration img').attr('src')=='img/louerunlogement.demenager.png') {
		$('#demenager').liquidCanvas("[border{color:rgba(255, 255, 255, 0.95); width:2} gradient{from:rgba(38, 177, 290, 0.95); to:rgba(30, 65, 127, 0.95);}] => roundedRect{radius:10}");
	} else {
		$('#demenager').liquidCanvas("[border{color:rgba(255, 255, 255, 0.5); width:1} gradient{from:rgba(38, 177, 290, 0.95); to:rgba(30, 65, 127, 0.95);}] => roundedRect{radius:10}");
	}
	if ($('#illustration img').attr('src')=='img/louerunlogement.faire-face-aux-difficultes.png') {
		$('#faire-face-aux-difficultes').liquidCanvas("[border{color:rgba(255, 255, 255, 0.95); width:2} gradient{from:rgba(38, 177, 290, 0.95); to:rgba(30, 65, 127, 0.95);}] => roundedRect{radius:10}");
	} else {
		$('#faire-face-aux-difficultes').liquidCanvas("[border{color:rgba(255, 255, 255, 0.5); width:1} gradient{from:rgba(38, 177, 290, 0.95); to:rgba(30, 65, 127, 0.95);}] => roundedRect{radius:10}");
	}
	if ($('#illustration img').attr('src')=='img/louerunlogement.quitter.png') {
		$('#quitter').liquidCanvas("[border{color:rgba(255, 255, 255, 0.95); width:2} gradient{from:rgba(38, 177, 290, 0.95); to:rgba(30, 65, 127, 0.95);}] => roundedRect{radius:10}");
	} else {
		$('#quitter').liquidCanvas("[border{color:rgba(255, 255, 255, 0.5); width:1} gradient{from:rgba(38, 177, 290, 0.95); to:rgba(30, 65, 127, 0.95);}] => roundedRect{radius:10}");
	}
	if (!$.browser.safari) $('#rechercher').children('ul').fadeOut(0);
	if (!$.browser.safari) $('#signer-le-bail').children('ul').fadeOut(0);
	if (!$.browser.safari) $('#demenager').children('ul').fadeOut(0);
	if (!$.browser.safari) $('#faire-face-aux-difficultes').children('ul').fadeOut(0);
	if (!$.browser.safari) $('#quitter').children('ul').fadeOut(0);
	$('#suggestion').liquidCanvas("[border{color:rgba(255, 255, 255, 0.5); width:1} fill{color:rgba(82, 149, 154, 0.5)}] => roundedRect{radius:10}");
	$('#information').liquidCanvas("[border{color:rgba(255, 255, 255, 0.5); width:1} fill{color:rgba(120, 105, 131, 0.5)}] => roundedRect{radius:10}");
	$('#liens').liquidCanvas("[border{color:rgba(255, 255, 255, 0.5); width:1} fill{color:rgba(255, 228, 101, 0.2)}] => roundedRect{radius:10}");
	$('#nav-gauche').liquidCanvas("[border{color:rgba(255, 255, 255, 0.5); width:1} fill{color:rgba(30, 65, 127, 0.7)}] => 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(30, 65, 127, 0.7)}] => ecken{tl:0; bl:0; br:10; tr:10}");
	$('#quizz-logement').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}");
	//$('#cadre').liquidCanvas("[border{color:rgba(255, 255, 255, 0.5); width:1} fill{color:rgba(255, 255, 255, 0.1)}] => 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});
	});
	$('#rechercher').hover(
    	function(){
    	//$('.dummy').hide();
    	$(this).css('cursor','pointer');
        $(this).stop().animate(
            {height: '365px'},
            {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);
	});
	$('#signer-le-bail').hover(
    	function(){
    	//$('.dummy').hide();
    	$(this).css('cursor','pointer');
        $(this).stop().animate(
            {height: '290px'},
            {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);
	});
	$('#demenager').hover(
    	function(){
    	//$('.dummy').hide();
    	$(this).css('cursor','pointer');
        $(this).stop().animate(
            {height: '240px'},
            {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);
	});
	$('#faire-face-aux-difficultes').hover(
	    	function(){
	    	//$('.dummy').hide();
	    	$(this).css('cursor','pointer');
	        $(this).stop().animate(
	            {height: '210px'},
	            {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);
		});
		$('#quitter').hover(
	    	function(){
	    	//$('.dummy').hide();
	    	$(this).css('cursor','pointer');
	        $(this).stop().animate(
	            {height: '210px'},
	            {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);
		});
});
   
$(document).ready(function(){
	$("#accordion").accordion({ autoHeight: false, active: false, clearStyle: true, collapsible: true, fillSpace: true });
	if ($("#accordion > h3").length==1) {
		$("#accordion").accordion("activate", 0);
	}
	$("a[href^='http://']").not("a[href*='fastt.org']").click(function(){ 
		window.open(this.href,'external'); 
		return false; 
	});
	$("a[href^='https://']").click(function(){ 
		window.open(this.href,'external'); 
		return false; 
	});
	
	$(".sheet").each(function() {
		var id=$(this).attr("name");
		$.ajax
		({
		type: "GET",
		url: "sheet.php",
		data: "id="+id,
		cache: false,
		success: function(result)
		{
			$(".sheet[name="+id+"]").html(result);
		}
		});
	});
	
	$("a.bulle").each(function() {
		var id=$(this).attr("rel");
		$.ajax
		({
		type: "POST",
		url: "lexique.php",
		data: "id="+id,
		cache: false,
		success: function(result)
		{
			$("a.bulle[rel="+id+"]").qtip({
				content: {
					text: result
				},
				show: 'mouseover',
				hide: 'mouseout', 
				style: { 
					name: 'cream', 
					tip: true 
				}
			});
		}
		});
	});
	
});

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');
}

