//JAVASCRIPT DOCUMENT BY OXTAL
//JAVASCRIPT DOCUMENT: html2.js.php

var image_to_load = new Array();
function image_init(){
	var i, imgObj;
	
	if (document.all && document.styleSheets && document.styleSheets[0] && document.styleSheets[0].addRule){
		document.styleSheets[0].addRule('*', 'behavior: url(/css/htc/iepngfix.htc)');
	}
	
	imgObj = new Image();
	
	for(i = 0; i < image_to_load.length; i++){
	
		if( !image_to_load[i][1] ){
		
			imgObj.src = image_to_load[i][0];
			image_to_load[i][1] = true;
		}
	}
	
}

function add_image_preload(imageSrc){
	image_to_load[image_to_load.length] = new Array(imageSrc, false);
}


/*
Add characters
	alphabet: 	65 a 90
	numbers: 	48 a 57
	keypad: 	96 a 105
	enter:		13
	space:		32
	specials:	59, 61, 106, 107, 108, 109, 110, 111, 188, 190, 191, 192, 219, 220, 221, 222

	
Remove characters
	backspace:	8
	delete:		46
	
*/

var unicode_add_chars = new Array(65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,48,49,50,51,52,53,54,55,56,57,96,97,98,99,100,101,102,103,104,105,13,32,59,61,106,107,108,109,110,111,188,190,191,192,219,220,221,222);

var unicode_rem_chars = new Array(8,46);

var ERROR_CONTROL_BORDERCOLOR = "#FFAAAA";


//GRAPHICAL PURPOSE
function findPos(obj){

	var curleft = 0;
	var curtop = 0;
	if(obj != null){
		if (obj.offsetParent) {
		
			curleft = obj.offsetLeft;
			curtop = obj.offsetTop;
			
			while( (obj = obj.offsetParent) ) {
				curleft += obj.offsetLeft
				curtop += obj.offsetTop
			}
		}
		
		return [curleft,curtop];
	}else
		return [0,0];
}

function empty( variable ){
	var res = true;

	if( typeof(variable) == "string" ){
		if(variable.length > 0)
			res = false;	
			
	}else if( typeof(variable) == "number" ){
		if(variable != 0)
			res = false;
			
	}else if( typeof(variable) == "boolean" ){
		res = !variable;

	}else if( typeof(variable) == "object" ){
	
		if( typeof(variable.attributes) != "undefined" ){
			if(variable.attributes.length)
				res = false;
		}

		if( typeof(variable.childNodes) != "undefined" ){
			if(variable.childNodes.length)
				res = false;
		}
			
	}else if( typeof(variable) == "function" ){
		res = false;
	}

	return res;
	
}
	
// JavaScript Document

function Ajax( url, method){

	this.url = url;
	this.method = method;

	this.set_function = Ajax_set_function;
	this.statechange = Ajax_statechange;
	this.send = Ajax_send;
	this.valid_http_request = Ajax_valid_http_request;
	var status = this.valid_http_request();

	if( status ){
		if (window.XMLHttpRequest) {
			//MOZ
			this.xhr = new XMLHttpRequest();

			this.xhr.open(this.method, this.url, true);

		} else if (window.ActiveXObject) {
			//IE
			this.xhr = new ActiveXObject("Microsoft.XMLHTTP");
			if (this.xhr) {
				this.xhr.open(this.method, this.url, true);
			}
		}

		if (this.xhr){
			//Request header type to carry post data
			this.xhr.setRequestHeader('Content-Type','application/x-www-form-urlencoded; charset=UTF-8');

			//Request header type to remove cache on query
			this.xhr.setRequestHeader("Cache-Control", "no-cache");

			this.xhr.onreadystatechange = this.set_function(this);
		}else{
			alert("Your browser does not support AJAX, some features will be missing.");
		}

	}else{
		alert("Ajax missing request information: url=" + this.url + ", ou methode=" + this.method );
	}
}

	function Ajax_valid_http_request(){

		if(	!( typeof(this.url)=="string" && this.url!="" && this.url!="undefined" && this.url!="null") )
			return false;
			
		if(	!( typeof(this.method)=="string" && (this.method=="POST" || this.method=="GET") ) )
			return false;
		
		return true;
	}

	function Ajax_statechange(obj){
		try{

			if(this.xhr.readyState == 4){

				if(this.xhr.status == 200){
	
					if(typeof(obj.onComplete) == "function"){

						obj.onComplete.call(obj, obj.xhr.responseText, obj.xhr.responseXML );
					}
					
				}
			}
		}catch(error){
//			alert( "AJAX ERROR: " + error );
		}	
	}
	
	function Ajax_set_function(param){
		return function(){param.statechange(param); };
	}	
	
	function Ajax_send(post_data){
		if(this.method == "POST"){

			if(typeof(post_data) == "object"){
				if( post_data.tagName.toUpperCase() == "FORM" ){

					var send_data = new Array();
					var i, elem;
					var coll = post_data.elements;
					
					for(i = 0; i < coll.length; i++){
						
						elem = coll[i];
						
						if(elem.tagName.toUpperCase() == "INPUT"){
							
							if( elem.type.toUpperCase() == "CHECKBOX"){

								if( elem.checked ||  elem.checked=="CHECKED" )
									send_data[send_data.length] = elem.name + "=" + elem.value;
								else
									send_data[send_data.length] = elem.name + "=__NULL__";

							}else if( elem.type.toUpperCase() == "RADIO" ){

								if( elem.checked ||  elem.checked=="CHECKED" )
									send_data[send_data.length] = elem.name + "=" + elem.value;
								//else
								//	send_data[send_data.length] = elem.name + "=__NULL__";
							
							}else if( elem.type.toUpperCase() == "TEXT" || elem.type.toUpperCase() == "HIDDEN" ) {

								if(elem.value.length > 0)
									send_data[send_data.length] = elem.name + "=" + elem.value;
								else
									send_data[send_data.length] = elem.name + "=__NULL__";

							}else if( elem.type.toUpperCase() == "PASSWORD" ){
								
								var val = elem.value;
								var no_encrypt = elem.getAttribute("no_encrypt");
								
								if( val.length > 0){
									if( typeof(hex_sha1) == "function" && no_encrypt != "1")
										val = hex_sha1(val);
									
									
								}else
									send_data[send_data.length] = elem.name + "=__NULL__";
									
								send_data[send_data.length] = elem.name + "=" + val;
							}
							
						}else if(elem.tagName.toUpperCase() == "SELECT"){
							if(elem.selectedIndex >= 0){
								if(elem.options[elem.selectedIndex].value != "__UNSET__")
									send_data[send_data.length] = elem.name + "=" + elem.options[elem.selectedIndex].value;
							}else
								send_data[send_data.length] = elem.name + "=__UNSET__";
						
						}else if(elem.tagName.toUpperCase() == "TEXTAREA"){
							send_data[send_data.length] = elem.name + "=" + elem.value;
						}
					}
					
					//CHANGE OF SPECIALS CHARS
					var j = 0;
					for(j = 0; j < send_data.length; j++){
						send_data[j] = send_data[j].replace(/&/g, '!@!');

					}

					send_data = send_data.join("&");

					if(this.xhr.readyState == 1)
						this.xhr.send(send_data);
					else
						alert("Ajax state not ready");
					
				}else{

					if(this.xhr.readyState == 1)
						this.xhr.send(null);
					else
						alert("Ajax state not ready");

				}
					
			}else{

				if(this.xhr.readyState == 1)
					this.xhr.send(post_data);

				else
					alert("Ajax state not ready");
				
			}
		}else{

			if(this.xhr.readyState == 1)
				this.xhr.send(null);
			else
				alert("Ajax state not ready");

		}
		
	}
//--JAVASCRIPT PART: node_handling
	function page_init(){

		if( (typeof(page_load)).toUpperCase() == "FUNCTION")
			page_load();

		if( typeof(menu_init) == "function" )
			menu_init();

		if(typeof(NO_ERGO) == "undefined")
			controls_ergo();

	}

	function controls_ergo(){
		var inputs = document.getElementsByTagName('input');
		var i;

		for(i = 0; i < inputs.length; i++){
			if( inputs[i].onfocus == null){
				if(inputs[i].type.toLowerCase() == 'text'  || inputs[i].type.toLowerCase() == 'password'){
					inputs[i].onfocus = control_ergo_in;
					inputs[i].onblur = control_ergo_out;
				}
			}
			
		}

		inputs = document.getElementsByTagName('select');
		for(i = 0; i < inputs.length; i++){
			if( inputs[i].onfocus == null){
				inputs[i].onfocus = control_ergo_in;
				inputs[i].onblur = control_ergo_out;
			}
			
		}

		inputs = document.getElementsByTagName('textarea');
		for(i = 0; i < inputs.length; i++){
			if( inputs[i].onfocus == null){
				inputs[i].onfocus = control_ergo_in;
				inputs[i].onblur = control_ergo_out;
			}
			
		}

	}
	
	function control_ergo_in(){
		if(typeof(ERGO_COLOR) == "undefined")
		  this.style.backgroundColor = "#EEEEEE";
		else
		  this.style.backgroundColor = ERGO_COLOR;

	}
	
	function control_ergo_out(){
		this.style.backgroundColor = "";
	}

	function apply_control_saver(formObj){
		formObj = formObj.getElementsByTagName('form')[0];
		if(formObj){
		
			var i;
			
			if( typeof(formObj.is_saved) == 'object' && typeof(formObj.is_changed) == 'object' ){
			
				var ctrl = formObj.getElementsByTagName('input');
				for(i = 0; i < ctrl.length; i++){
					if(ctrl[i].type == "text" || ctrl[i].type == "password" || ctrl[i].type == "checkbox" ||ctrl[i].type == "radio" ){
						if( typeof(ctrl[i].onchange) == "function"){
						
						}else
							ctrl[i].onchange = function(){ control_changed(this);};
					}
				}

				ctrl = formObj.getElementsByTagName('select');
				for(i = 0; i < ctrl.length; i++){
					if( typeof(ctrl[i].onchange) == "function"){
						
					}else
						ctrl[i].onchange = function(){ control_changed(this);};
				}
				
				ctrl = formObj.getElementsByTagName('textarea');
				for(i = 0; i < ctrl.length; i++){
					if( typeof(ctrl[i].onchange) == "function"){
						
					}else
						ctrl[i].onchange = function(){ control_changed(this);};
				}
				
				
			}
		}
	}
	
	function close_context_menu(){
	
	}
	
	function clear_object_content(obj){
		var tmp;
		var cpt;
		try{
			if(obj.lang != "list_template" && obj.lang != "form_template"){
				for((cpt = obj.childNodes.length - 1); cpt >= 0; cpt--){
				  tmp = obj.childNodes[cpt];
				  if(tmp.lang != "list_template" && tmp.lang != "form_template")
					  obj.removeChild(tmp);
				}
			}
		}catch(error){
		
		}
	}
	
	function cancel_bubble(e){

		if( !e )
			e = window.event;
			
		e.cancelBubble = true;
		if( e.stopPropagation )
			e.stopPropagation();
	}

	var localXML = new Array();

	function bring_center_form(objBody, objFormOr, close_callback_function, destroy_original, vertical_offset, no_overlay){

		if(!no_overlay || typeof(no_overlay) == "undefined")
			no_overlay = false;
			
		var objForm = objFormOr.cloneNode(true);
		var objOverlay = document.createElement("div");
		
		objOverlay.setAttribute('id', 'ol_' + objForm.id);
		objOverlay.className  = "overlay";
		objOverlay.onclick = add_close_function(objForm, close_callback_function);
			
		if(!no_overlay)
			objBody.appendChild(objOverlay);

		
	
		var objCenter = document.createElement("div");
		objCenter.className = "centerer";
		objCenter.setAttribute('id', 'fc_' + objForm.id);
		objCenter.onclick = add_close_function(objForm, close_callback_function);
		
		objForm.onclick = add_cb_function();
		
		objForm.style.display = "block";
		
		if(typeof(objFormOr.className) == "undefined")
			objForm.className = "form_container";
		else
			objForm.className = "form_container " + objFormOr.className;

		if( !vertical_offset)
			vertical_offset = 10;
			
		if( typeof(window) == "object"){
			if( window.scrollY ){
					var scrollX = window.scrollX;
					var scrollY = window.scrollY;
			}else{
				var scrollX = document.documentElement.scrollLeft;
				var scrollY = document.documentElement.scrollTop;
	
			}
		}else{
			var scrollX = 0;
			var scrollY = 0;
		}

		var docHeight = document.documentElement.scrollHeight;

		var form_total_height = parseInt(objForm.style.height) +  parseInt(scrollY);
		//Vertical offset + Adjustement
		form_total_height +=  10 + 30;

		if(docHeight < form_total_height)
			docHeight = form_total_height
			
		objOverlay.style.height = docHeight + "px";
		
		objForm.style.top = (scrollY + vertical_offset) + "px";
		objCenter.appendChild(objForm);	
		objBody.appendChild(objCenter);

		//-- SET VALUES FOR SELECT BOX, DUE TO CLONING PROBLEM

		var original_container = objFormOr; 
		var bring_container = objCenter;
		
		var k;
		
		var original_coll_form = original_container.getElementsByTagName("form");
		var bring_coll_form = bring_container.getElementsByTagName("form");
		
		for(k = 0; k < original_coll_form.length; k++){
		
			var original_myForm = original_coll_form[k];
			var bring_myForm = bring_coll_form[k];

			if( original_myForm.elements ){
				if(original_myForm.elements.getElementsByTagName){
					var original_select_tags = original_myForm.elements.getElementsByTagName("SELECT");
					var bring_select_tags = bring_myForm.elements.getElementsByTagName("SELECT");
					
					var i = 0; 
					var j;
					
					var original_opt, bring_opt;
		
					for(i = 0; i < original_select_tags.length; i++){
					
						for(j = 0; j < original_select_tags[i].options.length; j++){
						
							original_opt = original_select_tags[i].options[j];
							bring_opt = bring_select_tags[i].options[j];
							
							if(original_opt.selected){
								bring_opt.selected = "SELECTED";
							}
						}
		
					}
				}
			}
		}

		if(destroy_original){
			objFormOr.parentNode.removeChild(objFormOr);
		}
		
		if(typeof(bring_opened) == "function"){
			bring_opened();
		} 

		controls_ergo();
		apply_control_saver(objForm);
		objForm.onclick = function(event){cancel_bubble(event); calendar_close(); };
		return objForm;
	}

	function add_close_function(objForm, close_callback_function){
		var func = function() { close_sub_form( objForm, close_callback_function ); calendar_close(); return false; };
		return func;
	}
	
	function add_cb_function(){
		return function(event){ cancel_bubble(event); };
	}

	function control_changed(control){
		var form = recursive_form_find(control,0);
		var is_changed = form.getElementsByTagName("INPUT")[1];
		is_changed.value = "1";
	}

	var max_level = 15;
	function recursive_form_find(obj, level){
	
		if( typeof(obj) != "undefined" && obj != null ){
			if(obj.tagName == "FORM"){
				return obj;
			}else{
				if(level > max_level){
					alert("Erreur de recherche de formulaire:#188");
					return null;
				}else{
					return recursive_form_find(obj.parentNode, level++);
				}
			}
		}else
			return null;
	}

	function fill_form(objForm, record, id){
		var i, j, k, l, field, field_name, form_element;
	
		if( (objForm.tagName).toUpperCase() == "FORM" )
			form_control = objForm;
		else
			form_control = objForm.getElementsByTagName("FORM")[0];
	
		if(record.constructor != null)
			var pos = record.constructor.toString().indexOf("Array");
		else{
			if( typeof(record.join) != "undefined")
				pos = 1;
		}

		if( pos > 0 ){
			//IF THE RECORD IS AN ASSOCIATIVE ARRAY, MUST CONVERT TO XMLDOC
			var xmlRecord = convert_array_to_xml( record, id );
			xmlRecord = xmlRecord.firstChild;
		}else
			var xmlRecord = record;
	
		var field_value;
		
		for(i = 0; i < xmlRecord.childNodes.length; i++){
		
			field = xmlRecord.childNodes[i];
			if(field.hasChildNodes()){
				field_value = field.childNodes[0].nodeValue
			}else
				field_value = '';
			
			if(field_value == null)
				field_value = ''
				
			if(typeof(field) != "undefined"){
			
				field_name = field.tagName;
			
				if(field_name == "dynamic_properties"){
	
				}else{
					if(field_name != ""){

						for(k = 0; k < form_control.elements.length; k++){
							form_element = form_control.elements[k];
						
							if(form_element.name == field_name){
								 if(form_element.tagName.toUpperCase() == "INPUT"){
		
									if(form_element.type.toUpperCase() == "TEXT"){
		
										form_element.value = field_value;

									}else if(form_element.type.toUpperCase() == "HIDDEN"){
										if(form_element.className != "no_clear")
											form_element.value = field_value;
		
									}
								 
								 }else{
									if(form_element.tagName.toUpperCase() == "SELECT"){
										
										for(l = 0; l < form_element.options.length; l++){
										
											if( form_element.options[l].value == field_value){
												form_element.options[l].selected = "selected";
												form_element.options[l].setAttribute('selected', 'selected');
												break;
											}
										}
									}
								 }
								
								break;	
							}
							
						}
					}
				}		
			}
		}

	}

	function updateHtmlNode(templateObject, xmlNode, update_existing, index, name_extra){
	
		var j, tmp_object, tmp_cell;
		var property_name, content, tmp_content, node;
		
		var is_new = false;

		if(typeof(name_extra) != "string")
			name_extra = "";
			
	
		if(xmlNode != null){
		
			var template = templateObject.innerHTML;
			template = template.split("#@#");
				
			var template_out = templateObject.innerHTML;
			template_out = template_out.split("#@#");
			
			var id = xmlNode.getAttribute('id');
			
			if( ! update_existing){
	
				var tmp_object = document.createElement( templateObject.tagName );
				tmp_object.className = templateObject.className;
				//tmp_object.name = templateObject.name;
				var value_property = templateObject.value;
				
				if(typeof(value_property) != "undefined" && value_property != null && typeof(value_property) == "string" ){
				
					value_property = value_property.split("#@#");
					value_property = value_property[1];
					
					if(value_property.length > 0){
					
						var value_node = xmlNode.getElementsByTagName(value_property)[0];
						tmp_object.value = value_node.firstChild.nodeValue;
					}

				}
				
				tmp_object.setAttribute('id', name_extra + "rec_" + xmlNode.getAttribute('id') );
				
				if(templateObject.getAttribute('name') != null)
					tmp_object.setAttribute('name', templateObject.getAttribute('name') );

				is_new = true;

			}else{
			
				var top_object = templateObject.parentNode;
				var tmp_object;
				for(j = 0; j < top_object.childNodes.length; j++){
				
					tmp_object = top_object.childNodes[j];
					
					if( typeof(tmp_object) == 'object' && tmp_object.innerHTML != "undefined" ){
					
						if( typeof(tmp_object.id) == "string" ){
						
							if(tmp_object.id != templateObject.id){

								if(tmp_object.id == name_extra + "rec_" + id){
								
									tmp_object = top_object.childNodes[j];
									break;
			
								}
							}
						}
	
					}
					
					tmp_object = '';
				}
			}
			

			
			if( typeof( tmp_object.id) == "undefined" || tmp_object.id == templateObject.id){
			
				var tmp_object = document.createElement( templateObject.tagName );
				tmp_object.className = templateObject.className;
				tmp_object.setAttribute('id', name_extra + "rec_" + xmlNode.getAttribute('id') );
				
				if(templateObject.getAttribute('name') != null)
					tmp_object.setAttribute('name', templateObject.getAttribute('name') );

				is_new = true;
			}
			


			for(j = 1; j < template.length; j = j + 2){
		
				property_name = template[j];
				
				if(property_name == "index")
					template_out[j] = id;
				else{
					node = xmlNode.getElementsByTagName(property_name)[0];

					if( typeof(node) != "undefined"){

						node = node.firstChild;
						
						if(typeof(node) != "undefined" && node != null)
							template_out[j] = node.nodeValue;
						else
							template_out[j] = "";

					}
				}
			}

			content = "";
			for(j = 0; j < template_out.length; j++){
				content = content + "" + template_out[j];
		
			}

			if(templateObject.tagName.toUpperCase() == "TR"){

				content = content.replace(/\<TD\>/g, "<td>");
				content = content.replace(/\<\/td\>/gi, "");
				var tempo_div = document.createElement('div');
/*
				var lclass = tmp_object.className;

				if( lclass.indexOf("#@#") != -1){
					lclass = lclass.substr(3);
					lclass = lclass.substr(0, lclass.length - 3);
					
					
					node = xmlNode.getElementsByTagName( lclass )[0];
					
					if( typeof(node) != "undefined"){

						node = node.firstChild;
					}
					
					if( typeof(node) != "undefined" )
						tmp_object.className = node.nodeValue;
				}
*/
				try{
				
					if(typeof(content.split) == "function"){
						tmp = content.split("<td>");
						tmp.shift();
					}else
						tmp = new Array();
						
				}catch(error2){
					tmp = new Array();
				}
				
				content = "";

				if( is_new && tmp.length > 0){
				
				

					for(j = 0; j < tmp.length; j++){
					
						if( typeof(tmp_object.cells.length) == "undefined"){
							tmp_cell = tmp_object.insertCell(0);
							
							if( tmp_cell == null){
								tmp_cell = document.createElement("TD");
								tmp_object.appendChild( tmp_cell );
								
							}
							
							tmp_cell.innerHTML = tmp[j];
							
						
						}else{
							tmp_cell = tmp_object.insertCell(tmp_object.cells.length);
							tmp_cell.innerHTML = tmp[j];
						}
					}

				}else{
				
					for(j = 0; j < tmp.length; j++){
					
						tmp_cell = tmp_object.cells[j];
						tmp_cell.innerHTML = tmp[j];
			
					}
				
				}

			}else{
			
				if(templateObject.tagName.toUpperCase() == "TABLE"){
				
					tmp_object = document.createElement("span");
					tmp_object.innerHTML = "<TABLE>" + content + "</TABLE>";

				}else
					tmp_object.innerHTML = content;
			}
			
			templateObject.parentNode.appendChild(tmp_object);
			
		}else{
		//xmlNode == null, DELETING
			var id = index;

			//DELETING
			var top_object = templateObject.parentNode;
			var tmp_object;

			for(j = 0; j < top_object.childNodes.length; j++){
			
				tmp_object = top_object.childNodes[j];
				if( typeof( tmp_object ) == 'object' && tmp_object.innerHTML != undefined ){
					index = tmp_object.getAttribute('id');

					if( index == name_extra + "rec_" + id ){
					
						if(tmp_object.tagName != "row")
							tmp_object.parentNode.removeChild(tmp_object);
						else
							tmp_object.parentNode.deleteRow(index);

						break;
	
					}
	
				}
			}

		}

	}

	function recursive_element_by_id(parent_object, object_id, depth){
	
		var i, node;
			
		if( (typeof(parent_object)).toUpperCase() == "OBJECT" && depth < 25){
		
			if(parent_object.hasChildNodes){
			
				for(i = 0; i < parent_object.childNodes.length; i++){
				
					node = parent_object.childNodes[i];
					
					if(node.id == object_id){
						return node;
					}else{
					
						node = recursive_element_by_id( node, object_id, (depth + 1) );
						if(node != null){
						
							if(node.id == object_id){
						
								return node;
							}
						}
					}
				
				}
				
			}else{
				return null;
			}
		}else{
			return null;
		}
	
		return null;
	}
	
	function convert_array_to_xml( my_array, id ){
	
		if (document.implementation && document.implementation.createDocument) {
		//MOZ
			xmlDoc = document.implementation.createDocument("", "", null);
			return build_xml(xmlDoc, my_array, id );
			
		}else if (window.ActiveXObject) {
	  	//IE
			xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
			return build_xml(xmlDoc, my_array, id );
		}else {
			alert('Your browser can\'t handle this XML CREATION script');
			return null;
		}

	}
	
	function build_xml(xmlDoc, my_array, id ){
	
		var field, elem, text_node;
		
		var record = xmlDoc.createElement("record");
		xmlDoc.appendChild(record);
		record.setAttribute('id', id);
				
		for( field in my_array){
			
			elem = xmlDoc.createElement(field);
			record.appendChild( elem );
			
			text_node = xmlDoc.createTextNode( my_array[field] );
			elem.appendChild( text_node );
			
			
		}
	
		return xmlDoc;
	
	}
//--JAVASCRIPT PART: ajax_form
	function load_datas( remote_object, add_url_param){

		var command = retrieve_template( remote_object );
		var data_provider_url = command['data_provider'];
		var complement_control_id = command['complement_control_id'];
		var xml_name = command['xml_name'];

		if(!add_url_param)
			add_url_param = ''

		

		if(data_provider_url != null && data_provider_url != "null"){
			data_provider_url += add_url_param;
			var myAjax = new Ajax( data_provider_url , 'POST');
			

			if( typeof(complement_control_id) != "undefined" && complement_control_id!="null" && complement_control_id!=null && complement_control_id != ""){

				//EDITING AND DELETING
				var datas = remote_object;
	
				var found = false;
				var recursive_limit = 15;
				var recursive_count = 0;
				
				var main_container = remote_object;			
				
				while( !found ){
				
						
					if( typeof(main_container) == "object"){
					
						if(typeof(main_container.id) == "string"){
							if(main_container.id == "main_container"){
								
								found = true;
							}
						}
					
					}
					recursive_count++;
					
					if(recursive_count > recursive_limit)
						break;
						
					main_container = main_container.parentNode;
				}
				
	
				var listing_object = recursive_element_by_id( main_container, complement_control_id, 0);
				
				if( typeof( listing_object ) == "undefined" ){
					listing_object = document.getElementById( complement_control_id );
				}
	
	
				myAjax.onComplete = add_function(receive_update, remote_object, listing_object);
				
				var is_saved = datas.getElementsByTagName("INPUT")[0];
				is_saved.value = "1";

				myAjax.send(datas);
	
				datas.getElementsByTagName("INPUT")[0].value = "0";
				datas.getElementsByTagName("INPUT")[1].value = "0";

			}else{
				//LISTING AND AUTHENTICATION
	
	
					myAjax.onComplete = add_function(receive_listing_datas, remote_object);
					myAjax.send(remote_object);
			}
		}

	}

	function retrieve_template( remote_object ){
	
		if( (typeof(remote_object)).toUpperCase() == "OBJECT" && remote_object != null && remote_object != "null" && remote_object != ""){
			var title_command = remote_object.getAttribute('title');

			var data_provider_command = remote_object.getAttribute('data_provider');
			//ALTERNATE ATTRIBUTE
			if(typeof(data_provider_command) != "undefined"){
				if(data_provider_command != null){
					if(data_provider_command.length > 0)
						title_command = data_provider_command;
				}
			}
			
			

			var commands = title_command.split(";");

			var command_args = new Array();
			var tmp, command_name, command_value;
				
			for(var i = 0; i < commands.length; i++){
			
				tmp = commands[i].split(":");
	
				command_name = tmp.shift();
				command_value = tmp.join(":");
				
				if(command_value == "true")
					command_value = true;
				else if(command_value == "false")
					command_value = false;
					
				command_args[ command_name ] = command_value;

			}
			
			return command_args
		}else{
			return new Array();
		}
	}

	function add_function(receive_function, param1, param2){
	
		return function(responseText, responseXML){ receive_function(responseText, responseXML, param1, param2); };
	}
	
	function close_this_sub_form( control, close_callback_function){
	
		var objForm = recursive_form_find(control, 0);
		var fc = objForm.parentNode.parentNode;
		fc.onclick.call();
		
		if( (typeof(close_callback_function)).toUpperCase() == "FUNCTION" ){
			close_callback_function.call();
		}
	}

	function close_sub_form( objForm, close_callback_function){
	
		var is_saved = objForm.getElementsByTagName("INPUT")[0];
		var is_changed = objForm.getElementsByTagName("INPUT")[1];
		var res = true;

		if( typeof(is_saved) == "object" && typeof(is_changed) == "object" ){
		
			if(is_saved.value == "0" && is_changed.value != "0"){
				var res = confirm("Voulez vous quitter sans sans sauvegarder vos informations?");
			}
		}
		
		if(res){
			//PRECLOSE JOB
			if( (typeof(preclose_sf)).toUpperCase() == "FUNCTION" ){
	
				preclose_sf(objForm.id);
			}
		
			var objCenter = document.getElementById( "fc_" + objForm.id );
			var objOverlay = document.getElementById( "ol_" + objForm.id );
			
			if(typeof(objCenter) == "undefined" || objCenter == null || objCenter == "null" || objCenter == ""){

				objCenter = document.getElementById( "fc_" + objForm.parentNode.id );
				objOverlay = document.getElementById( "ol_" + objForm.parentNode.id );
			
			}
			
			if( typeof(objCenter) != "undefined" && objCenter != null){
				objCenter.parentNode.removeChild(objCenter);
			}
			
			if( typeof(objOverlay) != "undefined" && objOverlay != null){
				objOverlay.parentNode.removeChild(objOverlay);
			}
			
			clear_ajax_form(objForm);
					
			if( (typeof(close_callback_function)).toUpperCase() == "FUNCTION" ){
				close_callback_function.call();
			}
		}

	}
	
	function save_ajax_form(control){
	
		var form = recursive_form_find(control,0);
		load_datas( form );
	}

	function delete_ajax_form(control, action){
	
		var form = recursive_form_find(control,0);
		load_datas( form, action );
	}
	
	function delete_ajax_list_item(control){
//		load_datas(, 'del');
	}
	
	function clear_ajax_form(form_object){
	
		if( form_object != null && typeof(form_object) != "undefined" ){
		
			if(form_object.tagName != "form")
				form_object = recursive_form_find(form_object,0);
				
			if( form_object != null && typeof(form_object) != "undefined" ){
				for(i = 0; i < form_object.elements.length; i++){
			
					elem = form_object.elements[i];
					if( (typeof(elem)).toUpperCase() == "OBJECT") {
						
						if(elem.name != ""  && (elem.tagName).toUpperCase() != "FIELDSET" && (elem.disabled == false || elem.disabled == "false") ){
		
							if(elem.type != "checkbox" && elem.type != "radio" &&elem.type != "button" && elem.type != "image" && elem.type != "submit" && elem.type != "reset" && elem.className != "no_clear" )
								elem.value = "";
								
							
							
						}
					}							
				}
			}
		}
	}
	
	function lock_ajax_form(form_object){
	
		if(form_object.tagName != "form")
			form_object = recursive_form_find(form_object,0);
	
		for(i = 0; i < form_object.elements.length; i++){
	
			elem = form_object.elements[i];
			if( (typeof(elem)).toUpperCase() == "OBJECT") {
			
				
				if(elem.name != ""  && (elem.tagName).toUpperCase() != "FIELDSET" && (elem.type).toUpperCase() != "HIDDEN" && (elem.disabled == false || elem.disabled == "false") ){

					elem.disabled = true;
					elem.className = "control_disabled";
					
				}
			}							
		}
	}
	
	function unlock_ajax_form(form_object){
	
		if(form_object.tagName != "form")
			form_object = recursive_form_find(form_object,0);
	
		for(i = 0; i < form_object.elements.length; i++){
	
			elem = form_object.elements[i];
			if( (typeof(elem)).toUpperCase() == "OBJECT") {
			
				
				if(elem.name != ""  && (elem.tagName).toUpperCase() != "FIELDSET" && (elem.type).toUpperCase() != "HIDDEN" && (elem.disabled == true || elem.disabled == "true") ){

					elem.disabled = false;
					elem.className = "";
					
				}
			}							
		}
	}
		
	function show_sub_form(body_name, form_name, template_name, index, is_password_checked){
	
		var objBody = document.getElementById(body_name);
		var objForm =  document.getElementById(form_name);
		objForm = bring_center_form(objBody, objForm);
	
		if(typeof is_password_checked == "undefined" || is_password_checked == "undefined")
			is_password_checked = true;
				
		try{
		
			if(is_password_checked){
				form_control = objForm.getElementsByTagName("FORM")[0];
				password_validator.add_security_to_form(form_control);
			}
		}catch(error){
		
		}
	
		var tmp = retrieve_template( template_name );
		var data_provider_url = tmp[0];
		var data_provider_action = tmp[1];
		var complementary_form = tmp[2];
		var data_provider_varname = tmp[3];
		var owner_object = tmp[4];
		var template_info = tmp[5];
		
		var xmlObj = localXML[data_provider_varname];
		
		var global = xmlObj.getElementsByTagName("GLOBAL")[0];
		var records_container = global.getElementsByTagName("records")[0];
		if(typeof(records) != "undefined"){
			var records = records_container.getElementsByTagName("record");
		
			var record = find_record(records, index);
			if( typeof(record) == "object" ){
				fill_form(objForm, record );
			}
		}		
	}

	function find_record(xmlRecords, id){
		var res = null;
		var i = 0;
		for(i = 0; i < xmlRecords.length; i++){
			if(xmlRecords[i].getAttribute('id') == id){
				res = xmlRecords[i];
				break;
			}
		}
		
		return res;
		
	}
	
	function receive_update(responseText, responseXML, form_object, list_object){
		var global = responseXML.getElementsByTagName("GLOBAL")[0];
		var status = global.getElementsByTagName("status")[0].childNodes[0].nodeValue;
		var description = global.getElementsByTagName("description")[0].childNodes[0].nodeValue;
		var insert_item = global.getElementsByTagName("insert_item");

		if( insert_item.length == 1)
			insert_item = insert_item[0].childNodes[0].nodeValue;
		else
			insert_item = null;
			
		var command = retrieve_template( form_object );
		var close_after = command['close_after'];
	
		var xml_name = command['xml_name'];
		localXML[ xml_name ] = responseXML;
	
		if( close_after != false){
			//INTERFACE MUST BE CLOSE
			close_sub_form(form_object);
		}else{
			if( typeof(form_changed) == "function")
				form_changed(form_object, list_object);
		}
		
		
		
		var call_back_function = command['call_back_function'];
		if(call_back_function != null && typeof(call_back_function) != "undfined"){
			
			try{
				if(insert_item){
					var protected_item = "'" + escape(insert_item) + "'";
					
					eval(call_back_function + "(" + protected_item + ")");
					
				}else
					eval(call_back_function + "()");
			}catch(error){
//				alert(error);
			}

		}
		
		
		if( typeof( call_back_function) == "function" ){
			call_back_function.call(null, insert_item);
		}

		load_datas( list_object );
		
	}

	function receive_listing_datas(responseText, responseXML, remote_object){

		var command = retrieve_template( remote_object );
		var data_provider_url = command['data_provider'];
		var complement_control_id = command['complement_control_id'];
		var xml_name = command['xml_name'];
		var call_back_function = command['call_back_function'];
		var record_name_extra = command['record_name_extra'];

		if( complement_control_id != "" && typeof(complement_control_id) !="undefined" )
			myRemote = document.getElementById( complement_control_id );	
		else
			myRemote = remote_object;

		var previousXML = localXML[ xml_name ];
	
	
		if( typeof( previousXML ) != "undefined" ){

			if(previousXML == responseXML)
				return null;
				
			else{
				//UPDATE
	
				var pglobal = previousXML.getElementsByTagName("GLOBAL")[0];
				var precords_list = pglobal.getElementsByTagName("records")[0];
				
				if(typeof(precords_list) == "object"){

					var precords = precords_list.getElementsByTagName("record");
					
					var global = responseXML.getElementsByTagName("GLOBAL")[0];
					var records_list = global.getElementsByTagName("records")[0];
					var records = records_list.getElementsByTagName("record");
					
					var id, is_found, rec, prec;
					var updated_ids = new Array();
					
					for(i = 0; i < precords.length; i++){
		
						prec = precords[i];
						id = prec.getAttribute('id');
						rec = find_record(records, id );
						updated_ids[ updated_ids.length ] = id;				

						if( rec != null){
						
							if( prec != rec){
								//UPDATED RECORD
								updateHtmlNode(myRemote, rec, true, 0, record_name_extra);
							}
							
						}else{
							//DELETED RECORD
							updateHtmlNode(myRemote, null, false, id, record_name_extra);
						}

					}

					for(i = 0; i < records.length; i++){

						rec = records[i];
						is_found = false;

						for(j = 0; j < updated_ids.length; j++){

							if( rec.getAttribute('id') == updated_ids[j] ){
								is_found = true;
								break;

							}
						}

						if(!is_found){
							//NEW RECORD
							updateHtmlNode(myRemote, rec, false, 0, record_name_extra);
						}
					}


					localXML[ xml_name ] = responseXML;
				}
			}
			
		}else{
			//INSERT
			localXML[ xml_name ] = responseXML;

			var global = responseXML.getElementsByTagName("GLOBAL")[0];
			if(typeof(global) == "object"){

				var records_list = global.getElementsByTagName("records")[0];
				
				if( typeof(records_list) == "object"){
					var records = records_list.getElementsByTagName("record");
		


					if( typeof(records) != "undefined"){

						var id;
						for(i = 0; i < records.length; i++){
							id = records[i].getAttribute('id');
							var tmp_control  = document.getElementById( record_name_extra + "rec_" + id);
							
							if(tmp_control)
								updateHtmlNode(myRemote, records[i],true, 0, record_name_extra);
							else
								updateHtmlNode(myRemote, records[i],false, 0, record_name_extra);
						}
					}
				}
			}
			
		}
		

		
		if(call_back_function != null && typeof(call_back_function) != "undfined"){
			
			try{
				eval(call_back_function + "()");
			}catch(error){

			}

		}
		
		
		if( typeof( call_back_function) == "function" ){
			call_back_function.call(null);
		}

		return true;
	}
	
	function page_receive(responseText, responseXML){
	
		var global = responseXML.getElementsByTagName("GLOBAL")[0];
		var html_content = global.getElementsByTagName("html_content")[0];
		var html_content = html_content.firstChild.nodeValue;
		
		var myDiv = document.createElement("DIV");
		myDiv.setAttribute('id', 'mydiv');
		myDiv.style.display = "none";
		myDiv.innerHTML = html_content;	

		document.body.appendChild(myDiv);
		var myInsert = myDiv.getElementsByTagName("DIV")[0];
		var myForm = myDiv.getElementsByTagName("FORM")[0];
		bring_center_form( document.body, myInsert, close_cb_fc, true );
		
		if(typeof(page_receive_init) == "function")
			page_receive_init(myInsert.id);
	
	}
	
	function close_cb_fc(){
		
		var myDiv = document.getElementById('mydiv');
		myDiv.parentNode.removeChild( myDiv );

		if( (typeof(close_sf)).toUpperCase() == "FUNCTION" ){

			close_sf();
		}
	}
//JAVASCRIPT DOCUMENT
//READ AND WRITE, CENTRALIZED
//JAVASCRIPT DOCUMENT: rating.php
function rate(rate_type, rate_remote, amount, rating_token){

	myAjax = new Ajax( "http://www.allardtechnologies.com/data_provider/module_softwares.php?tZ=1283905576&dp=module_loader&module=rating_comment_favorite&a=rate&rating_type=" + rate_type + "&rating_remote_id=" + rate_remote + "&rating_value=" + amount + "&rating_token=" + rating_token, 'POST');
				myAjax.onComplete = receive_rating;
				myAjax.send();
}

function receive_rating(responseText, responseXML){

}

var rating_set = new Array();

function rating_move(obj, amount, rating_type, rating_remote_id){

	var i = 0;
	
	var cell = obj.parentNode;
	var row = cell.parentNode;
	
	
	if(typeof(rating_set[rating_type + ":" + rating_remote_id]) != "undefined"){
		return;
	}
	
	rating_set_images(row, amount);
	

}

function rating_set_images(row, amount){

	if( amount <= row.cells.length ){
	
		var nb = Math.floor(amount);

		for(i = 0; i < nb; i++){

			row.cells[i].style.backgroundImage = "url(/images/design/etoile_pleine_profil.jpg)";
		}
		
		if( (amount - nb) > 0){
			row.cells[i].style.backgroundImage = "url(/images/design/etoile_demi_profil.jpg)";
			i++;
		}
		
		while(i < row.cells.length){
			row.cells[i].style.backgroundImage = "url(/images/design/etoile_vide_profil.jpg)";
			i++;
		}
	
	}
}

function rating_clear(obj){
	var table = obj.parentNode.parentNode;
	var rating_value = table.getAttribute("rating_value");
	var diff, icon;
	
	var full_star_path = "/images/design/etoile_pleine_profil.jpg";
	var half_star_path = "/images/design/etoile_demi_profil.jpg";
	var empty_star_path = "/images/design/etoile_vide_profil.jpg";
	
	for(i = 0; i < obj.cells.length; i++){
		diff = (rating_value - i ) * 10 ;
				
		if( diff >= 10 ){
			icon = full_star_path;
		}else if( diff > 0 && diff < 10){
			icon = half_star_path;
		}else{
			icon = empty_star_path;
		}
		obj.cells[i].style.backgroundImage = "url(" + icon + ")";
	}
}

function rating_process(obj, amount, rating_type, rating_remote_id, rating_token){

	var cell = obj.parentNode;
	var row = cell.parentNode;
	
	
	if(typeof(rating_set[rating_type + ":" + rating_remote_id]) == "undefined"){
		rating_set[rating_type + ":" + rating_remote_id] = amount;
		row.onmouseout = null;
		rate(rating_type, rating_remote_id, amount, rating_token);
	}

}

var favorite_control_pending;

function show_favorite_form(curr_obj ){

	favorite_control_pending = curr_obj;
	var ns = curr_obj.parentNode.getElementsByTagName("div")[0];

	show_callout(ns.innerHTML, curr_obj, 10, 10, 225, 158, 0, false, null );
}

var favorite_object_pending;

function add_to_favorite( curr_obj ){
	
	favorite_object_pending = curr_obj;
	
	var myForm = recursive_form_find( curr_obj );
	
	var id_favorite_group = myForm.id_favorite_group;
	var fg_name = recursive_element_by_id(myForm, 'name', 0);
	
	var is_valid = true;
	
	if(typeof(id_favorite_group) != "object" || id_favorite_group == null)
		is_valid = false;
//	else if(id_favorite_group.value <= 0 )
//		is_valid = false;
	
	if( !is_valid && fg_name.value.length > 0 )
		is_valid = true;

	if( is_valid ){
		var url = "http://www.allardtechnologies.com/data_provider/module_softwares.php?tZ=1283905576&dp=module_loader&module=rating_comment_favorite&a=add_favorite";
		var myAjax = new Ajax(url, 'POST');
		myAjax.onComplete = add_to_favorite_receive
		myAjax.send(myForm);
		
	}else{
		id_favorite_group.style.border="1px solid #FF0000;"
		fg_name.style.border="1px solid #FF0000;"
	}
}

function add_to_favorite_receive(responseText, responseXML){
	close_this_callout(favorite_object_pending);

	var global = responseXML.getElementsByTagName("GLOBAL")[0];
	var status = global.getElementsByTagName("status")[0].firstChild.nodeValue;
	var id_favorite= global.getElementsByTagName("id_favorite")[0].firstChild.nodeValue;

	if(status == "OK"){

		var pn = favorite_control_pending.parentNode;
		favorite_control_pending.style.display = "none";
		var conf = document.createElement("span");
		conf.innerHTML = "Fait parti de vos favoris <span class='favorite_link' onclick='JAVASCRIPT: remove_from_favorite("+id_favorite+", this)'>retirer</span>&nbsp;&nbsp;<span class='favorite_link' onclick='JAVASCRIPT: view_favorite("+id_favorite+");'>voir</span>";
		pn.appendChild( conf );
		
	}
	
	
	favorite_object_pending = null;
	favorite_control_pending = null;
}

function remove_from_favorite(id_favorite, obj){

	if(typeof(obj) == "object"){
		var sn = obj.parentNode;
		var pn = sn.parentNode;
	
		clear_object_content(sn);
		
		pn.removeChild(sn);
	
		var btn = pn.getElementsByTagName("input")[0];
		btn.style.display = "block";
	}
	
	var url = "http://www.allardtechnologies.com/data_provider/module_softwares.php?tZ=1283905576&dp=module_loader&module=rating_comment_favorite&a=del_favorite&id_favorite=" + id_favorite;
	var myAjax = new Ajax(url, 'GET');
	myAjax.send();
	
}

function view_favorite(id_favorite){
	document.location = "/page_module.php?tZ=1283905576&module=rating_comment_favorite&page=favorite_view&id_favorite=" + id_favorite;
}
//JAVASCRIPT DOCUMENT: side_menu.js.php

var menu_mouse_over_add = "_up";
var menu_file_ext = ".png";
var color_switch = new Array("#000000", "#FFFFFF");

function sm_over(obj){

	var id = obj.id;
			
	var rem_obj = document.getElementById(id + "_reg");
	var bring_obj = document.getElementById(id + "_over");
	
	
	if(typeof(rem_obj) == "object")
		rem_obj.style.display = "none";
		
	if(typeof(bring_obj) == "object")
		bring_obj.style.display = "block";
	
	
}

function sm_out(obj){

	var id = obj.id;
			
	var rem_obj = document.getElementById(id + "_over");
	var bring_obj = document.getElementById(id + "_reg");
	
	
	if(typeof(rem_obj) == "object")
		rem_obj.style.display = "none";
		
	if(typeof(bring_obj) == "object")
		bring_obj.style.display = "block";

}//JAVASCRIPT DOCUMENT: keyword.js.php
var current_keyword_type_obj;
var current_id_mmi;
function keyword_type(obj, id_mmi){

	current_keyword_type_obj = obj;
	current_id_mmi = id_mmi;
	var myAjax = new Ajax( "data_provider/module_softwares.php?tZ=1283905576&dp=module_loader&module=photo_album&a=keyword_list&is_accepted=Y&mask=" + obj.value + "&id_mmi=" + id_mmi, "POST");
	myAjax.onComplete = keyword_type_receive;
	myAjax.send();
	
}

function keyword_type_receive(responseText, responseXML){

	var obj = current_keyword_type_obj;
	
	if( typeof(obj) != "object")
		return;
		
	var control_name = obj.getAttribute("lister_control");
	var lister_control = document.getElementById( control_name );
	
	var global = responseXML.getElementsByTagName("GLOBAL")[0];
	var records_container = global.getElementsByTagName("records")[0];
	var records = records_container.getElementsByTagName("record");
	var i, id_keywords, text, token, new_li;
	
	clear_object_content(lister_control);
	
	if( lister_control.tagName == "UL" ){
	
		
		if(typeof(records) != "undefined"){
			
			for(i = 0; (i < 10 &&  i < records.length); i++){
			
				id_keywords = records[i].getElementsByTagName("id_keywords")[0].firstChild.nodeValue;
				text = records[i].getElementsByTagName("text_")[0].firstChild;
				if(text)
					text = text.nodeValue;
					
				token = records[i].getElementsByTagName("token")[0];
				if(token)
					token = token.firstChild.nodeValue;
						
				new_li = document.createElement("LI");
				new_li.innerHTML = text;
				new_li.setAttribute("token", token);
				new_li.setAttribute("id_keywords", id_keywords);
				new_li.onclick = keyword_add;
				new_li.style.cursor = "pointer";
				new_li.onmouseover = list_over;
				new_li.onmouseout = list_out;
				
				lister_control.appendChild(new_li);
				
			}
		
			
		}	
	
	}else if( lister_control.tagName == "SELECT" ){
	
	}

}

function keyword_add(){

	if(current_id_mmi){
	
		var id_keywords = this.getAttribute("id_keywords");
		var token = this.getAttribute("token");
		
		var myAjax = new Ajax( "data_provider/module_softwares.php?tZ=1283905576&dp=module_loader&module=photo_album&a=keyword_add&is_accepted=Y&id_keywords=" +id_keywords + "&id_multimedia_item=" + current_id_mmi + "&token=" + token, "POST");
		myAjax.onComplete = keyword_add_receive;
		myAjax.send();
	}
}

function keyword_add_receive(responseText, responseXML){
	var lister = document.getElementById('tag_list');
	load_datas(lister);
}//JAVASCRIPT DOCUMENT: chat.js.php
var pool_check_timer;
function load_poolling_system(){
}

var pool_notifier;

function pool_check(){

	//CHAT POOL
	var myAjax = new Ajax( "data_provider/module_softwares.php?tZ=1283905576&dp=module_loader&module=chat&a=chat_get_action" , "POST");
	myAjax.onComplete = chat_get_action;
	myAjax.send();
	
}

var users_sender = new Array();
var rooms = new Array();

function chat_get_action(responseText, responseXML){

	if(typeof(responseXML) != "undefined"){
	
		var global = responseXML.getElementsByTagName("GLOBAL")[0];
		var records_list = global.getElementsByTagName("records")[0];
		
		if(typeof(records_list) != "undefined"){
		
			var records = records_list.getElementsByTagName("record");
			var id, sender, receiver, room, moment, type, value, user_nickname, user_avatar, room_name, room_created, token;
			
			if(typeof(records) != "undefined"){
			
				var i;
				
				for(i = 0;  i < records.length; i++){
				
					id = records[i].getElementsByTagName("id_chat_action")[0].firstChild.nodeValue;

					token = records[i].getElementsByTagName("token")[0].firstChild.nodeValue;
					
					sender = records[i].getElementsByTagName("id_chat_users_sender")[0];
					if(sender.hasChildNodes())
						sender = sender.firstChild.nodeValue;
						
					receiver = records[i].getElementsByTagName("id_chat_users_receiver")[0];
					if(receiver.hasChildNodes())
						receiver = receiver.firstChild.nodeValue;
						
					room = records[i].getElementsByTagName("id_chat_room")[0];
					if(room.hasChildNodes())
						room = room.firstChild.nodeValue;

					moment = records[i].getElementsByTagName("moment")[0].firstChild.nodeValue;

					type = records[i].getElementsByTagName("chat_action_type")[0].firstChild.nodeValue;

					value = records[i].getElementsByTagName("chat_value")[0].firstChild.nodeValue;

					user_nickname = records[i].getElementsByTagName("user_nickname")[0];
					if(user_nickname.hasChildNodes())
						user_nickname = user_nickname.firstChild.nodeValue;

					room_name = records[i].getElementsByTagName("room_name")[0];
					if(room_name.hasChildNodes())
						room_name = room_name.firstChild.nodeValue;
						
					room_created = records[i].getElementsByTagName("room_created")[0];
					if(room_created.hasChildNodes())
						room_created = room_created.firstChild.nodeValue;
				
					if(type == "PRIVATE_MESSAGE"){
					
						if(typeof(users_sender[sender]) != "undefined"){
							var check_window = pm_windows[sender];
							
							if( typeof(check_window) == "object"){
								if(!check_window.closed){
									//TODO: emphasize the line of this users because the window is opened						
								}else{
									//TODO: emphasize the line of this users because the window is closed
								}
							}else{
									//TODO: emphasize the line of this users because the window is closed
							}
							
						}else{
							users_sender[sender] = new Array(moment, value, user_nickname, token, receiver );
							update_chat_status_content(type, sender);
						}
						
					}
					
				
				}
				
				
			
			}
		}else{
			var code = global.getElementsByTagName("code")[0];
			
			if(typeof(code) != "undefined"){
				code = code.firstChild.nodeValue;
				
				if(code == 1)
					window.clearInterval( pool_check_timer );
			}
			
		}	
	}
}


function update_chat_status_content(type, sender){

	var sender_infos = users_sender[sender];
	
	var notifier = document.createElement("a");

	notifier.onclick = show_chat_status;
	notifier.innerHTML = "Vous avez des messages priv&eacute;s";
	pool_notifier.appendChild(notifier);
	
	var div;
	var elem;
	var is_found = false;
	
	div = document.getElementById('chat_status');
	var is_div = false;
	try{
	
		if(typeof(div) == "object" && div.tagName=="div")
			is_div = true;
			
	}catch(error){
	
	}
	
	if( !is_div){

		div = document.createElement("div");
		div.style.position = "relative";
		div.style.float = "left";
		div.style.clear = "both";
		div.style.zIndex = "6";
		div.style.display = "none";
		div.id = 'chat_status';
		document.body.appendChild(div);
	
	}else{
	
		var coll = div.getElementsByTagName("div");
		var i = 0;
		
	
			
		for(i = 0; i < coll.length; i++){
			elem = coll[i];
			if(elem.id == "sender_" + sender){
				is_found = true;
			}
		}
	}
		
	if( !is_found ){
	
		elem = document.createElement("div");
		elem.id = "sender_" + sender;
//		elem.innerHTML = "<img src='" + sender_infos[3] + "' /><br />" + sender_infos[2] + "<br /> A dit: " + sender_infos[1];
		elem.innerHTML = "Interlocuteur: <b>" + sender_infos[2] + "</b> A dit: " + sender_infos[1];
		elem.innerHTML = elem.innerHTML + "<a href=\"JAVASCRIPT: show_private_chat(" + sender + ", '" + sender_infos[3]+ "','" + sender_infos[4] + "');\">Discuter</a>";
		div.appendChild(elem);
	}


}

function show_chat_status(){
	var div = document.getElementById('chat_status');
	div.style.display = "block";
}

var pm_windows = new Array();

function show_private_chat(sender, token, receiver){
  var url = "/page_module.php?tZ=1283905576&module=chat&page=private_messaging&sender=" + sender + "&token=" + token + "&receiver=" + receiver;
	
  pm_windows[sender] = window.open(url, "pc_" + sender, "location = no, menubar = no, resizable = yes, scrollbars = yes, status = no, toolbar = no, width=450, height=450");
   pm_windows[sender].id = sender;
}

function close_private_chat(){
	pm_windows[this.id] = null;
}

var room_windows = new Array();
function show_room_chat(id_chat_room){
	var url = "/page_module.php?tZ=1283905576&module=chat&page=room_messaging&id_chat_room=" + id_chat_room;

	room_windows[id_chat_room] = window.open(url, "rc_" + id_chat_room, "location = no, menubar = no, resizable = yes, scrollbars = yes, status = no, toolbar = no, width=920, height=660");

}


function close_room_chat(id_chat_room){
	room_windows[id_chat_room] = null;
	try{
		var url = "/data_provider/module_softwares.php?tZ=1283905576&dp=module_loader&module=chat&a=chat_add_message&chat_action_type=QUIT&id_chat_room=" + id_chat_room;
	
		var myAjax = new Ajax(url, "POST");
		myAjax.send();
	}catch(error){
		//ERROR TROWN IN CASE OF PREMATURE WINDOW CLOSING
	alert("Error on close_room_chat: " + error);
	}
}


function change_status(status, obj){
	var url = "data_provider/module_softwares.php?tZ=1283905576&dp=module_loader&module=chat&a=chat_set_status&status=" + status;

	var myAjax = new Ajax(url, "POST");
	myAjax.send();

	var active_status = document.getElementById("active_status");
	
	if( typeof(active_status) == "object" && active_status != null){
	
		if( typeof(obj) == "object" )
			active_status.innerHTML = obj.innerHTML;
		else
			active_status.innerHTML = obj;
	}
}//JAVASCRIPT DOCUMENT: motd.js.php
function edit_motd(control){

	if( control.childNodes[0].tagName!="INPUT" ){

		var itext = document.createElement("INPUT");
		itext.type = "text";
		itext.id = "motd_control";
		itext.onchange = save_motd;
		var original_value = control.innerHTML;
		value = encode_macro(original_value);
		value = spell_uncheck(value);
		itext.value = value;
		
		itext.onkeypress = function(event){kp_motd(event,original_value)};


		itext.size = 64;
		itext.maxLength = 64;

		itext.style.backgroundColor = "#FFFFFF";
		itext.style.color = "#000000";
		control.innerHTML = "";
		control.appendChild(itext);
		itext.focus();
	}			
}

function kp_motd(evObj, original_value){
	if(window.event){
		var keyCode = window.event.keyCode;
	}else
		var keyCode = evObj.keyCode;
		
	if(keyCode == 27){
		var itext = document.getElementById('motd_control');
		var pn = itext.parentNode;
	
		pn.removeChild(itext);
		pn.innerHTML = original_value;
	}
}

function save_motd(){
	var itext = document.getElementById('motd_control');
	if(itext.value.length > 0 ){
		var url = "http://www.allardtechnologies.com/data_provider/module_softwares.php?tZ=1283905576&dp=module_loader&module=security&a=user_edit&motd=" + itext.value;
		var myAjax = new Ajax(url, "POST");
		myAjax.onComplete = changed_motd;
		myAjax.send();
	}else{

		 itext.value = "Laisser votre message en cliquant";
		 changed_motd(null, null);
	}
}

function changed_motd(responseText, responseXML){

	var itext = document.getElementById('motd_control');
	
	var value = itext.value;
	var pn = itext.parentNode;
	
	pn.removeChild(itext);
	
	value = spell_check(value);
	value = decode_macro(value);
	//value = wordwrap(value, 64, "<br />");
	pn.innerHTML = value;
	
}//JAVASCRIPT DOCUMENT: callout.js.php


var callouts = new Array();
	
function show_callout( html_content, curr_obj, offset_x, offset_y, width, height, timer, mouse_based, evObj, prevent_opening, drawType ){
	
	var in_height = height
	var i;
	var present_callout = false;
	if(typeof(mouse_based) != "boolean")
		mouse_based = false;

	if(typeof(prevent_opening) != "boolean")
		prevent_opening = true;

	if( typeof(drawType) != "string" )
		drawType = "BL";
	
	if( typeof(curr_obj) == "string" ){
		curr_obj = document.getElementById(curr_obj);
	}
	
	for(i = 0; i < callouts.length; i++){
		if(curr_obj == callouts[i][0]){
			present_callout = true;
		}
	}
	
	var style_set = new Array();
	
	//UPPER ROW
	style_set[0] = " style='background-image: url(/images/design/core/callout_tl.png);width:40px;height:32px;' ";
	style_set[1] = " style='background-image: url(/images/design/core/callout_top.png);height:32px;' ";
	style_set[2] = " style='background-image: url(/images/design/core/callout_tr.png);width:41px;height:32px;' ";

	//MIDDLE ROW	
	style_set[3] = " style='background-image: url(/images/design/core/callout_left.png);width:40px;' ";
	style_set[4] = " style='background-color: #FFFFFF;' ";
	style_set[5] = " style='background-image: url(/images/design/core/callout_right.png);width:41px;vertical-align:top;' ";

	//LOWER ROW
	style_set[6] = " style='background-image: url(/images/design/core/callout_bl.png);width:40px;height:34px;' ";
	style_set[7] = " style='background-image: url(/images/design/core/callout_bottom.png);height:34px;' ";
	style_set[8] = " style='background-image: url(/images/design/core/callout_br.png);width:41px;height:34px;' ";

	
	if(drawType.toUpperCase() == "BL"){
		style_set[6] = " style='background-image: url(/images/design/core/callout_bl_selected.png);width:40px;height:34px;' ";
	}else if(drawType.toUpperCase() == "TL"){
		style_set[0] = " style='background-image: url(/images/design/core/callout_tl_selected.png);width:40px;height:32px;' ";
	}else if(drawType.toUpperCase() == "TR"){
		style_set[2] = " style='background-image: url(/images/design/core/callout_tr_selected.png);width:41px;height:32px;' ";
	}else if(drawType.toUpperCase() == "BR"){
		style_set[8] = " style='background-image: url(/images/design/core/callout_br_selected.png);width:41px;height:34px;' ";
	}
	


	var closing_control = "<span style=\"position:relative;left:10px;cursor:pointer;font-weight:bold;font-size:1.3em; color:#C00000;\" onclick=\"JAVASCRIPT: close_this_callout(this);\" title=\"Fermer cette fen&ecirc;tre\">X</span>"


	var begin_html = "<table style=\"width:"+width+"px; height:"+(height + 34)+"px;\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\">";
	begin_html += "<tr><td " + style_set[0] + "><!-- TL --></td>";
	begin_html += "<td " + style_set[1] + "><!-- TC --></td>";
	begin_html += "<td " + style_set[2] + "></td></tr>";

	begin_html += "<tr><td " + style_set[3] + "><!-- TL --></td>";
	begin_html += "<td valign=\"top\" " + style_set[4] + "><div style=\"overflow:hidden;height:" + (in_height-(32+34)+ 34) + "px;\">";
	
	var end_html = "</div></td><td " + style_set[5] + "><!-- TR -->" + closing_control + "</td></tr><tr>";
	end_html += "<td " + style_set[6] + "><!-- TL --></td>";
	end_html += "<td " + style_set[7] + "><!-- TC --></td>";
	end_html += "<td " + style_set[8] + "><!-- TR --></td></tr></table>";
	
	if( !present_callout){
	
		var callout_control = document.createElement("DIV");
		callout_control.className = "call_out";
		
//-		var corner = document.createElement("IMG");
//-		corner.src = "/images/design/callout_coin_droite.png";
//-		corner.className = "corner_image";

		var callout_container = document.createElement("DIV");
		callout_container.className = "call_out_container";

		if( typeof(width) != "undefined")
			callout_container.style.width = parseInt(width) + "px";
			
		if( typeof(height) != "undefined")
			callout_container.style.height = parseInt(height) + "px";
		
		if( typeof(html_content) == "string")
			callout_container.innerHTML = begin_html + html_content + end_html;
		else{
			if( typeof(html_content) == "object"){
				callout_container.innerHTML = begin_html + html_content.innerHTML + end_html;
			}
		}
		
		callout_control.style.zIndex = 50;

//-		callout_control.appendChild(corner);
		callout_control.appendChild(callout_container);
	
		if( typeof(curr_obj) != "undefined" ){
			var pos = findPos(curr_obj);
	
			callout_control.style.position = "absolute";
	
			if(mouse_based){
			
					if(window.event){
	
//						var callout_x = event.clientX + document.documentElement.scrollLeft + offset_x + "px";
//						var callout_y = (event.clientY - (height) - 50) + document.documentElement.scrollTop + offset_y + "px";

						var rX = event.clientX + document.documentElement.scrollLeft;
						var rY = event.clientY + document.documentElement.scrollTop;
						var tmp = callout_pos(rX, rY, offset_x, offset_y, width, height, drawType);
						callout_x = tmp[0];
						callout_y = tmp[1];
					}else{
	
						if(typeof(evObj) != "undefined"){
	
//							var callout_x = evObj.pageX + offset_x + "px";
//							var callout_y = evObj.pageY - (height) - 50 + offset_y + "px";
							var rX = evObj.pageX;
							var rY = evObj.pageY;
							var tmp = callout_pos(rX, rY, offset_x, offset_y, width, height, drawType);
							callout_x = tmp[0];
							callout_y = tmp[1];

						}
					}
	
			}else{
	
//				var callout_x = (parseInt(pos[0]) + offset_x ) + "px";
//				var callout_y = (parseInt(pos[1]) + offset_y - (height) - 50 ) + "px";

				var rX = parseInt(pos[0]);
				var rY = parseInt(pos[1]);
				var tmp = callout_pos(rX, rY, offset_x, offset_y, width, height, drawType);
				callout_x = tmp[0];
				callout_y = tmp[1];
				
			}
	
			callout_control.style.left = callout_x + "px";
			callout_control.style.top = callout_y + "px";
		}
		
		
		document.body.appendChild(callout_control);
		callouts[callouts.length] = new Array(curr_obj, callout_control);
	
		if(typeof(timer) != "undefined"){
			if(timer > 0)
				window.setTimeout( add_close_callout(curr_obj, prevent_opening) , timer * 1000);
		}
	}
	
	return curr_obj;
}

function add_close_callout(curr_obj, prevent_opening){

	return function(){ close_callout(curr_obj, prevent_opening); };
}

function add_remove_callout( index ){

	return function(){ remove_callout( index ); };
}

function remove_callout(index){
	callouts.splice(index,1);
}

function callout_pos(x, y, offsetX, offsetY, width, height, drawType){
	
	var callout_x, callout_y;
	drawType = drawType.toUpperCase();
	var top_type = drawType.substring(0,1);
	var left_type = drawType.substring(1,2);
	
	// BOTTOM OR TOP	
	if(top_type == "B"){
		callout_y = y - (height) - 50 + offsetY;
	}else{
		callout_y = y + offsetY;
	}

	// LEFT OR RIGHT
	if(left_type == "L"){
		callout_x = x + offsetX;	
	}else{
		callout_x = x - width - offsetX;
	}

	return new Array(callout_x, callout_y);	

}

function close_callout(curr_obj, prevent_opening){
	var i;
	if(typeof(curr_obj) == "object" && curr_obj != null){
		for(i = 0; i < callouts.length; i++){
			if(curr_obj == callouts[i][0]){
				var tmp = callouts[i][1];
				clear_object_content(tmp);
				tmp.parentNode.removeChild(tmp);
				
				if(prevent_opening){
					//WONT APPEAR FOR 30 SECONDS
					window.setTimeout( add_remove_callout( i ) , 30000);
				}else{
					remove_callout(i)
				}
				
				break;
			}
		}
	}
}

function close_this_callout(curr_obj, prevent_opening){
	var curr_obj_pointer = curr_obj;
	var max_iteration = 15;
	var iteration = 0;
	var i;
	
	while(typeof(curr_obj_pointer.parentNode) == "object"){
		
		if(curr_obj_pointer.className == "call_out"){
		
			for(i = 0; i < callouts.length; i++){
				if(curr_obj_pointer == callouts[i][1]){
					var tmp = callouts[i][1];
					clear_object_content(tmp);
					tmp.parentNode.removeChild(tmp);
					
					if(prevent_opening){
						//WONT APPEAR FOR 30 SECONDS
						window.setTimeout( add_remove_callout( i ) , 30000);
					}else{
						remove_callout(i)
					}
					
					i = callouts.length + 1;
					iteration = max_iteration + 1;
				}
			}
		
			
		}else
			curr_obj_pointer = curr_obj_pointer.parentNode;
		
		if(iteration < max_iteration)
			iteration++;
		else
			break;
	}
}

//-- CONTENT HELER
function callout_helper_content_error(title, message, errors){
	var error_message = "<p style=\"color:#C00000;text-transform:uppercase;margin:0px;font-size:1.3em;padding-bottom:5px;\">";
	error_message +=  title + "</p>";
	
	error_message += "<p>" + message + " </p>";
	error_message +=  "<p style=\"color:" + ERROR_CONTROL_BORDERCOLOR + ";\">" + errors.join("<br />") + "</p>";
	
	return error_message;
}

function callout_helper_content_confirm(title, message, buttons){
	var error_message = "<p style=\"color:#C00000;text-transform:uppercase;margin:0px;font-size:1.3em;padding-bottom:5px;\">";
	error_message +=  title + "</p>";
	
	error_message += "<p>" + message + " </p>";
	error_message +=  "<p>" + buttons.join(" ") + "</p>";
	
	return error_message;
}
//------------------------------------- CUSTOM_MENU
//-------------------------------------------------


var nbMenu = 6;
var menu_height = 31;
var v_duration = 400;
var backgroundColors = new Array("#FFFFFF", "#4CA9BB");
var backgroundOpacity = new Array(0.30, 0.80);
var slider_is_open = false;

var slider_timer;
var drop_menu_timer;
var menu_timer;

var time_drop_menu = 200;
var time_bg =  1000;

function open_menu_slider(){
	if(!slider_is_open){
		myFXbg = new Fx.Style('menu_slider', 'background-color', {duration: v_duration, wait:false });
		myFXbg.start(backgroundColors[0], backgroundColors[1]);
		myFXbg = new Fx.Style('menu_slider', 'opacity', {duration: v_duration, wait:false });
		myFXbg.start(backgroundOpacity[0], backgroundOpacity[1]);
		slider_is_open = true;
	}
}

function close_menu_slider(){
	if(slider_is_open){
		myFXbg = new Fx.Style('menu_slider', 'background-color', {duration: v_duration });
		myFXbg.start(backgroundColors[1], backgroundColors[0]);
		myFXbg = new Fx.Style('menu_slider', 'opacity', {duration: v_duration });
		myFXbg.start(backgroundOpacity[1], backgroundOpacity[0]);
		slider_is_open = false;
	}
}
//-- MENU_INIT() CALLED BY DEFAULT, CHANGE NAME TO PREVENT OPERATION
function menu_init01(){
	var i, myMenuItem, myContentItem, myDropMenuItem;
	
	for(i = 0; i < nbMenu; i++){
	
		myMenuItem = $('menu_item_' + (i+1) );
		myContentItem = $('menu_content_' + (i+1) );
		
		
		myDropMenuItem = $('drop_menu_item_' + (i+1) );
		var pos = findPos(myMenuItem);
		
		
		
		if( myDropMenuItem != null){
		
			myDropMenuItem = myDropMenuItem.cloneNode( true );
			document.body.appendChild(myDropMenuItem);
			
			myDropMenuItem.addEvent('mouseenter', add_mouseenter_dm(myDropMenuItem));
			myDropMenuItem.addEvent('mouseleave', add_mouseleave_dm(myMenuItem, myContentItem, myDropMenuItem));
		
		}
		
		myMenuItem.addEvent('mouseleave', add_mouseleave(myMenuItem, myContentItem, myDropMenuItem, pos));
		myMenuItem.addEvent('mouseenter', add_mouseenter(myMenuItem, myContentItem, myDropMenuItem, pos));
		

		
	}
}

function add_mouseenter(menuItem, contentItem, dropMenuItem, menuPos){
	return function(){
	
			if(typeof(slider_timer) != "undefined" && slider_timer != null && slider_timer != "null")
				window.clearTimeout(slider_timer);

			var myFX = new Fx.Style(contentItem, 'opacity', {duration: v_duration, wait:false });
			myFX.start(0,1);

			if(typeof(dropMenuItem) == "object" && dropMenuItem != null && dropMenuItem != "null"){

				dropMenuItem.style.position = "absolute";
				dropMenuItem.style.zIndex = 90;
				dropMenuItem.style.left = (menuPos[0] - 2) + "px";
				dropMenuItem.style.top = (menuPos[1] + menu_height + 7  ) + "px";
				
				var myFX = new Fx.Style(dropMenuItem, 'opacity', {duration: v_duration, wait:false });
				myFX.set(0);
				dropMenuItem.style.display = "block";
				myFX.start(0,1);
			}
			
				
			if(!slider_is_open)
				open_menu_slider();
		};
}

function add_mouseleave(menuItem, contentItem, dropMenuItem, menuPos){
	return function(){

			if(typeof(dropMenuItem) == "object" && dropMenuItem != null && dropMenuItem != "null"){
				drop_menu_timer = window.setTimeout(function(){close_drop_menu(dropMenuItem)}, time_drop_menu);
				
				menu_timer = window.setTimeout(function(){
					var myFX = new Fx.Style(contentItem, 'opacity', {duration: v_duration, wait:false });
					myFX.start(1,0);
				}, time_drop_menu);
			}else{
				var myFX = new Fx.Style(contentItem, 'opacity', {duration: v_duration, wait:false });
				myFX.start(1,0);
				
			}
			
			slider_timer = window.setTimeout("close_menu_slider()", time_bg);
			
		};
}

function add_mouseenter_dm(dropMenuItem){
	return function(){
		window.clearTimeout(slider_timer);	
		window.clearTimeout(drop_menu_timer);
		window.clearTimeout(menu_timer);
	};
}

function add_mouseleave_dm(menuItem, contentItem, dropMenuItem){
	return function(){
	
		var myFX = new Fx.Style(contentItem, 'opacity', {duration: v_duration, wait:false });
		myFX.start(1,0);
		
		close_drop_menu(dropMenuItem);
		slider_timer = window.setTimeout("close_menu_slider()", time_bg);
		
	};
}

function close_drop_menu(dropMenuItem){
	var myFX = new Fx.Style(dropMenuItem, 'opacity', {duration: v_duration, wait:false });
	myFX.start(1,0);
}

//JAVASCRIPT DOCUMENT: text_and_array.js.php

function in_array(needle, haystack ){

	var i = 0;
	
	for(i = 0; i < haystack.length; i++){
	
		if( haystack[i] == needle ){
		
			return true;
		}
	}

	return false;
}

function check_keystroke(obj, event_object, startup){
	
	if( typeof(text_color_matrix) == "undefined" )
		var color = new Array("#77E818", "#C0E818","#E3E818", "#E88E18", "#E82118");
	else
		var color = text_color_matrix;
	
	if(!startup){
	
		if(!event_object)
			event_object = event;
	
		var keyCode = event_object.keyCode;
		var shiftKey = event_object.shiftKey;
		
		var limiter_control_name = obj.getAttribute("limiter_control");
		var control_limit = parseInt( obj.getAttribute("limit") );
		
		var limiter_control = document.getElementById( limiter_control_name );
		var control_content = obj.value.toString();
		var char_count = control_content.length;
		
		if( in_array(keyCode, unicode_add_chars) )
			char_count++;
	
		if( in_array(keyCode, unicode_rem_chars) ){
			char_count--;
			window.setTimeout(function(){check_keystroke(obj, event_object);}, 300);
		}
		
		var resulting_chars = control_limit - char_count;
		
		if(resulting_chars < 0){
			obj.value = control_content.substr( 0, control_limit);
			char_count = control_limit;
		}
			
		var perc = Math.round(100 * char_count / control_limit);
		var color_level = color[ Math.round( ( (perc / 100) * color.length) - 1 ) ];
		if(limiter_control){
			limiter_control.style.backgroundColor = color_level;																				
			limiter_control.style.width = perc + "%";
		}
		
		if(char_count <= control_limit ){
			return true;
			
		}else{
		
			if( in_array(keyCode, unicode_rem_chars) ){
				return true;
				
			}else{
			
				if( in_array(keyCode, unicode_add_chars) ){
	
					return false;
				}else{
					return true;
				}
				
			}
		}
		
	}else{
		//STARTUP INIT
		var limiter_control_name = obj.getAttribute("limiter_control");
		var control_limit = parseInt( obj.getAttribute("limit") );
		
		var limiter_control = document.getElementById( limiter_control_name );
		var control_content = obj.value.toString();
		var char_count = control_content.length;
		var resulting_chars = control_limit - char_count;
		
		var perc = Math.round(100 * char_count / control_limit);
		var color_level = color[ Math.round( ( (perc / 100) * color.length) - 1 ) ];

		limiter_control.style.backgroundColor = color_level;																				
		limiter_control.style.width = perc + "%";
		return false;
	
	}	
}

function wordwrap(text, length, separator){
	var actual_length = text.length;
	var output = new Array();
	
	if(actual_length > length){
		var pointer = 0;
		while(pointer < actual_length){
			output[output.length] = text.substr(pointer,length)
			pointer = pointer + length;
		}
		
		return output.join(separator);
	}else
		return text;
}

function spell_check(text){
	
	text = text.replace( /\</g , "&lt;" );
	text = text.replace( /\>/g , "&gt;" );
		
	return text;
}

function spell_uncheck(text){
	
	text = text.replace( /&lt;/g , "<" );
	text = text.replace( /&gt;/g , ">" );
		
	return text;
}


function encode_macro( text){

	//BOLD
	text = text.replace( /\<(b|B)\>/g , "[b]" );
	text = text.replace( /\<\/(b|B)\>/g , "[/b]" );

	//ITALIC
	text = text.replace( /\<(i|I)\>/g , "[i]" );
	text = text.replace( /\<\/(i|I)\>/g , "[/i]" );

	//UNDELINE
	text = text.replace( /\<(u|U)\>/g , "[u]" );
	text = text.replace( /\<\/(u|U)\>/g , "[/u]" );

	return text;
}

function decode_macro( text ){

	//BOLD
	text = text.replace( /\[(b|B)\]/g , "<b>" );
	text = text.replace( /\[\/(b|B)\]/g , "</b>" );

	//ITALIC
	text = text.replace( /\[(i|I)\]/g , "<i>" );
	text = text.replace( /\[\/(i|I)\]/g , "</i>" );

	//UNDELINE
	text = text.replace( /\[(u|U)\]/g , "<u>" );
	text = text.replace( /\[\/(u|U)\]/g , "</u>" );

	return text;
}
//JAVASCRIPT DOCUMENT: control.js.php
function search_input_out(obj, text, color){
			
	if(obj.value == ""){
		obj.style.color = color;
		obj.value = text;
	}

}

function search_input_in(obj, text, color){

	if(obj.value == text){
		obj.style.color = color;
		obj.value = "";
	}
}

function search_form_submit(form_name, search_object_name, text){
	var form_object = document.getElementById(form_name);
	
	var search_object = document.getElementById(search_object_name);
	if( search_object.value == text){
		search_object.value = "";
	}
	
	form_object.submit();

}

function search_input_kp(evObj, obj, form_name, search_object_name, text  ){

	if(evObj)
		var keyCode = evObj.keyCode;
	else
		var keyCode = event.keyCode;

	if(keyCode == 13){
		search_form_submit(form_name, search_object_name, text);
	}
}

function list_over(control){
	control.className = "line_over";
}

function list_out(control){
	control.className = "";
}

var last_page = new Array();

function show_page(id_page, className, page_prefix){

	if(typeof(className) == "undefined" || className == null || className == '')
		className = "selected";

	if(typeof(page_prefix) == "undefined" || page_prefix == null || page_prefix == '')
		page_prefix = "page_";

	if( ! last_page[page_prefix])
		last_page[page_prefix] = 1;

	if(id_page != last_page[page_prefix]){

		var oldcontrol = document.getElementById( page_prefix + last_page[page_prefix]);
		if( oldcontrol )
			oldcontrol.style.display = "none";

		var tab = document.getElementById("tab_" + page_prefix + last_page[page_prefix]);
		
		if(tab != null)
			tab.className = "";

		
		var control = document.getElementById( page_prefix + id_page);
		
		if(control)
			control.style.display = "block";

		var tab = document.getElementById("tab_" + page_prefix + id_page);
		
		if(tab != null)
			tab.className = className;

		

		last_page[page_prefix] = id_page;
		
	}
}

function validate_email(elementValue){
  var emailPattern = /^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$/;
  return emailPattern.test(elementValue);
}

function set_ro(currObj){
			
	var name = currObj.name;
	var form = currObj.form;
	var coll = form[name];
	var i;
	
	if( currObj.tagName.toUpperCase() == "INPUT" ){
	
		if( currObj.type.toUpperCase() == "CHECKBOX" || currObj.type.toUpperCase() == "RADIO" ){
			for( i = 0; i < coll.length; i++ )
				coll[i].checked = coll[i].defaultChecked;
		}else if(currObj.type.toUpperCase() == "TEXT"){
			currObj.value = currObj.defaultValue;
		}else
			alert("This control type(" + currObj.type.toUpperCase() + ") must be protected with the 'READONLY' attribute");
			
	}else if( currObj.tagName.toUpperCase() == "SELECT"){
		coll = currObj.options;
		
		if(currObj.multiple){
			for( i = 0; i < coll.length; i++ )
				coll[i].selected = coll[i].defaultSelected;
			
		}else{
			for( i = 0; i < coll.length; i++ ){
				if(coll[i].defaultSelected){
					currObj.selectedIndex = i;
					break;
				}
			}
		}
	}else if( currObj.tagName.toUpperCase() == "TEXTAREA"){
		currObj.value = currObj.defaultValue;
	}
	
	return false;
}

//-- CALENDAR CONTROL
function show_calendar(currObj, inputControlName, format ){

	var tmp_date, tmp_time;
	var pos = findPos(currObj);

	if( typeof(format) == "undefined" || format == null || format == "null"){
		format = "date";
	}else{
		if(format != "date" && format != "datetime")
			format = "date";
	}

	var ownerForm = recursive_form_find(currObj);
	var inputControl = ownerForm[inputControlName];
	set_date = inputControl.value

	if(set_date != null && set_date.length >= 10){
		var tmp = set_date.split(" ");
		if(tmp[0])
			var tmp_date = tmp[0].split("-");
		if(tmp[1])
			var tmp_time = tmp[1].split(":");
		else
			var tmp_time = new Array(0,0,0);
			
		var dateObj = new Date(tmp_date[0], (tmp_date[1] - 1), tmp_date[2], tmp_time[0], tmp_time[1], tmp_time[2]);
	}else
		var dateObj = new Date();

	//-- BUILD CALENDAR CONTAINER
	var myDiv = document.createElement('DIV');
	
	//-- NAME FOR CLEARING OF CONTROLS
	myDiv.setAttribute('name', "CALENDAR_CONTROL");
	myDiv.name = "CALENDAR_CONTROL";

	//-- STORE DATE OBJECT WITHIN MAIN DIV ATTRIBUTE: DATE
	myDiv.setAttribute('date', dateObj.toString() );
	myDiv.date = dateObj.toString();
	
	myDiv.setAttribute('setdate', dateObj.toString() );
	myDiv.setdate = dateObj.toString();
	
	myDiv.setAttribute('linked_control', inputControlName);
	myDiv.linked_control = inputControlName;

	myDiv.setAttribute('format', format);
	myDiv.format = format;

	//-- POSITIONNING
	myDiv.style.zIndex = 100;
	myDiv.style.position = "absolute";
	myDiv.style.left = pos[0] + 30 + "px";
	myDiv.style.top = pos[1] + 30 + "px";
	
	//-- DESIGN, SUBJECT TO MIGRATE IN CSS SOON
	myDiv.className = "calendar_control";
	
	myDiv.onclick = cancel_bubble;
	//-- INTEGRATE INNERHTML
	myDiv.innerHTML = calendar_content( dateObj, dateObj );


	document.body.appendChild(myDiv);
}

//var day_of_week = new Array('D', 'L', 'M', 'M', 'J', 'V', 'S');
var day_of_week = new Array('Dim', 'Lun', 'Mar', 'Mer', 'Jeu', 'Ven', 'Sam');
var month_of_year = new Array('Janvier','F&eacute;vrier', 'Mars', 'Avril', 'Mai', 'Juin', 'Juillet', 'Ao&ucirc;t', 'Septembre', 'Octobre', 'Novembre', 'D&eacute;cembre' );

var nb_days_of_month = new Array(31,28,31,30,31,30,31,31,30,31,30,31);

function calendar_content(dateObj, setdateObj){
	var content = "<table cellpadding='0' cellspacing='0' class='calender_main_table'>";
	
	if( dateObj == null)
		dateObj = new Date();
	
	var month = dateObj.getMonth();
	var year =  dateObj.getFullYear();
	
	if(setdateObj){
		var seldate = setdateObj.getDate();
		var selmonth = setdateObj.getMonth();
		var selyear = setdateObj.getFullYear();
	}else
		var seldate = dateObj.getDate();
		
	var origin_date = new Date( dateObj.toString() );
	origin_date.setDate(1);
	var day = origin_date.getDay();

	var begin_year = new Date( origin_date.toString() );
	begin_year.setMonth(0);

	var begin_ts = begin_year.getTime() / 1000;
	var month_ts = origin_date.getTime() / 1000;
	var to_days = Math.floor( (month_ts - begin_ts) / 86400) + 2;
	
	var begin_week = Math.floor( (begin_year.getDay() + to_days) / 7) + 1;

	var is_leap = calendar_is_leap_year( year );
	if( is_leap ){
		var nb_days = 366;
		
		if(month != 1 )
			var nb_days_in_month = nb_days_of_month[month];
		else
			var nb_days_in_month = nb_days_of_month[month] + 1;
	}else{
		var nb_days = 365;
		var nb_days_in_month = nb_days_of_month[month];
	}
	
	if(month > 0){
		var nb_days_prev_month = nb_days_of_month[month - 1];
		if(month == 2 && is_leap)
			nb_days_prev_month + 1
	}else
		var nb_days_prev_month = nb_days_of_month[11];
	
	var i, j;

	content += "<tr>";
		content += "<th class='help' onmouseover=\"JAVASCRIPT: calendar_over(this);\" onmouseout=\"JAVASCRIPT: calendar_out(this);\" onclick=\"JAVASCRIPT: calendar_help();\" align=\"center\" title=\"Ce calendrier à été conçu et développer par Oxtal Solutions ©2008-2009\">";
			content += " <img src=\"/images/calender/btn_calender_help.png\" alt=\"Aide\" /> ";
		content += "</th>";
		
		content += "<th colspan='6'  class='today' align=\"center\"><div>";
			content += month_of_year[ month ];
			content += " " + year;
		content += "</div></th>";
		
		content += "<th class='close' onmouseover=\"JAVASCRIPT: calendar_over(this);\" onmouseout=\"JAVASCRIPT: calendar_out(this);\" onclick=\"JAVASCRIPT: calendar_close();\"  align=\"center\">";
			content += " <img src=\"/images/calender/btn_calender_close.png\" alt=\"Fermer\" /> ";
		content += "</th>";

	content += "</tr>";
	
	content += "<tr>";
		content += "<td class='prev_year' onmouseover=\"JAVASCRIPT: calendar_over(this);\" onmouseout=\"JAVASCRIPT: calendar_out(this);\" onclick=\"JAVASCRIPT: calendar_redraw(this, -1, 'y');\" >";
			content += " ";
		content += "</td>";
		content += "<td class='prev_month' onmouseover=\"JAVASCRIPT: calendar_over(this);\" onmouseout=\"JAVASCRIPT: calendar_out(this);\" onclick=\"JAVASCRIPT: calendar_redraw(this, -1, 'm');\">";
			content += "  ";
		content += "</td>";
	
	content += "<td colspan='4' class='today' align=\"center\" onclick=\"JAVASCRIPT: calendar_go_today(this);\" >";
	content += "Aujourd'hui";
	content += "</td>";
		content += "<td  class='next_month' onmouseover=\"JAVASCRIPT: calendar_over(this);\" onmouseout=\"JAVASCRIPT: calendar_out(this);\" onclick=\"JAVASCRIPT: calendar_redraw(this, 1, 'm');\">";
		content += "  ";
		content += "</td>";
		content += "<td  class='next_year' onmouseover=\"JAVASCRIPT: calendar_over(this);\" onmouseout=\"JAVASCRIPT: calendar_out(this);\" onclick=\"JAVASCRIPT: calendar_redraw(this, 1, 'y');\">";
		content += "  ";
		content += "</td>";

	content += "</tr>";

	content += "<tr><td align=\"center\" class=\"day_header week_num\">sem</td>";

	for(i = 0; i < day_of_week.length; i++){
	
		if(i == 0 || i == 6)
			content += "<td class='day_header week-end'>" + day_of_week[i] + "</td>";
		else
			content += "<td class='day_header'>" + day_of_week[i] + "</td>";
	}

	content += "</tr>";

	content += "<tr> <td align=\"center\" class=\"week_num\">" + begin_week + "</td>";

	if(day > 0){
		
		for(i = 0; i < day; i++){
			content+= "<td class='prev_day' onmouseover=\"JAVASCRIPT: calendar_over(this);\" onmouseout=\"JAVASCRIPT: calendar_out(this);\" onclick=\"calendar_redraw(this, -1, 'm');\" title=\"" + (to_days + (i - day)) + "\">";
			content+= (nb_days_prev_month - (day - i ) + 1) + "</td>";
		}
	}
		
	var is_close = false;
	var sel = "";

	for(i = 0; i < nb_days_in_month; i++){
		
		if( (i + 1) == seldate && month == selmonth && year == selyear )
			sel = " selected ";
		else
			sel = "";
			
		if( (i + day ) % 7 == 0 && i + day != 0){

			content+= "</tr><tr> <td align=\"center\" class=\"week_num\">" + (begin_week + Math.floor( (i + day) / 7) )+ "</td>";
			content+= "<td class='day" + sel + "' onmouseover=\"JAVASCRIPT: calendar_over(this);\" onmouseout=\"JAVASCRIPT: calendar_out(this);\" onclick=\"JAVASCRIPT: calendar_set_date(this,'";
			content+= year + "', '"+month+"', '"+(i+1)+"')\" title=\"" + (to_days + i) + "\" >" + (i + 1) + "</td>";
			
		}else{
			if( (i + day + 1 ) % 7 == 0 && i == (nb_days_in_month -1)){
				content+= "<td class='day" + sel + "' onmouseover=\"JAVASCRIPT: calendar_over(this);\" onmouseout=\"JAVASCRIPT: calendar_out(this);\" onclick=\"JAVASCRIPT: calendar_set_date(this,'"+year+"', '"+month+"', '"+(i+1);
				content+= "')\" title=\"" + (to_days + i) + "\" >" + (i + 1) + "</td>";

				is_close = true;
				content+= "</tr>";
			}else{
				content+= "<td class='day" + sel + "' onmouseover=\"JAVASCRIPT: calendar_over(this);\" onmouseout=\"JAVASCRIPT: calendar_out(this);\" onclick=\"JAVASCRIPT: calendar_set_date(this,'"+year+"', '"+month+"', '"+(i+1);
				content+= "')\" title=\"" + (to_days + i) + "\" >" + (i + 1) + "</td>";
			}
		}
	}

	
	if(!is_close){

		var nb_leaving = 7 - ((nb_days_in_month + day) % 7);

		for(i = 0; i < nb_leaving; i++){
			content+= "<td class='next_day' onmouseover=\"JAVASCRIPT: calendar_over(this);\" onmouseout=\"JAVASCRIPT: calendar_out(this);\" onclick=\"JAVASCRIPT: calendar_redraw(this, 1, 'm');\" title=\"" + (to_days + (i + nb_days_in_month)) + "\">" + (i + 1) + "</td>";	
		}

		content += "</tr>";
	}

	content += "<tr><td colspan=\"8\" class=\"pick_a_day\" align=\"center\">Veuillez chiosir une date</td></tr>";
			
	content += "</table>";
	
	return content;
}

function calendar_set_date(currObj, year, month, date){

	if(currObj.getAttribute('name') == "CALENDAR_CONTROL"){
		var myDiv = currObj;
	}else{
		var myDiv = currObj.parentNode;
		
		while(myDiv = myDiv.parentNode){
	
			if(myDiv.getAttribute('name') == "CALENDAR_CONTROL")
				break;
		}
	}

	month++
	if(month <=9)
		month= "0" + month;


	if(date <=9)
		date= "0" + date;
	
	var linked_control = myDiv.getAttribute('linked_control');
	var format = myDiv.getAttribute('format');

	if(linked_control){
		linked_control = document.getElementById(linked_control);
		if(linked_control){
		
			dateObj = new Date();
			var hours = dateObj.getHours(); 
			var minutes = dateObj.getMinutes();
			var seconds = dateObj.getSeconds();
			
			if(hours <= 9)
				hours = "0" + hours;

			if(minutes <= 9)
				minutes = "0" + minutes;

			if(seconds <= 9)
				seconds = "0" + seconds;
				
			
			var add = " " + hours;
			add +=  ":" + minutes;
			add += ":" + seconds;

			if(format == "datetime")
				linked_control.value = year + "-" + month + "-" + date + add; //" 00:00:00";
			else
				linked_control.value = year + "-" + month + "-" + date;
		}
	}
	
	dateObj = new Date(year, month, date);
		
	myDiv.setAttribute('date', dateObj.toString());
	myDiv.setAttribute('setdate', dateObj.toString());
	
	calendar_close();
}

function calendar_redraw(currObj, step, unit){
	var myDiv = currObj.parentNode;
	
	while(myDiv = myDiv.parentNode){

		if(myDiv.getAttribute('name') == "CALENDAR_CONTROL")
			break;
	}
	
	var dateObj = myDiv.getAttribute('date');
	dateObj = new Date(dateObj);

	var setdateObj = myDiv.getAttribute('setdate');
	setdateObj = new Date(setdateObj);


	var month = dateObj.getMonth();
	var year =  dateObj.getFullYear();

	if(unit == 'm'){
		dateObj.setMonth(month + step);
	}else if(unit == "y"){
		dateObj.setYear(year + step);
	}
	
	myDiv.setAttribute('date', dateObj.toString() );
	myDiv.date = dateObj.toString();
	
	myDiv.innerHTML = calendar_content( dateObj, setdateObj );

}

function calendar_is_leap_year(year){
	if(year % 4 == 0 && (year % 100 != 0 || year % 400 == 0 ) )
		return true;
	else
		return false;
}

function calendar_go_today(currObj){
	var myDiv = currObj.parentNode;
	
	while(myDiv = myDiv.parentNode){

		if(myDiv.getAttribute('name') == "CALENDAR_CONTROL")
			break;
	}
	
	var dateObj = new Date();
	myDiv.setAttribute('date', dateObj.toString() );
	myDiv.date = dateObj.toString();
	
	var setdateObj = myDiv.getAttribute('setdate');
	setdateObj = new Date(setdateObj);
	
	myDiv.innerHTML = calendar_content( dateObj, setdateObj );

	calendar_set_date(myDiv, dateObj.getFullYear(), dateObj.getMonth(), dateObj.getDate());
}

function calendar_close(){

	var ctls = document.getElementsByTagName("DIV");
	var i, ctl;

	for(i = 0; i < ctls.length; i++){

		ctl = ctls[i];
		
		if(ctl.name == "CALENDAR_CONTROL"){
			clear_object_content( ctl );
			ctl.parentNode.removeChild( ctl );
		}
	}

}

function calendar_over(currObj){
	currObj.style.color = "#FF0000";
}

function calendar_out(currObj){
	currObj.style.color = "";
}

function calendar_help(){
	alert("Ce calendrier à été conçu et développer par Oxtal Solutions ©2008");
}

function btn_over(currObj, imageName){

	if(currObj){

		var image = currObj.getElementsByTagName("img")[0];

		if(image){
			image.src = "/images/design/core/" + imageName + ".png";
		}
	
	}
}

function btn_out(currObj, imageName){

	if(currObj){

		var image = currObj.getElementsByTagName("img")[0];

		if(image){
			image.src = "/images/design/core/" + imageName + ".png";
		}
	
	}
}

function form_captcha(currObj, captcha_control_name){

	var myForm = recursive_form_find( currObj );
	var input = myForm[captcha_control_name];
	
	if(typeof(input) != "undefined" && typeof(hex_sha1) == "function"){
		var user_token = input.value;
		user_token = user_token.toUpperCase();
		
		var token = hex_sha1(user_token);
		
		var token_check = input.getAttribute("token");
		if( token == token_check)
			return true;
		
	}else
		alert("Error, no control or SHA1 JS function");
	
	return false;
}

var hilighted_keyword = '';
var hilighted_index = null;
var last_pattern_asked = '';

function keywording_check_type(event_object, pattern_control_id, list_choice_id, list_added_id, data_transport){

	cancel_bubble( event_object );
	
	var list_choice_control = document.getElementById( list_choice_id );
	var pattern_control = document.getElementById( pattern_control_id );

	var choices_coll = list_choice_control.getElementsByTagName("li");


	if(event_object)
		var keyCode = event_object.keyCode;
	else
		var keyCode = event.keyCode;
	
	switch(keyCode){
		case 13: //ENTER
			if(hilighted_index < choices_coll.length)
				keywording_add(choices_coll[hilighted_index].name, choices_coll[hilighted_index].innerHTML, pattern_control_id, list_choice_id, list_added_id)
			else
				keywording_add(0, pattern_control.value, pattern_control_id, list_choice_id, list_added_id);
		break;
		
		case 27: //ESCAPE

			keywording_clear(pattern_control_id, list_choice_id);
		break;
		
		case 38: //TOP ARROW

			if(hilighted_index > 0){
				choices_coll[ hilighted_index ].style.backgroundColor = "";
				hilighted_index--;
				choices_coll[ hilighted_index ].style.backgroundColor = "#FFBBBB";
				hilighted_keyword = choices_coll[ hilighted_index ].innerHTML;
			}
		break;
		
		case 40: //BOTTOM ARROW

			if(hilighted_index < (choices_coll.length - 1)){
				choices_coll[ hilighted_index ].style.backgroundColor = "";
				hilighted_index++;
				choices_coll[ hilighted_index ].style.backgroundColor = "#FFBBBB";
				hilighted_keyword = choices_coll[ hilighted_index ].innerHTML;
			}
		break;
		
		case 37: // LEFT ARROW
		case 39: // RIGHT ARROW
			// USE FOR MOVING CURSOR
		break;

		default: //KEYTYPE
			//SEARCH
			keywording_search(pattern_control_id, list_choice_id, list_added_id);
		break;		
	}

	
	// return false;
}

function keywording_add(id, text, pattern_control_id, list_choice_id, list_added_id){

	var data_transport = document.getElementById(pattern_control_id + '_td').value;
	var remote_variable = document.getElementById(pattern_control_id + '_kv').value;
	
	eval( "var remote_id = " + remote_variable +  ";" );

	
	var url = "/page_module.php?tZ=1283905577&page=keywords_thesaurus_add&module=system&a=page&sid=";
		url += "&pc=" + pattern_control_id;
		url += "&lc=" + list_choice_id;
		url += "&la=" + list_added_id;
		

		url += "&dt=" + data_transport;
		url += "&idk=" + id;
		url += "&txt=" + text;
		url += "&rid=" + remote_id;
		
		
		var Ar = new Ajax(url, "GET");
		Ar.onComplete = keywording_add_receive;
		Ar.send();
	
}

function keywording_add_receive(responseText, responseXML){
	var pattern_control_id = responseXML.getElementsByTagName('pc')[0].firstChild.nodeValue;
	var list_choice_id = responseXML.getElementsByTagName('lc')[0].firstChild.nodeValue;
	var list_added_id = responseXML.getElementsByTagName('la')[0].firstChild.nodeValue;

	var kwt_id = responseXML.getElementsByTagName('idk')[0].firstChild.nodeValue;
	var kwt_text = responseXML.getElementsByTagName('kwt')[0].firstChild.nodeValue;
	

	keywording_clear(pattern_control_id, list_choice_id);
	
	var list_added_control = document.getElementById(list_added_id);

	var listItem = document.createElement("LI");
	listItem.innerHTML = keywording_item_html(kwt_id, kwt_text, pattern_control_id, list_choice_id, list_added_id);
	listItem.name = kwt_id;
	listItem.setAttribute("name", kwt_id);

	list_added_control.appendChild( listItem );
}

function keywording_populate(pattern_control_id, list_choice_id, list_added_id){
	
	var data_transport = document.getElementById(pattern_control_id + '_td').value;
	var remote_variable = document.getElementById(pattern_control_id + '_kv').value;
	
	eval( "var remote_id = " + remote_variable +  ";" );
	if(remote_id > 0){
		var url = "/page_module.php?tZ=1283905577&page=keywords_thesaurus_get&module=system&a=page&sid=";
		url += "&pc=" + pattern_control_id;
		url += "&lc=" + list_choice_id;
		url += "&la=" + list_added_id;
		
		url += "&dt=" + data_transport;
		url += "&rid=" + remote_id;
		
		
		var Ar = new Ajax(url, "GET");
		Ar.onComplete = keywording_populate_receive;
		Ar.send();
	}	
}

function keywording_populate_receive(responseText, responseXML){
	

	var pattern_control_id = responseXML.getElementsByTagName('pc')[0].firstChild.nodeValue;
	var list_choice_id = responseXML.getElementsByTagName('lc')[0].firstChild.nodeValue;
	var list_added_id = responseXML.getElementsByTagName('la')[0].firstChild.nodeValue;

	var records = responseXML.getElementsByTagName('record');
	
	var i, listItem, kwt_id, kwt_text;
	
	var list_added_control = document.getElementById( list_added_id );
	clear_object_content( list_added_control );

	if(records != null ){
		var found = false;

		for(i = 0; i < records.length; i++){
		
			kwt_id = records[i].getElementsByTagName("id_keywords")[0].firstChild.nodeValue;
			kwt_text = records[i].getElementsByTagName("text_")[0].firstChild.nodeValue;
			
			listItem = document.createElement("LI");
			listItem.innerHTML = keywording_item_html(kwt_id, kwt_text, pattern_control_id, list_choice_id, list_added_id);
			listItem.name = kwt_id;
			listItem.setAttribute("name", kwt_id);

			list_added_control.appendChild( listItem );
	
		}
	}
}

function keywording_item_html(id_keywords, text,  pattern_control_id, list_choice_id, list_added_id){
	var html_content = "";
	
			html_content = "<div style=\"width:150px;float:left;text-align:left;\">" + text + "</div>";
			html_content += "<span onclick=\"JAVASCRIPT:keywording_del(" + id_keywords;
			
			html_content +=  ", '"+pattern_control_id+"','"+list_choice_id+"','"+list_added_id+"');\">X</span>";
	return html_content;
}

function keywording_del(id, pattern_control_id, list_choice_id, list_added_id){

	var data_transport = document.getElementById(pattern_control_id + '_td').value;
	var remote_variable = document.getElementById(pattern_control_id + '_kv').value;
	
	eval( "var remote_id = " + remote_variable +  ";" );
	
	
	var url = "/page_module.php?tZ=1283905577&page=keywords_thesaurus_del&module=system&a=page&sid=";
	url += "&pc=" + pattern_control_id;
	url += "&lc=" + list_choice_id;
	url += "&la=" + list_added_id;
	

	url += "&dt=" + data_transport;
	url += "&idk=" + id;
	url += "&rid=" + remote_id;
	
	var Ar = new Ajax(url, "GET");
	Ar.onComplete = keywording_del_receive;
	Ar.send();
}

function keywording_del_receive(responseText, responseXML){

	var pattern_control_id = responseXML.getElementsByTagName('pc')[0].firstChild.nodeValue;
	var list_choice_id = responseXML.getElementsByTagName('lc')[0].firstChild.nodeValue;
	var list_added_id = responseXML.getElementsByTagName('la')[0].firstChild.nodeValue;

	var kwt_id = parseInt(responseXML.getElementsByTagName('idk')[0].firstChild.nodeValue);


	var list_added_control = document.getElementById(list_added_id);

	
	var coll = list_added_control.getElementsByTagName("li");
	var i, val;
	
	for(i = 0; i < coll.length; i++){
		val = parseInt( coll[i].getAttribute("name") );

		if(val == kwt_id){
			list_added_control.removeChild(coll[i]);
			break;
		}
	}
}

function keywording_clear(pattern_control_id, list_choice_id){

	var list_choice_control = document.getElementById( list_choice_id );
	var pattern_control = document.getElementById( pattern_control_id );

	last_pattern_asked = '';
	pattern_control.value = '';

	clear_object_content(list_choice_control);
	list_choice_control.style.display = "none";
				
	hilighted_keyword = '';
	hilighted_index = null;
}

function keywording_search(pattern_control_id, list_choice_id, list_added_id){

	
	var pattern_object = document.getElementById( pattern_control_id);
	
	if(pattern_object.value != last_pattern_asked){
	
		var url = "/page_module.php?tZ=1283905577&page=keywords_thesaurus&module=system&a=page&sid=";
		url += "&pa=" + pattern_object.value;
		url += "&pc=" + pattern_control_id;
		url += "&lc=" + list_choice_id;
		url += "&la=" + list_added_id;
		
		var Ar = new Ajax(url, "GET");
		Ar.onComplete = keywording_search_receive;
		Ar.send();
		last_pattern_asked = pattern_object.value;
	}
}

function keywording_search_receive(responseText, responseXML){
	
	var pattern_control_id = responseXML.getElementsByTagName('pc')[0].firstChild.nodeValue;
	var list_choice_id = responseXML.getElementsByTagName('lc')[0].firstChild.nodeValue;
	var list_added_id = responseXML.getElementsByTagName('la')[0].firstChild.nodeValue;
	
	var records = responseXML.getElementsByTagName('record');

	
	var i, listItem, kwt_id, kwt_text;
	
	var list_choice_control = document.getElementById( list_choice_id );
	clear_object_content( list_choice_control );

	if(records != null ){
		var found = false;

		for(i = 0; i < records.length; i++){
		
			kwt_id = records[i].getElementsByTagName("id_keywords")[0].firstChild.nodeValue;
			kwt_text = records[i].getElementsByTagName("text_")[0].firstChild.nodeValue;
	
			listItem = document.createElement("LI");
			listItem.innerHTML = kwt_text;
			listItem.name = kwt_id;
			
			if(hilighted_keyword == ''){
				hilighted_keyword = kwt_text;
				hilighted_index = i;
			}
			
			if(hilighted_keyword == kwt_text){
				listItem.style.backgroundColor = "#FFBBBB";
				hilighted_index = i;
				found = true;
			}
			
			listItem.style.textAlign = "left";
			
			listItem.onclick = keywording_attach_function(kwt_id, kwt_text, pattern_control_id, list_choice_id, list_added_id);
			list_choice_control.appendChild( listItem );
		}
		

		if(records.length >= 1){
			list_choice_control.style.display = "inline";

			if(!found){
				hilighted_index = 0;
				list_choice_control.getElementsByTagName("li")[ hilighted_index ].style.backgroundColor = "#FFBBBB";
				hilighted_keyword = choices_coll[ hilighted_index ].innerHTML;
				
			}

		}else
			list_choice_control.style.display = "none";

	}else
		list_choice_control.style.display = "none";

}

function keywording_attach_function(id, text, pattern_control_id, list_choice_id, list_added_id){
	return function(){ keywording_add(id, text, pattern_control_id, list_choice_id, list_added_id); };
}
//JAVASCRIPT DOCUMENT: auth.js.php
var auth_in_progress = "";
function check_auth(form_id){
	auth_in_progress = form_id;
	
	var my_form = document.getElementById(form_id);
	var url_auth = "http://www.allardtechnologies.com/data_provider/module_softwares.php?tZ=1283905577&dp=module_loader&module=security&a=user_auth";
	
	var myAjax = new Ajax(url_auth, 'POST');
	
	myAjax.onComplete = receive_auth;
	var username = my_form.elements.namedItem('lusername').value;
	var userpass = my_form.elements.namedItem('luserpass').value;
	
	userpass = hex_sha1(userpass);
	var qs = "&username=" + username + "&userpass=" + userpass;
	
	myAjax.send(qs);

}


function receive_auth(responseText, responseXML){

	var my_form = document.getElementById(auth_in_progress);
	auth_in_progress = "";
	
	var global = responseXML.getElementsByTagName("GLOBAL")[0];
	
	var status = global.getElementsByTagName("status")[0].childNodes[0].nodeValue;
	
	var description = global.getElementsByTagName("description")[0].childNodes[0].nodeValue;
	
	if(status == "OK"){
		var cookie_send = global.getElementsByTagName("cookie")[0].childNodes[0].nodeValue;
		
		document.cookie = cookie_send;
		document.location = "/main.php";
	}else{
		send_auth_error();
	}

}

var is_showing_auth_error = false;

function send_auth_error(){
	if(!is_showing_auth_error){

			var btn = document.getElementById('btnCheckAuth');
      if (btn != null)
      {
				var error_content = callout_helper_content_error("Attention", "Le nom d'utilisateur ou le mot de passe que vous avez saisi est incorrecte. ", new Array());
				show_callout(error_content, btn, 25, 15, 300, 120,0, false, null, false, 'bl');
			}
  }
}


function auth_error_close(){
	is_showing_auth_error = false;
}


function key_type(event_object, obj){

	if(event_object)
		var keyCode = event_object.keyCode;
	else
		var keyCode = event.keyCode;

	if(keyCode == 13){

		check_auth(obj.form.id);
	}

}//JAVASCRIPT DOCUMENT: auth.js.php

function show_help(topic){
	if(!topic)
		topic = '0';
	
	var tmp = topic.split("_");
	
	if(tmp.length >1){
		last_opened_category = '' + tmp[0];
		last_opened_topic = tmp[0] + '_' + tmp[1];
	}else{
		last_opened_category = '' + tmp[0];
		last_opened_topic = '0';
	}
	var Ar = new Ajax("http://www.allardtechnologies.com/data_provider/module_softwares.php?tZ=1283905577&dp=module_loader&page=help.admin&module=system&a=page&sid=&topic=" + topic, "GET");
	Ar.onComplete = page_receive;
	Ar.send();
}

var last_opened_category = '0';

function help_open_category(index){

	var category_panel, category_menu;
	
	if( last_opened_category != null){
		category_panel = document.getElementById('category_panel_' + last_opened_category);
		category_panel.style.display = "none";
	}
	
	if(last_opened_category != '0' && last_opened_category != null){

		category_menu = document.getElementById('category_menu_' + last_opened_category);
		category_menu.style.display = "none";
		category_menu.parentNode.getElementsByTagName("span")[0].style.backgroundColor = "";
	}
	
	if(last_opened_topic != '0'){

		var topic_panel = document.getElementById('topic_panel_' + last_opened_topic);
		topic_panel.style.display = "none";	
		var topic_menu = document.getElementById('topic_menu_' + last_opened_topic);
		topic_menu.getElementsByTagName("span")[0].style.backgroundColor = "";
	}
	
	category_panel = document.getElementById('category_panel_' + index);
	category_panel.style.display = "block";
	
	if(index != '0' ){
		category_menu = document.getElementById('category_menu_' + index);
		category_menu.style.display = "block";

		category_menu.parentNode.getElementsByTagName("span")[0].style.backgroundColor = "#9999FF";
	}
		
	last_opened_category = index;
}

var last_opened_topic = '0';

function help_open_topic(index, e){

	if(last_opened_category != null){

		var category_panel = document.getElementById('category_panel_' + last_opened_category);
		category_panel.style.display = "none";
	}

	if(last_opened_topic != '0'){
		var topic_panel = document.getElementById('topic_panel_' + last_opened_topic);
		topic_panel.style.display = "none";	
		
		var topic_menu = document.getElementById('topic_menu_' + last_opened_topic);
		topic_menu.getElementsByTagName("span")[0].style.backgroundColor = "";

	}

	var topic_panel = document.getElementById('topic_panel_' + index);
	topic_panel.style.display = "block";	
	
	var topic_menu = document.getElementById('topic_menu_' + index);
	topic_menu.getElementsByTagName("span")[0].style.backgroundColor = "#9999FF";
	
	last_opened_topic = index;
	if(e != null)
		cancel_bubble(e);
}
//JAVASCRIPT DOCUMENT: image_bank.js.php

function show_image_bank_form(){
	var Ar = new Ajax("http://www.allardtechnologies.com/data_provider/module_softwares.php?tZ=1283905577&dp=module_loader&page=image_bank_box&module=system&a=page", "GET");
	Ar.onComplete = page_receive;
	Ar.send();
	
}

var old_zone = null;

function show_zone(zone_id, old_zone_id){
	var main_table = document.getElementById('fc_main_container');
	main_table = main_table.getElementsByTagName("table")[0];
	var tables = main_table.getElementsByTagName("table");
	var i;
	var old_zone_ref, zone;
	
	for(i = 0; i < tables.length; i++){
	
		if( tables[i].id == zone_id )
			if( tables[i] )
				zone = tables[i];

		if(tables[i].id == old_zone_id)
			old_zone_ref = tables[i];
	}

	if(zone){
		
		if(old_zone != null ){
			old_zone.style.display = "none";
		}else{
			old_zone = old_zone_ref;
			old_zone.style.display = "none";
		}
		
		zone.style.display = "block";
		old_zone = zone;
	}

}// JavaScript Document
/*
 * A JavaScript implementation of the Secure Hash Algorithm, SHA-1, as defined
 * in FIPS PUB 180-1
 * Version 2.1a Copyright Paul Johnston 2000 - 2002.
 * Other contributors: Greg Holt, Andrew Kepert, Ydnar, Lostinet
 * Distributed under the BSD License
 * See http://pajhome.org.uk/crypt/md5 for details.
 */

/*
 * Configurable variables. You may need to tweak these to be compatible with
 * the server-side, but the defaults work in most cases.
 */
var hexcase = 0;  /* hex output format. 0 - lowercase; 1 - uppercase        */
var b64pad  = ""; /* base-64 pad character. "=" for strict RFC compliance   */
var chrsz   = 8;  /* bits per input character. 8 - ASCII; 16 - Unicode      */

/*
 * These are the functions you'll usually want to call
 * They take string arguments and return either hex or base-64 encoded strings
 */
function hex_sha1(s){return binb2hex(core_sha1(str2binb(s),s.length * chrsz));}
function b64_sha1(s){return binb2b64(core_sha1(str2binb(s),s.length * chrsz));}
function str_sha1(s){return binb2str(core_sha1(str2binb(s),s.length * chrsz));}
function hex_hmac_sha1(key, data){ return binb2hex(core_hmac_sha1(key, data));}
function b64_hmac_sha1(key, data){ return binb2b64(core_hmac_sha1(key, data));}
function str_hmac_sha1(key, data){ return binb2str(core_hmac_sha1(key, data));}

/*
 * Perform a simple self-test to see if the VM is working
 */
function sha1_vm_test()
{
  return hex_sha1("abc") == "a9993e364706816aba3e25717850c26c9cd0d89d";
}

/*
 * Calculate the SHA-1 of an array of big-endian words, and a bit length
 */
function core_sha1(x, len)
{
  /* append padding */
  x[len >> 5] |= 0x80 << (24 - len % 32);
  x[((len + 64 >> 9) << 4) + 15] = len;

  var w = Array(80);
  var a =  1732584193;
  var b = -271733879;
  var c = -1732584194;
  var d =  271733878;
  var e = -1009589776;

  for(var i = 0; i < x.length; i += 16)
  {
    var olda = a;
    var oldb = b;
    var oldc = c;
    var oldd = d;
    var olde = e;

    for(var j = 0; j < 80; j++)
    {
      if(j < 16) w[j] = x[i + j];
      else w[j] = rol(w[j-3] ^ w[j-8] ^ w[j-14] ^ w[j-16], 1);
      var t = safe_add(safe_add(rol(a, 5), sha1_ft(j, b, c, d)),
                       safe_add(safe_add(e, w[j]), sha1_kt(j)));
      e = d;
      d = c;
      c = rol(b, 30);
      b = a;
      a = t;
    }

    a = safe_add(a, olda);
    b = safe_add(b, oldb);
    c = safe_add(c, oldc);
    d = safe_add(d, oldd);
    e = safe_add(e, olde);
  }
  return Array(a, b, c, d, e);

}

/*
 * Perform the appropriate triplet combination function for the current
 * iteration
 */
function sha1_ft(t, b, c, d)
{
  if(t < 20) return (b & c) | ((~b) & d);
  if(t < 40) return b ^ c ^ d;
  if(t < 60) return (b & c) | (b & d) | (c & d);
  return b ^ c ^ d;
}

/*
 * Determine the appropriate additive constant for the current iteration
 */
function sha1_kt(t)
{
  return (t < 20) ?  1518500249 : (t < 40) ?  1859775393 :
         (t < 60) ? -1894007588 : -899497514;
}

/*
 * Calculate the HMAC-SHA1 of a key and some data
 */
function core_hmac_sha1(key, data)
{
  var bkey = str2binb(key);
  if(bkey.length > 16) bkey = core_sha1(bkey, key.length * chrsz);

  var ipad = Array(16), opad = Array(16);
  for(var i = 0; i < 16; i++)
  {
    ipad[i] = bkey[i] ^ 0x36363636;
    opad[i] = bkey[i] ^ 0x5C5C5C5C;
  }

  var hash = core_sha1(ipad.concat(str2binb(data)), 512 + data.length * chrsz);
  return core_sha1(opad.concat(hash), 512 + 160);
}

/*
 * Add integers, wrapping at 2^32. This uses 16-bit operations internally
 * to work around bugs in some JS interpreters.
 */
function safe_add(x, y)
{
  var lsw = (x & 0xFFFF) + (y & 0xFFFF);
  var msw = (x >> 16) + (y >> 16) + (lsw >> 16);
  return (msw << 16) | (lsw & 0xFFFF);
}

/*
 * Bitwise rotate a 32-bit number to the left.
 */
function rol(num, cnt)
{
  return (num << cnt) | (num >>> (32 - cnt));
}

/*
 * Convert an 8-bit or 16-bit string to an array of big-endian words
 * In 8-bit function, characters >255 have their hi-byte silently ignored.
 */
function str2binb(str)
{
  var bin = Array();
  var mask = (1 << chrsz) - 1;
  for(var i = 0; i < str.length * chrsz; i += chrsz)
    bin[i>>5] |= (str.charCodeAt(i / chrsz) & mask) << (32 - chrsz - i%32);
  return bin;
}

/*
 * Convert an array of big-endian words to a string
 */
function binb2str(bin)
{
  var str = "";
  var mask = (1 << chrsz) - 1;
  for(var i = 0; i < bin.length * 32; i += chrsz)
    str += String.fromCharCode((bin[i>>5] >>> (32 - chrsz - i%32)) & mask);
  return str;
}

/*
 * Convert an array of big-endian words to a hex string.
 */
function binb2hex(binarray)
{
  var hex_tab = hexcase ? "0123456789ABCDEF" : "0123456789abcdef";
  var str = "";
  for(var i = 0; i < binarray.length * 4; i++)
  {
    str += hex_tab.charAt((binarray[i>>2] >> ((3 - i%4)*8+4)) & 0xF) +
           hex_tab.charAt((binarray[i>>2] >> ((3 - i%4)*8  )) & 0xF);
  }
  return str;
}

/*
 * Convert an array of big-endian words to a base-64 string
 */
function binb2b64(binarray)
{
  var tab = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
  var str = "";
  for(var i = 0; i < binarray.length * 4; i += 3)
  {
    var triplet = (((binarray[i   >> 2] >> 8 * (3 -  i   %4)) & 0xFF) << 16)
                | (((binarray[i+1 >> 2] >> 8 * (3 - (i+1)%4)) & 0xFF) << 8 )
                |  ((binarray[i+2 >> 2] >> 8 * (3 - (i+2)%4)) & 0xFF);
    for(var j = 0; j < 4; j++)
    {
      if(i * 8 + j * 6 > binarray.length * 32) str += b64pad;
      else str += tab.charAt((triplet >> 6*(3-j)) & 0x3F);
    }
  }
  return str;
}

	
//END OF GLOBAL JAVASCRIPT FILE