// site_global_params.js
// fichier javascript avec les paramètres récurrents du site

$(document).ready(function(){
	
	// construit le menu de navigation principal -------------------------------------
    $(".menuvertical li").hover(
			function(){ $("ul", this).fadeIn("fast"); }, 
			function() { } 
		);
    if (document.all) {
        $(".menuvertical li").hoverClass("sfHover");
    }
	// ---- fin

	$("#login_form input[@name=login]").focus(
			function() { if(this.value == 'Votre email') this.value = '';  }
			);
	$("#login_form input[@name=mdp]").focus(
			function() { if(this.value == 'Mot de passe') this.value = '';  }
			);
	$("#login_form").submit(
			function() {
				var formx = $("input[@name=login]",this);
				if(formx.val() == '' || formx.val() == 'Votre email') {
					$(formx).focus();
					return false;
				}
				var formx = $("input[@name=mdp]",this);
				if(formx.val() == '' || formx.val() == 'Mot de passe') {
					$(formx).focus();
					return false;
				}
			});
	
	// construit le form de perte de mot de passe -------------------------------------
    $(".link_passlost").toggle(
			function(){
				$("#link_passlost_form").attr('action','club_votre_compte_actions.php');
				$("#link_passlost_form").slideToggle("slow");
			},
			function(){
				$("#link_passlost_form").slideToggle("fast");
			}
		);
	// ---- fin
	//



	// mini zoom images
	
	$(".zoom_pic").hover(
		function() {
			var original_src 	= $(this).attr('src');
			var original_h		= $(this).height();
			var alt_pic			= $(this).attr('alt');
			var $$ = $(this);
			$(".zoom_pic_preview").remove();		
			
			if(alt_pic != undefined) alt_pic = "<div style='font-size:10px; color:#333333; max-width:250px; text-align:center; border-top:1px #cccccc dotted; padding:5px 10px; font-weight:normal; text-decoration:none;'>"+alt_pic+"</div>";
			else alt_pic = '';
			
			$$.after("<div class='zoom_pic_preview' style='position:absolute; border:1px #cccccc solid; margin:-"+original_h+"px 0 0 150px; display:none; background-color:#ffffff;'><img src='"+original_src+"' />"+alt_pic+"</div>");
			if($(".zoom_pic_preview").width() > 150) {
				
			if($.browser.msie) $(".zoom_pic_preview").css('marginLeft','0px');
					$(".zoom_pic_preview").show();
					$(".zoom_pic_preview").click( function() {
						$(this).hide();				
					});
			}
		},
		function() {
			$(".zoom_pic_preview").remove();
		}
	);



});

$.fn.hoverClass = function(c) {
	return this.each(function(){
		$(this).hover( 
			function() { $(this).addClass(c);  },
			function() { $(this).removeClass(c); }
		);
	});
};

function getelementheight(cherche) {
	var maxh = 0;
	$(cherche).each(function(i){
		var height = $(this).height();
		//alert(height+'/ maxh:'+maxh);
		maxh = Math.max(height,maxh);			
	});
	//alert('maxh:'+maxh);
	return maxh;
}

  