var URL_url = window.location.toString();

function sendUrlToFlash(){
	return URL_url;
}

function playIdSong(id){
	var fo = $('mp3player');
	fo.playSong(id);
}

function openCloseAlb(d){
	var dp = d.parentNode;
	dp = dp.parentNode;
	if(dp.offsetHeight==52){
		dp.style.height='auto';
		dp.style.backgroundPosition='0 100%';
		d.className='panierclosealbum';
	} else {
		dp.style.height='30px';
		dp.style.backgroundPosition='0 51px';
		d.className='panieropenalbum';
	}
}

var _FLASHMENUX,_FLASHMENUY,_DEROULH;
var _DDEROUL=0;
var _DEROULRUN=false;

onload=function(){
	/*
	_FLASHMENUX = pxLeft('menuH');
	_FLASHMENUY = pxTop('menuH');
	//alert(_FLASHMENUX+" "+_FLASHMENUY);
	
	for(var i=0,j=_COLO.length;i<j;i++){
		var col1 = getRGBCol(_COLO[i]);
		var col2 = getRGBCol(_COLF[i]);
		_COLON[i]=col1;
		_COLD[i]=new Array();
		for(var k=0;k<3;k++) _COLD[i].push(col2[k]-col1[k]);
	}
	Init_Menu_FX();
	_DEROULH = $('deroul').offsetHeight;
	//alert(_FLASHDIM[0]+' '+_FLASHDIM[1]);
	var w= $('deroul').offsetWidth;
	$('deroul').style.height = '0px';
	//$('deroul').style.left = ((_FLASHMENUX+161) - (w/2))+'px';
	//$('deroul').style.top = (_FLASHMENUY+33)+'px';
	var m = $('menuH');
	m.className = 'menujs';
	var lis = m.getElementsByTagName('li');
	$('deroul').style.left = (pxLeft(lis[1]))+'px';
	//$('deroul').style.top = (pxTop(lis[1])+30)+'px';
	for(var i=0,j=lis.length-1;i<j;i++){
		createMenuH(lis[i]);
	}
	*/
}

function showPart(nb){
	var as = $('footpartliste').getElementsByTagName('a');
	for(var i=0,j=as.length;i<j;i++){
		$('part'+as[i].name).style.display = 'none';
	}
	$('part'+nb).style.display = 'block';
}


var _menumvmt;
var _menuox = 0;
var _menuow = 0;
var _menufx = 0;
var _menufw = 0;
var _menuduration = 700;
var _menutimer = 0;
var _menuspeed = 25;

var _deroulmvmt;
var _deroulspeed = 0.25;

function createMenuH(d){
	d.onmouseover = function(){
		//if(this.innerHTML.indexOf('artistes')>0) showDefil();
		//else hideDefil(255);
		clearInterval(_menumvmt);
		var b = $('back');
		_menuow = b.offsetWidth;
		_menuox = b.offsetLeft;
		_menufw = this.offsetWidth - _menuow;
		_menufx = this.offsetLeft - _menuox;
		_menutimer = 0;
		_menumvmt = setInterval('moveMenuH2()',_menuspeed);
	};
}

function easeOutBack(x, t, b, c, d, s) {
	if (s == undefined) s = 1.70158;
	return c*((t=t/d-1)*t*((s+1)*t + s) + 1) + b;
	
}

function moveMenuH2(){
	_menutimer += _menuspeed;
	var x = _menutimer / _menuduration;
	var t = (1-x)*-1;
	var mw = easeOutBack(x, _menutimer, _menuow, _menufw, _menuduration);
	var mx = easeOutBack(x, _menutimer, _menuox, _menufx, _menuduration);
	var d = $('back');
	d.style.width = Math.floor(mw)+'px';
	d.style.left = Math.floor(mx)+'px';
	if(_menutimer == _menuduration) clearInterval(_menumvmt);
}

function showDefil(x){
	var lis = $('menuH').getElementsByTagName('li');
	$('deroul').style.left = (pxLeft(lis[1]))+'px';
	_DEROULRUN=true;
	//_deroulmvmt = setInterval('deroulon()',_deroulspeed);
	affDeroul();
}

function deroulon(){
	_DDEROUL += 0+(0.25*(_DEROULH-_DDEROUL));
	$('deroul').style.height = Math.round(_DDEROUL)+'px';
	if(Math.round(_DDEROUL)>=_DEROULH) clearInterval(_deroulmvmt);
}

function affDeroul(){
	//alert('bb');
	if(_DEROULRUN && Math.round(_DDEROUL)<_DEROULH){
		_DDEROUL += 0+(0.25*(_DEROULH-_DDEROUL));
		$('deroul').style.height = Math.round(_DDEROUL)+'px';
		setTimeout('affDeroul();',20);
	}
}

function hideDefilChk(e){
	if (!e) var e = window.event;
	var tg = (window.event) ? e.srcElement : e.target;
	tg = $('deroul');
	if (tg.nodeName != 'DIV') return;
	var reltg = (e.relatedTarget) ? e.relatedTarget : e.toElement;
	while (reltg != tg && reltg.nodeName != 'BODY'){
		reltg= reltg.parentNode;
	}
	if (reltg== tg) return;
	hideDefil();
}


function hideDefil(x){
	if(x!=255){
		//alert('ou');
	}
	_DEROULRUN = false;
	cacheDeroul();
}

function cacheDeroul(){
	//alert('bb');
	if(!_DEROULRUN && Math.round(_DDEROUL)>0){
		_DDEROUL += 0+(0.25*(0-_DDEROUL));
		$('deroul').style.height = Math.round(_DDEROUL)+'px';
		setTimeout('cacheDeroul();',20);
	}
}

var Li;var LiObj=[];
function Init_Menu_FX(){Li=$('deroulul').getElementsByTagName('li');for(var i=0,j=Li.length;i<j;i++){LiObj[i]=new CLi(i);}}

var _COLO=['fafafa','fafafa','fafafa','fafafa','fafafa','fafafa','fafafa','fafafa','fafafa','fafafa'];
var _COLF=['7C4005','000000','CB5601','010A42','D50000','2A420B','09A3CF','0000ff','0000ff','0000ff'];
//var _COLF=['AB845E','5B5B5B','DE925C','5C6185','E45B5B','768562','0000ff','0000ff','0000ff','0000ff'];
var _COLD=[]; // valeur de 0 à 255 stocké séparement
var _COLON=[]; // pareil mais converti depuis _COLO

function CLi(i)
{	
	this.i=i;
	this.obj=Li[i];
	var ad = Li[i].getElementsByTagName('a');
	this.obj.lien = ad[0];
	this.obj.that = this;
	this.c=238;
	this.dc=0;
	this.run=false;
	this.col1=Li[i].col1;
	this.obj.style.backgroundColor="RGB("+_COLON[this.i].join(',')+")";
	//alert(this.col1);
	this.obj.onmouseover=function(){this.that.run=true;LiObj[this.that.i].over();};
	this.obj.onmouseout=function(){this.that.run=false;LiObj[this.that.i].out();};
}

CLi.prototype.over=function(){
	if(this.run&&this.dc<1){
		this.dc=Math.min((this.dc+0.05),1);
		var tc = new Array();
		for(var i=0;i<3;i++) tc.push(Math.round(_COLON[this.i][i]+_COLD[this.i][i]*this.dc));
		this.obj.style.backgroundColor="RGB("+tc.join(',')+")";
		var g=Math.round(255*this.dc);
		this.obj.lien.style.color="RGB("+g+","+g+","+g+")";
		setTimeout("LiObj["+this.i+"].over();",20);
	}
}

CLi.prototype.out=function(){
	if(!this.run&&this.dc>0){
		this.dc=Math.max((this.dc-0.03),0);
		var tc = new Array();
		for(var i=0;i<3;i++) tc.push(Math.round(_COLON[this.i][i]+_COLD[this.i][i]*this.dc));
		this.obj.style.backgroundColor="RGB("+tc.join(',')+")";
		var g=Math.round(255*this.dc);
		this.obj.lien.style.color="RGB("+g+","+g+","+g+")";
		setTimeout("LiObj["+this.i+"].out();",20);
	}
}

var _LASTANNSHOW=-1;

function showAnnonce(nb){
	if(_LASTANNSHOW>=0){
		$('ann'+_LASTANNSHOW).style.display='none';
	}
	$('ann'+nb).style.display='block';
	_LASTANNSHOW=nb;
}

function setZoom(img, dir, width, height, margin, zIndex, delay) {
  setTimeout(function() {
    if (img.dir==dir) {
      if(zIndex==10 && dir=='rtl') img.src = $('imgzoom'+img.alt).src;
      if(zIndex==9 && dir=='ltr') img.src = $('imgsmall'+img.alt).src;
	  img.style.width=width;
      img.style.height=height;
      img.style.margin=margin;
      img.style.zIndex=zIndex;
    }
  }, delay);
}

function larger(img, width, height, fact) {
	
	
  img.dir='rtl';
  var widthf=(width*fact)-width;
  var heightf=(height*fact)-height;
  var now=parseInt(img.style.zIndex);
  for(var i=now+1; i<=10; i++) {
	
    var w = (width + widthf*i/10)+'px';
    var h = (height + heightf*i/10)+'px';
	var m=(-i)+'px 0 0 '+(-widthf/2*i/10)+'px';
    setZoom(img, 'rtl', w, h, m, i, 20*(i-now));
  }
  
}

function smaller(img, width, height, fact) {
	img.dir='ltr';
  var widthf=(width*fact)-width;
  var heightf=(height*fact)-height;
  now=parseInt(img.style.zIndex);
  for(i=now-1; i>=0; i--) {
    var w = (width + widthf*i/10)+'px';
    var h = (height + heightf*i/10)+'px';
	//alert('small w='+w+' h='+h+' i='+i);
    var m=(-i)+'px 0 0 '+(-widthf/2*i/10)+'px';
    setZoom(img, 'ltr', w, h, m, i, 20*(now-i));
  }
}

function agendahomeover(d){
	d.style.backgroundColor = '#eeeeee';
}

function agendahomeout(d){
	d.style.backgroundColor = 'transparent';
}

function agendahomeclick(d,agendaurl){
	location.href=agendaurl;
	return false;
}

function addsmiley(s){
	$('comment').value += ' '+s;
}

var _loginbarmvmt;
var _loginbarduration = 700;
var _loginbartimer = 0;
var _loginbarspeed = 25;

function toggleLoginBarDisplay(){
	clearInterval(_loginbarmvmt);
	//_menumvmt = setInterval('moveMenuH2()',_menuspeed);
	//alert($('loginbarre').style.top);
	if(parseInt($('loginbarre').style.top)==-30) {
		_loginbartimer = _loginbarduration;
		_loginbarmvmt = setInterval('moveLoginBar2()',_loginbarspeed);
	}
	else _loginbarmvmt = setInterval('moveLoginBar1()',_loginbarspeed);
	//alert(parseInt($('loginbarrebg').style.top));
}

function moveLoginBar1(){
	_loginbartimer += _loginbarspeed;
	var x = _loginbartimer / _loginbarduration;
	var t = (1-x)*-1;
	var mh = easeOutBack(x, _loginbartimer, 0, 185, _loginbarduration);
	//var d = $('loginbarrebg');
	$('loginbarre').style.top = Math.floor(-215+mh)+'px';
	//$('loginbarrecontentbg').style.top = Math.floor(-185+mh)+'px';
	if(_loginbartimer >= _loginbarduration) clearInterval(_loginbarmvmt);
}

function moveLoginBar2(){
	_loginbartimer -= _loginbarspeed;
	var x = _loginbartimer / _loginbarduration;
	var t = (1-x)*-1;
	var mh = easeOutBack(x, _loginbartimer, 0, 185, _loginbarduration);
	//var d = $('loginbarrebg');
	$('loginbarre').style.top = Math.floor(-215+mh)+'px';
	//$('loginbarrecontentbg').style.top = Math.floor(-185+mh)+'px';
	if(_loginbartimer <= 0) clearInterval(_loginbarmvmt);
}

