function $(obj)
{
	return document.getElementById(obj);
}


//Fonction permettant de connaître la position d'un objet
//par rapport au bord gauche de la page.
//Cet objet peut être à l'intérieur d'un autre objet.
function getLeft(obj)
{
	if (obj.offsetParent)
		return (obj.offsetLeft + getLeft(obj.offsetParent));
	else
		return (obj.offsetLeft);
}

//Fonction permettant de connaître la position d'un objet
//par rapport au bord haut de la page.
//Cet objet peut être à l'intérieur d'un autre objet.
function getTop(obj)
{
	if (obj.offsetParent)
		return (obj.offsetTop + getTop(obj.offsetParent));
	else
		return (obj.offsetTop);
}


function writeCookie(name, value, hours)
{
	var expire = "";
	if(hours != null)
	{
	expire = new Date((new Date()).getTime() + hours * 3600000);
	expire = "; expires=" + expire.toGMTString();
	}
	document.cookie = name + "=" + escape(value) + expire;
}


// JavaScript Document
function deleteIt(txt, url)
{
	if(confirm('Voulez-vous supprimer '+txt+' ?'))
	{
		document.location.href=url;	
	}
}


function afficheId(baliseId) 
{
	if (document.getElementById && document.getElementById(baliseId) != null) 
	{
		document.getElementById(baliseId).style.visibility='visible';
		document.getElementById(baliseId).style.display='block';
	}
}

function cacheId(baliseId) 
{
	if (document.getElementById && document.getElementById(baliseId) != null) 
	{
		document.getElementById(baliseId).style.visibility='hidden';
		document.getElementById(baliseId).style.display='none';
	}
}

function tabSelect(nb)
{
	// le deuxieme est present  ?
	if(!document.getElementById('form_tab1'))
		return;
	
	
	for(i=0; i < tab_number ;i++)
	{
		document.getElementById('form_tab'+i).className = 'form_tab';
		cacheId('form_tab_content'+i);	
	}
		
	afficheId('form_tab_content'+nb);
	document.getElementById('form_tab'+nb).className = 'form_tab_active';
}

function getBrowserWidth()
{
	if( typeof( window.innerWidth ) == 'number' )
	{
	  largeur = window.innerWidth;
	  //hauteur = window.innerHeight;
	} 
	else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
	  largeur = document.documentElement.clientWidth;
	  //hauteur = document.documentElement.clientHeight;
	} 
	else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) 
	{
	  largeur = document.body.clientWidth;
	  //hauteur = document.body.clientHeight;
	}
	else 
	{
	  largeur = -1;
	  //hauteur = -1;
	} 	
	
	return largeur;
}



function popupImg(img, wi, hi)
{
	titre="Image";
	w=open("",'image','width='+wi+',height='+hi+',toolbar=no,scrollbars=no,resizable=yes');
	w.document.write("<html><head><title>"+titre+"</title>");
	w.document.write("<sc"+"ript language=java"+"script> function checksize()  { wf=(screen.availWidth-"+wi+")/2; wh=(screen.availheight-"+hi+")/2; window.moveTo(wf, wh);}</"+"script></head>");
	w.document.write("<body style='margin:0' onload='checksize()'><table border='0' width='100%' height='100%'><tr><td align='center'><a href='#' onclick='window.close();'><img name='img' src='"+img+"' border='0'></a></td></tr></table>");
	w.document.write("");
	w.document.write("</body></html>");
	w.document.close();
}


function printIt(cid)
{
	url = document.location.href;
	w = window.open('', 'printIt', 'width=680,height=700,location=no,toolbar=no,scrollbars=yes,resizable=yes');

	src = document.documentElement.innerHTML;
	// FF
	if(!document.all)
	{
		headers = src.substr(0, src.indexOf('<body>'));
		headers = headers.substr(0, headers.indexOf('<script'));
	}
	else
	{
		headers = src.substr(0, src.indexOf('<BODY>'));				
		headers = headers.substr(0, headers.indexOf('<SCRIPT'));
		headers += '</head>';
	}

	
	// on capture la source
	txt = document.getElementById(cid).innerHTML;
	
	w.document.writeln('<html>');
	w.document.write(headers);
	
	w.document.writeln('<body style="background-color:white;">');
	w.document.writeln('<div id="printable">');
		w.document.writeln('<div id="printable_header"><img src="img/print_header.jpg"></div>');
		w.document.write('<div style="padding:10px;">'+txt+'</div>');
	w.document.writeln('</div>');
	
	w.document.writeln('<div id="printable_bottom">');
		w.document.writeln('<span class="printable_url">'+url+"</span><br /><br />");
		w.document.writeln('<img src="img/print_sign.gif">');
	w.document.writeln('</div>');
	
	
	// on cache le bouton d'impression
	w.document.writeln('<sc'+'ript language=java'+'script>');
		w.document.writeln('document.getElementById("print_button").style.display="none";');
	w.document.writeln('</'+'script>');
	
	w.document.writeln('</body></html>');
	w.document.close();
	w.focus();
	w.print();	
}



