/// JavaScript Document
function etendre(n,o,icon) {
	var node = n;
	if ( icon == 'rep' ) {
		img = 'images/admin/';
	}else{
		img = 'images/';
	}
	if ( node.style.display == 'block') {
		node.style.display = 'none';
		o.src = img+'plus.gif';
	} else {
		node.style.display = 'block';
		o.src = img+'minus.gif';
	}
};

function user_menu(uid,divId) {
	var menuContainer = document.getElementById(divId + '_menu');
	var liContainer = document.getElementById(divId + '_li');
	if (!menuContainer){
		var html = "<div style='float: right; padding: 2px;'><img alt='Fermer' src='./../images/close.gif'/></div><a href='/forum/profile.php?mode=viewprofile&amp;u=" + uid + "'><img alt='Voir le profil' src='./../images/lutin.gif' width='17' height='18'/> Voir le profil</a><br/>\n";
  			html += "<a href='/forum/privmsg.php?mode=post&amp;u=" + uid + "'><img alt='Envoyer un MP' src='./../images/mail.png' width='22' height='17'/> Moucheron privé</a><br/>\n";
  			html += "<a href='/forum/cash.php?mode=donate&amp;u=" + uid + "'><img alt='Donner' src='./../images/donnerN.gif' width='17' height='17'/> Donner</a><br/>\n";
  		menuContainer = document.createElement("div");
  		menuContainer.id = divId + '_menu';
  		menuContainer.className='user_menu';
  		menuContainer.innerHTML = html;
  		liContainer.appendChild(menuContainer);
   		menuContainer.style.position = 'absolute';
  		menuContainer.style.display = 'block';
  	}else{
  		if (menuContainer.style.display == 'none'){
  			menuContainer.style.display = 'block';
  		} else {
			menuContainer.style.display = 'none'; 
		}
	}	
}
function metier_menu(mid,affiche) {
	var menuContainer = document.getElementById(mid + '_menu');
	var liContainer = document.getElementById(mid + '_li');
	if (!menuContainer){
		var html = '<div style=\'float: right; padding: 2px;\'><img alt=\'Fermer\' src=\'./../images/close.gif\'/></div>'+affiche;
  		menuContainer = document.createElement("div");
  		menuContainer.id = mid + '_menu';
  		menuContainer.className='user_menu';
  		menuContainer.innerHTML = html;
  		liContainer.appendChild(menuContainer);
   		menuContainer.style.position = 'absolute';
  		menuContainer.style.display = 'block';
  	}else{
  		if (menuContainer.style.display == 'none'){
  			menuContainer.style.display = 'block';
  		} else {
			menuContainer.style.display = 'none'; 
		}
	}	
}
// Coded by Travis Beckham 
// Heavily modified by Craig Erskine 
// extended to TagName img by reddog (and little personal tip) 
tooltip = { 
   name : "tooltipDiv", 
   offsetX : -30, 
   offsetY : 26, 
   tip : null 
}; 
tooltip.init = function () { 

var tipNameSpaceURI = "http://www.w3.org/1999/xhtml"; 
if(!tipContainerID){ var tipContainerID = "tooltipDiv";} 
var tipContainer = document.getElementById(tipContainerID); 

if(!tipContainer){ 
  tipContainer = document.createElementNS ? document.createElementNS(tipNameSpaceURI, "div") : document.createElement("div"); 
  tipContainer.setAttribute("id", tipContainerID); 
  tipContainer.style.display = "none"; 
  document.getElementsByTagName("body").item(0).appendChild(tipContainer); 
} 

   if (!document.getElementById) return; 

   this.tip = document.getElementById (this.name); 
   if (this.tip) document.onmousemove = function (evt) {tooltip.move (evt)}; 

   
infobulle=function (ancre){
	var a, sTitle, zTitle; 
   	var anchors = document.getElementsByTagName (ancre); 
   	for (var i = 0; i < anchors.length; i ++) { 
    	a = anchors[i]; 
    	sTitle = a.getAttribute("title");
		zTitle = a.getAttribute("alt");
   		if(sTitle) { 
			a.setAttribute("tiptitle", sTitle); 
  	    	a.removeAttribute("title"); 
  	    	a.removeAttribute("alt"); 
  	    	a.onmouseover = function() {tooltip.show(this.getAttribute('tiptitle'))}; 
  	    	a.onmouseout = function() {tooltip.hide()}; 
		} else if(zTitle) {
			a.setAttribute("tiptitle", zTitle); 
        	a.removeAttribute("title"); 
        	a.removeAttribute("alt"); 
        	a.onmouseover = function() {tooltip.show(this.getAttribute('tiptitle'))}; 
        	a.onmouseout = function() {tooltip.hide()}; 
    	} 
	}
}
infobulle("input");
infobulle("area");
infobulle("a");
infobulle("img");
infobulle("acronym");
}; 
tooltip.move = function (evt) { 
   var x=0, y=0; 
   if (document.all) {// IE 
    
      x = (document.documentElement && document.documentElement.scrollLeft) ? document.documentElement.scrollLeft : document.body.scrollLeft; 
      y = (document.documentElement && document.documentElement.scrollTop) ? document.documentElement.scrollTop : document.body.scrollTop; 
      x += window.event.clientX; 
      y += window.event.clientY; 
       
   } else {// Mozilla 
      x = evt.pageX; 
      y = evt.pageY; 
   } 
   this.tip.style.left = (x + this.offsetX) + "px"; 
   this.tip.style.top = (y + this.offsetY) + "px"; 
}; 
tooltip.show = function (text) { 
   if (!this.tip) return; 
   this.tip.innerHTML = text; 
   this.tip.style.visibility = "visible"; 
   this.tip.style.display = "block"; 
}; 
tooltip.hide = function () { 
   if (!this.tip) return; 
   this.tip.style.visibility = "hidden"; 
   this.tip.style.display = "none"; 
   this.tip.innerHTML = ""; 
}; 
//global variables that can be used by ALL the function son this page. 
var inputs; 
var imgFalse = 'templates/subSilver/images/false.png'; 
var imgTrue = 'templates/subSilver/images/true.png'; 

//this function runs when the page is loaded, put all your other onload stuff in here too. 
function CheckInit() { 
    replaceChecks(); 
} 

function replaceChecks() { 
     
    //get all the input fields on the page 
    inputs = document.getElementsByTagName('input'); 

    //cycle trough the input fields 
    for(var i=0; i < inputs.length; i++) { 

        //check if the input is a checkbox 
        if(inputs[i].getAttribute('type') == 'checkbox') { 
             
            //create a new image 
            var img = document.createElement('img'); 
             
            //check if the checkbox is checked 
            if(inputs[i].checked) { 
                img.src = imgTrue; 
            } else { 
                img.src = imgFalse; 
            } 

            //set image ID and onclick action 
            img.id = 'checkImage'+i; 
            //set image 
            img.onclick = new Function('checkChange('+i+')'); 
            //place image in front of the checkbox 
            inputs[i].parentNode.insertBefore(img, inputs[i]); 
             
            //hide the checkbox 
            inputs[i].style.display='none'; 
        } 
    } 
} 

//change the checkbox status and the replacement image 
function checkChange(i) { 

    if(inputs[i].checked) { 
        inputs[i].checked = ''; 
        document.getElementById('checkImage'+i).src=imgFalse; 
    } else { 
        inputs[i].checked = 'checked'; 
        document.getElementById('checkImage'+i).src=imgTrue; 
    } 
} 


window.onload = function () { 
   tooltip.init (); 
   CheckInit();
};

