/*
var https=Array();
var httpsI=0;
var gr_cible=Array();
*/
var https=Array();
var https_i=0;
var gr_cible=Array();

/*
function setEditorValue(val,editor){
	if(dd.ie){
		// IE :
		editor.SetHTML(val);
	}else{
		// firefox :
		editor.InsertHtml(val);
		editor.Commands.GetCommand('FitWindow').Execute();
		editor.Commands.GetCommand('FitWindow').Execute();
	}
}

function getPageContent(page,editor){
	https[httpsI]=getHTTPObject();
	gr_cible[httpsI] = editor;
	getUrl(page,"callBackPageContent("+httpsI+")",httpsI);
	httpsI++;
}
function callBackPageContent(i){
	if (https[i].readyState == 4) {
		setEditorValue(https[i].responseText,gr_cible[i]);
		gr_cible[i]='';
	}
}
*/

/* ---------------------------------------------------- */
/* ---------------------------------------------------- */
/* POPUP */

function OpenWin(Loc,x,y){
	var r = "wMessageWindow"+Math.floor(Math.random()*1000000); ;
	controle=window.open(Loc,r,"toolbar=no,scrollbars=yes,directories=no,resizable=no,menubar=no,location=no,width="+x+",height="+y+",left=100,top=100,screenX=100,screenY=100");
	controle.focus();
}


/* ---------------------------------------------------- */
/* ---------------------------------------------------- */
/* test formulaire */
function isEmail(value){
  var re=/^[a-z0-9_-](\.?[a-z0-9_-])*[@]([a-z0-9_-]+\.)+([a-z]{2,3})$/i;
  return re.test(value)?true:false;
}

function only_space(chaine) {
  if (chaine=="") {return true;}
  if (chaine==" ") {return true;}
  for (var i=0 ; i<chaine.length ; i++) {
    if (chaine.charAt(i)!=" ") {
      return false;
    }
  }
  return true;
}


/* ---------------------------------------------------- */
/* ---------------------------------------------------- */
/* calques visibles / invisibles */
function _show(calque){
	try{
		document.getElementById(calque).style.visibility="visible";
		document.getElementById(calque).style.display="block";
	}catch(e){}
}
function _hide(calque){
	try{
		document.getElementById(calque).style.visibility="hidden";
		document.getElementById(calque).style.display="none";
	}catch(e){}
}
function showHide(calque){
	if (document.getElementById(calque).style.visibility=="hidden" || document.getElementById(calque).style.display=="none"){
		_show(calque);
	}else{
		_hide(calque);
	}
}


/* ---------------------------------------------------- */
/* ---------------------------------------------------- */
/* Ajax */
function ajaxGet(url,cible){
	https[https_i]=getHTTPObject();
	document.getElementById(cible).innerHTML = "<DIV style='width: 100%; height: 100%; text-align: center; vertical-align: middle;'><br /><img src='img/chargement.gif' border=0 alt='Chargement en cours...' /><br /><br /></DIV>";
//	document.getElementById(cible).innerHTML="<DIV style='width: 100%; height: 100%; text-align: center; vertical-align: middle;'><br /><img src='img/chargement.gif' border=0 alt='Chargement en cours...' /><br /><br /></DIV>";
	gr_cible[https_i]=cible;
	getUrl(url,"ajaxWrite("+https_i+")",https_i);
	https_i++;
}


function ajaxPost(url,cible){
	https[https_i]=getHTTPObject();
	document.getElementById(cible).innerHTML = "<DIV style='width: 100%; height: 100%; text-align: center; vertical-align: middle;'><br /><img src='img/chargement.gif' border=0 alt='Chargement en cours...' /><br /><br /></DIV>";
//	document.getElementById(cible).innerHTML="<DIV style='width: 100%; height: 100%; text-align: center; vertical-align: middle;'><br /><img src='img/chargement.gif' border=0 alt='Chargement en cours...' /><br /><br /></DIV>";
	gr_cible[https_i]=cible;
	postUrl(url,"ajaxWrite("+https_i+")",https_i);
	https_i++;
}



function ajaxWrite(i){
	if (https[i].readyState == 4) {
		try{
			document.getElementById(gr_cible[i]).innerHTML = https[i].responseText;
		}catch(e){}
		gr_cible[i]="";
	}
}


function ajaxAndFunc(url,func){
	https[https_i]=getHTTPObject();
	gr_cible[https_i]=null;
	getUrl(url,func+"("+https_i+")",https_i);
	https_i++;
}


function ajaxForm(formulaire,cible){
	try{
		var formu=document.getElementById(formulaire);
		actionForm = formu.action;
		methodForm = formu.method;
		var inputs = formu.getElementsByTagName("input");
		var formValues="";
		for (i=0;i<inputs.length;i++){
			switch(inputs[i].type){
				case "hidden" :
				case "text" :
					formValues+="&"+inputs[i].name+"="+inputs[i].value;
					break;
				case "radio" :
				case "checkbox" :
					if (inputs[i].checked) {formValues+="&"+inputs[i].name+"="+inputs[i].value;}
					break;
			}
		}
		url = actionForm+ "?" +formValues;
		switch(methodForm.toUpperCase()){
			case "POST" : ajaxPost(url,cible); break;
			case "GET" : ajaxGet(url,cible); break;
			default : ajaxGet(url,cible); break;			
		}
	}catch(e){}
}



/* ---------------------------------------------------- */
/* ---------------------------------------------------- */
/* ajax - interne : */
function getHTTPObject() {
  var xmlhttp;
  /*@cc_on
  @if (@_jscript_version >= 5)
    try {
      xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
      } catch (e) {
      try {
        xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
        } catch (E) {
        xmlhttp = false;
        }
      }
  @else
  xmlhttp = false;
  @end @*/
  if (!xmlhttp && typeof XMLHttpRequest != 'undefined') {
    try {
      xmlhttp = new XMLHttpRequest();
      } catch (e) {
      xmlhttp = false;
      }
    }
  return xmlhttp;
  }
//var http = getHTTPObject();


function getUrl(url,callback,i){
	if (url.indexOf("?")>0){
		url += "&randomNumber="+Math.random();
	}else{
		url += "?randomNumber="+Math.random();
	}
	https[i].open("GET", url, true);
	https[i].onreadystatechange = function(){eval(callback);};
	https[i].send(null);
}

function postUrl(url,callback,i){
	if (url.indexOf("?")>0){
		url += "&randomNumber="+Math.random();
	}else{
		url += "?randomNumber="+Math.random();
	}
	https[i].open("POST", url, true);
	https[i].onreadystatechange = function(){eval(callback);};
	https[i].send(null);
}