if (document.body)
{
var larg = (document.body.clientWidth);
var haut = (document.body.clientHeight);
}

else
{
var larg = (window.innerWidth);
var haut = (window.innerHeight);
}

haut = haut-142;

//var haut2 = document.getElementById('mgs_bloc').innerHeight;

//if (haut2>haut){ haut = haut2; }
//document.getElementById('mgs_corps').height = haut;


function montre(id) {
	var d = document.getElementById(id);
	if (d) {d.style.display='block';}
}

	
function cache(id){
	document.getElementById(id).style.display='none';
}


///////////////////////////////////////////////////////////////
///////////////	affichage cadre oublie mail	//////////////////
///////////////////////////////////////////////////////////////

function aff_oublie() {
	var d = document.getElementById('oublie2');
	d.style.display='block';
}

window.onload=montre;
// fin du script -->

///////////////////////////////////////////////////////////////
//////////////////	Position du curseur	//////////////////
///////////////////////////////////////////////////////////////

var x=0;
var y=0;

function position(e) {
if (navigator.appName.substring(0,3) == "Net") {
x = e.pageX;
y = e.pageY;
}
else {
x = event.x+document.body.scrollLeft;
y = event.y+document.body.scrollTop;
}
}

if(navigator.appName.substring(0,3) == "Net") document.captureEvents(Event.MOUSEMOVE);

document.onmousemove = position;




//////////////////////////////////////////////////////////////////
///////////	Gestion infos-bulles				//////////
//////////////////////////////////////////////////////////////////

function montreinfobulle(texte){
	document.getElementById('infobulle-text').innerHTML = texte;
	document.getElementById('infobulle').style.display= 'block';
	document.getElementById('infobulle').style.top = (y-document.getElementById('infobulle').offsetHeight)+'px';
	document.getElementById('infobulle').style.left = (x+5)+'px';
}

function cacheinfobulle(){
	document.getElementById('infobulle').style.display= 'none';
}


//////////////////////////////////////////////////////////////////
////////////	Gestion de la palette de couleur			//////////
////////////								//////////
//////////////////////////////////////////////////////////////////



function dec_hex(dec){ 
    var hexa='0123456789ABCDEF',hex=''
    while (dec>15){
		tmp=dec-(Math.floor(dec/16))*16;
		hex=hexa.charAt(tmp)+hex;
		dec=Math.floor(dec/16);
    }
    
	hex=hexa.charAt(dec)+hex;
    
	if (hex.length=0){ hex = '00'; }
	if (hex.length<2){ hex = '0'+hex; }

	return hex;
}

///////////////////////////////////////////////////////
cltexte='';
pix=3;
t='';
c=new Array('00','11','22','33','44','55','66','77','88','99','AA','BB','CC','DD','EE','FF');
d=new Array('22','33','55','66','77','99','AA','BB','CC','DD','EE','FF');

tabR = new Array();
tabV = new Array();
tabB = new Array();
var R = '';
var V = '';
var B = '';
var index=0;

///////////////////////////////////////////////////////////

for(i=0;i<c.length-1;i++){
	R = '255';
	V = parseInt(c[i],16);
	B = '0';
	def = '255';
	auxR = Math.round((def-R) / d.length);
	auxV = Math.round((def-V) / d.length);
	auxB = Math.round((def-B) / d.length);
	for(j=0;j<d.length-1;j++){
		tabR[index+','+j] = R;
		tabV[index+','+j] = V;
		tabB[index+','+j] = B;
		R = R*1 + auxR*1;
		V = V*1 + auxV*1;
		B = B*1 + auxB*1;
	}
	index++;
}

for(i=c.length-2;i>-1;i--){
V = '255';
R = parseInt(c[i],16);
B = '0';
def = '255';
auxR = Math.round((def-R) / d.length);
auxV = Math.round((def-V) / d.length);
auxB = Math.round((def-B) / d.length);
	for(j=0;j<d.length-1;j++){
		R = R*1 + auxR*1;
		V = V*1 + auxV*1;
		B = B*1 + auxB*1;
		tabR[index+','+j] = R;
		tabV[index+','+j] = V;
		tabB[index+','+j] = B;
	}
index++;
}

for(i=0;i<c.length-1;i++){
V = '255';
B = parseInt(c[i],16);
R = '0';
def = '255';
auxR = Math.round((def-R) / d.length);
auxV = Math.round((def-V) / d.length);
auxB = Math.round((def-B) / d.length);
	for(j=0;j<d.length-1;j++){
		R = R*1 + auxR*1;
		V = V*1 + auxV*1;
		B = B*1 + auxB*1;
		tabR[index+','+j] = R;
		tabV[index+','+j] = V;
		tabB[index+','+j] = B;
	}
index++;
}

for(i=c.length-2;i>-1;i--){
B = '255';
V = parseInt(c[i],16);
R = '0';
def = '255';
auxR = Math.round((def-R) / d.length);
auxV = Math.round((def-V) / d.length);
auxB = Math.round((def-B) / d.length);
	for(j=0;j<d.length-1;j++){
		R = R*1 + auxR*1;
		V = V*1 + auxV*1;
		B = B*1 + auxB*1;
		tabR[index+','+j] = R;
		tabV[index+','+j] = V;
		tabB[index+','+j] = B;
	}
index++;
}

for(i=1;i<c.length-1;i++){
B = '255';
R = parseInt(c[i],16);
V = '0';
def = '255';
auxR = Math.round((def-R) / d.length);
auxV = Math.round((def-V) / d.length);
auxB = Math.round((def-B) / d.length);
	for(j=0;j<d.length-1;j++){
		R = R*1 + auxR*1;
		V = V*1 + auxV*1;
		B = B*1 + auxB*1;
		tabR[index+','+j] = R;
		tabV[index+','+j] = V;
		tabB[index+','+j] = B;
	}
index++;
}

for(i=c.length-2;i>0;i--){
R = '255';
B = parseInt(c[i],16);
V = '0';
def = '255';
auxR = Math.round((def-R) / d.length);
auxV = Math.round((def-V) / d.length);
auxB = Math.round((def-B) / d.length);
	for(j=0;j<d.length-1;j++){
		R = R*1 + auxR*1;
		V = V*1 + auxV*1;
		B = B*1 + auxB*1;
		tabR[index+','+j] = R;
		tabV[index+','+j] = V;
		tabB[index+','+j] = B;
	}
index++;
}


////////////////////////////////////////////////////////////////////

function genere_palette(noir,id){

t='<table border=1 cellspacing=0 cellpadding=0 bgcolor="#000"><tr  style="margin:0px; padding:0px; border: none;">';
for(i=d.length-1;i>-1;i--){
	var couleur = d[i]+d[i]+d[i];
	t+='<tr><td onclick="change_noir(\''+d[i]+'\',\''+id+'\')" style="margin:0px; padding:0px; border: none; width:10px; height:7px; background-color:#'+couleur+'"></td></tr>';
	}
t+='</table>';
document.getElementById('noir').innerHTML = t;

////////////////////////////////////////////

if(noir<175){ cltexte = '#FFF' }else{ cltexte = '#000' }
t='<table border=1 cellspacing=0 cellpadding=0 bgcolor="#000"><tr  style="margin:0px; padding:0px; border: none;">';
for(j=0;j<d.length-1;j++){
	t+='<tr>';
		for(i=0;i<index;i++){
			R = tabR[i+','+j];
			V = tabV[i+','+j];
			B = tabB[i+','+j];
			R = dec_hex(Math.round(R*noir / 255))+'';
			V = dec_hex(Math.round(V*noir / 255))+'';
			B = dec_hex(Math.round(B*noir / 255))+'';
			var couleur = R+V+B+'';
			t+='<td onmouseover="change_couleur(\''+couleur+'\')" onclick="change_couleur_select(\''+couleur+'\',\''+id+'\');" style="margin:0px; padding:0px; border: none; width:'+pix+'px; height:7px; background-color:#'+couleur+'"></td>';
		}
	t+='</tr>';
}
t+='<tr>';
for(i=0;i<index;i++){
	R = dec_hex(Math.round(i / index * 256));
	var couleur = R+R+R+'';
	t+='<td onmouseover="change_couleur(\''+couleur+'\')" onclick="change_couleur_select(\''+couleur+'\',\''+id+'\')" style="margin:0px; padding:0px; border: none; width:'+pix+'px; height:7px; background-color:#'+couleur+'"></td>';
}
t+='</tr></table>';
document.getElementById('palette').innerHTML = t;
}

function generer(noir,id){

genere_palette(noir,id);

document.getElementById('pal').style.top = y+'px';
document.getElementById('pal').style.left = (x-150)+'px';
document.getElementById('pal').style.display = 'block';
}

function change_noir(couleur,id){
	var noir = parseInt(couleur,16);
	genere_palette(noir,id);
}

function change_couleur(couleur){
		document.getElementById('couleur').value = '#'+couleur+'';
		document.getElementById('couleur').style.background = '#'+couleur+'';
		document.getElementById('couleur').style.color = cltexte;
}

function change_couleur_select(couleur,id){
		document.getElementById(id).value = '#'+couleur+'';
		document.getElementById(id).style.background = '#'+couleur+'';
		document.getElementById(id).style.color = cltexte;
}

//////////////////////////////////////////////////////

