function recherche() {
	document.getElementById('form_saisie').focus();
}

function autohide() {
	if (document.getElementById('form_login') != undefined) {
		document.getElementById('form_login').value = '';
	}
	if (document.getElementById('form_pswd') != undefined) {
		document.getElementById('form_pswd').value = '';
	}
}

window.onload = function () {
	recherche();
	setCategorie();
	setTitleAnnuaire('enfants');
	setAnnuLink();
}

window.onclick = function () {
	autohide();
}


function setCategorie() {
	$('#annuaire-home > div > div > a.ah-fermer').click(function() {
		$(this).parent().fadeOut(500, function() {
			$('#annuaire-home > .visible > div.ah-hide').first().fadeIn(500);
			$('#annuaire-home > .visible > div.ah-hide').first().removeClass('ah-hide');
		});
		return false;
	});
}

function setTitleAnnuaire(annuaire) {
	$('#annuaire-home-title-enfants').html('<a href="#" class="ah-active">enfants</a>').removeClass();
	$('#annuaire-home-title-parents').html('<a href="#" class="ah-active">parents</a>').removeClass();
	$('#annuaire-home-title-enseignants').html('<a href="#" class="ah-active">enseignants</a>').removeClass();
	
	$('#annuaire-home-title-' + annuaire).html(annuaire).addClass('ah-selected');

	$('#annuaire-home > .visible').removeClass('visible').addClass('invisible');
	$('#annuaire-home-' + annuaire).removeClass('invisible').addClass('visible');

	$('#annuaire-home > ul > li > a').click(function() {
        setTitleAnnuaire($(this).html());
        return false;
    });
}

function setAnnuLink() {
	$('a.site-a').click(function() {
		var elemId = $(this).attr('id');
		id = elemId.substr(2, elemId.length);
		
		$.get('/annuaire/hit/' + id);
		
		return true;
	});
}





$(document).ready(function() {
	$('#coin-slider').coinslider({ width: 654, height:248, effect:'rain', navigation: false, delay: 5000, opacity: 0.8, links:true });
});

$(function() {
    $(".toolTip").toolTips();
    $(".toolTipGallery").toolTips( { baseLine:'middle', click:false } );
});
