	function twAller(_url,_cadre,_target) {
	  if (_cadre) {
		parent._cadre.location.href = _url;
	  } else if (_target) {
		_target = window.open(_url,_target);
	  } else {
		window.location.href = _url;
	  }
	}

	function getCookie(c_name) {
		var i,x,y,ARRcookies=document.cookie.split(";");
		for (i=0;i<ARRcookies.length;i++) {
			x=ARRcookies[i].substr(0,ARRcookies[i].indexOf("="));
			y=ARRcookies[i].substr(ARRcookies[i].indexOf("=")+1);
			x=x.replace(/^\s+|\s+$/g,"");
			if (x==c_name) {
				return unescape(y);
			}
		}
	}
	
	equipe_fav1=getCookie('ck_fav1');
	equipe_fav2=getCookie('ck_fav2');
	
	$(document).ready(function(){
		$('#left_haut h3, #right_haut h3').each( function() {
			//alert(typeof $(this).attr('onclick'));
			if (typeof $(this).attr('onclick') == "function") $(this).append('<img class=\"lien_titre\" src=\"./css/transparent_1x1.png\" />' );
		});
		$('#left_haut h3, #right_haut h3').hover( function() {
			$(this).children('.lien_titre').css('background-position','bottom left');
			$(this).children('.lien_titre').css('background-position','');
		});
		
		init_title = $( '#zone_clic area' ).attr('title');
		init_lien = $( '#zone_clic area' ).attr('href');
		$( '#zone_clic area' ).css({'cursor':'url(../images/home_trans_32.png), pointer'});
		$(window).scroll(function () {
			offset = $(document).scrollTop();
			$( '#lien_logo_BO' ).parent().animate({top:offset+"px"},{duration:400,queue:false},{easing:'swing'});
			if (offset) {
				$( '#zone_clic area' ).css({'cursor':'url(../images/arrow_up_trans_32.png), pointer'}).attr({'title':'Retour en haut de page','href':'#'});
				$( '#top_page' ).attr({'src':'../images/arrow_up_trans.png'});
			}
			else {
				$( '#zone_clic area' ).css({'cursor':'url(../images/home_trans_32.png), pointer'}).attr({'title':init_title,'href':init_lien});
				$( '#top_page' ).attr({'src':'../images/home_trans.png'});
			}
		});
		

		animationBandeau=$( '#bandeauFlash param[name="movie"]' ).attr('value');
		
		$( '#dialog_classement' ).dialog({
			autoOpen: false,
			width:600,
			height:200,
			modal: false,
			buttons: {
				"Valider": function() {
					//alert($( this ).find("form > label").text())
					fav1=$( this ).find("form > label").filter(":eq(0)").attr('for');
					fav2=$( this ).find("form > label").filter(":eq(1)").attr('for');
					//alert("favori 1: "+fav1+"\nfavori 2: "+fav2);
					var date_exp = new Date();
					date_exp.setTime(date_exp.getTime()+(365*24*3600*1000)); // cookie valide 1an
					document.cookie="ck_fav1="+fav1+"; expires="+date_exp.toGMTString();
					document.cookie="ck_fav2="+fav2+"; expires="+date_exp
					.toGMTString();
					$( this ).dialog( "close" );
					window.location.reload(false);
				},
				"Annuler": function() {
					$( this ).dialog( "close" );
				}
			},
			open: function () {
				$( '#bandeauFlash param[name="movie"]' ).attr('value','');
				$( '#bandeauFlash embed' ).attr('src','');
				$( '#def_favoris' )
					.prepend( $( '#def_favoris label:[for="'+equipe_fav2+'"]' ) )
					.prepend( $( '#def_favoris label:[for="'+equipe_fav1+'"]' ) );
				//alert("favori 1: "+equipe_fav1+"\nfavori 2: "+equipe_fav2);
				$( '#def_favoris label' ).miseEnFormeDialogueFavoris();
			},
			close: function () {
				$( '#bandeauFlash param[name="movie"]' ).attr('value',animationBandeau);
				$( '#bandeauFlash embed' ).attr('src',animationBandeau);
			}
		});

		
		$( '#def_favoris' ).buttonset();
		
		$( '#def_favoris' ).sortable({
			update: function(event, ui) {
				$(this).children("label").miseEnFormeDialogueFavoris();
			}
		});
		$( '#def_favoris' ).disableSelection();

	});


	(function($) {
		$.fn.miseEnFormeDialogueFavoris = function() {
			$(this)
				.removeClass("ui-state-active").removeClass("ui-state-default")
				.filter(":eq(0), :eq(1)").addClass("ui-state-active").end()
				.filter(":eq(2), :eq(3)").addClass("ui-state-default").end();
			$(this)
				.css("margin","0")
				.removeClass("ui-corner-all ui-corner-left ui-corner-right")
				.filter(":first").addClass("ui-corner-left").end()
				.filter(":eq(1)").addClass("ui-corner-right").end()
				.filter(":eq(2), :last").addClass("ui-corner-all").css({"margin-left":"22px"}).end();

			return this;
		}
	})(jQuery);

