$(document).ready(function(){
/* chemin de l'habillage
------------------------------------------------------------------------------*/

	var cheminImg = "ui/default/images/orange/";		// Valeur par defaut
	if ($("#notre_catalogue img:first").attr("src"))
	{
		chemin = $("#notre_catalogue img:first").attr("src").split("/")[2];		/* calcul a partir de la 1ere image du menu gauche */
		// recherche du chemin complet des images
		var firstImagePath = $("#notre_catalogue img:first").attr("src");
		if ( firstImagePath != null && firstImagePath.lastIndexOf("/") > 0) {
			cheminImg = firstImagePath.substring(0, firstImagePath.lastIndexOf("/")+1);
		}
	}
	else
	{
		var chemin = ".";																		/* chemin par defaut */	
	}
	
/* options de formulaire
------------------------------------------------------------------------------*/
	$("#abonnements .colonne.centre form .bloc").hide();									/* affichage des formulaires en fonction des options cochees */
	$("#abonnements .colonne.centre form input").each(function(){
		if($(this).attr("name") == "motif")
		{
			if(this.checked){
				
				$(this).parents("p").next(".bloc").show();
				
			}
			$(this).click(function(){
				validator.removeAll();
				YAHOO.util.Event.removeListener("buttonSend", "click");
				$("#abonnements .colonne.centre form .bloc").slideUp();
				if(this.checked){
					var from = this.id.substr(this.id.indexOf(".")+1)
					
					$(this).parents("p").next(".bloc").slideDown("normal",function(){
						addCoordonnesRules();
						addRulesTab[from].call();
					});
					
					
				}
			});
		}
	});
	$("#abonnements .colonne.centre form .temporaire").hide();
	if($("#changement_temporaire").length)
	{
		if($("#changement_temporaire")[0].checked)
		{
			$("#abonnements .colonne.centre form .temporaire").show();
			$("#abonnements .colonne.centre form span.temporaire").prev("span").hide();
		}
	}
	$("#abonnements .colonne.centre form input").each(function(){
		if($(this).attr("name") == "adresse.definitif")
		{
			$(this).click(function(){
				//if($("#adresse.definitif")[0].checked)
				if(document.getElementById('adresse.changement_temporaire').checked)
				{
					$("#abonnements .colonne.centre form span.temporaire").show();
					if($.browser.msie)
						$("#abonnements .colonne.centre form div.temporaire").show();
					else
						$("#abonnements .colonne.centre form div.temporaire").slideDown();
					$("#abonnements .colonne.centre form span.temporaire").prev("span").hide();
				}
				else
				{
					$("#abonnements .colonne.centre form span.temporaire").hide();
					if($.browser.msie)
						$("#abonnements .colonne.centre form div.temporaire").hide();
					else
						$("#abonnements .colonne.centre form div.temporaire").slideUp();
					$("#abonnements .colonne.centre form span.temporaire").prev("span").show();
				}
			});
		}
	});



/* PNG fix
------------------------------------------------------------------------------*/
	$(document).pngFix();
	$("a").each(function(){																			/* correctif IE6 */
		if($(this).children("img").length)
			$(this).css("zoom","1");
	});
	/*$(".submit span").each(function(){															
		if($(this).css("filter").length)
		{
			$(this).click(function(){
				$(this).parents("form").submit();
				this.blur();
				return(false);	
			});
		}
	});*/
/* zebra
------------------------------------------------------------------------------*/
	$(".zebra tbody tr:odd").addClass("odd");													/* zebra tableau */
/* boutons
------------------------------------------------------------------------------*/
	$(".bouton img").each(function(){															/* rollover boutons */
		$(this).hover(function(){
			$(this).attr("src",$(this).attr("src").replace("_off","_on"));
		},function(){
			$(this).attr("src",$(this).attr("src").replace("_on","_off"));
		});
	});
	/* rollover boutons sous IE6 */
	/*if(document.all){
		$(".bouton").each(function(){															
			$(this).hover(function(){
				$(this).find("span").css("filter",$(this).find("span").css("filter").replace("_off","_on"));
			},function(){
				$(this).find("span").css("filter",$(this).find("span").css("filter").replace("_on","_off"));
			});
		});
	}	*/
	$("input.bouton").each(function(){															/* rollover boutons formulaires */
		$(this).hover(function(){
			$(this).attr("src",$(this).attr("src").replace("_off","_on"));
		},function(){
			$(this).attr("src",$(this).attr("src").replace("_on","_off"));
		});
	});
	/* rollover boutons formulaires sous IE6 */
	/*
	$(".submit").each(function(){															
		$(this).hover(function(){
			$(this).css("filter",$(this).css("filter").replace("_off","_on"));
		},function(){
			$(this).css("filter",$(this).css("filter").replace("_on","_off"));
		});
	});*/
/* panier
------------------------------------------------------------------------------*/
	$("#onglet_panier").hover(function(){
		$(this).addClass("hover");
		if(!$.browser.opera)
		{
			$(this).children("div").hide();
			$(this).children("div").slideDown("slow");
		}
	},function(){
		$(this).removeClass("hover");
		if(!$.browser.opera)
		{
			$(this).children("div").slideUp("slow");
			$(this).children("div").show();
		}
	});
/* champs textes
------------------------------------------------------------------------------*/
	$("input.text").each(function(){																/* gestion des champs preremplis */
		if($(this).attr("title"))
		{
			var title = $(this).attr("title");
			if($(this).val() == "")
			{
				$(this).val(title);
				$(this).addClass("title");
			}
			$(this).focus(function(){
				if($(this).val() == title)
				{
					$(this).val("");
					$(this).removeClass("title");
				}
			});
			
		}
	});
/* flash
------------------------------------------------------------------------------*/
	/* */
	/*$("#abonnements_cadeaux .flash").flash({			*/										/* abonnement dans le menu droit */
	/*	src:"ui/default/flash/abonnements_cadeaux.swf",*/
	/*	width:178,*/
	/*	height:179,*/
	/*	wmode:"transparent"						*/													/* pour supperposer ce flash et le rendre transparent */
	/*	},{*/
	/*		version:8*/
	/*	}*/
	/*);*/

	
});
