﻿var vsp,vsptimer,sig,sigtimer;
$(document).ready(function(){
	var ids=((location.hostname.indexOf(".fr")>0)?0:1),idns=((ids==1)?0:1);
	var pied=$("#bas_de_page");
	var fourl=$(".footer_url",pied),w=$("a",fourl.eq(1)).outerWidth();
	vsp=$("<div style=\"position:absolute;width:"+w+"px;height:0;overflow:hidden;left:0\"></div>");
	var vs=$("<div style=\"border-top:3px solid #d20606;background:#fff;\"></div>");
	sig=vsp.clone();
	var si=vs.clone();
	vs.append(fourl.eq(idns));
	vs.append(fourl.eq(ids).clone());
	vs.html(vs.html().replace(/\|/gi,""));
	vsp.append(vs);
	$("a",vs).css({width:w+"px"});
	$(".footer_url",vs).css({"float":"none"}).hover(function(){
		clearTimeout(vsptimer);
	},
	function(){
		vsptimer=setTimeout("clo()",1000);
	});
	fourl.eq(ids).hover(function(){
		clearTimeout(vsptimer);
		clearTimeout(sigtimer);
		clog();
		vsp.stop().animate({marginTop:"-42px",height:"35px"},300);
	},
	function(){
		vsptimer=setTimeout("clo()",1000);
	});
	$(".left",pied).prepend(vsp);
	
	w=$("a",fourl.eq(4)).outerWidth();
	sig.css({width:w+"px",left:fourl.eq(ids).outerWidth()+"px",zIndex:"99"});
	for(var i=2;i<8;i++) si.append(fourl.eq(i));
	si.append(fourl.eq(8).clone());
	si.html(si.html().replace(/\|/gi,""));
	sig.append(si);
	$("a",si).css({width:w+"px"});
	$(".footer_url",si).css({"float":"none"}).hover(function(){
		clearTimeout(sigtimer);
	},
	function(){
		sigtimer=setTimeout("clog()",1000);
	});
	fourl.eq(8).hover(function(){
		clearTimeout(sigtimer);
		clearTimeout(vsptimer);
		clo();
		sig.stop().animate({marginTop:"-106px",height:"99px"},300);
	},
	function(){
		sigtimer=setTimeout("clog()",1000);
	});
	$(".left",pied).prepend(sig);
    $(window).resize(checkFooter);
	checkFooter();
});
var clo=function(){
	vsp.stop().animate({marginTop:0,height:0},300);
}
var clog=function(){
	sig.stop().animate({marginTop:0,height:0},300);
}
var checkFooter = function(){
    var _b=$("#bas_de_page");
    var bd=$("body");
    var _c=$("#ctnr");
    var _wn=$(window);
	var flp=$("#flaPlayer");
	var mxw=800,mxh=480;
	var wdw=_wn.width(), wdh=_wn.height(),wf=((wdw<mxw)?mxw:wdw),hf=((wdh<mxh)?mxh:wdh);
	if(flp.attr("id")){
	flp.css({width:wf+"px",height:hf+"px"});
	bd.css({width:wf+"px",height:hf+"px"});
	_b.css({width:bd.width()+"px"});
	}
    var _h=-_b.outerHeight();
    var _h1=_c.height(),_h3=wdh;
	if(location.hash=="#debug"){
		if(flp.attr("id")) _h1=mxh;
	}
	_b.css("top",(_h1<_h3)?_h3+_h:"auto");
}