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=no,menubar=no,location=no,scrollbars=1,resizable=0,top="+top+",left="+left+",height="+h+",width="+w;
	var newwin = window.open(url,type,wintype);
	newwin.focus();
}


function webEditor(field)
{
	//var editwin=window.open('/services/webeditor/word.php?name='+field,'WebEditor','personalbar=no,toolbar=no,status=yes,scrollbars=no,location=no,resizable=yes,menubar=no,titlebar=no,Top='+20+',Left='+20+',Width='+770+',Height='+620);
	var editwin=window.open('/services/miniword.php?name='+field,'WebEditor','personalbar=no,toolbar=no,status=yes,scrollbars=no,location=no,resizable=yes,menubar=no,titlebar=no,Top='+20+',Left='+20+',Width='+640+',Height='+450);
	editwin.focus();
}

function webColor(value)
{
	return showModalDialog('/services/color/color.htm',value,'status=no,scroll:no;resizable:no;dialogWidth:250px;dialogHeight:370px');
}

function webSearchCalendar(name,hidden,init)
{
	if( ! init)
	{
		init="";
	}
	calwin=window.open('/services/calendar/calendar.php?name='+name+'&hidden='+hidden+'&dt='+init+'&darkcolor=EB9999&lightcolor=CCCCCC&textcolor=BF0000','calendar_'+name,'status=no,toolbar=no,scrollbars=yes,resizable=yes,width=200,height=180');
	calwin.focus();
}


function webCalendar(name,hidden,init)
{
	if( ! init)
	{
		init="";
	}
	calwin=window.open('/services/calendar/calendar.php?name='+name+'&hidden='+hidden+'&dt='+init,'calendar_'+name,'status=no,toolbar=no,scrollbars=yes,resizable=yes,width=200,height=180');
	calwin.focus();
}

//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;
	}
}

function RollOver(id,typeMenu,chemin) 
// change le fond d'une zone réactive du Menu principal
// id : id du tag actif - typeMenu: Citoyen, Tourisme, ou Economie
{	
	TD = document.getElementById(id);
	cheminBackground = chemin+'bgMenu'+typeMenu+'.gif';	
	TD.style.backgroundImage='url('+cheminBackground+')';
}
function RollOut(id,typeMenu) 
// change le fond d'une zone réactive du Menu principal
// id : id du tag actif - typeMenu: Citoyen, Tourisme, ou Economie
{	
	TD = document.getElementById(id);
	if (typeMenu == 'Citoyen') couleur = '#0066CC';
	if (typeMenu == 'Tourisme') couleur = '#FF9900';
	if (typeMenu == 'Eco') couleur = '#009933';
	TD.style.backgroundColor=couleur;
	TD.style.backgroundImage='none';
}