function stepaction(action,i)
{
	document.wizard.step_action.value = action;
	document.wizard.step_nb.value = i;
	document.wizard.submit();
}

function popup(url, type, h, w)
{
  var nsNav = (document.layers) ? 1 : 0;
  var ieNav = (document.all) ? 1 : 0;
  var left = 0;
  var top = 0;

  if(ieNav){
    left = (document.body.clientWidth - w)/2;
	top = (document.body.clientHeight - h)/2;
  }
  else if(nsNav){
    left = (self.innerWidth - w)/2;
	top = (self.innerHeight - h)/2;
  }
  wintype="toolbar=0,menubar=0,location=0,scrollbars=1,resizable=1,top="+top+",left="+left+",height="+h+",width="+w;
  var newwin = window.open(url,type,wintype);
  newwin.focus();
}

function popupvide(url, type, h, w)
{
  var nsNav = (document.layers) ? 1 : 0;
  var ieNav = (document.all) ? 1 : 0;
  var left = 0;
  var top = 0;

  if(ieNav){
    left = (document.body.clientWidth - w)/2;
	top = (document.body.clientHeight - h)/2;
  }
  else if(nsNav){
    left = (self.innerWidth - w)/2;
	top = (self.innerHeight - h)/2;
  }
  wintype="toolbar=0,menubar=0,location=0,scrollbars=0,resizable=0,top="+top+",left="+left+",height="+h+",width="+w;
  var newwin = window.open(url,type,wintype);
  newwin.focus();
}


function webEditor(field)
{
	window.open('kernel/services/webeditor/word.php?name='+field,'WebEditor','personalbar=no,toolbar=no,status=no,scrollbars=no,location=no,resizable=yes,menubar=no,titlebar=no,Top='+20+',Left='+20+',Width='+770+',Height='+620);
}

function webColor(value)
{
	return showModalDialog('kernel/services/color/color.htm',value,'status=no,scroll:no;resizable:no;dialogWidth:250px;dialogHeight:370px');
}

function webCalendar(name,hidden)
{
	window.open('kernel/services/calendar/calendar.php?name='+name+'&hidden='+hidden,'calendar_'+name,'status=yes,toolbar=no,scrollbars=yes,resizable=yes,width=200,height=180,left=20,top=20');
}

function webCalendar2(hidden)
{
	window.open('kernel/services/calendar/calendar2.php?hidden='+hidden,'calendar_'+hidden,'status=yes,toolbar=no,scrollbars=yes,resizable=yes,width=200,height=180,left=20,top=20');
}


//function replace
function replace(string,text,by) {
// Replaces text with by in string
    var strLength = string.length, txtLength = text.length;
    if ((strLength == 0) || (txtLength == 0)) return string;

    var i = string.indexOf(text);
    if ((!i) && (text != string.substring(0,txtLength))) return string;
    if (i == -1) return string;

    var newstr = string.substring(0,i) + by;

    if (i+txtLength < strLength)
        newstr += replace(string.substring(i+txtLength,strLength),text,by);

    return newstr;
}

//Paste the textareavalue in another area value field1 => field2
function paste(field1, field2, size){
	var2 = eval("document.wizard."+field2+".value");
	if(var2 == "")
	{
		var1 = eval("document.wizard."+field1+".value");
		var1 = replace(var1,'"',"''");
		var1 = replace(var1,'\r',"<br>");
		var1 = replace(var1,'\n',"<br>");
		if(size!="")
		{
			if(var1.length > size)
			{
				var3 = var1.substring(0,size-4)+"...";
			}
			else
			{
				var3 = var1;
			}
		}
		else
		{
			var3 = var1;
		}
		vareval = "document.wizard."+field2+".value=\""+var3+"\";";
		eval(vareval);
	}
}

function checkRights(formulaire,init_field,tab_id)
{
	for (i=0;i<tab_id.length;i++)
	{
		var e = formulaire.elements[tab_id[i]];
		if( formulaire.elements[init_field].checked>0  )
			e.checked = 1;
		else
			e.checked = 0;
	}
}

