FunctionsOnLoad = new Array(); 
FormAction = new Array(); 
div = new Array();

//document.oncontextmenu=function Functiononcontext() {return false;}
		
window.onload = function() { 
   for(ii=0; ii<FunctionsOnLoad.length; ii++) {
		FunctionsOnLoad[ii]();
	} 
}

function FunctionOnLoad(Funct) { 
    FunctionsOnLoad[FunctionsOnLoad.length] = Funct; 
} 

function initfunc() {
	div["dp_message"]=document.getElementById("dp_message");
	div["ombre"]=document.getElementById("ombre");
	div["dp_transparent"]=document.getElementById("dp_transparent");
	div["dp_ajax"]=document.getElementById("dp_ajax");
	div["dp_ajax_ombre"]=document.getElementById("dp_ajax_ombre");
	div["dp_ajax_trans"]=document.getElementById("dp_ajax_trans");
	
	if (document.getElementById("menu_top")) {
		div["ribon"]=document.getElementById("ribon");
	}
}

FunctionOnLoad(initfunc);


function ie6() {
	div["dp_ajax"].style.position = 'absolute';
	div["dp_ajax_ombre"].style.position = 'absolute';
	if (document.getElementById("menu_top")) {
		div["menu_top"]=document.getElementById("menu_top");
	}
	window.onscroll = FunctionOnScroll_ie6;
}

function other() {
	div["dp_ajax"].style.position = 'fixed';
	div["dp_ajax_ombre"].style.position = 'fixed';
	if (document.getElementById("menu_top")) {
		div["menu_top"]=document.getElementById("menu_top");
		div["menu_top"].style.position = 'fixed';
		document.getElementById("ribon_line").style.position = 'fixed';
	}
	window.onscroll = FunctionOnScroll_other;
}

if(!window.XMLHttpRequest) {
	FunctionOnLoad(ie6);
}
else {
	FunctionOnLoad(other);
}

function FunctionOnScroll_other() {

	delete winSizeScrolled;
}

function FunctionOnScroll_ie6() {

	delete winSizeScrolled;
	
	if (div["dp_ajax"].style.visibility == 'visible') {
		SizeAjaxDiv();
	}
	
	if (div["dp_message"].style.visibility == 'visible' && div["dp_message"].className != 'DropDown' && div["dp_message"].className != 'newsbulle' && div["dp_message"].className != 'bulle') {
		DisplayBox();
	}	
	
	if (document.getElementById("menu_top")) {
		Top = document.documentElement.scrollTop;
		div["menu_top"].style.top = Top+"px";
	}
	
}

window.onresize = FunctionOnResize;

function FunctionOnResize() {
	
	delete docSize;
	delete winSize;
	delete winSizeScrolled;
	delete winCenter;
	
	if (div["dp_transparent"].style.visibility == 'visible') {
		window.onresize ='';
		DisplayBox();
		window.onresize = FunctionOnResize;
	}
	if (div["dp_ajax_trans"].style.visibility == 'visible') {
		window.onresize ='';
		DisplayAjaxTransparent();
		window.onresize = FunctionOnResize;
	}
	if (div["dp_ajax"].style.visibility == 'visible') {
		SizeAjaxDiv();
	}	
}


function ShowRibon() {
	div["ribon"].style.display='block';
	if (typeof(ribonout) == 'number') clearTimeout(ribonout);
}

function CloseRibon(e) {
	if (!e) var e = window.event; 
	if (typeof(window.innerWidth) == 'number') {
		/*Non-IE*/
		try {
			cpr = div["ribon"].compareDocumentPosition(e.relatedTarget);
		}
		catch(excp) {
			cpr = 4;
		}
		if (!(cpr & 16)) ribonout = setTimeout("div['ribon'].style.display='none';",0);

	}
	else {
		if (!div["ribon"].contains(e.toElement)) ribonout = setTimeout("div['ribon'].style.display='none';",0);
	}
}

function CloseRibonNow() {
	if (typeof(ribonout) == 'number') clearTimeout(ribonout);
	div["ribon"].style.display='none';
}

function ChangeRibon(menu) {
	if(typeof(current_menu)!='undefined') {
		document.getElementById('ribon'+current_menu).style.display='none';
		onglet=document.getElementById('menu'+current_menu);
		onglet.className='ong';
		onglet.childNodes[0].className='ongtl';
		onglet.childNodes[1].className='ongt';
	}
	current_menu=menu;
	document.getElementById('ribon'+current_menu).style.display='block';
	onglet=document.getElementById('menu'+current_menu)
	onglet.className='onga';
	onglet.childNodes[0].className='ongtla';
	onglet.childNodes[1].className='ongta';
}




function Bulle(e,contenu) {
	div["dp_message"].style.position='absolute';
	MoveBulle(e);
	div["dp_message"].innerHTML=contenu;
	div["dp_message"].className='bulle';
    div["dp_message"].style.visibility="visible";
}

function MoveBulle(e) {
	if (!e) var e = window.event; 
    MousePosition=GetMousePosition(e);
    div["dp_message"].style.left=MousePosition[0]+12+"px";
    div["dp_message"].style.top=MousePosition[1]-2+"px";
}

function ClearBulle() {
	div["dp_message"].style.visibility="hidden";
}

function NewsBulle(e,action) {


	if (!e) var e = window.event; 
	div["dp_message"].className='newsbulle';
	
	
	MousePosition=GetMousePosition(e);
	DocumentSize=GetDocumentSize();
	WindowCenter=GetWindowCenter();
	WindowSize = GetWindowSizeScrolled();
	MsgSize = GetDivSize(div["dp_message"]);
	
	document.getElementById('dp_message').style.position='absolute';
	msg = div["dp_message"].offsetWidth;
	glob = document.getElementById('global').offsetWidth;	
	
	if (MousePosition[0] >WindowCenter[0]) {
		right = document.getElementById('column_right').offsetWidth;	
		div["dp_message"].style.left=DocumentSize[0]/2-msg+glob/2-right-10+"px";
	}
	else {
		left = document.getElementById('column_left').offsetWidth;	
		div["dp_message"].style.left=DocumentSize[0]/2-glob/2+left+10+"px";
	}
	
	if (MsgSize[1]+MousePosition[1]>WindowSize[1]) {
		div["dp_message"].style.top=WindowSize[1]-MsgSize[1]+"px";
	}
	else {
		div["dp_message"].style.top=MousePosition[1]-10+"px";
	}
 

	div["dp_message"].innerHTML='<table style="border:0"><tr><td id="ajax_process"><img src="/icon/processing.gif"></td></tr></table>';
	div["dp_message"].style.visibility="visible";
		
	ajaxXhr ('dp_message', action, 'GET');
	
}

function AddButtonValue(FormName, Value) {

	var Form = document.getElementById(FormName);
	var NewInput = document.createElement('input');
	NewInput.setAttribute('type', 'hidden');
	NewInput.setAttribute('name', 'button');
	NewInput.setAttribute('value', Value);
	Form.appendChild(NewInput);

}

function AddParseAction(FormName, Value) {

	var Form = document.getElementById(FormName);
	if (typeof(FormAction[FormName])=='undefined') {
		FormAction[FormName] = Form.action;
	}
	Form.action = Form.action+'/'+Value;
}

/*
function RemoveParseAction(FormName, Value) {

	var Form = document.getElementById(FormName);
	Form.action = FormAction[FormName];
}
*/

function RemoveParseAction(FormName) {
	var Form = document.getElementById(FormName);
	if (Form.action.match(/\/[^\/]*\/[^\/]*\/[^\/]*$/g)) Form.action = Form.action.replace(/\/[^\/]*$/g,'');
}

function RemoveFormAction(FormName) {
	document.getElementById(FormName).action = '';
}

function ChangeTarget(FormName, Value) {

	var Form = document.getElementById(FormName);
	Form.target = Value;
}

function AddType(FormName, Value) {

	var Form = document.getElementById(FormName);
	Form.action = Form.action.replace(/action_type/g,Value);	
}

function ChangeType(FormName, Value) {
	var Form = document.getElementById(FormName);
	var reg=new RegExp("[^/]+$", "g");
	Form.action = Form.action.replace(reg,Value);
}

function ConfirmBox(contenu,Confirm,ConfirmAction,Cancel,FormName) {
		
	div["dp_message"].className='ConfirmBox';
	
   	contenu+= '<br><br><form style="display:inline;"><input type="button" id="dp_message_button" value="'+Confirm+'" onClick="AddParseAction(\''+FormName+'\', \''+ConfirmAction+'\'); document.'+FormName+'.submit()">&nbsp;';
	contenu+= '<input type="button" value="'+Cancel+'" onClick="ClearBox()"></form>';
    div["dp_message"].innerHTML=contenu;

	DisplayBox();
	document.getElementById("dp_message_button").focus();	
}

function ConfirmBoxNF(contenu,Confirm,ConfirmURL,Cancel) {
		
	div["dp_message"].className='ConfirmBox';
	
   	contenu+= '<br><br><form style="display:inline;"><input type="button" id="dp_message_button" value="'+Confirm+'" onClick="window.location.href=\''+ConfirmURL+'\';">&nbsp;';
	contenu+= '<input type="button" value="'+Cancel+'" onClick="ClearBox()"></form>';
    div["dp_message"].innerHTML=contenu;

	DisplayBox();
	document.getElementById("dp_message_button").focus();	
}





function ConfirmBox2(contenu,Confirm,ConfirmAction,Cancel) {
		
	div["dp_message"].className='ConfirmBox';
	
   	contenu+= '<br><br><form style="display:inline;" method="POST" action="'+ConfirmAction+'"><input type="submit" id="dp_message_button" value="'+Confirm+'">&nbsp;';
	contenu+= '<input type="button" value="'+Cancel+'" onClick="ClearBox()"></form>';
    div["dp_message"].innerHTML=contenu;

	DisplayBox();
	document.getElementById("dp_message_button").focus();	
}

function ChoiceBox(contenu,Choice,Cancel,FormName) {
	
	div["dp_message"].className='ChoiceBox';
	
   	contenu+= '<br><br><form style="display:inline;">';
	for (i=0;i<Choice.length;i++){
		contenu+= '<input type="button" value="'+Choice[i][0]+'" onClick="AddParseAction(\''+FormName+'\', \''+Choice[i][1]+'\'); document.'+FormName+'.submit()">&nbsp;';
   	}
	contenu+= '<input type="button" value="'+Cancel+'" onClick="ClearBox()"></form>';
    div["dp_message"].innerHTML=contenu;

	DisplayBox();
}


function ChoiceBoxNF(contenu,Choice,Cancel) {
	

	div["dp_message"].className='ChoiceBox';
	
   	contenu+= '<br><br><form style="display:inline;">';
	for (i=0;i<Choice.length;i++){
		contenu+= '<input type="button" value="'+Choice[i][0]+'" onClick="window.location.href=\''+Choice[i][1]+'\';">&nbsp;';
   	}
	contenu+= '<input type="button" value="'+Cancel+'" onClick="ClearBox()"></form>';
    div["dp_message"].innerHTML=contenu;

	DisplayBox();
}


function ChoiceBoxType(contenu,Choice,Cancel,FormName) {
	
	div["dp_message"].className='ChoiceBox';
	
   	contenu+= '<br><br><form style="display:inline;">';
	for (i=0;i<Choice.length;i++){
		contenu+= '<input type="button" value="'+Choice[i][0]+'" onClick="AddType(\''+FormName+'\', \''+Choice[i][1]+'\'); document.'+FormName+'.submit()">&nbsp;';
   	}
	contenu+= '<input type="button" value="'+Cancel+'" onClick="ClearBox()"></form>';
    div["dp_message"].innerHTML=contenu;

	DisplayBox();
}

function MsgBox(contenu) {
	
	initfunc();
	div["dp_message"].className='MsgBox';
	
   	contenu+= '<br><br><form style="display:inline;"><input type="button" id="dp_message_button" value="OK" onClick="ClearBox()"></form>';
    div["dp_message"].innerHTML=contenu;

	DisplayBox();
	document.getElementById("dp_message_button").focus();
}

function MsgBoxNF(contenu, NewURL) {
	
	div["dp_message"].className='ChoiceBox';
	
	contenu+= '<br><br><form style="display:inline;"><input type="button" value="OK" onClick="openURL(\''+NewURL+'\')">&nbsp</form>';
    div["dp_message"].innerHTML=contenu;
	
	DisplayBox();
	document.getElementById("dp_message_button").focus();
}


function ProcessBox(contenu, FormName) {

	PreLoad("/icon/processing.gif");
	initfunc();
	ProcessBox2(contenu, FormName);
}

function ProcessBox2(contenu, FormName) {

	if (CheckLoad()) {
		div["dp_message"].className='MsgBox';
		contenu+= '<br><br><br><img src="/icon/processing.gif"><br><br><br>';
		div["dp_message"].innerHTML=contenu;
		DisplayBox();
		document.forms[FormName].submit();
	}
	else {
		setTimeout("ProcessBox2('"+contenu+"', '"+FormName+"')",100);	
	}
}


function PreLoad(img) {
	Preloaded = new Image();
	Preloaded.src = img;
}

function CheckLoad() {
	if (Preloaded.complete) {
		return true;
	}
	else {
		return false;
	}
}


function DisplayBox() {

	ToggleSelect('hidden');
	DisplayTransparent();
	
	if(!window.XMLHttpRequest) {
		div["dp_message"].style.position='absolute';
		div["ombre"].style.position='absolute';
		WindowCenter = GetWindowCenter();	
		var PosX = WindowCenter[0] - div["dp_message"].offsetWidth/2;
		var PosY = WindowCenter[1] - div["dp_message"].offsetHeight/2;
	}
	else {
		div["dp_message"].style.position='fixed';
		div["ombre"].style.position='fixed';
		WindowSize = GetWindowSize();	
		var PosX = (WindowSize[0] - div["dp_message"].offsetWidth)/2;
		var PosY = (WindowSize[1] - div["dp_message"].offsetHeight)/2;	
	}
	
	div["dp_message"].style.left = PosX + "px";
	div["dp_message"].style.top = PosY + "px";

//	div["dp_message"].style.visibility="visible";	
	div["dp_message"].style.display="none";	
	div["dp_message"].style.visibility="visible";	
	$('#dp_message').fadeIn('fast');
	
	div["ombre"].style.width = div["dp_message"].offsetWidth+"px";
	div["ombre"].style.height = div["dp_message"].offsetHeight+"px";
	div["ombre"].style.left = PosX - 10 + "px";
	div["ombre"].style.top = PosY + 10 + "px";

//	div["ombre"].style.visibility="visible";
	div["ombre"].style.display="none";
	div["ombre"].style.visibility="visible";
	$('#ombre').fadeIn('fast');
}



function ClearBox() {

	ToggleSelect('visible');
	div["dp_message"].style.visibility="hidden";
	div["dp_transparent"].style.visibility="hidden";
	div["ombre"].style.visibility="hidden";
	div["dp_message"].style.width="";
	div["dp_message"].style.height="";
}

function ClearAjaxBox() {

	ToggleSelect('visible');
	div["dp_ajax"].style.visibility="hidden";
	div["dp_ajax_trans"].style.visibility="hidden";
	div["dp_ajax_ombre"].style.visibility="hidden";	
	div["dp_ajax"].style.width="";
	div["dp_ajax"].style.height="";
	
	scripts=document.getElementById('ajax_div').getElementsByTagName('script');
	for(iy=0;iy<scripts.length; iy++) {
		if (scripts[iy].id.substr(0,10) == "clear_ajax") {
			eval(scripts[iy].innerHTML);
		}
	}

	div["dp_ajax"].innerHTML = '';

}

function ToggleSelect(visibility) {

	var selects=document.getElementsByTagName("select");
	for (i=0;i<selects.length;i++){
		selects[i].style.visibility=visibility;
	}
}
	
function DisplayTransparent() {

	DocumentSize=GetDocumentSize();
	div["dp_transparent"].style.width=DocumentSize[0]+"px";
	div["dp_transparent"].style.height=DocumentSize[1]+"px";
	
//	div["dp_transparent"].style.visibility="visible";
	div["dp_transparent"].style.display="none";
	div["dp_transparent"].style.visibility="visible";
	$('#dp_transparent').fadeTo('fast', 0.4);
}

function DisplayAjaxTransparent() {

	DocumentSize=GetDocumentSize();
	div["dp_ajax_trans"].style.width=DocumentSize[0]+"px";
	div["dp_ajax_trans"].style.height=DocumentSize[1]+"px";
	div["dp_ajax_trans"].style.visibility="visible";
}

function GetDocumentSize() {

	if (typeof(docSize)=='undefined' ) {

		docSize = new Array();

		if( typeof( window.innerWidth ) == 'number' ) {
			/*Non-IE*/
			docSize[0] = document.documentElement.scrollWidth;
			docSize[1] = document.documentElement.scrollHeight;
		} else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
			/*IE 6+ in 'standards compliant mode' */
			docSize[0] = document.documentElement.scrollWidth;
			docSize[1] = document.documentElement.scrollHeight;
		} else if( document.body && ( document.body.scrollWidth || document.body.scrollHeight ) ) {
			/*IE 4 compatible*/
			docSize[0] = document.body.scrollWidth;
			docSize[1] = document.body.scrollHeight;
		}

		var WindowSize = GetWindowSize();
		if (WindowSize[0]>docSize[0]) docSize[0]=WindowSize[0];
		if (WindowSize[1]>docSize[1]) docSize[1]=WindowSize[1];

	}
	
	return docSize;
}

function GetWindowSize() {

	if (typeof(winSize)=='undefined' ) {
	
		winSize = new Array();
		
		if( typeof( window.innerWidth ) == 'number' ) {
			/*Non-IE*/
			winSize[0] = document.documentElement.clientWidth;
			winSize[1] = document.documentElement.clientHeight;
		} 
		else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
			/*IE 6+ in 'standards compliant mode'*/
			winSize[0] = document.documentElement.clientWidth;
			winSize[1] = document.documentElement.clientHeight;
		} 
		else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
			/*IE 4 compatible*/
			winSize[0] = document.body.clientWidth;
			winSize[1] = document.body.clientHeight;
		}
		
	}
	
	return winSize;
}

function GetWindowSizeScrolled() {

	if (typeof(winSizeScrolled)=='undefined' ) {

		winSizeScrolled = new Array();
		
		if( typeof( window.innerWidth ) == 'number' ) {
			/*Non-IE*/
			winSizeScrolled[0] = window.innerWidth + document.documentElement.scrollLeft;
			winSizeScrolled[1] = window.innerHeight + document.documentElement.scrollTop;
		} else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
			/*IE 6+ in 'standards compliant mode'*/
			winSizeScrolled[0] = document.documentElement.clientWidth + document.documentElement.scrollLeft;
			winSizeScrolled[1] = document.documentElement.clientHeight + document.documentElement.scrollTop;
		} else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
			/*IE 4 compatible*/
			winSizeScrolled[0] = document.body.clientWidth + document.documentElement.scrollLeft;
			winSizeScrolled[1] = document.body.clientHeight + document.documentElement.scrollTop;
		}
	
	}
		
	return winSizeScrolled;
}

function GetWindowCenter() {

	if (typeof(winCenter)=='undefined' ) {

		var winCenter = new Array();
		
		var WindowSize = GetWindowSize();
			
		winCenter[0] = document.documentElement.scrollLeft + WindowSize[0]/2;
		winCenter[1] = document.documentElement.scrollTop + WindowSize[1]/2;
	
	}
	
	return winCenter;
}

function GetDivSize(div) {

	var divSize = new Array();
	
		divSize[0] = div.offsetWidth;
		divSize[1] = div.offsetHeight;
		
	return divSize;
}

function GetMousePosition(e) {

	var MousePosition = new Array();

	if (!e) var e = window.event;
	if (e.pageX || e.pageY) 	{
		MousePosition[0] = e.pageX;
		MousePosition[1] = e.pageY;
	}
	else if (e.clientX || e.clientY) 	{
		MousePosition[0] = e.clientX + document.documentElement.scrollLeft + document.body.scrollLeft;
		MousePosition[1] = e.clientY + document.documentElement.scrollTop + document.body.scrollTop;
	}
    
	if (MousePosition[0]<0) MousePosition[0]=0;
    if (MousePosition[1]<0) MousePosition[1]=0;

	return MousePosition;
}


function SelectChange(SelectObj) {
	
	var SelectedValues = new Array();
	var selects=document.getElementsByTagName("select");
	var mySelectedIndex=SelectObj.options.selectedIndex;
	
	if (typeof(InitialValues)=='undefined') {
		InitialValues = new Array();
		for (i=0;i<selects[0].options.length;i++){
			InitialValues[i] = selects[0].options[i].value;
		}
	}

	for (i=0;i<selects.length;i++){
		SelectedValues[i]=selects[i].options[selects[i].options.selectedIndex].value;
		for (j=selects[i].options.length;j>0;j--){
			selects[i].options[j] = null;
		}
	}
	
	for (i=0;i<selects.length;i++){
		for (j=1;j<InitialValues.length;j++){
			var flag = 0;		
			for (k=0;k<SelectedValues.length;k++) {
				if (InitialValues[j] == SelectedValues[k]) {
					if (i != k) {
						flag = 1;
					}
					else {
						flag =2;
					}
				}
			}
			if (flag != 1) {
				selects[i].options[j]=new Option(InitialValues[j], InitialValues[j]);	
			}
			if (flag == 2) {
				selects[i].options.selectedIndex=j;	
			}
		}
	}

}

function openwindow(page) {
  window.open(page,"popup","menubar=yes, status=yes, scrollbars=yes,width=850, height=800");
}

/*function display_template(FormName,Field) {
	var Selects=document.getElementsByName("template");
	var Template=(Selects[0].options[Selects[0].options.selectedIndex].value);
	Href = window.location.href;
	Href=Href.replace(/#/g,'');	
	openwindow(Href+'?template='+Template+'&field='+Field);
}
*/


function checkSearch() {

	var input = document.getElementsByName("find");
	if (input[0].value.length<3) {
		MsgBox('Veuillez entrer au moins 3 caractères.')
		return false;
	}
	else {
		return true;
	}
}


function checkSiteSearch() {

	var input = document.getElementsByName("site_find");
	if (input[0].value.length<3) {
		MsgBox('Veuillez entrer au moins 3 caractères.')
		return false;
	}
	else {
		return true;
	}
}


function selectAll(FormName) {
	for(i=0; i<FormName.elements.length; i++) {
		if(FormName.elements[i].type=="checkbox") {
			FormName.elements[i].checked=true;
		}
	}
}

function deselectAll(FormName) {
	for(i=0; i<FormName.elements.length; i++) {
		if(FormName.elements[i].type=="checkbox") {
			FormName.elements[i].checked=false;
		}
	}
}








function createIframe (iframeName, width, height) {
	var iframe;
	if (document.createElement && (iframe = document.createElement('iframe'))) {
		iframe.name = iframe.id = iframeName;
		iframe.width = width;
		iframe.height = height;
//		iframe.style = "position:absolute";
		iframe.top = 0;
		iframe.src = 'http://127.0.0.1/cms/page/modify_form/92/80218b1e5f';
		document.body.appendChild(iframe);
	}
}

function SizeAjaxDiv(maxWidth, maxHeight) {
	
	WindowSize = GetWindowSize();
	if (typeof(maxWidth)=='undefined') maxWidth=1000; else maxWidth=parseInt(maxWidth);
	if (typeof(maxHeight)=='undefined') maxHeight=1000; else maxHeight=parseInt(maxHeight);
	
	
	if (WindowSize[0] > maxWidth+200) width = maxWidth; else width = WindowSize[0]-200;
	if (document.getElementById("menu_top")) {
		if (WindowSize[1] > maxHeight+200) height =maxHeight; else height = WindowSize[1]-80;
	}
	else {
		if (WindowSize[1] > maxHeight+200) height =maxHeight; else height = WindowSize[1]-50;
	}
	
	div["dp_ajax"].style.width=width+"px";
	div["dp_ajax"].style.height=height+"px";			
	div["dp_ajax_ombre"].style.width = (parseInt(width)+10)+"px";
	div["dp_ajax_ombre"].style.height = (parseInt(height)+12)+"px";
	
	WindowCenter=GetWindowCenter();
	if(!window.XMLHttpRequest) {
/*		if (document.getElementById("menu_top")) {
			Top = document.documentElement.scrollTop+50;
		}
		else {
			Top = document.documentElement.scrollTop+20;
		}
		div["dp_ajax"].style.top=Top+"px";
		div["dp_ajax_ombre"].style.top = (parseInt(Top)+10)+"px";
*/		
		div["dp_ajax"].style.top=document.documentElement.scrollTop+WindowCenter[1]-height/2+"px";
		div["dp_ajax_ombre"].style.top =document.documentElement.scrollTop+WindowCenter[1]-height/2+10+"px";	
		
		div["dp_ajax"].style.left=WindowCenter[0]-width/2+"px";
		div["dp_ajax_ombre"].style.left = WindowCenter[0]-width/2-10+"px";
	}
	else {
		if (document.getElementById("menu_top")) {
			if (height==maxHeight) {
				div["dp_ajax"].style.top=(WindowSize[1]-height)/2+"px";
				div["dp_ajax_ombre"].style.top=(WindowSize[1]-height)/2+10+"px";	
			}
			else {
				div["dp_ajax"].style.top=50+"px";
				div["dp_ajax_ombre"].style.top = 60+"px";
			}
		}
		else {
			if (height==maxHeight) {
				div["dp_ajax"].style.top=(WindowSize[1]-height)/2+"px";
				div["dp_ajax_ombre"].style.top =(WindowSize[1]-height)/2+10+"px";	
			}
			else {
				div["dp_ajax"].style.top=20+"px";
				div["dp_ajax_ombre"].style.top = 30+"px";
			}
		}
		if (width==maxWidth) {
			div["dp_ajax"].style.left=(WindowSize[0]-width)/2+"px";
			div["dp_ajax_ombre"].style.left=(WindowSize[0]-width)/2-10+"px";
		}
		else {
			div["dp_ajax"].style.left=100+"px";
			div["dp_ajax_ombre"].style.left = 90-10+"px";
		}
	}
		
	div["dp_ajax_container"]=document.getElementById("dp_ajax_container");
	
	div["dp_ajax_container"].style.width=width-10+"px";
	div["dp_ajax_container"].style.height=height-18+"px";
	div["ajax_div"].style.width=width-28+"px";
	
	if (document.getElementById("ajax_process")) {
		document.getElementById("ajax_process").style.width=width-10+"px";
		document.getElementById("ajax_process").style.height=height-26+"px";
	}
}




function ajaxDiv(divClass, action, method, postdata, width, height) {

	PreLoad("/icon/processing.gif");
	ajaxDiv2(divClass, action, method, postdata, width, height);
}

function ajaxDiv2(divClass, action, method, postdata, width, height) {

	if (CheckLoad()) {
		
		ToggleSelect('hidden');
		DisplayAjaxTransparent();
		
		div["dp_ajax"].className=divClass;	
		div["dp_ajax"].innerHTML = '<div id="dp_ajax_close" onclick="ClearAjaxBox();"><img src="/icon/close_ajax32.gif"></div><div id="dp_ajax_container"><div id="ajax_div"></div></div>';
		
		div["ajax_div"]=document.getElementById("ajax_div");
		div["ajax_div"].innerHTML='<table style="border:0"><tr><td id="ajax_process"><img src="/icon/processing.gif"></td></tr></table>';
		
		SizeAjaxDiv(width, height);
				

		div["dp_ajax_ombre"].style.visibility="visible";	
		div["dp_ajax"].style.visibility="visible";
		
		ajaxXhr ('ajax_div', action, method, postdata);
		
	}
	else {
		setTimeout("ajaxDiv2('"+divClass+"', '"+action+"', '"+method+"', '"+postdata+"', '"+width+"', '"+height+"')",100);	
	}
}


function ajaxXhr (divname, action, method, postdata) {

	var xhr; 

	try {xhr = new ActiveXObject('Msxml2.XMLHTTP');}
	catch (error1) {
		try {xhr = new ActiveXObject('Microsoft.XMLHTTP');}
		catch (error2) {
			try {xhr = new XMLHttpRequest();}
			catch (error3) {
				xhr = false;
			}
		}
	}
  
	xhr.onreadystatechange  = function() { 
		if(xhr.readyState  == 4) {
			if(xhr.status  == 200) {

				div[divname].innerHTML = xhr.responseText;
				
				scripts=div[divname].getElementsByTagName('script');
				for(iy=0;iy<scripts.length; iy++) {
					if (scripts[iy].id.substr(0,10) != "clear_ajax") {
						eval(scripts[iy].innerHTML);
					}
				}
				
				
			}
			else {
				 div[divname].innerHTML = "Error code " + xhr.status;
			}
		}
	}
	if (method=='GET' || method=='get') {
		xhr.open(method,'/ajax'+action,true); 
		xhr.send(null); 
	}
	if (method=='POST' || method=='post') {	
		xhr.open(method,'/ajax'+action,true); 
		xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");                  
		xhr.setRequestHeader("Content-length", postdata.length);
		xhr.setRequestHeader("Connection", "close");
		xhr.send(postdata); 
	}
	
}



function ajaxPost(FormName) {
	postdata='';
	for ($o=0; $o<document.forms[FormName].elements.length; $o++) {
		if (postdata.length != 0) postdata += '&';
		postdata += document.forms[FormName].elements[$o].name+'='+document.forms[FormName].elements[$o].value;
	}
	return postdata;
}

/*




/*4 caracters desc: 1 for required or not and 3 for valid_type (tel, str, num, etc.) */

function checkForm(form) {
	
	var error_msg='';
	var inputs = form.getElementsByTagName('input');
	var selects = form.getElementsByTagName('select');
	
	if (typeof(color) != "undefined") {
		for (i=0;i<inputs.length;i++) {
			var field = inputs[i];
			if (field.style.background == 'red') {
				field.style.background = color;
				break;
			}
		}
		for (i=0;i<selects.length;i++) {
			var field = selects[i];
			if (field.style.background == 'red') {
				field.style.background = color;
				break;
			}
		}
	}
	
	for (i=0;i<inputs.length;i++){
		if (inputs[i].type == 'text' || inputs[i].type == 'password') {
			var field = inputs[i];
			if (field.name.substring(0,3) == '%%%') {
			
				var required = field.name.substring(3,4);
				var valid_type = field.name.substring(4,7);
				var value = field.value.replace(/^\s+|\s+$/g,''); /*trim()*/

				if ((required == '1') && (value.length == 0)) {
					error_msg='Ce champ doit impérativement être rempli';
					break;		
				}
				
				if (valid_type == 'mel') {
					var filter = /^[^@]+@[^@.]+\.[^@]*\w\w$/ ;
					var illegalChars= /[\(\)\<\>\,\;\:\\\"\[\]]/ ;
					if ((!filter.test(value)) || (value.match(illegalChars))) {
						error_msg='L\'adresse email est invalide';
						break;
					}
				}

				if (valid_type == 'tel') {
					var stripped = value.replace(/[\(\)\.\-\+\ ]/g, ''); 
					if ((isNaN(parseInt(stripped))) || (!(stripped.length == 10))) {
						error_msg='Le numéro de téléphone est invalide (xx xx xx xx xx)';
						break;				
					}
				}
				
				if (valid_type == 'num') {
					if (isNaN(value)) {
						error_msg='Cette valeur doit inpérativement être un nombre';
						break;				
					}
				}
			}
		}
	}
	if (error_msg != '') {
		color = field.style.background; 
		if (color =='') {
			color = 'white';
		}
		field.style.background = 'red'; 
		MsgBox(error_msg);
		return false;
	}
	else {
		for (i=0;i<selects.length;i++){
			var field = selects[i];
			if (field.name.substring(0,3) == '%%%') {
				var required = field.name.substring(3,4);
				if (required == '1') {
					var value = field.options[field.selectedIndex].value.replace(/^\s+|\s+$/g,''); /*trim()*/
					if (value.length == 0) {
						error_msg='Ce champ doit impérativement être rempli';
						break;		
					}		
				}
			}
		}
		if (error_msg != '') {
			color = field.style.background; 
			if (color =='') {
				color = 'white';
			}
			field.style.background = 'red'; 
			MsgBox(error_msg);
			return false;
		}
		else {
			return true;
		}
	}
}



function openURL(URL) {
	window.location.href=URL;
}



function getElementPosition(e) {
	var e1=e, e2=e;
	var x=0, y=0;
	if(e1.offsetParent) {
		do {
			x += e1.offsetLeft;
			y += e1.offsetTop;
		} while(e1 = e1.offsetParent);
	}
	while((e2 = e2.parentNode) && e2.nodeName.toUpperCase() !== 'BODY') {
		x -= e2.scrollLeft;
		y -= e2.scrollTop;
	}
	return [x, y];
}


function getElementSize (e) {
	return [e.offsetWidth, e.offsetHeight];
}

function selectImage(element, scrollHeight, content) {
		
	div["dp_message"].innerHTML=content;
	
	div["dp_message"].className='DropDown';
	div["dp_message"].style.height = scrollHeight+'px';
	pos = getElementPosition(element);
	size = getElementSize(element);
	div["dp_message"].style.left= pos[0]+'px';
	elementpos = pos[1] + size[1];
	div["dp_message"].style.top= elementpos+'px';
	div["dp_message"].style.width = size[0]-2+'px';
		
	div["dp_message"].style.visibility="visible";
	
	notFirstClick = true;
	document.onclick = FunctionOnClickSelectImage;
}

function FunctionOnClickSelectImage() {
		if (notFirstClick == true) {
			notFirstClick = false;
		}
		else {
			ClearBox();
			document.onclick ='';
		}
}

function clearSelectImage(element, value, image, text) {
	if (image !='') {
		document.getElementById('selectImage'+element).src = image;
		document.getElementById('selectImage'+element).style.visibility = 'visible';
		document.getElementById('selectText'+element).innerHTML = text;
	}
	input = document.getElementsByName(element);
	for (var i=0;i<input.length;i++) {
		if (input[i].form != "undefined") input[i].value = value;
		$(input).change();
	}
}


function TestMsg() {

	if (div["dp_message"].innerHTML!='') {
		setTimeout("MsgBox('"+div["dp_message"].innerHTML+"')",100);	
	}
}


function Show(curValue, value, fields) {
	
	for (var j=0;j<value.length;j++) {
	
		if (curValue == value[j]) {
			var tab = new Array();
			for (var i=0;i<fields[j].length;i++) {
				document.getElementById(fields[j][i]+'_header').style.display = 'block';
				document.getElementById(fields[j][i]+'_field').style.display = 'block';
				tab[i]=fields[j][i];
			}
		}
		else {
			for (var i=0;i<fields[j].length;i++) {
				var flag = true;
				if (typeof(tab) != 'undefined') {
					for (var k=0;k<tab.length;k++) {
						if (tab[k] == fields[j][i]) flag=false;
					}
				}
				if (flag) {
					document.getElementById(fields[j][i]+'_header').style.display = 'none';
					document.getElementById(fields[j][i]+'_field').style.display = 'none';
				}
			}	
		}
	}
}


$(document).ready(function(){
	$(".form_list_line0, .form_list_line1").hover(function(){
		$(this).addClass("form_list_line2");
	}, function(){
		$(this).removeClass("form_list_line2");
    });
	
	$("#menu dl, #menu_v dl").mouseenter(function(){
		$('#s'+this.id).slideDown(200);
    });
	
	$("#menu dl, #menu_v dl").mouseleave(function(){
		$('#s'+this.id).stop(true, true).slideUp(200);
    });

	

	
	$(".inputFile").change(function() {
		$(this).parent().parent().children(".inputTrue").val($(this).val());
		$(this).parent().parent().children(".inputFake").val($(this).val());
	});
		
	$(".inputFake").click(function() {
		this.select();
	});

	$(".inputFake").change(function() {
		if ($(this).val() != "" && $(this).val() != $(this).parent().children(".inputTrue").val()) {
			$(this).val($(this).parent().children(".inputTrue").val());
		}
	});	
	
});





