function createCookie(name, value, days)
{
  if (days) {
    var date = new Date();
    date.setTime(date.getTime()+(days*24*60*60*1000));
    var expires = "; expires="+date.toGMTString();
    }
  else var expires = "";
  document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name)
{
  var ca = document.cookie.split(';');
  var nameEQ = name + "=";
  for(var i=0; i < ca.length; i++) {
    var c = ca[i];
    while (c.charAt(0)==' ') c = c.substring(1, c.length); //delete spaces
    if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length, c.length);
    }
  return null;
}

function eraseCookie(name)
{
  createCookie(name, "", -1);
}

function toggle(x) {
	var c = readCookie('seance');
	c = str_replace(',','%2C',c);

	if (c.indexOf('%2C'+x) >= 0) {
		c = str_replace('%2C'+x,'',c);
		document.getElementById('img'+x).src='/miff33/images/plus_s.gif';
	} else {
		c = c+'%2C'+x;
		document.getElementById('img'+x).src='/miff33/images/ok_s.gif';
	}

	eraseCookie('seance')
	createCookie('seance', c, 100)
}


function toggle2(x) {
	var c = readCookie('seance');
	c = str_replace(',','%2C',c);

	if (c.indexOf('%2C'+x) >= 0) {
		c = str_replace('%2C'+x,'',c);
		document.getElementById('img'+x).src='/miff33/images/plus.gif';
	} else {
		c = c+'%2C'+x;
		document.getElementById('img'+x).src='/miff33/images/ok.gif';
	}

	eraseCookie('seance')
	createCookie('seance', c, 100)
}

function str_replace(search, replace, subject) {
    return subject.split(search).join(replace);
} 


function $(id) {
var $ = document.getElementById(id);

$.fadeIn = function(delay,callbk,out) {
    var _this = this;
    for (i = 1; i <= 100; i++) {
      (function(j) {
            setTimeout(function() {  
                  if (out==true) j=100-j;
                  _this.style.opacity = j/100;
                  _this.style.MozOpacity = j/100;
                  _this.style.KhtmlOpacity = j/100;
                  _this.style.zoom = 1; // for ie, set haslayout
                  _this.style.display="block"; 
                   if (j==100&&callbk!=undefined) {callbk.call(_this);}
                   else if (out==true&&callbk!=undefined&&j==0) {callbk.call(_this);}
                  _this.style.filter = "alpha(opacity=" + j + ");";},j*delay/100);
                 
        })(i);     
    }
};

$.fadeOut = function(delay,callbk) {
    $.fadeIn(delay,callbk,true);
};

return $;
}


