function remplace(text,find,repl){
  var found = text.indexOf(find);
  var retVal= "";
  var start = 0;
  while(found != -1){
    retVal +=text.substring(start,found) +repl;
    start = found+find.length;
    found =text.indexOf(find,start);
  }
  retVal +=text.substring(start,text.length);
  return retVal;
}

function ucfirst(str) {
   str = str.toLowerCase();
   return str.substr(0,1).toUpperCase()+str.substr(1)
}

function MM_findObj(n, d) { //v4.0
	var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
		d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
	if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
	for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
	if(!x && document.getElementById) x=document.getElementById(n); return x;
	}

function MM_swapImgRestore() { 
		var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
	}

function MM_swapImage() { 
		var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
		if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
		}
		
function MM_showHideLayers() { //v3.0
	var i,p,v,obj,args=MM_showHideLayers.arguments;
	for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
		if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v='hide')?'hidden':v; }
		obj.visibility=v; }
	}

function Openhw (path,nom,h,w){
		win = window.open(path,nom,"width="+w+",height="+h+",toolbar=yes,location=no,status=no,menubar=no,scrollbars=no,resizable=no");
}

function OpenhwNoToolbar (path,nom,h,w){
		win = window.open(path,nom,"width="+w+",height="+h+",toolbar=no,location=no,status=no,menubar=no,scrollbars=no,resizable=no");
}

function OpenhwWithParam (path,nom,h,w,toolbar,menubar,scrollbars){
		win = window.open(path,nom,"width="+w+",height="+h+",toolbar="+ toolbar + ",location=no,status=no,menubar="+ menubar +",scrollbars="+ scrollbars +",resizable=no");
}

function Openhwscroll (path,nom,h,w){
		win = window.open(path,nom,"width="+w+",height="+h+",toolbar=yes,location=no,status=no,menubar=no,scrollbars=yes,resizable=no");
}

function AddEncodedParameter(pageUrl, parameterName, parameterValue)
{
	var parameterEncodedValue = new String();
	var character;
			
	if ((pageUrl) && (parameterValue) && (parameterName))
	{
		for (var index=0; index < parameterValue.length; index++) 
		{ 
			character = parameterValue.charAt(index); 
			if (character == '?' ) parameterEncodedValue += "%3F"; 
			else if (character == '&') parameterEncodedValue += "%26"; 
			else if (character == '/') parameterEncodedValue += "%2F"; 
			else parameterEncodedValue += character; 
		}
	
		return pageUrl + parameterName + '=' + parameterEncodedValue;
	}
	else
	{
		return '';
	}
}

function UpperCase(text)
{
	document.write(text.toUpperCase());
}

// Vérifier la pression sur la touche Entrée et soumet le formulaire
function checkEnterAndSubmit(e,myForm,submitUrl){ //e is event object passed from function invocation
	var characterCode;  //literal character code will be stored in this variable
	
	if(e && e.which){ //if "which" property of event object is supported (NN4)
		e = e;
		characterCode = e.which; //character code is contained in NN4's which property
	}
	else{
		e = event;
		characterCode = e.keyCode; //character code is contained in IE's keyCode property
	}
	
	if(characterCode == 13){ //if generated character code is equal to ascii 13 (if enter key)
		if (submitUrl != null && submitUrl != "")
		{
			// On change l'attribut "action" du 1er formulaire sur la page
			//alert(document.__aspnetForm);
			//alert(document.__aspnetForm.action);
			document.__aspnetForm.action = submitUrl;
			document.__aspnetForm.submit();
		}
	}
}

function nomargin(){
	// permet de déterminer le navigateur en fonction de nos besoins
	var dom = net = iex = false;
	if (document.getElementById) dom = true; // IE5+ ou Netscape6+/Mozilla
	if (document.layers) net = true; // Netscape4 
	if (document.all) iex = true; // IE4+
	
	if (iex) {
	  var larg_utile = "document.body.offsetWidth";
	  var haut_utile = "document.body.offsetHeight";
	}
	else if (dom || net) {
	  var larg_utile = "window.innerWidth";
	  var haut_utile = "window.innerHeight";
	}
	else {}
	var nb_couleurs = screen.colorDepth;
	var larg_ecran = screen.width;
	var haut_ecran = screen.height;
	
	var iddiv = "TakeCareCenter";
	if(!document.getElementById("TakeCareCenter")){
		iddiv = "TakeCareCenter_Home";
	}
	if(eval(larg_utile)<960){
	    if(document.getElementById(iddiv)){
		   document.getElementById(iddiv).style.left = 0;
		   document.getElementById(iddiv).style.marginLeft = 0;
		}
	}else{
		if(document.getElementById(iddiv)){
		   document.getElementById(iddiv).style.left = "50%";
		   document.getElementById(iddiv).style.marginLeft = "-480px";
		}
	}
	if(eval(haut_utile)<600){
		if(document.getElementById(iddiv)){
		   document.getElementById(iddiv).style.top = 0;
		   document.getElementById(iddiv).style.marginTop= 0;
		}
	}else{
	    if(document.getElementById(iddiv)){
		   document.getElementById(iddiv).style.top = 0;
		   document.getElementById(iddiv).style.marginTop= 0;
		}
	}
}

window.onload= nomargin;
window.onresize= nomargin;

/************** Ouverture d'un div site map ou info site **************/
function OpenClosedDiv(id_pres){
	if(document.getElementById(id_pres).style.display != 'block' ){
		document.getElementById(id_pres).style.display = 'block';
	}
	else {
		document.getElementById(id_pres).style.display = 'none';
	}
}

