var current_page = 'vendredi-1';

$(function()
{
	$.blockUI({ 
        message: msg,
		fadeIn: 1,
        css: { 
            border: 'none', 
            padding: '15px', 
            backgroundColor: '#fff', 
            '-webkit-border-radius': '10px', 
            '-moz-border-radius': '10px', 
            opacity: .5, 
            color: '#000',
			fontSize: '12pt'
        },
		overlayCSS:  { 
			backgroundColor: '#000', 
			opacity: 1
		}
    }); 
	
	$('#menu a, #menu_page a, #logo a, #logo_page a').click(function() {
		$.blockUI({ 
            message: null,
			fadeIn: 700,
			overlayCSS:  { 
				backgroundColor: '#000', 
				opacity: 1
			}
        }); 
		setTimeout('document.location="'+this.href+'"', 800); 
		return false;
	});
	
	$('h3 a').click(function() {
		var page = this.className;
		$('#'+current_page).slideUp(function() {
			$('#'+page).slideDown();
			current_page = page;
		});
	});
	$('#programme a').click(function() {
		var page = this.className;
		if(current_page.indexOf('vendredi') != -1) { var page2 = 'vendredi'; }
		if(current_page.indexOf('samedi') != -1) { var page2 = 'samedi'; }
		if(current_page.indexOf('dimanche') != -1) { var page2 = 'dimanche'; }
		
		$('#programme .'+page2+'-1').removeClass('current');
		$(this).addClass('current');
		$('#'+current_page).slideUp(function() {
			$('#'+page).slideDown();
			current_page = page;
		});
	});
	
	$('input[name="envoyer"]').click(function()
	{
		$.post('index.php',{ action:'envoi', nom:$('input[name="envoyer"]').val(), prenom:$('input[name="prenom"]').val(), societe:$('input[name="societe"]').val(), telephone:$('input[name="telephone"]').val(), email:$('input[name="email"]').val(), message:$('textarea[name="message"]').val() }, function(data) {
			$('#text').html(data);
		});
		return false;
	});
});

function showIndexElements()
{
	$('#logo').show('drop', { direction: 'down' }, 1500);	
	$('#date').show('drop', {}, 1200);
	
	setTimeout('showIndexMenu()',1500);
}

function showIndexMenu() {
	$('#menu').fadeIn('slow');
}

function showPageElements()
{
	$('#logo_page').show('drop', { direction: 'down' }, 1500);	
	$('#date_page').show('drop', {}, 1200);
	
	setTimeout('showPageMenu()',1500);
	setTimeout('showPageText()',1500);
}

function showPageMenu() {
	$('#menu_page').fadeIn('slow');
}

function showPageText() {
	$('#text').slideDown();
}

window.onload = function() {
	if(page == 'index') {
		setTimeout('showIndexElements()',500);
	}
	else {
		setTimeout('showPageElements()',500);
	}
	$('#loading').fadeOut('slow');
	$.unblockUI();
};