/**
 * Lance les fonctions necessaires au chargement de la page
 */ 
var j = jQuery.noConflict();

j(document).ready(function(){
	
    j('input.toClear').inputCleaner();
    j("#nav").horizontalMenu();    
    
    // Gestion des rubriques SearchReports
    j('.sBlocSearchReports .niveau-2').hide();
    j('.sBlocSearchReports .niveau-1 a').click(function(){
        if(j(this).next().is('.niveau-2') == true) {
            if(j(this).parent().is('.actif') == false) {
                fermerRubriques();
            }
            j(this).parent().toggleClass('actif');
            j(this).next().slideToggle('normal');
            return false;
        }
    });
    
    function fermerRubriques() {
        var elements = j('.sBlocSearchReports .niveau-1 a');
        elements.parent().removeClass('actif');
        elements.next().slideUp('normal');
    };
	
	
	// Gestion du process Etape 2
	j('#blocCentre').each(function() {			
		j('#blocCentre .blocFormulaire .radio input[type=radio]').click(function(){
				var attrId = j(this).attr('value');
				if (attrId == 'someoneelse') {
				  j('#blocAccount').slideDown();
				}
				else if (attrId == 'myself') {
				  j('#blocAccount').slideUp();
				}
		});
	});
	
     // Gestion  billing adress
	/*  j('#blocCentre .blocCheckbox').hide(); */
	 j('input[type=checkbox]#checkbox').click(function(){
		if (j('#checkbox').attr('checked') == true) { 
			j('#blocCentre .blocCheckbox').show();
		} 
		else {
			j('#blocCentre .blocCheckbox').hide();
		}
	});

	
	
	
	j('#accountForm, #confirmationForm').submit(function(){
		if (!j('#agreeTerms').attr('checked')) {
			alert('You must accept the terms and conditions.');
			return false;
		}
	});
	
	j('#account_email_confirm').bind('paste', function(){
		return false;
	});

    
});
