function dims_openwin(url,w,h)
{
	dimswin=window.open(url,'dimswin','width='+w+', height='+h+', status=no, menubar=no, toolbar=no, scrollbars=yes, resizable=yes, screenY=20, screenX=20');
	dimswin.moveTo((screen.width-w)/2,(screen.height-(h+60))/2);
	dimswin.focus();
}


function dims_confirmform(form, message) 
{
	if (confirm(message)) form.submit();
}

function dims_confirmlink(link, message) 
{
	if (confirm(message)) location.href=link;
}


function dims_switchstyle(obj, opacity)
{
	obj.style.filter='alpha(opacity:'+(opacity)+')';
	obj.style.MozOpacity = opacity/100;
}

function dims_validatefield(field_label, field_object, field_type)
{
	var ok = true;
	var i;
	var nbpoint = 0;
	var msg = new String();
	var reg = new RegExp("<FIELD_LABEL>","gi");
	
	field_value = field_object.value;

	if (field_type == 'email')
	{

		var email = field_value;
		var aroba = email.indexOf("@");
	
		if (aroba == -1)
		{
			ok = false;
			msg = lstmsg[0];
		}
	
		if (ok)
		{
			var point = email.indexOf(".", aroba);
			if ((point == -1) || (point == (aroba + 1)))
			{
				ok=false;
				msg = lstmsg[1];
			}
		}
	
		if (ok)
		{
			var point = email.lastIndexOf(".");
			if ((point + 1) == email.length)
			{
				ok = false;
				msg = lstmsg[2];
			}
		}
	
		if (ok)
		{
			point = email.indexOf("..")
			if (point != -1)
			{
				ok = false;
				msg = lstmsg[3];
			}
		}
	}

	if (field_type == 'string')
	{
		if (field_value.length==0) 
		{
			ok = false;
			msg = lstmsg[4];
		}
	}

	if (field_type == 'int')
	{
		if (field_value.length==0 || field_value.length>12) ok = false;
		for (i=0;i<field_value.length;i++)
		{
			if (field_value.charAt(i)<'0' || field_value.charAt(i)>'9') ok = false;
		}
		if (!ok) msg = lstmsg[5];
	}

	if (field_type == 'float')
	{
		if (field_value.length==0) ok = false;
		for (i=0;i<field_value.length;i++)
		{
			if (field_value.charAt(i)=='.') nbpoint++;
			if (field_value.charAt(i)<'0' || field_value.charAt(i)>'9') ok = false;
		}
		if (nbpoint>1) ok = false;
		
		if (!ok) msg = lstmsg[6];
	}

	if (field_type == 'date')
	{
		var thedate = field_value.split("/");
		if (thedate.length != 3 || isNaN(parseInt(thedate[0])) || isNaN(parseInt(thedate[1])) || isNaN(parseInt(thedate[2]))) thedate = field_value.split("-");
		if (thedate.length != 3 || isNaN(parseInt(thedate[0])) || isNaN(parseInt(thedate[1])) || isNaN(parseInt(thedate[2]))) thedate = field_value.split(":");
		if (thedate.length != 3 || isNaN(parseInt(thedate[0])) || isNaN(parseInt(thedate[1])) || isNaN(parseInt(thedate[2]))) ok = false;
		if (ok)
		{
			var datetotest = new Date(eval(thedate[2]),eval(thedate[1])-1,eval(thedate[0]));
			var year = datetotest.getYear()
			if ((Math.abs(year)+"").length < 4) year = year + 1900
			ok = ((datetotest.getDate() == eval(thedate[0])) && (datetotest.getMonth() == eval(thedate[1])-1) && (year == eval(thedate[2])));
		}
		if (!ok) msg = lstmsg[7];
	}

	if (field_type == 'time')
	{
		if (field_value.length!=5) ok = false;
		else
		{
			h=field_value.substring(0,2);
			m=field_value.substring(3,5);
			if (parseInt(h)<0 || parseInt(h)>23) ok = false;
			if (parseInt(m)<0 || parseInt(m)>59) ok = false;
			madate=new Date(01,01,2000,h,m);
			if (madate=="NaN" || field_value.charAt(2)!=':') ok = false;
		}
		if (!ok) msg = lstmsg[8];
	}

	if (field_type=='emptydate')
	{
		if (field_value.length!=0)
		{
			var thedate = field_value.split("/");
			if (thedate.length != 3 || isNaN(parseInt(thedate[0])) || isNaN(parseInt(thedate[1])) || isNaN(parseInt(thedate[2]))) thedate = field_value.split("-");
			if (thedate.length != 3 || isNaN(parseInt(thedate[0])) || isNaN(parseInt(thedate[1])) || isNaN(parseInt(thedate[2]))) thedate = field_value.split(":");
			if (thedate.length != 3 || isNaN(parseInt(thedate[0])) || isNaN(parseInt(thedate[1])) || isNaN(parseInt(thedate[2]))) ok = false;
			if (ok)
			{
				var datetotest = new Date(eval(thedate[2]),eval(thedate[1])-1,eval(thedate[0]));
				var year = datetotest.getYear()
				if ((Math.abs(year)+"").length < 4) year = year + 1900
				ok = ((datetotest.getDate() == eval(thedate[0])) && (datetotest.getMonth() == eval(thedate[1])-1) && (year == eval(thedate[2])));
			}
			if (!ok) msg = lstmsg[7];
		}
	}
	
	if (field_type=='emptytime')
	{
		if (field_value.length!=0)
		{
			if (field_value.length!=5) ok = false;
			else
			{
				h=field_value.substring(0,2);
				m=field_value.substring(3,5);
				if (parseInt(h)<0 || parseInt(h)>23) ok = false;
				if (parseInt(m)<0 || parseInt(m)>59) ok = false;
				madate=new Date(01,01,2000,h,m);
				if (madate=="NaN" || field_value.charAt(2)!=':') ok = false;
			}
			if (!ok) msg = lstmsg[8];
		}
	}
	
	if (!ok)
	{
		alert(msg.replace(reg,field_label));
		field_object.style.background = error_bgcolor;
		field_object.focus();
	}

	return (ok);
}

/* declaration de variables permettant la maj de contenu dynamique */
var tabxmlarg = new Array();
var tabxmlresult = new Array();
var nbxmlarg=0;
var modexmlarg=0;
var xmlfinished=0;

function getHTTPObject()
{
	var xmlhttp = false;
	
	/*@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 @*/
	
	/* on essaie de créer l'objet si ce n'est pas déjà fait */
	if (!xmlhttp && typeof XMLHttpRequest != 'undefined')
	{
		try
		{
			xmlhttp = new XMLHttpRequest();
		}
		catch (e)
		{
			xmlhttp = false;
		}
	}
	
	if (xmlhttp)
	{
		/* on définit ce qui doit se passer quand la page répondra */
		xmlhttp.onreadystatechange=function()
		{
			if (xmlhttp.readyState == 4) /* 4 : état "complete" */
			{
				
				if (xmlhttp.status == 200) /* 200 : code HTTP pour OK */
				{
					/*
					Traitement de la réponse.
					Ici on affiche la réponse dans une boîte de dialogue.
					*/
					var tabxmlvalue = new Array();
					var result= xmlhttp.responseText;
					tabxmlvalue=result.split("|");
					for(i=0;i<nbxmlarg;i++)
					{
						if (modexmlarg == 0)
						{
							document.getElementById(tabxmlarg[i]).innerHTML=tabxmlvalue[i];
						}
						else
						{
							tabxmlresult[i]=tabxmlvalue[i];
						}
					}
				}
			}
			if (xmlhttp.responseText!="") xmlfinished=1;
			else 
			{
				for(i=0;i<nbxmlarg;i++) tabxmlresult[i]="";
			}
		}
	} 
	
	return xmlhttp;
}

/**
  * Envoie des données à l'aide d'XmlHttpRequest?
  * @param string methode d'envoi ['GET'|'POST']
  * @param string url
  * @param string données à envoyer sous la forme var1=value1&var2=value2...
  */
function sendData(method, url, data)
{
    var xmlhttp = getHTTPObject();

    if (!xmlhttp)
    {
        return false;
    }

    if(method == "GET")
	{
		if(data == 'null')
		{
			xmlhttp.open("GET", url, true); /* ouverture asynchrone */
			xmlhttp.setRequestHeader('Content-Type','application/x-www-form-urlencoded; charset=ISO-8859-15');
		}
		else
		{
			xmlhttp.open("GET", url+"?"+data, true);
			xmlhttp.setRequestHeader('Content-Type','application/x-www-form-urlencoded; charset=ISO-8859-15');
		}
		xmlhttp.send(null);
	}
	else if(method == "POST")
	{
		xmlhttp.open("POST", url, true); /* ouverture asynchrone */
		xmlhttp.setRequestHeader('Content-Type','application/x-www-form-urlencoded; charset=ISO-8859-15');
		xmlhttp.send(data);
	}
	return true;
}
 
function dims_getxmlhttp(url,op,params,mode)
{
	var args='xmlhttp=1&op='+op+params;
	modexmlarg=mode;
	xmlfinished=0;
	nbxmlarg=dims_getxmlhttp.arguments.length-4;
	
	for(i=0;i<nbxmlarg;i++)
	{
		tabxmlarg[i]=dims_getxmlhttp.arguments[i+4];
	}
	
	return !sendData(
		'GET',url,
		args
	);
}

function dims_checkall(form, mask, value)
{
	var len = form.elements.length;
	var reg = new RegExp(mask,"g");

	for (var i = 0; i < len; i++)
	{
		var e = form.elements[i];
		if (e.name.match(reg))
		{
		e.checked = value;
		}
	}
}