function do_nothing() {
	
}

function onclick_publication_banners(int_id_entities, int_id_publications) {
	document.getElementById("id").value = int_id_entities;
	document.getElementById("operation").value = "id_publications_kamex_" + int_id_publications;
	document.getElementById("frm_reload").submit();
}

function onclick_publication_categories(int_id_entities, int_id_publications) {
	document.getElementById("id").value = int_id_entities;
	document.getElementById("operation").value = "id_publications_kamex_" + int_id_publications;
	document.getElementById("frm_reload").submit();
}

function onclick_publication_subcategories(int_id_entities, int_id_publications) {
	document.getElementById("id").value = int_id_entities;
	document.getElementById("operation").value = "id_publications_kamex_" + int_id_publications;
	document.getElementById("frm_reload").submit();
}

function onclick_publication_products(int_id_entities, int_id_publications) {
	document.getElementById("id").value = int_id_entities;
	document.getElementById("operation").value = "id_publications_kamex_" + int_id_publications;
	document.getElementById("frm_reload").submit();
}

function onclick_publication_news(int_id_entities, int_id_publications) {
	document.getElementById("id").value = int_id_entities;
	document.getElementById("operation").value = "id_publications_kamex_" + int_id_publications;
	document.getElementById("frm_reload").submit();
}

function onclick_publication_news2(int_id_entities, int_id_publications) {
	document.getElementById("id").value = int_id_entities;
	document.getElementById("operation").value = "id_publications_kamex2_" + int_id_publications;
	document.getElementById("frm_reload").submit();
}


function onclick_move(int_id_entities, str_operation) {
	document.getElementById("id").value = int_id_entities;
	document.getElementById("operation").value = str_operation;
	document.getElementById("frm_reload").submit();
}

function show_message(str_var) {
	var str_msg = "";
	try {
		eval('str_msg = ' + str_var + ';');
	}
	catch(e) {
	}
	if(str_msg != "") {
		alert(str_msg);
	}
}
function select_append_to(str_form, str_list, str_value, str_text, boo_selected)
{
	var elOptNew = document.createElement('option');
	elOptNew.value = str_value;
	elOptNew.text = str_text;
	if(boo_selected) {
		elOptNew.setAttribute("selected","selected");
	}
	eval("var elSel = document." + str_form + "." + str_list + ";");
	try {
		elSel.add(elOptNew, null); // standards compliant; doesn't work in IE
	}
	catch(ex) {
		elSel.add(elOptNew); // IE only
	}
}

function select_clear(str_form, str_list) {
	eval("var obj_sel = document." + str_form + "." + str_list + ";");
	var len = obj_sel.length-1;
	for(var i =len; i>=0; i--){
		obj_sel.remove(i);
	}
}


function operation(id, operation) {
	document.getElementById("id").value = id;
	document.getElementById("operation").value = operation;
	document.getElementById("frm_reload").submit();
}

function go_to(module, action, mode, id, operation, m_parent, a_parent) {
	document.getElementById("m").value = module;
	document.getElementById("a").value = action;
	document.getElementById("mode").value = mode;
	document.getElementById("id").value = id;
	document.getElementById("operation").value = operation;
	document.getElementById("m_parent").value = m_parent;
	document.getElementById("a_parent").value = a_parent;
	document.getElementById("frm_reload").submit();
}

function go_to_filters(module, action, mode, id, operation, m_parent, a_parent, hid_filter1, hid_filter2, hid_filter3, hid_filter4, hid_filter5, hid_filter6) {
	document.frm_reload.hid_filter1.value = hid_filter1;
	document.frm_reload.hid_filter2.value = hid_filter2;
	document.frm_reload.hid_filter3.value = hid_filter3;
	document.frm_reload.hid_filter4.value = hid_filter4;
	document.frm_reload.hid_filter5.value = hid_filter5;
	document.frm_reload.hid_filter6.value = hid_filter6;
	go_to(module, action, mode, id, operation, m_parent, a_parent);
}

function get_select_value(str_select_form , str_select_name) {
	res = "";
	eval('res = document.' + str_select_form + '.' + str_select_name + '.options[document.' + str_select_form + '.' + str_select_name + '.selectedIndex].value;');
	return (res);
}

function change_language(id_languages) {
	document.getElementById("id_languages").value = id_languages;
	document.getElementById("frm_reload").submit();
}

function path() {
	this.tab_path_type = new Array();	
	this.tab_path_text = new Array();	
	this.tab_path_href = new Array();	
	this.int_path = 0;	
	
	this.add = function (str_type, str_text, str_href) {
		this.int_path++;
		this.tab_path_type[this.int_path-1] = str_type;	
		this.tab_path_text[this.int_path-1] = str_text;	
		this.tab_path_href[this.int_path-1] = str_href;	
	}
	
	this.show = function () {
		var int_i;
		var str_html;
		str_html = "";
		for(int_i=0;int_i<=this.int_path-1;int_i++) {
			if(this.tab_path_type[int_i] == "a") {
				str_html += '&nbsp;&nbsp;<a href="' + this.tab_path_href[int_i] + '" class="path_a">' + this.tab_path_text[int_i] + '</a></span>';
			} else {
				str_html += '&nbsp;&nbsp;<span class="path_text">' + this.tab_path_text[int_i] + '</span>';
			}
		}
		document.getElementById("current_path").innerHTML = str_html;
	}
}
var id_popup;
function popup(str_module, str_action, str_params) {
	// popup_width and popup_height are global
	var str_index = "index_admin2_popup.php";
	var str_url = str_index + "?m=" + str_module + "&a=" + str_action + "&" + str_params;
	id_popup = window.open(str_url,null,"height="+glo_popup_height+",width="+glo_popup_width+",status=yes,toolbar=no,menubar=no,location=no,resizable=yes,scrollbars=yes");
}

function popup_cust(str_module, str_action, str_params, int_width, int_height) {
	// popup_width and popup_height are not global (int_width, int_height)
	var str_index = "index_admin2_popup.php";
	var str_url = str_index + "?m=" + str_module + "&a=" + str_action + "&" + str_params;
	id_popup = window.open(str_url,null,"height="+int_height+",width="+int_width+",status=yes,toolbar=no,menubar=no,location=no,resizable=yes,scrollbars=yes");
}

function list_add(str_id_list_1, str_id_list_2, str_id_hidden) {
	var obj_list_1 = document.getElementById(str_id_list_1);
	var obj_list_2 = document.getElementById(str_id_list_2);
	if(obj_list_1.selectedIndex >= 0) {
		var str_value = obj_list_1.options[obj_list_1.selectedIndex].value;
		var str_name = obj_list_1.options[obj_list_1.selectedIndex].text;
		appendOptionLast(str_id_list_2, str_name, str_value);
		removeOptionSelected(str_id_list_1);
		get_selected(str_id_list_2, str_id_hidden);
	}
}

function list_remove(str_id_list_1, str_id_list_2, str_id_hidden) {
	var obj_list_1 = document.getElementById(str_id_list_1);
	var obj_list_2 = document.getElementById(str_id_list_2);
	if(obj_list_1.selectedIndex >= 0) {
		var str_value = obj_list_1.options[obj_list_1.selectedIndex].value;
		var str_name = obj_list_1.options[obj_list_1.selectedIndex].text;
		appendOptionLast(str_id_list_2, str_name, str_value);
		removeOptionSelected(str_id_list_1);
		get_selected(str_id_list_1, str_id_hidden);
	}
}

function get_selected(str_id_list, str_id_hidden) {
	var i, str_tmp, str_separator;
	var obj_list = document.getElementById(str_id_list);
	var obj_hidden = document.getElementById(str_id_hidden);
	str_tmp = "";
	str_separator = "";
	for(i=0;i<obj_list.length;i++) {
		str_tmp += str_separator + obj_list.options[i].value;
		str_separator = ",";
	}
	obj_hidden.value = str_tmp;
}

function appendOptionLast(id, name, value)
{
  var elOptNew = document.createElement('option');
  elOptNew.text = name;
  elOptNew.value = value;
  var elSel = document.getElementById(id);

  try {
    elSel.add(elOptNew, null); // standards compliant; doesn't work in IE
  }
  catch(ex) {
    elSel.add(elOptNew); // IE only
  }
}


function removeOptionSelected(id)
{
  var elSel = document.getElementById(id);
  var i;
  for (i = elSel.length - 1; i>=0; i--) {
    if (elSel.options[i].selected) {
      elSel.remove(i);
    }
  }
}

/*
		$str_html .= '	function validate_form(){'."\n";
		$str_html .= '		var res=true;'."\n";
		$str_html .= '		return(res);'."\n";
		$str_html .= '	}'."\n";
*/

// Definicion del objecto por un campo solo
function field() 
{
	this.id="";
	this.label="";
	this.display_type="";
	this.data_type="";
	this.cols=0;
	this.rows=0;
	this.min_length=0;
	this.max_length=0;
	this.min_value=0;
	this.max_value=0;
	this.mandatory=0;
}


function form_validation() {
	
	this.num_fields=0;
	this.fields=Array();
	this.num_errors=0;
	this.mode="";

	this.add_field = function (obj_field) {
		this.num_fields++;
		this.fields[this.num_fields]=obj_field;
	}
	
	this.validate = function () {
		// Buscar el campo
		var str_msg_error="";
		var str_msg_error_tmp="";
		var boo_no_error=true;
		var str_RC="";

		this.num_errors=0;
		// Buscar cada campo
		for(int_one_field in this.fields) 
		{
			str_msg_error_tmp="";
			str_msg_error_tmp=this.verify_one_field(this.fields[int_one_field],true);

			if(str_msg_error_tmp!="") 
			{		
				str_msg_error=str_msg_error+str_RC+str_msg_error_tmp;
				str_RC="\n";
				boo_no_error=false;
			}
		}
		//boo_no_error=false;
		if(!boo_no_error) 
		{
			str_msg_error = app["error_title_js"] + "\n\n" + str_msg_error;
			alert(str_msg_error);
		}
		return(boo_no_error);
	}


	this.verify_one_field = function (obj_field, boo_show_msg_error) {

		var str_msg_error="";
		var str_msg_error_tmp="";
		var boo_field_valid=true;
		var str_RC="";

		// If the object exists
		if(document.getElementById(obj_field.id)) 
		{
			// Mandatory
			if(obj_field.mandatory==1 && obj_field.data_type != "password") 
			{
				str_msg_error_tmp=this.field_mandatory(obj_field);
				if(str_msg_error_tmp!="") 
				{
					boo_field_valid=false;
					str_msg_error=str_msg_error+str_RC+str_msg_error_tmp;
					str_RC="\n";
				}
			}

			if(obj_field.mandatory==0 || (obj_field.mandatory==1 && boo_field_valid)) 
			{
				switch(obj_field.display_type) {
					case "text":
						if(obj_field.min_length != 0 && obj_field.max_length != 0 && obj_field.data_type != "password" ) {
							str_msg_error_tmp=this.field_min_length(obj_field);
							if(str_msg_error_tmp!="") 
							{
								boo_field_valid=false;
								str_msg_error=str_msg_error+str_RC+str_msg_error_tmp;
								str_RC="\n";
							}
							str_msg_error_tmp=this.field_max_length(obj_field);
							if(str_msg_error_tmp!="") 
							{
								boo_field_valid=false;
								str_msg_error=str_msg_error+str_RC+str_msg_error_tmp;
								str_RC="\n";
							}
						}
						switch(obj_field.data_type) {
							case "title":
								break;
							case "int":
								// Verify that the value is an integer : [0-9]
								str_msg_error_tmp=this.field_int(obj_field);
								if(str_msg_error_tmp!="") 
								{
									boo_field_valid=false;
									str_msg_error=str_msg_error+str_RC+str_msg_error_tmp;
									str_RC="\n";
								}
								if(boo_field_valid && (obj_field.min_value != obj_field.max_value)) {
									// Verify that the value is the minimum required
									str_msg_error_tmp=this.field_min_value(obj_field);
									if(str_msg_error_tmp!="") 
									{
										boo_field_valid=false;
										str_msg_error=str_msg_error+str_RC+str_msg_error_tmp;
										str_RC="\n";
									}
									// Verify that the value is the maximum required
									str_msg_error_tmp=this.field_max_value(obj_field);
									if(str_msg_error_tmp!="") 
									{
										boo_field_valid=false;
										str_msg_error=str_msg_error+str_RC+str_msg_error_tmp;
										str_RC="\n";
									}
								}
								break;
							case "float":
								// Verify that the value is an float : [0-9] and , and .
								str_msg_error_tmp=this.field_float(obj_field);
								if(str_msg_error_tmp!="") 
								{
									boo_field_valid=false;
									str_msg_error=str_msg_error+str_RC+str_msg_error_tmp;
									str_RC="\n";
								}
								if(boo_field_valid && (obj_field.min_value != obj_field.max_value)) {
									// Verify that the value is the minimum required
									str_msg_error_tmp=this.field_min_value(obj_field);
									if(str_msg_error_tmp!="") 
									{
										boo_field_valid=false;
										str_msg_error=str_msg_error+str_RC+str_msg_error_tmp;
										str_RC="\n";
									}
									// Verify that the value is the maximum required
									str_msg_error_tmp=this.field_max_value(obj_field);
									if(str_msg_error_tmp!="") 
									{
										boo_field_valid=false;
										str_msg_error=str_msg_error+str_RC+str_msg_error_tmp;
										str_RC="\n";
									}
								}
								break;
							case "datetime":
								// Verify that the value is a date : aaaa-mm-dd or aaaa-mm-dd hh:mm:ss
								str_msg_error_tmp=this.field_datetime(obj_field);
								if(str_msg_error_tmp!="") 
								{
									boo_field_valid=false;
									str_msg_error=str_msg_error+str_RC+str_msg_error_tmp;
									str_RC="\n";
								}
								break;
							case "email":
								// Verify that the value is an email : xxxxxx@xxxx.xxxx
								str_msg_error_tmp=this.field_email(obj_field);
								if(str_msg_error_tmp!="") 
								{
									boo_field_valid=false;
									str_msg_error=str_msg_error+str_RC+str_msg_error_tmp;
									str_RC="\n";
								}
								break;
							case "password":							
								var str_password = document.getElementById(obj_field.id).value;
								var str_password_confirm = document.getElementById(obj_field.id + "_confirm").value;
								if(this.mode == "add" || (this.mode == "edit" && (str_password != "" || str_password_confirm != ""))) {							
									if(boo_field_valid) {
										if(obj_field.min_length != 0 && obj_field.max_length != 0 ) {
											str_msg_error_tmp=this.field_min_length(obj_field);
											if(str_msg_error_tmp!="") 
											{
												boo_field_valid=false;
												str_msg_error=str_msg_error+str_RC+str_msg_error_tmp;
												str_RC="\n";
											}
											str_msg_error_tmp=this.field_max_length(obj_field);
											if(str_msg_error_tmp!="") 
											{
												boo_field_valid=false;
												str_msg_error=str_msg_error+str_RC+str_msg_error_tmp;
												str_RC="\n";
											}
										}
									}
									if(boo_field_valid) {
										if(str_password == "") {
											this.num_errors++;
											str_msg_error_tmp = this.num_errors + " - " + obj_field.label + " : " + app["mandatory_password_empty"];
											boo_field_valid=false;
											str_msg_error=str_msg_error+str_RC+str_msg_error_tmp;
											str_RC="\n";
										}
										if(str_password_confirm == "") {
											this.num_errors++;
											str_msg_error_tmp = this.num_errors + " - " + obj_field.label + " (" + app["confirmation"] + ") : " + app["mandatory_password_confirm_empty"];
											boo_field_valid=false;
											str_msg_error=str_msg_error+str_RC+str_msg_error_tmp;
											str_RC="\n";
										}
									}
									if(boo_field_valid) {
										// Verify that password and password_confirm are the same
										str_msg_error_tmp=this.field_password(obj_field);
										if(str_msg_error_tmp!="") 
										{
											boo_field_valid=false;
											str_msg_error=str_msg_error+str_RC+str_msg_error_tmp;
											str_RC="\n";
										}
									}
								}
								break;
						}
						break;
					default:
				}

			}

			//str_msg_error = obj_field.id;
			// Send error message if requested
			if(boo_show_msg_error) 
			{
				return(str_msg_error);
			}
			else 
			{
				return("");
			}
		} 
		else 
		{
			// Object no exists => no message
			return("");
		}			
	}


	// Verify if field password is valid
	this.field_password = function (obj_field) 
	{
		var str_msg_error="";
		var str_password = document.getElementById(obj_field.id).value;
		var str_password_confirm = document.getElementById(obj_field.id + "_confirm").value;
		if (str_password != str_password_confirm) 
		{
			this.num_errors++;
			str_msg_error = this.num_errors + " - " + obj_field.label + " (" + app["confirmation"] + ") : " + app["mandatory_password_confirm"];
		}
		return(str_msg_error);
	}

	// Verify if field value is an email
	this.field_email = function (obj_field) 
	{
		var str_msg_error="";
		var x = document.getElementById(obj_field.id).value;
		var filter  = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
		if (!filter.test(x)) 
		{
			this.num_errors++;
			str_msg_error = this.num_errors + " - " + obj_field.label + " : " + app["mandatory_email"];
		}
		return(str_msg_error);
	}


	// Verify if field value is a date with time
	this.field_datetime = function (obj_field) 
	{
   		var boo_result = true;
   		var boo_bisextil = false;
		var tab_months = new Array();
		tab_months[1] = 31;
		tab_months[2] = 28;
		tab_months[3] = 31;
		tab_months[4] = 30;
		tab_months[5] = 31;
		tab_months[6] = 30;
		tab_months[7] = 31;
		tab_months[8] = 31;
		tab_months[9] = 30;
		tab_months[10] = 31;
		tab_months[11] = 30;
		tab_months[12] = 31;
		var str_msg_error="";
		var x = document.getElementById(obj_field.id).value;
		var filter  = /([1-9][0-9][0-9][0-9])-([0-9][0-9])-([0-9][0-9]) [0-9][0-9]:[0-9][0-9]:[0-9][0-9]/;
		var res = filter.exec(x);
		if (!res) 
		{
			this.num_errors++;
			str_msg_error = this.num_errors + " - " + obj_field.label + " : " + app["mandatory_datetime"];
		} else {
			if(res[1] < 2000 || res[1] > 2200) {
				boo_result = false;
			}
			if(boo_result) {
				if(res[2] < 1 || res[2] > 12) {
					boo_result = false;
				}
				if(boo_result) {
					if(this.isBi(res[1])) {
						tab_months[2] = 29; 
					}
					if(res[3] < 1 || res[3] > tab_months[parseInt(res[2],10)]) {
						boo_result = false;
					}
				}
			}
			if(!boo_result) {
				this.num_errors++;
				str_msg_error = this.num_errors + " - " + obj_field.label + " : " + app["mandatory_datetime"];
			}
		}
		return(str_msg_error);
	}


	this.isBi = function (str_year) 
	{
		var int_dif = str_year-2000;
		if(int_dif<0) {
			int_dif*=-1;
		}
		if(int_dif%4==0) {
			return true;
		} else {
			return false;
		}
	} 
	// Verify if value is the minimum required
	this.field_max_value = function (obj_field) 
	{
		var str_msg_error="";
		var str_value = document.getElementById(obj_field.id).value;
		if(str_value > obj_field.max_value) {
			this.num_errors++;
			str_msg_error = this.num_errors + " - " + obj_field.label + " : " + app["mandatory_max_value"] + " " + obj_field.max_value;
		}
		return(str_msg_error);
	}


	// Verify if value is the minimum required
	this.field_min_value = function (obj_field) 
	{
		var str_msg_error="";
		var str_value =document.getElementById(obj_field.id).value;
		if(str_value < obj_field.min_value) {
			this.num_errors++;
			str_msg_error = this.num_errors + " - " + obj_field.label + " : " + app["mandatory_min_value"] + " " + obj_field.min_value;
		}
		return(str_msg_error);
	}


	// Verify if field value is an integer
	this.field_int = function (obj_field) 
	{
		var str_msg_error="";
		var str_valid_chars = "0123456789-";
   		var str_char;
   		var boo_result = true;
		var str_string=document.getElementById(obj_field.id).value;
		if (str_string.length > 0) 
		{
			//  test strString consists of valid characters listed above
			for (i = 0; i < str_string.length; i++) 
			{
				str_char = str_string.charAt(i);
				if (str_valid_chars.indexOf(str_char) == -1 && boo_result) 
				{
					boo_result = false;
					this.num_errors++;
					str_msg_error = this.num_errors + " - " + obj_field.label + " : " + app["mandatory_int"];
				}
			}
		}
		return(str_msg_error);
	}

	// Verify if field value is a float
	this.field_float = function (obj_field) 
	{
		var str_msg_error="";
		var str_valid_chars = "0123456789-.";
   		var str_char;
   		var boo_result = true;
		var str_string=document.getElementById(obj_field.id).value;
		if (str_string.length > 0) 
		{
			//  test strString consists of valid characters listed above
			for (i = 0; i < str_string.length; i++) 
			{
				str_char = str_string.charAt(i);
				if (str_valid_chars.indexOf(str_char) == -1 && boo_result) 
				{
					boo_result = false;
					this.num_errors++;
					str_msg_error = this.num_errors + " - " + obj_field.label + " : " + app["mandatory_float"];
				}
			}
			if(str_string.indexOf(".") < 0) {
					boo_result = false;
					this.num_errors++;
					str_msg_error = this.num_errors + " - " + obj_field.label + " : " + app["mandatory_float"];
			}
		}
		return(str_msg_error);
	}

	// Verify if text length is valid
	this.field_min_length = function (obj_field) 
	{
		var str_msg_error="";
		var boo_field_valid=true;
		var str_value = new String(document.getElementById(obj_field.id).value);
		if(str_value.length < obj_field.min_length) {
			boo_field_valid = false;
			this.num_errors++;
			str_msg_error = this.num_errors + " - " + obj_field.label + " : " + app["mandatory_min_length"] + obj_field.min_length + app["mandatory_character"];
		}
		return(str_msg_error);
	}

	// Verify if text length is valid
	this.field_max_length = function (obj_field) 
	{
		var str_msg_error="";
		var boo_field_valid=true;
		var str_value = new String(document.getElementById(obj_field.id).value);
		if(str_value.length > obj_field.max_length) {
			boo_field_valid = false;
			this.num_errors++;
			str_msg_error = this.num_errors + " - " + obj_field.label + " : " + app["mandatory_max_length"] + obj_field.max_length + app["mandatory_character"];
		}
		return(str_msg_error);
	}


	// Verify if a mandatory field had a value
	this.field_mandatory = function (obj_field) 
	{
		var str_msg_error="";
		var boo_field_valid=true;
		// El tratamiento depende del tip de campo
		switch(obj_field.display_type) 
		{
			case "hidden":
			case "text":
			case "file":
			case "password":
			case "textarea":
				// Verify if there is a value in the field
				if(document.getElementById(obj_field.id).value=="") 
				{
					boo_field_valid = false;
					this.num_errors++;
					str_msg_error = this.num_errors + " - " + obj_field.label + " : " + app["mandatory_text"];
				}
				break;
			
			case "select":
				// Verify if there is a value selected
				if(document.getElementById(obj_field.id).selectedIndex < 0) {
					boo_field_valid = false;
					this.num_errors++;
					str_msg_error = this.num_errors + " - " + obj_field.label + " : " + app["mandatory_select"];
				}
				break;
			case "select_none":
				// Verify if there is a value selected (not None)
				if(document.getElementById(obj_field.id).selectedIndex < 1) {
					boo_field_valid = false;
					this.num_errors++;
					str_msg_error = this.num_errors + " - " + obj_field.label + " : " + app["mandatory_select_none"];
				}
				break;
			case "radio":
				// Verify if it is a table
				if(document.getElementsByName(obj_field.id)[0]) 
				{
					var boo_one_selected=false;
					// Verify if one element has been selected
					for(i=0;i<document.getElementsByName(obj_field.id).length;i++) 
					{
						if(document.getElementsByName(obj_field.id)[i].checked)
						{
							boo_one_selected=true;
						}
					}
					// No element selected => error
					if(!boo_one_selected) 
					{
						boo_field_valid=false;
						this.num_errors++;
						str_msg_error = this.num_errors + " - " + obj_field.label + " : " + app["mandatory_radio"];
					}
				} 
				else 
				{
					// It is not a table => verify if element has been selected
					if (document.getElementsByName(obj_field.id).checked) 
					{
						// No error
					} 
					else 
					{
						// Element not selected => error
						boo_field_valid=false;
						this.num_errors++;
						str_msg_error = this.num_errors + " - " + obj_field.label + " : " + app["mandatory_radio"];
					}
				}
				break;
			case "external":
				// Verify if there is an element in the list
				if(document.getElementById(obj_field.id).options.length <= 0) {
					boo_field_valid = false;
					this.num_errors++;
					str_msg_error = this.num_errors + " - " + obj_field.label + " : " + app["mandatory_external"];
				}
				break;
			case "key":
				break;
		}
		return(str_msg_error);
	}

}


// TO SHOW THE DESCRIPTION OF AN ELEMENT 

function show_description(e, text, position_y)
{
	// Shift to not have the arrow just on the mouse but some pixels on the right
	shift_left = 5;
	// Shift to have the arrow on the element
	shift_top = -35;
	
	// Get mouse cursor position (depend of the navigator)
	if(document.all)
	{
		// IE6, IE7, Opera => not using the event in parameter
		if (event.pageX || event.pageY) 	{
			posx = event.pageX;
			posy = event.pageY;
		}
		else if (event.clientX || event.clientY) 	{
			posx = event.clientX + document.body.scrollLeft
				+ document.documentElement.scrollLeft;
			posy = event.clientY + document.body.scrollTop
				+ document.documentElement.scrollTop;
		}
	}
	else 
	{
		// Firefox => using the event in parameter
		if (e.pageX || e.pageY) 	{
			posx = e.pageX;
			posy = e.pageY;
		}
		else if (e.clientX || e.clientY) 	{
			posx = e.clientX + document.body.scrollLeft
				+ document.documentElement.scrollLeft;
			posy = e.clientY + document.body.scrollTop
				+ document.documentElement.scrollTop;
		}
	}
	
	// To be sure it is an integer (sometimes FF is giving "2 px")
	posx = parseInt(posx,10);
	posy = parseInt(posy,10);
	
	// Access to the div
   	var desc = document.getElementById("description");

	// Display the div
	desc.style.display = "inline";

	// Set div position ( the 'px' are mandatory for FF and Opera)
	desc.style.left = (posx + shift_left) + "px";
	desc.style.top = (position_y + shift_top) + "px";

	// Set div content
	document.getElementById("description_content").innerHTML = text;
}

function hide_description()
{
  document.getElementById("description").style.display = "none";
}

// Calculate the top position of an element
function position_top(the_object) {
	
	var curtop = 0;
	
	obj = the_object;
	
	if (obj.offsetParent) {
		try {
			curtop_tmp = obj.offsetTop;
		}
		catch(e) {
			curtop_tmp = 0;
		}
		// First method is to try to get offsetParent
		curtop = curtop_tmp;
		valid = true;
		try {
			obj = obj.offsetParent;
		}
		catch(e) {
			// If no working
			valid = false;
		}
		
		// Second method is to get the offsetTop of the object and its parents
		while (valid) {

			try {
				curtop_tmp = obj.offsetTop;
			}
			catch(e) {
				curtop_tmp = 0;
			}
			curtop += curtop_tmp;
			
			try {
				obj = obj.offsetParent;
			}
			catch(e) {
				valid = false;
			}
		}
	}
	
	return curtop;
}

function show_area(str_id_area)
{
	var obj_area;
	obj_area = document.getElementById(str_id_area);
	if (obj_area.style.display == 'none') 
	{
		obj_area.style.display='';
	} else {
		obj_area.style.display='none';	
	}
}

function show_hide_area(str_id_area, str_status)
{
	var obj_area;
	obj_area = document.getElementById(str_id_area);
	if (str_status == "show") 
	{
		obj_area.style.display='';
	} else {
		obj_area.style.display='none';	
	}
}

function set_image_size(str_id, int_width_current, int_height_current, int_width_origin, int_height_origin) {
	// If the object exists
	if(document.getElementById(str_id)) {
		obj_img = document.getElementById(str_id);
		if(obj_img.width == int_width_current && obj_img.width == int_height_current) {
			obj_img.width = int_width_origin;
			obj_img.height = int_height_origin;
			if(document.getElementById(str_id + "_size_link")) {
				document.getElementById(str_id + "_size_link").innerHTML = app["Previous_size"];
			}
		} else {
			obj_img.width = int_width_current;
			obj_img.height = int_height_current;
			if(document.getElementById(str_id + "_size_link")) {
				document.getElementById(str_id + "_size_link").innerHTML = app["Original_size"];
			}
		}
	}
}
