/* Fonction permettant de vider le champ input passé en paramètre */

function focus_input(input_id){	
		document.getElementById(input_id).value = ''; 
}

function open_url(url){	
		window.location = url ; return false; 
}

$(document).ready(function(){	
	$('#hide_delegation').hide();
	$('#ezcoa-637_choix_contact_1').click( function () {
		$("#hide_delegation").slideDown(300);
	});
	$('#ezcoa-637_choix_contact_0').click( function () {
		$("#hide_delegation").slideUp(300);
	});
	
	$('#hide_advanced').hide();
	$('#show_advanced').toggle( function () {
		$("#hide_advanced").slideDown(300);
	}, function () {
		$("#hide_advanced").slideUp(300);
	}	
	);
	
	$('.infobulle').hide();
	$('.click-infobulle').css("cursor","pointer");
	$('.click-infobulle').toggle( function () {
		$(this).parent().next('.infobulle').slideDown(300);
	}, function () {
		$(this).parent().next('.infobulle').slideUp(300);
	}	
	);
	
	/* librairie : menu gauche filtrage */
	if ($('.cadre-rech').length > 0) {
		$('.cadre-rech #kw').bind('focus', function (){
			if ($(this).val() == 'Nom')	{
				$(this).val('');
			}
		});
		$('.cadre-rech #kw').bind('blur', function (){
			if ($(this).val() == '')	{
				$(this).val('Nom');
			}
		});
	}
	
	
	/* traitements shop userregister : modif affichage champs fonction choix type client */
	if ($('#frm-userregister').length > 0) {
		$('#CustomerType').bind('change', function (){
			select_val = $(this).find('option[@selected]').val();
			if (select_val != undefined && select_val.match(/particulier/i) == null) {
				$('#company-block').show();
			} else {
				$('#company-block').hide();
			}
		});

		/* initialisation de la r�gle qui pr�c�de */
		select_val = $('#CustomerType option[@selected]').val();
		if (select_val != undefined && select_val.match(/particulier/i) == null) {
			$('#company-block').show();
		} else {
			$('#company-block').hide();
		}
	}
	
	/* -------------------------------- études observatoire --------------------------- */
	if ($('#etudes-observatoire').length > 0) {
		/* afficher / masquer la description longue d'une étude */
		
		$('.afficher-corps').bind('click', function (){
			$(this).blur();
			$('#etudes-observatoire .afficher-corps span').text('En savoir plus');
			$('#etudes-observatoire .item').addClass('etude-masquee');
			
			if ($(this.parentNode.parentNode.parentNode).find('.corps').css('display') == 'none') {
				/* masque tous les autres */
				$('#etudes-observatoire .corps').hide();
				$(this.parentNode.parentNode.parentNode).removeClass('etude-masquee');
				$(this.parentNode.parentNode.parentNode).find('.corps').show();
				$(this).find('span').text('Masquer');
			} else {
				/* masque tous les autres */
				$('#etudes-observatoire .corps').hide();
			}
		});
	}
});