/*
##### Alérion
##### petit programme javaScript pour mettre un fond en normal ;) pour CanalBlog
##### conception 2008;
##### libre de droit faites-en bon usage
##### version 00810.07
*/
var urlimage;
var	repeterimage="oui"; 
var	fondvisible="non";
var posx="50%";
var posy="50%";
var repeterx="non";
var repetery="non";
var imagefixed="fixed";
var changerfondperso=true;

function addEvent(ou, eventName, quoi) {
if (ou.addEventListener)
ou.addEventListener(eventName, quoi, false);
else if (ou.attachEvent)
ou.attachEvent('on'+ eventName, quoi);
}

function changerlefond() {
  if (document.getElementById) {
  document.body.style.backgroundImage="url(" + urlimage + ")";
  document.body.style.backgroundPosition=posx + " " + posy;
  document.body.style.backgroundAttachment=imagefixed;
  if (repeterimage=="oui") { document.body.style.backgroundRepeat="repeat"; } 
  else if (repeterx=="oui") { document.body.style.backgroundRepeat="repeat-x"; }
  else if (repetery=="oui") { document.body.style.backgroundRepeat="repeat-y"; }
  else { document.body.style.backgroundRepeat="no-repeat"; }
  document.getElementById("container").style.backgroundColor="transparent";
    if (fondvisible=="non")  {
    document.getElementById("content").style.backgroundColor="transparent";
    if (document.getElementById("leftbar")) { document.getElementById("leftbar").style.backgroundColor="transparent"; }
    if (document.getElementById("rightbar")) { document.getElementById("rightbar").style.backgroundColor="transparent"; }
	document.getElementById("topbar").style.backgroundColor="transparent";
    }
  }
}

recupererarguments = function () {
  if (document.getElementById("optFondCB")) {
  var firstarg=document.getElementById("optFondCB");
  var arguments=firstarg.href;
  arguments=arguments.split("#");
  urlimage=arguments[0];
  var listarguments=arguments[1].split("_");
    for (Ka=0;Ka <= listarguments.length;Ka++) {
	if  (listarguments[Ka] == "reo") { repeterimage="oui"; }
	if  (listarguments[Ka] == "vio") { fondvisible="oui"; }
	if  (listarguments[Ka] == "ren") { repeterimage="non"; }
	if  (listarguments[Ka] == "rex") { repeterx="oui"; repeterimage="non";  }
	if  (listarguments[Ka] == "rey") { repetery="oui"; repeterimage="non";  }
	if  (listarguments[Ka] == "vin") { fondvisible="non"; }
	if  (listarguments[Ka] == "gau") { posx="0"; posy="0"; }
	if  (listarguments[Ka] == "dro") { posx="100%"; posy="0"; }
	if  (listarguments[Ka] == "cen") { posx="50%"; posy="50%"; }
    if  (listarguments[Ka] == "fin") { imagefixed="scroll"; }
	}
  } 
  else {
	repeterimage="oui"; 
	fondvisible="non";
  }
changerlefond();
}


addEvent(window, "load", recupererarguments);  
