var XHTMLNS = 'http://www.w3.org/1999/xhtml';

var initialY = 0;
var lastlink = '';
var block_scroll = 0;
var initialheight = 0;
var first_start = 0;
var type = 0;
var header_hauteur = 0; // la hauteur du header ( pas de scroll avant cette taille la ) // la hauteur par defaut est de 128, pou



function myStartScript(){
	//--- ON MET LA TAILLE DE POLICE CONVENU PAR L'UTILSATEUR
	
	getFontSize = parseInt(getCookie('font-size'));
	if(getFontSize >= min_fontSize && getFontSize <= max_fontSize){
	set_font_size(getFontSize) ;
	} 
	//------------------------------------------------------------------------------

	// ON RAJOUTE DANS LES BALISES TITLE DES LIENS LE RACCOURCI CLAVIER D'ACCES RAPIDE
	accessKey_inTitle();
	if(window.ActiveXObject){  document.recalc() } ;
   
	affichage_swf(); // tricks pour IE qui affiche des cadres au tour des flash et autres objects 
	externalLinks();
	title_img_parse();
}

function title_img_parse(){

	var wtag = new Array();
	wtag[0] = 'h1';
	wtag[1] = 'h2';
	wtag[2] = 'h3';
	
	for(var t = 0; t<wtag.length ; t++){
		title_elements = document.getElementsByTagName(wtag[t]);
		for( var i = 0;i<title_elements.length; i++){
			cElement = title_elements[i] ;
			//~ alert(cElement.style.color);

			//~ alert(defBgColor);
			if(cElement.className == 'title_img' || cElement.className == 'title_img_orange'){		
			
			defColor = getCssValue(cElement,'color');
			defBgColor = getCssValue(cElement,'backgroundColor');
			defWidth = parseInt(getCssValue(cElement,'width'));
			innerText = '';			
			//~ if(cElement){				
				for( var x = 0; x < cElement.childNodes.length; x++ ) {
					if( cElement.childNodes[x].className || cElement.childNodes[x].style) {					
						innerText += '<span style="color:' +getCssValue(cElement.childNodes[x],'color')+'" >'+ cElement.childNodes[x].innerHTML +'</span>';
					}else{
						innerText += cElement.childNodes[x].nodeValue;
					}
				}
				
				//~ alert(innerText);
				cElement.innerHTML = '<img src="./title_generator.php?width='+defWidth+'&size='+wtag[t]+'&background-color='+encodeURIComponent(defBgColor)+'&color='+encodeURIComponent(defColor)+'&texte='+encodeURIComponent(innerText)+'" alt="'+striptags(innerText)+'"/>' ;
				//~ cElement.innerHTML = '<img src="./title_generator.php?texte='+innerText+'" alt="'+escape(innerText)+'"/>' ;
				//~ break;
			}
		}	
	}
}





function addEvent(obj, evType, fn) {
	if (obj.addEventListener)	{
		obj.addEventListener(evType, fn, false);
		return true;
	}else if (obj.attachEvent){
		var r = obj.attachEvent('on'+evType, fn);
		return r;
	}else{
		return false;
	}
}

addEvent(window, "load", myStartScript);

//uniformisation des appels 
if (!document.createElementNS) {
	document.createElementNS = function(ns, elt) {
		return document.createElement(elt);
	}
}

function goURL(url){
   document.location.href = url;
}

function goURL_parent(url){
   window.opener.parent.document.location.href = url ;
   window.close();
}

function refresh_parent(wdiv,closing){   
   window.opener.parent.getRefresh(wdiv) ;
   if(closing == 1){
         window.close();
   }
}


var wtag = new Array();
wtag[0] = 'input';
wtag[1] = 'textarea';
wtag[2] = 'select';

function get_object_by_name(wname){

	for(var t = 0; t<wtag.length ; t++){

		var all_obj = document.getElementsByTagName(wtag[t]);
	   
		for( var i = 0;i<all_obj.length; i++){
			if(all_obj[i].name == wname){				
				return all_obj[i] ;
				break;
			}
		}	
	}
}

var last_shown = '';

function findPos(myobj) {
	if (myobj.offsetParent) {
	
		for (var posX = 0, posY = 0; myobj.offsetParent; myobj = myobj.offsetParent) {
			posX += myobj.offsetLeft;
			posY += myobj.offsetTop;
		}
		return [posX, posY];
		
	} else {
		return [myobj.x, myobj.y];
	}
}

function show_div(what_to_show){
   
     if(document.getElementById(what_to_show).style.display == 'none'){
         if(last_shown != '') {
            document.getElementById(last_shown).style.display = 'none' ;
         }
         document.getElementById(what_to_show).style.display = 'block' ;
         to_return = 1;
         last_shown = what_to_show;         
     } else {
         document.getElementById(what_to_show).style.display = 'none' ;
         to_return = 0;
     }
     first_start = 0;
     //return to_return;

}  

function pop_div(what_to_show){
     if(document.getElementById(what_to_show).style.display != 'block'){
         document.getElementById(what_to_show).style.display = 'block' ;
     }
}

function hide_div(what_to_show){
     if(document.getElementById(what_to_show).style.display != 'none'){
         document.getElementById(what_to_show).style.display = 'none' ;
     }
}


 function replaceAll(str, search, repl) {
    while (str.indexOf(search) != -1)
    str = str.replace(search, repl);
    return str;
}


function jumpMenu(target_baseurl,selObj){ //jump menu, based on dreamweaver concept
   if(selObj.options[selObj.selectedIndex].value != ''){
      eval("location='"+target_baseurl+selObj.options[selObj.selectedIndex].value+"'");
  }
}

function findPosY(obj) { // recupere la position d'un lien , ou alors le décalage avec son parent 

	if (obj.offsetParent)
		{
		for (var posX = 0, posY = 0; obj.offsetParent; obj = obj.offsetParent)
			{
			posX += obj.offsetLeft;
			posY += obj.offsetTop;
			}
		return posY;
		}
	else
		{
		return obj.y;
		}
}



// Ouvre un popup avec des options, dont par defaut le redimmensionnement
function open_newwindow(urltoshow,options) {
      //window.open(urltoshow,'sitepopup','resizable=yes,menubar=yes,'+options);
      window.open(urltoshow,'sitepopup','resizable=yes,'+options);
}

// open_newwindow('wqsdfqsdfqsdfqsd','width=450,height=380')

function affichage_swf(){
   var all_divs = document.getElementsByTagName('div');
   
   for( var i = 0;i<all_divs.length; i++){
         if(all_divs[i].id.substring(all_divs[i].id.length - 4, all_divs[i].id.length) == '.swf' ){ // si le div ce termine par .swf 
               
               
               if( fs_width = parseInt(all_divs[i].width) ){               
               }else fs_width = parseInt(all_divs[i].style.width) ; 

               if( fs_height = parseInt(all_divs[i].height) ){               
               }else fs_height = parseInt(all_divs[i].style.height) ;
               
              
         
               fs_script = '<object type="application/x-shockwave-flash" data="'+ all_divs[i].id  +'" ';
               
               if(fs_width >= 1){
                  fs_script =  fs_script + 'width="'+fs_width+'" ' ;
               }else fs_script =  fs_script + 'width="auto" ' ;
               
               if(fs_height >= 1){
                  fs_script =  fs_script + 'height="'+ fs_height +'" ';
               }else fs_script =  fs_script + 'height="auto" ' ;
               
               fs_script =  fs_script +  '>\n<param name="movie" value="'+ all_divs[i].id +'" />\n<param name="wmode" value="transparent" />\n<p>&nbsp;</p></object>'; ;
               writeHTML(fs_script,all_divs[i].id);    
               
               //writeHTML(fs_width+'x'+fs_height,all_divs[i].id);      

               all_divs[i].id = all_divs[i].id + '_OK' ;
         }
   }

}

function accessKey_inTitle(){
   var all_a = document.getElementsByTagName('a');
   
   for( var i = 0;i<all_a.length; i++){
         if(all_a[i].accessKey){         
            all_a[i].title = all_a[i].title + ' | [' + all_a[i].accessKey+']';   
            // ---- ADD underline on accesskey in innerHTML
            //~ innertxt = all_a[i].innerHTML ;
            //~ innertxtLower = innertxt.toLowerCase() ;
            
            //~ accessKey_pos = innertxtLower.indexOf(all_a[i].accessKey,0) + 1 ;
            //~ if(accessKey_pos >= 2){
               //~ new_txt = innertxt.substr(0,accessKey_pos-1) 
            //~ }else new_txt = ''
            
            //~ new_txt = new_txt +  '<u>' + innertxt.substr(accessKey_pos-1,1)  + '</u>' + innertxt.substr(accessKey_pos,innertxt.length);
            //~ all_a[i].innerHTML = new_txt;
         }
   }

}

function count_down(div,countdown){

      destination = div;
      CD = countdown - 1;
      
      if(countdown >= 1){
         writeHTML('('+(countdown - 1)+')',div+'_CD');
         if(countdown == 1){
            setTimeout("count_down(destination,(CD));",150);
         }else{
            setTimeout("count_down(destination,(CD));",1000);
         }
      }else{ // si on est a zero il faut effectuer la redirection vers la page du lien
         url = document.getElementById(div).href ;
         window.location = url;
      }
      
}

var current_hp ;
var current_hpDiv = null ;
var hpBoxHeight = 16;
var hpBoxWidth = 16;

function  show_help_point(what_id,hpPos){
   //~ position for help_point on the div
   //~ 012
   //~ 345
   //~ 678
   
   hpDiv = document.getElementById(what_id);
   
   if(current_hpDiv == what_id) return ;
   hide_help_point();

   if(!document.getElementsByTagName) return;
   

   
   hpDivPos = findPos(hpDiv); // on recuper la position du text area dans l'espace page
   wX = hpDivPos[0];
   wY = hpDivPos[1];   
   wH = hpDiv.offsetHeight;
   wW = hpDiv.offsetWidth;
   
   if( hpPos == 0 || hpPos == 3 || hpPos == 6 ){
      hpX = wX + 5 - (hpBoxWidth / 2 );
   }else if( hpPos == 2 || hpPos == 5 || hpPos == 8 ){
      hpX = wX + wW - 5 + (hpBoxWidth / 2 ) ;
   }else { // par defaut il est centré 
      hpX = wX + ( wW  / 2 ) - (hpBoxWidth / 2 ) ;
   }

   if( hpPos == 6 || hpPos == 7 || hpPos == 8 ){
      hpY = wY + wH - 5 + (hpBoxHeight / 2 );
   }else if( hpPos == 0 || hpPos == 1 || hpPos == 2 ){
      hpY = wY + 5 - (hpBoxHeight / 2 );
   }else { // par defaut il est centré
      hpY = wY + ( wH  / 2 ) - (hpBoxHeight / 2 );
   }

   var hpBox = document.createElementNS(XHTMLNS, 'div'); // on 	
   hpBox.id = "HP" ;
   hpBox.className = 'petit';

   //vbox.style.width = (bbcodebox_width+20) + 'px';
   //vbox.style.height = bbcodebox_height + 'px';

   hpBox.style.position = 'absolute' ; // on deplace notre tooltip vers la droite de xx px 
   hpBox.style.left = (hpX) + 'px' ; // on deplace notre tooltip vers la droite de xx px 
   hpBox.style.top = (hpY) + 'px' ; // on deplace vers le bas de xxpx


   document.getElementsByTagName('body')[0].appendChild(hpBox); // on definit notre balise d comme sous element de body  (affiche le tooltip en gros :) )
   current_hp = hpBox;	

   //---------------------------------------------------------------------------------------
   // REMPLISSAGE DES BOX
   //---------------------------------------------------------------------------------------

   if(current_hp){ // on a bien une help box 
      current_hp.innerHTML = '<img src="./img/fleche_help_point.gif" />';
      setTimeout("hide_help_point();",1000);
   }  

}

function hide_help_point(){	
	if (!document.getElementsByTagName) return;

	if (current_hp) {
		document.getElementsByTagName('body')[0].removeChild(current_hp);
		current_hp = null;
		current_hpDiv = null;
	}
	return;
}

var max_fontSize = '12';
var min_fontSize = '7';
var fontSize_unit = 'pt';
var fontSize_default = '9';

function set_font_size(action){

      actual_size = parseInt(getCssValue(document.getElementsByTagName('body')[0],'fontSize')) ;
      
      //writeHTML(actual_size,'sub_menu');      
      
      if( action && action == 'up'){         
         if(actual_size < max_fontSize){
            document.getElementsByTagName('body')[0].style.fontSize = (actual_size + 1) + fontSize_unit ;
         }         
      }else if(action && action == 'down'){
         if(actual_size > min_fontSize){
            document.getElementsByTagName('body')[0].style.fontSize = (actual_size - 1) + fontSize_unit ;
         }         
      }else if( !isNaN(action) ){
         document.getElementsByTagName('body')[0].style.fontSize = (action) + fontSize_unit ;
      }

      setCookie('font-size',document.getElementsByTagName('body')[0].style.fontSize);
      
}

function getCssValue(wobj,element) {

   var value = wobj.style[element] ;  
     
   if(value==null || value=='' || value=='undefined'){
      var aClass = wobj.className;
     
      if(aClass==null || aClass=='' || aClass=='undefined'){
         aClass = wobj.tagName.toLowerCase();
      }
	//~ alert(aClass);
      //writeHTML(aClass,'sub_menu');   
      var cssRules = 'rules';
      for (var sSheet=0; sSheet < document.styleSheets.length; sSheet++){
      
      if (document.styleSheets[0].cssRules) my_rules=document.styleSheets[sSheet].cssRules ;
      else if (document.styleSheets[0].rules) my_rules=document.styleSheets[sSheet].rules ;

         
         for (var rule=0; rule <my_rules.length ; rule++) {
		//~ alert(rule);
            var currentClass = my_rules[rule].selectorText.toLowerCase() ;
	     //~ alert(currentClass);s
            //document.getElementById('sub_menu').innerHTML = document.getElementById('sub_menu').innerHTML + '<br />' +currentClass ;
            if (currentClass == aClass || currentClass == '.'+aClass) {
                  //writeHTML('|' + aClass+'| - |' +currentClass+'| - |'+ document.styleSheets[sSheet].cssRules[rule].style[element] +'|' ,'sub_menu');   
               value = my_rules[rule].style[element] ;
            }
         }
      }
   }
    
   
   return  value;
}	

function setCookie(what, value) {
   var argv = setCookie.arguments ;
   var argc = setCookie.arguments.length ;
   var expires = (argc > 2) ? argv[2] : null ;
   var path = (argc > 3) ? argv[3] : null ;
   var domain = (argc > 4) ? argv[4] : null ;
   var secure = (argc > 5) ? argv[5] : false ;
   document.cookie = what+"="+escape(value)+
   ((expires==null) ? "" : ("; expires="+expires.toGMTString()))+
   ((path==null) ? "" : ("; path="+path))+
   ((domain==null) ? "" : ("; domain="+domain))+
   ((secure==true) ? "; secure" : "") ;
}

function getCookieVal(offset){
   var endstr=document.cookie.indexOf (";", offset);
   if (endstr==-1) endstr=document.cookie.length;
   return unescape(document.cookie.substring(offset, endstr));
}

function getCookie(what) {
   var arg = what+"=" ;
   var alen = arg.length ;
   var clen = document.cookie.length ;
   var i=0;
   while (i<clen){
      var j=i+alen;
      if (document.cookie.substring(i, j)==arg) return getCookieVal(j);
      i=document.cookie.indexOf(" ",i)+1;
      if (i==0) break;
   }
   return null;
}





var current_my_div ;
var chargement_box_width = 150 ;


function show_chargement(optional_text,destination){

	hide_chargement();
	
	output_div = document.getElementById(destination) ;
       
	if(!optional_text){
		optional_text = 'Chargement ...';
	}
	
	if(document.getElementsByTagName){
	
		my_cache_div = document.createElementNS(XHTMLNS, 'div'); // on 	
		my_div = document.createElementNS(XHTMLNS, 'div'); // on 	
		my_div.id = "AJAX_return";
			
		divpos = findPos(output_div); // on recuper la position du text area dans l'espace page
		dx = divpos[0];
		dy = divpos[1];		

		//my_div.style.width = (bbcodebox_width-6) + 'px';
		//my_div.style.height = bbcodebox_height + 'px';
		
		div_width = parseInt(output_div.offsetWidth)
		div_height = parseInt(output_div.offsetHeight)
		
		
		my_cache_div.style.cssText = 'background-color:#FFF;opacity:0.75;' ;
		my_cache_div.style.position = 'absolute' ;
		//my_cache_div.style.cssText = 'opacity:0.75;'
		
		my_cache_div.style.left = dx + 'px'; // on deplace notre tooltip vers la droite de xx px 
		my_cache_div.style.top = dy + 'px';
		my_cache_div.style.width = div_width + 'px';
		my_cache_div.style.height = div_height + 'px';
		
		my_div.style.cssText = 'font-size:9px;' ;
		my_div.style.position = 'absolute' ;
		my_div.style.padding = '8px' ;
		my_div.style.textalign = 'center' ;
		my_div.style.border = '1px solid #999' ;
		my_div.style.backgroundColor = '#EEE' ;
		my_div.style.color = '#555' ;
		
		my_div.style.left = parseInt( dx + (div_width - chargement_box_width) / 2)  + 'px'; // on deplace notre tooltip vers la droite de xx px 
		my_div.style.top = ( dy + 25) + 'px'; // on deplace vers le bas de xxpx
		
		document.getElementsByTagName('body')[0].appendChild(my_cache_div); // on definit notre balise d comme sous element de body  (affiche le tooltip en gros :) )
		document.getElementsByTagName('body')[0].appendChild(my_div); // on definit notre balise d comme sous element de body  (affiche le tooltip en gros :) 
              
		writeHTML('<table cellpadding="0px" cellspacing="1px" ><tr><td valign="center">'+ optional_text + '&nbsp;</td><td valign="center"><img src="./img/chargement.gif" alt="" /></td></tr></table>',my_div.id);
		//writeHTML(dx + ' ' + dy ,my_div.id);
		current_my_div = my_div;
		current_my_cache_div = my_cache_div;
		
	}else return;	
}

function hide_chargement(){
	if(document.getElementsByTagName){
		if (current_my_div) {
			document.getElementsByTagName('body')[0].removeChild(current_my_div);
			document.getElementsByTagName('body')[0].removeChild(current_my_cache_div);
			current_my_cache_div = null;
			current_my_div = null;
		}
	}
}


var current_helpbox = null ;
var current_helpinput = null ;


function show_helpbox(winput , wtxt){
	
	hide_helpbox();
			
	if(!document.getElementsByTagName) return; // on verifie qu'on peut recup les elements par tag, permet de savoir si en gros on a besoin d'exec cette fonction, puisk sans ca rien ne marche

	
	//---------------------------------------------------------------------------------------
	// HELP BOX
	//---------------------------------------------------------------------------------------
	txtpos = findPos(winput); // on recuper la position du text area dans l'espace page
	//divpos = findPos(document.getElementById('requested')); // on recuper la position du text area dans l'espace page
	tx = txtpos[0];
	ty = txtpos[1];
	
	inputHeight = winput.offsetHeight ;	
	inputWidth = winput.offsetWidth ;	
	
	var vbox = document.createElement('div'); // on
	vbox.id = "help_input_box";
	vbox.className = 'apercu_box petit classic_ul ';
	
	//vbox.style.width = (bbcodebox_width+20) + 'px';
	//vbox.style.height = bbcodebox_height + 'px';

	vbox.style.left = (tx) + 'px'; // on deplace notre tooltip vers la droite de xx px 
	vbox.style.top = (ty+inputHeight) + 'px'; // on deplace vers le bas de xxpx

	
	if(winput.type == 'select' || winput.type == 'select-one' ||winput.type == 'select-multiple' || winput.type == 'textarea'){
		vbox.style.top = (ty) + 'px'; // on deplace vers le bas de xxpx
		vbox.style.left = (tx + inputWidth) + 'px';		
	}
	vbox.style.width = '400px';
	

	document.getElementsByTagName('body')[0].appendChild(vbox); // on definit notre balise d comme sous element de body  (affiche le tooltip en gros :) )
	current_helpbox = vbox;	
	//---------------------------------------------------------------------------------------	

	//---------------------------------------------------------------------------------------
	// REMPLISSAGE DES BOX
	//---------------------------------------------------------------------------------------

	if(current_helpbox){ // on a bien une help box 
		
		if(isNaN(wtxt) && wtxt.substring(0,5) == 'HELP:' ){  // du text qui commence par HELP: alors il faut aller chercher la page php qui echo de l'aide 
			spe_url = './index.php?supertitle=help_api&whelp=' + wtxt.substring(5,wtxt.length) ;
			//writeHTML('<img src="./img/connect_box.gif" alt="" style="" class="float_left" />',current_helpbox.id);		//writeHTML('&nbsp;&nbsp;Veuillez patienter...',defautdestination);	
			my_chb_id = current_helpbox.id ;
			setTimeout("loadPage(spe_url,my_chb_id)",50);
		}else { // si c du texte 
			writeHTML(wtxt,current_helpbox.id);		//writeHTML('&nbsp;&nbsp;Veuillez patienter...',defautdestination);	
			//writeHTML(inputHeight,current_helpbox.id);		//writeHTML('&nbsp;&nbsp;Veuillez patienter...',defautdestination);	
			if(window.ActiveXObject){  document.recalc() } ; // hack pour recalculer les effets css avec le hack IE7
		}
	}

	//---------------------------------------------------------------------------------------
	
	current_helpinput = winput;
	if(current_helpinput){
		current_helpbox.focus();		
		//setTimeout("addEvent(current_helpinput, 'blur', hide_helpbox);",200); 
		//setTimeout("addEvent(current_helpbox, 'click', hide_helpbox);",400); 
		addEvent(current_helpbox, 'blur', hide_helpbox);	
		addEvent(current_helpbox, 'click', hide_helpbox);	
	}	
	
}

function hide_helpbox(){	
	if (!document.getElementsByTagName) return;

	if (current_helpbox) {
		document.getElementsByTagName('body')[0].removeChild(current_helpbox);
		current_helpbox = null;
		current_helpinput = null;
	}
	return;
}

if(window.ActiveXObject){

	function correctPNG() // correctly handle PNG transparency in Win IE 5.5 or higher.
	{
	for(var i=0; i<document.images.length; i++)
		{
		var img = document.images[i]

		var imgName = img.src.toUpperCase()
		if (imgName.substring(imgName.length-3, imgName.length) == "PNG")
			{
			var need_to_see = need_to_see + "<br />" + img.width+ "x" +img.height ;
					
			var imgID = (img.id) ? "id='" + img.id + "' " : ""
			var imgClass = (img.className) ? "class='" + img.className + "' " : ""
			var imgTitle = (img.title) ? "title='" + img.title + "' " : "title='" + img.alt + "' "
			var imgStyle = "display:inline-block;" + img.style.cssText
			var imgAttribs = img.attributes;
			for (var j=0; j<imgAttribs.length; j++)
			{
				var imgAttrib = imgAttribs[j];
				if (imgAttrib.nodeName == "align")
					{
					if (imgAttrib.nodeValue == "left") imgStyle = "float:left;" + imgStyle
					if (imgAttrib.nodeValue == "right") imgStyle = "float:right;" + imgStyle
					break
					}
			}
			var strNewHTML = "<span " + imgID + imgClass + imgTitle
			strNewHTML += " style=\"" + "width:" + img.width + "px; height:" + (img.height - 6) + "px;" + imgStyle + ";"
			strNewHTML += "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader"
			strNewHTML += "(src='" + img.src + "', sizingMethod='image');\"></span>"
			img.outerHTML = strNewHTML
			i = i-1
			}
		}
		document.getElementById('sub_menu').innerHTML = document.getElementById('sub_menu').innerHTML  +need_to_see ;
	}

	
	//window.attachEvent("onload", correctPNG); // decomment to use this png transparency script instead of IE7 plugin one
}


var langbox = null;
var langinput = null ;


function show_languagebox(ini_obj,referer_id){

	if(langbox) hide_languagebox(1);
			
	if(!document.getElementsByTagName) return; // on verifie qu'on peut recup les elements par tag, permet de savoir si en gros on a besoin d'exec cette fonction, puisk sans ca rien ne marche


	//---------------------------------------------------------------------------------------
	// HELP BOX
	//---------------------------------------------------------------------------------------
	txtpos = findPos(ini_obj); // on recuper la position du text area dans l'espace page
	//divpos = findPos(document.getElementById('requested')); // on recuper la position du text area dans l'espace page
	tx = txtpos[0];
	ty = txtpos[1];
	
       //document.getElementById('sub_menu').innerHTML = tx+'x'+ty;
	
	var vbox = document.createElement('div'); // on
	vbox.id = "language_select_box";
	vbox.className = 'language_box petit classic_ul';
	
	//vbox.style.width = (bbcodebox_width+20) + 'px';
	//vbox.style.height = bbcodebox_height + 'px';

	vbox.style.left = (tx-140) + 'px'; // on deplace notre tooltip vers la droite de xx px 
	vbox.style.top = (ty + 24) + 'px'; // on deplace vers le bas de xxpx

	vbox.style.width = '220px';
	

	document.getElementsByTagName('body')[0].appendChild(vbox); // on definit notre balise d comme sous element de body  (affiche le tooltip en gros :) )
	if(document.getElementById('focus_util').innerHTML == ''){
		document.getElementById('focus_util').innerHTML = '<a href="javascript: ;" id="focus_util_textarea" ></a>';
	}
	langbox = vbox;	
	langbox_for_focus = document.getElementById('focus_util_textarea');	
	
	//var langbox = langboxS[last_id];
	
	
	//---------------------------------------------------------------------------------------	

	//---------------------------------------------------------------------------------------
	// REMPLISSAGE DES BOX
	//---------------------------------------------------------------------------------------

	if(langbox){ // on a bien une help box 		
			spe_url = './index.php?supertitle=langue_selection&referer_id='+referer_id ;
			//writeHTML('<img src="./img/connect_box.gif" alt="" style="" class="float_left" />',current_helpbox.id);		//writeHTML('&nbsp;&nbsp;Veuillez patienter...',defautdestination);	
			my_chb_id = langbox.id ;
			setTimeout("loadPage(spe_url,my_chb_id)",50);
	}

	//---------------------------------------------------------------------------------------
	
	langinput = ini_obj;
	if(langinput){
		langbox_for_focus.focus();		
		//setTimeout("addEvent(current_helpinput, 'blur', hide_helpbox);",200); 
              body_obj = document.getElementsByTagName('body')[0];
		//setTimeout("addEvent(body_obj, 'click', hide_languagebox)",100); 
		addEvent(langbox_for_focus, 'blur', hide_languagebox);	
		//addEvent(document.getElementsByTagName('body')[0], 'click', hide_languagebox);	
	}	
}

function hide_languagebox(immediate){	
	if (!document.getElementsByTagName) return;

	if (langbox) {
		if(immediate == 1){
			document.getElementsByTagName('body')[0].removeChild(langbox);
			langbox = null;
			langinput = null;
		}else {
			setTimeout("document.getElementsByTagName('body')[0].removeChild(langbox);langbox = null;langinput = null;",400);			
		}
	}
	return;
}

function change_language(newlang_id,referer_id){
	document.location.href = './index.php?lang='+newlang_id+'&pageid='+referer_id;
}

function striptags(txt){
	return noHtml(txt);
}

 function noHtml(txt) {
    a = txt.indexOf('<');
    b = txt.indexOf('>');
    len = txt.length;
    c = txt.substring(0, a);
    if(b == -1) {
       b = a;
    }
    d = txt.substring((b + 1), len);
    txt = c + d;
    cont = txt.indexOf('<');
    if (cont != -1) {
      txt = noHtml(txt);
    }
    return txt;
 }

// Fonction sur les caractères restants pour un champs SPAW
function carac_restant(input_name,max_char,message,delete_extra_char){

	var iframe_elems = document.getElementsByTagName('iframe');
	
	for(i =0;i<iframe_elems.length ;i++){
		if(iframe_elems[i].name == input_name+'_rEdit' ){
			if(noHtml(iframe_elems[i].contentDocument.body.innerHTML).length > max_char){
				document.getElementById(input_name+'_retour_infos').innerHTML = message;
				if(delete_extra_char == 1){
					document.getElementById(input_name+'_retour_infos').innerHTML += ' | <span style="color:#F00" class="gras">'+ (max_char - noHtml(iframe_elems[i].contentDocument.body.innerHTML).length) +'</span>';
					//~ a =  iframe_elems[i].contentDocument.body.innerHTML.substring(0,max_char)  ;
					//~ b = iframe_elems[i].contentDocument.body.innerHTML.substring(max_char, iframe_elems[i].contentDocument.body.innerHTML.length) ;
					//~ iframe_elems[i].contentDocument.body.innerHTML = a ;
					//~ if(iframe_elems[i].contentDocument.body.setSelectionRange){
						//~ iframe_elems[i].setSelectionRange(max_char, max_char); // on redéfinis la selection
					//~ }else alert('blop');
					//~ //iframe_elems[i].contentDocument.body.innerHTML = iframe_elems[i].contentDocument.body.innerHTML.substring(0,max_char) + "<span style=\"color:#F00\">"+b+"</span>" ;						
				}
			}else{
				document.getElementById(input_name+'_retour_infos').innerHTML = '';
			}
		}
		//document.getElementById('retour_infos').innerHTML = noHtml(iframe_elems[i].contentDocument.body.innerHTML);
	}
	
	setTimeout("carac_restant('"+input_name+"',"+max_char+",'"+message+"',"+delete_extra_char+")",600);
	return;
}

function externalLinks() {
	if (!document.getElementsByTagName) return;
	var anchors = document.getElementsByTagName("a");
	for (var i=0; i<anchors.length; i++) {
		var anchor = anchors[i];
		if (anchor.getAttribute("href") &&
		anchor.getAttribute("rel") == "external")
		anchor.target = "_blank";
	}	
}

var global_demoBox = null;
var demoBoxInnerText =null;



function demo_gpsbee(){
	if( !demoBoxInnerText){
		demoBoxInnerText = document.getElementById('popup_div').innerHTML;
		document.getElementById('popup_div').innerHTML = '';
	}
	var demoBox = document.createElement('div'); // on
	demoBox.id = "demo_gpsbee_id";
	demoBox.className = 'petit';
	myHeight = findPosY(document.getElementById('last_element'));
	//vbox.style.width = (bbcodebox_width+20) + 'px';
	//vbox.style.height = bbcodebox_height + 'px';
	demoBox.style.position = 'absolute';
	demoBox.style.top = 0 + 'px'; // on deplace vers le bas de xxpx
	demoBox.style.left = 0+ 'px'; // on deplace notre tooltip vers la droite de xx px 
	demoBox.style.width = '100%'; // on deplace notre tooltip vers la droite de xx px 
	demoBox.style.height = (myHeight + 30 ) + 'px'; // on deplace notre tooltip vers la droite de xx px 
	demoBox.style.color = '#000000';
	//~ demoBox.style.backgroundColor = '#0000';
	//~ InnerText = document.getElementById('popup_div').innerHTML;
	demoBox.innerHTML ='<table style="width:600px;opacity:0.98;height:100%;margin-left:auto;margin-right:auto;background-color:#222;border:1px solid #FFF;color:#FFF;font-size:130%;"><tr><td><a id="popup_info" name="popup_info">&nbsp;</a>'+demoBoxInnerText+'</td></tr></table>';

	document.getElementsByTagName('body')[0].appendChild(demoBox); // on definit notre balise d comme sous element de body  (affiche le tooltip en gros :) )
	//~ addEvent(demoBox, 'click', gotosite_gpsbee);	
	global_demoBox = demoBox;
	location.href='#popup_info';
}

function close_gpsbee(){
	if(global_demoBox){
		document.getElementsByTagName('body')[0].removeChild(global_demoBox);
		global_demoBox = null;
		//~ location.href='./page-nos-solutions.html';
	}
}

function gotosite_gpsbee(){
	if(global_demoBox){
		document.getElementsByTagName('body')[0].removeChild(global_demoBox);
		global_demoBox = null;
		location.href='./page-nos-solutions.html';
	}
}
