function sld(id){
 $(id).innerHTML='&nbsp;&nbsp;&nbsp;<img src="'+website+'/images/loading_bar.gif">'
}

function ld(id){
 $(id).innerHTML='';
 $(id).className="loading_bar";
}

function ld2(id){
 $(id).innerHTML='';
 $(id).className="loading_bar2";
}
function ld3(obj){
 //obj.value=" ";
 obj.className=obj.className+"_loading";
}
function ld4(obj){
 obj.innerHTML='<img src="'+website+'/images/blank.png" width="30" height="1">'
 obj.className="loading_s";
}

var mouseX=0;
var mouseY=0;
function getMousePos(e)
{
if (!e)
var e = window.event||window.Event;

if('undefined'!=typeof e.pageX)
{
mouseX = e.pageX;
mouseY = e.pageY;
}
else
{
mouseX = e.clientX + document.body.scrollLeft;
mouseY = e.clientY + document.body.scrollTop;
}
return [mouseX,mouseY]
}
function confirmDel(msg){
return confirm(msg)
}

function confirmbox2(msg){
_14 = "delX";
_13="<div id='delX' style=\"display:none\" class=\"errbox\"><div>Suppression confirm</div></div>";

 if (!document.all) // if Mozilla, Safari etc
 {
   var n=document.createElement("DIV");
   document.body.appendChild(n);
   outerHtml(n, _13);
 }
 else  // if IE
  document.body.insertAdjacentHTML("afterbegin",_13);

var box=$(_14);
box.style.position="absolute";
box.style.left=(mouseX-5)+"px";
box.style.top=(mouseY-5)+"px";
box.style.width="220px";
box.style.display="block";
}
if(window.Event && document.captureEvents)
document.captureEvents(Event.MOUSEMOVE);

// Then assign the mouse handler

document.onmousemove = getMousePos;

function ainnerX(){
return window.pageXOffset||document.documentElement.scrollLeft||document.body.scrollLeft||0;
}

function ainnerY(){
return window.pageYOffset||document.documentElement.scrollTop||document.body.scrollTop||0;
}

function ainnerWidth(){
return window.innerWidth?window.innerWidth:document.documentElement&&document.documentElement.clientWidth?document.documentElement.clientWidth:document.body.clientWidth;
}

function ainnerHeight(){
return window.innerHeight?window.innerHeight:document.documentElement&&document.documentElement.clientHeight?document.documentElement.clientHeight:document.body.clientHeight;
}


function  outerHtml(n,_39){
if(n.outerHTML){
n.outerHTML=_39;
}else{
var _3a=document.createRange();
_3a.setStartBefore(n);
var df=_3a.createContextualFragment(_39);
n.parentNode.replaceChild(df,n);
}
}
//show div alert
function cumulativeOffset(_194){
var _195=0,valueL=0;
do{
_195+=_194.offsetTop||0;
valueL+=_194.offsetLeft||0;
if(_194.offsetParent==document.body){
if(Element.getStyle(_194,"position")=="absolute"){
break;
}
}
_194=_194.offsetParent;
}while(_194);
return [valueL,_195];
}


function reloadContent(){
 var url = parent.$F('reloadUrl');
 parentRetrieveURL(url,'ajaxcontentarea');
}

//ajax send form post and reload the content div result
function retrieveURL(url, divId){
$(divId).innerHTML = loadstatustext;
url+="&r=" + new Date().getTime();
new Ajax.Updater(divId, url, {asynchronous:true, evalScripts:true});
}

//ajax send form post and reload the content div result
function rURL(url, divId){
$(divId).innerHTML = "<div class='loading'><img src='"+website+"/images/loading_2.gif'></div>";
url+="&r=" + new Date().getTime();
new Ajax.Updater(divId, url, {asynchronous:true, evalScripts:true});
}

//ajax send form post and reload the content div result
function rFrm(form, divId){
var params = Form.serialize($(form));
url = getPostbackURL(form)+ "?" + params;
rsFrm(url, divId);
$(divId).innerHTML = "<div class='loading'><img src='"+website+"/images/loading_2.gif'></div>";
}
function rcFrm(form, divId, txt){
var params = Form.serialize($(form));
url = getPostbackURL(form)+ "?" + params;
rsFrm(url, divId);
$(txt).innerHTML = "<div class='loading2'><img src='"+website+"/images/loading.gif'></div>";
}
function dFrm(form, divId){
var params = Form.serialize($(form));
url = getPostbackURL(form)+ "?" + params;
rsFrm(url, divId);
}
function rsFrm(url, divId){
url+="&r=" + new Date().getTime();
new Ajax.Updater(divId, url, {asynchronous:true, evalScripts:true});
}


function retrieveDirectURL(url, divId){
url+="&r=" + new Date().getTime();
new Ajax.Updater(divId, url, {asynchronous:true, evalScripts:true});
}

function getXMLHttpRequest() {
  var g_request = null;
  if (!g_request) {
    if (window.XMLHttpRequest) {
      g_request = new XMLHttpRequest();
    } else if (window.ActiveXObject) {
      isIE = true;
      g_request = new ActiveXObject("Microsoft.XMLHTTP");
    }
  }
  return (g_request);
}


function evalScripts(areaId){
  var js = $(areaId).getElementsByTagName("script");
  for (var i=0; i<js.length; i++) {
   _html=js[i].innerHTML;
   _html=_html.replace("<!--", "");
   _html=_html.replace("//-->", "");
   eval(js[i].innerHTML);
  }
}



function sendForm(form, tagid) {
      var params = Form.serialize($(form));
      params+="&r=" + new Date().getTime();
      retrieveURL(getPostbackURL(form)+ "?" + params, tagid);
}

//ajax send form post and reload the content div result
function retrieveURL2(url, divId){
url+="&r=" + new Date().getTime();
loadingbox();
new Ajax.Updater(divId, url, {asynchronous:true, evalScripts:true});
}

function sendFormTable(idtr, form, tagid) {
      $(idtr).style.display='none';
      var obj = $(form);
      if(obj == null)
       obj = document.forms[form];
      var params = Form.serialize(obj);
      params+="&r=" + new Date().getTime();
      //document.write(getPostbackURL(form)+'?'+params);
      new Ajax.Updater(tagid, getPostbackURL(form), {asynchronous:true, evalScripts:true, parameters:params});
}

function sendForm2(form, tagid) {
      var obj = $(form);
      if(obj == null)
       obj = document.forms[form];
      var params = Form.serialize(obj);
      params+="&r=" + new Date().getTime();
      //loadingbox2(tagid);
      ajaxRetrieveUrl(getPostbackURL(form)+'?'+params, tagid);
}


//ajax send form post and reload the content div result
function sendAsync(formName){
var obj = $(formName);
if(obj == null)
 obj = document.forms[formName];
var params = Form.serialize(obj);
params+="&r=" + new Date().getTime();
new Ajax.Updater('rbodycontent02', getPostbackURL(formName), {asynchronous:true, evalScripts:false, parameters:params});
}


function sendForm02(form, form2, tagid) {
      var obj = $(form);
      var obj2 = $(form2);
      if(obj == null)
       obj = document.forms[form];
      var params = Form.serialize(obj)+'&'+Form.serialize(obj2);
      params+="&r=" + new Date().getTime();
      ajaxRetrieveUrl(getPostbackURL(form)+ "?" + params, tagid);
}

function ajaxRetrieveUrl(url, tagId) {
    var req;
    //loadingbox();
    if (window.XMLHttpRequest) { // Non-IE browsers
      req = new XMLHttpRequest();
      req.onreadystatechange = function(){
        if (req.readyState == 4){ // Complete
         if (req.status == 200) // OK response
           $(tagId).innerHTML = req.responseText;
           evalScripts(tagId);
           if($('LodingBox'))
           Element.remove("LodingBox");
           if($('LodingBox'+tagId))
           Element.remove("LodingBox"+tagId);
         }
      };
      try {
        req.open("GET", url, true);
      } catch (e) {
        alert(e);
      }
      req.send(null);
    } else if (window.ActiveXObject) { // IE
      req = new ActiveXObject("Microsoft.XMLHTTP");
      if (req) {
        req.onreadystatechange = function(){
        if (req.readyState == 4){ // Complete
         if (req.status == 200)
           $(tagId).innerHTML = req.responseText;
           evalScripts(tagId);
           if($('LodingBox'))
            Element.remove("LodingBox");
           if($('LodingBox'+tagId))
            Element.remove("LodingBox"+tagId);
         }
      };
       req.open("GET", url, true);
       req.send();
      }
    }
 }

function loadingbox2(tagid){
var _14="LodingBox"+tagid;
_13="<div id='LodingBox"+tagid+"' style=\"display:yes\" class=\"loadBox\">"+loadtext+"</div>";

 if (!document.all) // if Mozilla, Safari etc
 {
   var n=document.createElement("DIV");
   document.body.appendChild(n);
   outerHtml(n, _13);
 }
 else  // if IE
  document.body.insertAdjacentHTML("afterbegin",_13);


var scl = ainnerX();
var sct = ainnerY();
var h = screen.height;
var w = screen.width;
var box=$(_14);
box.style.left=0+"px";
box.style.top=(sct)+"px";
//Event.observe(window,"resize",doMoveBox, false);
//Event.observe(window,"scroll",doMoveBox, false);
}

function loadingbox(){
var _14="LodingBox";
_13="<div id='LodingBox' style=\"display:yes\" class=\"loadBox\">"+loadtext+"</div>";

 if (!document.all) // if Mozilla, Safari etc
 {
   var n=document.createElement("DIV");
   document.body.appendChild(n);
   outerHtml(n, _13);
 }
 else  // if IE
  document.body.insertAdjacentHTML("afterbegin",_13);


var scl = ainnerX();
var sct = ainnerY();
var h = screen.height;
var w = screen.width;
var box=$(_14);
box.style.left=0+"px";
box.style.top=(sct)+"px";
//Event.observe(window,"resize",doMoveBox, false);
//Event.observe(window,"scroll",doMoveBox, false);
}

function doMoveBox(evt){
var _1d=$("LodingBox");
_1d.style.left=ainnerX()+"px";
_1d.style.top=ainnerY()+"px";
 return true;
}

function removeBox(){
//Event.stopObserving(window,"resize",doMoveBox);
//Event.stopObserving(window,"scroll",doMoveBox);
Element.remove("LodingBox");
}


function autobox(spanId, form, value){
if(value.length>=3){
 var _14="auto"+spanId;
 if($(_14)){
 }else{
 _13="<div id='"+_14+"' style=\"display:none\" class=\"autobox\">sddd<br/></div>";
 if (!document.all) // if Mozilla, Safari etc
 {
   var n=document.createElement("DIV");
   document.body.appendChild(n);
   outerHtml(n, _13);
 }
  else  // if IE
   document.body.insertAdjacentHTML("afterbegin",_13);
 }
 var box=$(_14);
 box.style.position="absolute";
 var inp=$(spanId);
 ref=inp;
 var ofs=cumulativeOffset(ref);
 box.style.left=ofs[0]+"px";
 box.style.top=ofs[1]+20+"px";
 box.style.width=inp.size/2+"em";
 box.style.display="block";
 sendForm2(form, _14)
}
}

function removeAuto(spanId){
 Element.remove("auto"+spanId)
}


function autoComplete(input, url, tagId, btn){
 var ofs=cumulativeOffset(input.id);
 var box=$(tagId);
 if(input.value == '')
 box.style.display='none';
 else{
   if(input.value.length >= 2){
    box.style.display='block';
    box.style.left=ofs[0]+"px";
    box.style.top=ofs[1]+20+"px";
    box.style.display="block";
    ajaxRetrieveUrl(url, tagId);
   }else{
    box.innerHTML='';
    box.style.display='none';
   }

 }
 return false;
}

function autoCancel(tagId){
 var box=$(tagId);
 //box.innerHTML='';
 //box.style.display='none';
 return false;
}

function autoValue(obj, input, tagid){
  $(input).value=obj.innerHTML;
  $(tagid).style.display='none';
  $(input).focus();
}
function effectForm(form, tagid) {
      var obj = $(form);
      if(obj == null)
       obj = document.forms[form];
      var params = Form.serialize(obj);
      params+="&r=" + new Date().getTime();
      url = getPostbackURL(form)+'?'+params;
      effectRetrieveUrl(url, tagid);
}

function sendEffectForm(form, tagid) {
      var obj = $(form);
      if(obj == null)
       obj = document.forms[form];
      var params = Form.serialize(obj);
      params+="&r=" + new Date().getTime();
      url = getPostbackURL(form)+'?'+params;
      $(tagid).innerHTML=loadimg;
      $(tagid).style.display='block';
      effectRetrieveUrl(url, tagid);
}

function effectRetrieveUrl(url, tagId) {
    var req;
    if (window.XMLHttpRequest) { // Non-IE browsers
      req = new XMLHttpRequest();
      req.onreadystatechange = function(){
        if (req.readyState == 4){ // Complete
         if (req.status == 200) // OK response
           $(tagId).innerHTML = req.responseText;
           evalScripts(tagId);
           $(tagId).style.display='none';
           new Effect.toggle($(tagId),'blind')
         }
      };
      try {
        req.open("GET", url, true);
      } catch (e) {
        alert(e);
      }
      req.send(null);
    } else if (window.ActiveXObject) { // IE
      req = new ActiveXObject("Microsoft.XMLHTTP");
      if (req) {
        req.onreadystatechange = function(){
        if (req.readyState == 4){ // Complete
         if (req.status == 200)
           $(tagId).innerHTML = req.responseText;
           evalScripts(tagId);
           $(tagId).style.display='none';
           new Effect.toggle($(tagId),'blind')
         }
      };
       req.open("GET", url, true);
       req.send();
      }
    }
 }
var _w = 0;
function jSendForm(form){
var obj = $(form);
if(obj == null)
 obj = document.forms[form];
var params = Form.serialize(obj);
params+="&r=" + new Date().getTime();
action =getPostbackURL(form);
$('containerDiv').style.width='30%';
lightbox._centerWindow('containerDiv');
$('ajx').innerHTML = "<div class='text_contenu'><table align=center><tr><td>"+img+"</td><td>Chargement en cours ...</td></tr></table></div>";
//setTimeout("jActionComplete('"+action+"','"+params+"')", 1000);
params+="&lang=fr"
jActionComplete(action,params);
}
function jSend(actionName,params){
$('containerDiv').style.width='30%';
lightbox._centerWindow('containerDiv');
$('ajx').innerHTML = "<table align=center><tr><td>"+img+"</td><td>Chargement en cours ...</td></tr></table>";
setTimeout("jActionComplete('"+actionName+"','"+params+"')", 1000);
}
function jActionComplete(actionName,params){
params+="&r=" + new Date().getTime();
new Ajax.Updater('ajx', actionName, {asynchronous:true, evalScripts:true, parameters:params });
}
function jResponse(response, json){
$('containerDiv').style.width=_w+'%';
lightbox._centerWindow('containerDiv');
//new Effect.Grow($('containerDiv'));
}
function jSendUrl(actionName,params, w, title){
$('containerTitle').innerHTML=title;
lightbox.open();
//$('containerDiv').style.width='30%';
_w = w;
setTimeout("jAction('"+actionName+"','"+params+"')", 1000);
}

function jv(w, title, msg){
$('containerTitle').innerHTML=title;
lightbox.open();
$('containerDiv').style.width='30%';
_w = w;
$('ajx').innerHTML='Test'
}

function jSendUrl(actionName,params, w, title){
$('containerTitle').innerHTML=title;
lightbox.open();
$('containerDiv').style.width='30%';
_w = w;
setTimeout("jAction('"+actionName+"','"+params+"')", 1000);
}


function jAction(actionName,params){
params+="&r=" + new Date().getTime();
new Ajax.Updater('ajx', actionName, {asynchronous:true, evalScripts:true, parameters:params, onComplete:function(response, json) { jResponse(response, json); } });
}
function jClose(){
lightbox.close(); // DOM
}

function parentJClose(){
parent.lightbox.close(); // DOM
}



