var syntaxColor='#888'; //couleur des suggestion de formulaire

// abbr
abbr('FFE', "Fédération Française d'Escrime")
abbr('LDM', 'Lames du Marais')

// liens externe
$("a[href^='http']").attr("target","_blank")

// afficher title
$("[title]").tooltip({ 
	    track: true, 
	    delay: 0,
			showURL: false,
	    fade: 250 
	});

// confirmation
$("a[href*='?del=']").attr("onclick","return confirm('Etes-vous sur de vouloir supprimer votre inscription ?\\nSi vous souhaitez juste ne plus vous voir figurer ici, décochez \"se souvenir de moi\" dans la 4ème page du formulaire d\\'inscription.')")
//XXX: incompatible IE 6 

// etape1
$("input[@value='JJ/MM/AAAA']").css({	color:syntaxColor });
$("input[@value='JJ/MM/AAAA']").bind("click focus", function(){
		if (this.value=='JJ/MM/AAAA')
		{
			this.value='';
			$(this).css({	color:"black"	});
		}
 });
$("input[@value='JJ/MM/AAAA']").bind("blur", function(){
		if (this.value=='')
		{
			this.value='JJ/MM/AAAA';
			$(this).css({	color:syntaxColor	});
		}
 });
// etape2
$("input[name='changePrix']").parent().hide();
$("#codeReduc").bind("keypress", function(){
		$("input[name='changePrix']").parent().show();
 });
 
if ($("#buyAllInOne1").length && $("#buyAllInOne1").attr('checked')==true) $("#aLaCarte").hide();
$("#buyAllInOne0, #buyAllInOne1").bind("change focus", function(){
		if ($("#buyAllInOne0").attr('checked')==true) $("#aLaCarte").show();
		else $("#aLaCarte").hide();
 });

 
// etape4
neededTo("#xpRecons, #xpSport, #xpClub", "#xpDescription")
neededTo("#xpSport", "#xpCombat")
neededTo("#xpEscrime", "#xpOlympique, #xpArtistique, #xpMedieval")
neededTo("#xpOlympique, #xpArtistique, #xpMedieval", "#xpLDM, #xpClub")
neededTo("#xpRecons, #xpGN, #xpSport, #xpLDM, #xpClub", "#xpPast, #xpPeu, #xp5ans")
neededTo("#xpPast, #xpPeu, #xp5ans", "#xpLoisir, #xpCompet")
neededTo("#xpCompet", "#xpNationale, #xpInternationale, #xpMaitre")



// attire l'attention sur l'ancre active
focusId('',2)
$("a[@href*='#']").bind("click focus", function(){
	focusId(this.href.split('#')[1], 2)
 	});

// image survol
$("div.miniatures").hover(function() {
			var url = $("img", this).attr('src').replace('.mini', '.big');
			$('#theBigOne').attr('src',url);
			return '';
	});









//functionsPerso

function neededTo(needed, toShow)
{
	if (!$(needed).is('[@checked]')) $(toShow).parent().hide();
	$(needed).bind("change focus blur", function(){
			if ($(needed).is('[@checked]')) $(toShow).parent().show();
			else $(toShow).parent().hide();
		});
}
function abbr(bref, detail)
{
	if (navigator.appName != "Microsoft Internet Explorer" && document.location.href.split('admin').length != 2)
	{
		myRegExp = new RegExp('\>([^\>\<]*)'+bref+'([^\>\<]*)\<','g');
	
		document.body.innerHTML = document.body.innerHTML.replace(myRegExp, function(){
				return '>'+RegExp.$1+'<abbr title="'+detail+'">'+bref+'</abbr>'+RegExp.$2+'<';
			});
	}
}
function focusId(ancre,iter)
{
	if (!ancre) ancre = document.location.href.split('#')[1];
	if (ancre)
	{
		var monAncre = $('#'+ancre)
/*		var pClass = monAncre.parent().attr('class')
		if(pClass=='clair' || pClass=='fonce' || pClass=='clair warningNoBold' || pClass=='fonce warningNoBold')
		{
			monAncre = $('#'+ancre).parent()
		}*/
		if (!monAncre.attr('orgClass'))
		{
			monAncre.attr('orgClass', monAncre.attr('class'))
		}
		monAncre.attr('class',monAncre.attr('orgClass')+' warningNoBold')
		setTimeout('blurId("'+ancre+'",'+(iter-1)+')',250);
	}
}
function blurId(ancre,iter)
{
	var monAncre = $('#'+ancre)
/*	var pClass = monAncre.parent().attr('class')
	if(pClass=='clair' || pClass=='fonce' || pClass=='clair warningNoBold' || pClass=='fonce warningNoBold')
	{
		monAncre = $('#'+ancre).parent()
	}*/
	monAncre.attr('class', monAncre.attr('orgClass'))
	if(iter) setTimeout('focusId("'+ancre+'",'+iter+')',250);
}
