

//global variables

emailregex=/^([a-zA-Z0-9._-]+@([a-zA-Z0-9._-]+\.)+[a-zA-Z0-9._-]{2,4})$/;



/*_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-



@DESCRIPTION	:

 This .js is just for detecting and sending the good datas to exhibitors_list.php for the function search 

$Name: not supported by cvs2svn $:	contact_$lang.js ;;

$Date: 2008-11-05 11:25:31 $:	19/01/2006 			;;

$Log: not supported by cvs2svn $
Revision 1.21  2008/11/05 11:12:41  cvs
*** empty log message ***

Revision 1.20  2008/10/20 07:07:57  cvs
*** empty log message ***

Revision 1.19  2008/10/13 04:45:05  cvs
*** empty log message ***

Revision 1.18  2008/05/30 05:39:58  kepler
task 606213 - 1.3  Active tabs tab color

Revision 1.15  2008/05/23 06:51:11  kepler
task 597923 - 1.23

Revision 1.14  2008/05/23 05:31:22  kepler
task 597923 - 1.21

Revision 1.11  2008/05/21 12:55:32  cvs
597909

Revision 1.10  2008/05/21 12:47:23  cvs
597909

Revision 1.9  2008/05/20 13:58:17  cvs
597909

Revision 1.7  2008/04/21 08:13:39  kepler
task 566801

Revision 1.6  2008/04/21 02:39:13  kepler
task 566801

Revision 1.5  2008/03/25 00:16:21  kepler
task 544842: modify sendSearchForm and checkAllElementsSearchForm

Revision 1.4  2007/09/06 17:20:28  cvs
clean up of the repository taking production version

Revision 1.3  2007/09/06 16:30:29  cvs
clean up of the repository by replacing all files with the production version


Revision 1.2  2007/09/05 15:23:33  cvs

corrected a bug in the search form which prevented the checkboxes to appear again when the 'Clear' button had been pressed



Revision 1.1.1.1  2007/07/13 20:43:29  cvs

first import

 : V1.0						;;

$Note$ :

	;;

_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_- */



// --== getStandsList ==--

// @Access : public ;;

// @role   : switch the mode of stands' input to mode list;;

//				   note: this is a mini search of the stands, we filter the stands by the first letters and generate a list to choose

function getStandsList()

{

	if(TrimString(document.myform.begin_letters_stand.value)!='')

	{

		if(document.myform.p_id.value != 0)

		  str = "&p_id="+document.myform.p_id.value;

  	else

  	  str = "";

  	  

		GetStandsList_DIV("/visitors/search_form.php?stand_div_mode=stand_list&begin_letters="+document.myform.begin_letters_stand.value+str);

		//stands_div.innerHTML='';

	}

}



// --== getStandsInput ==--

// @Access : public ;;

// @role   : switch the mode of stands' input to mode input;;

//				   note: this is a mini search of the stands, we filter the stands by the first letters and generate a list to choose

function getStandsInput()

{

	if(!navigator.appName=="Microsoft Internet Explorer")

	{

		document.myform.st_id=undefined;

	}

	GetStandsList_DIV("/visitors/search_form.php?stand_div_mode=stand_input");

}



// --== sendPrintNgoForm ==--

// @Access : public ;;

// @role   : validate and send the form to record the email for getting the guide PDF;;

function sendPrintNgoForm()

{

	
	if(!emailregex.test(document.getElementById('email_vg').value))

	{

		alert(MSG__BAD_EMAIL_FORMAT);

		return false;

	}
	
	var add_params="&email="+document.getElementById('email_vg').value;

	/*add_params+="&infos="+document.forms.myform.infos.value;

	add_params+="&exhibitors="+document.forms.myform.exhibitors.value;

	add_params+="&plan="+document.forms.myform.plan.value;

	add_params+="&products="+document.forms.myform.products.value;*/
	
	List("/visitors/printngo.php?mode=save"+add_params);

}



// --== TrimString ==--

// @Access : public ;;

// @Args 	 : a string

// @role   : elimilate the spaces at the beginning and the endding of a string;;

function TrimString(sInString)

{

  sInString = sInString.replace( /^\s+/g, "" );// strip leading

  return sInString.replace( /\s+$/g, "" );// strip trailing

}



// --== sendMeetingForm ==--

// @Access : public ;;

// @role   :  validate and send the form for a meeting;;

function sendMeetingForm()

{

  var form = document.myform;

  err=false;

  errmsg='';

  

  if(!emailregex.test(form.email.value))

  {

  	err=true;

  	errmsg += MSG__BAD_EMAIL_FORMAT + "\n";	

  }



  if(!isValidDate(form.yyyy.value, form.mm.value, form.dd.value))

  {

		err=true;

		errmsg+= MSG__BAD_DATE_FORMAT + "\n";

  }



  if(TrimString(form.name.value)==''||TrimString(form.forename.value)==''||TrimString(form.company.value)==''||TrimString(form.phone.value)==''||TrimString(form.desc.value)=='')

  {

		err=true;

		errmsg += MSG__ALL_FIELDS_MANDATORY;

  }

	if(err)

	{

		alert(errmsg);

	} 

	else

	{

		// send the parameters of a research

		add_params="&e_id="+form.e_id.value;

    add_params+="&me_ge_id="+form.me_ge_id.value;

		add_params+="&email="+form.email.value;

		add_params+="&name="+form.name.value;

		add_params+="&forename="+form.forename.value;

		add_params+="&company="+form.company.value;

		add_params+="&phone="+form.phone.value;

		add_params+="&desc="+escape(form.desc.value);

		add_params+="&yyyy="+escape(form.yyyy.value);

		add_params+="&mm="+escape(form.mm.value);

		add_params+="&dd="+escape(form.dd.value);

		add_params+="&hour="+escape(form.hour.value);

		add_params+="&min="+escape(form.min.value);

		/*

		add_params+="&ge_name="+'<xsl:value-of select="$ge_name"/>'

		add_params+="&ge_classment="+'<xsl:value-of select="$ge_classment"/>'

		add_params+="&st_id="+'<xsl:value-of select="$st_id"/>'

		add_params+="&p_id="+'<xsl:value-of select="$p_id"/>'

		add_params+="&td_id="+'<xsl:value-of select="$td_id"/>'

		add_params+="&keywords="+'<xsl:value-of select="$keywords"/>'

		*/

	

		List("/visitors/meeting.php?page_mode=save"+add_params);

	}

}



// --== sendMeetingForm ==--

// @Access : public ;;

// @Args   : number of a year,number of a month,number of a day;;

// @role   : detect weither a number of a year is a valid year;;

function isValidDate(yyyy,mm,dd)

{

	little_months="04|06|09|11";

	if(little_months.indexOf(mm)>-1 && dd>30)

	{

		return false;

	}

	if(mm=='02')

	{

		if((((yyyy%4==0) && (yyyy%100!=0)) || (yyyy%400==0)))

		{

			if(dd>29)

			{

				return false;

			}

		}

		else

		{

			if(dd>28)

			{

				return false;

			}

		}

	}

	return true;

}



/*

// --== changeSearchProfil ==--

// @Access : public ;;

// @role   : switch the mode of the profil of research

function changeSearchProfil()

{

	research_profil=(research_profil=="basic")?"advance":"basic";  

	Layer_SetContent("lbl_change_profil",(research_profil=="basic")?"Recherche avancée":"Recherche simple");

	form_advance.style.display=(research_profil=="basic")?"none":"block";

}*/



// --== clearSearchForm ==--

// @Access : public ;;

// @role   : reset the research form

function clearSearchForm() /*showList = true*/

{

	// clear the texts of the titles	

	/*if(document.getElementById("products_only"))

		title_new_product.className='';

	if(document.getElementById("title_company"))

		title_company.className='';

	title_stand.className='';

	if(document.getElementById("search_by_product"))

		title_product.className='';

	if(document.getElementById("search_by_trade"))

		title_trade.className='';

	title_keywords.className='';

	title_ctry.className='';*/

  

  //close all the search panels

  for (var i = 1; i <= 7; i++) {

    trySetDisplay("search2-" + i, "none");

  }

	

	//reset the research form

	if(document.getElementById("products_only"))

		document.myform.products_only.checked=false;

	document.myform.search_by_company.checked=false;

  document.myform.search_by_company.style.visibility = 'hidden';

	document.myform.search_by_stand.checked=false;

	document.myform.search_by_stand.style.visibility = 'hidden';

  

	if(document.getElementById("search_by_product")) {

		document.myform.search_by_product.checked=false;

    document.myform.search_by_product.style.visibility = 'hidden';

  }

	if(document.getElementById("search_by_trade")) {

		document.myform.search_by_trade.checked=false;

    document.myform.search_by_trade.style.visibility = 'hidden';

	}
    if (document.myform.search_by_keywords) {
  	   document.myform.search_by_keywords.checked=false;
       document.myform.search_by_keywords.style.visibility = 'hidden';
    }


	document.myform.search_by_country.checked=false;

  document.myform.search_by_country.style.visibility = 'hidden';

  

	document.myform.ge_name.value='';

	document.myform.keywords.value='';



	document.myform.p_id.value=0;

	document.myform.c_id.value=0;

	document.myform.ctry_id.value=0;



	getStandsInput();



  // clear the checkbox of trade

  if(document.getElementById("search_by_trade"))

  {

	  if(typeof(document.forms["myform"].elements["td_id[]"].length)=="undefined")// if there is only one

	  {

	 		document.forms["myform"].elements["td_id"].checked=false;

		}

	  else// if there are more than one

	  {

	    for (var i=0; i < document.forms["myform"].elements["td_id[]"].length; i++)

	 		{

	    	document.forms["myform"].elements["td_id[]"][i].checked=false;

			}

		}

	}	

  clearProduct();
	//refresh the list of the exhibitors
  List("/visitors/exhibitor_list.php?products_only=0");
}



// --== setAllElementsSearchForm( ==--

// @Access : public ;;

// @Args   : mode, if we click on the checkboxs, we don't need verify the elements' status in the search forms

// @role   : set the titles' color, and the depend on the status of the checkboxs, change the fields

function setAllElementsSearchForm(mode)
{
	if(mode!=1)
	{
		checkAllElementsSearchForm();
	}

	if(document.myform.search_by_company.checked==false)
	{
		document.myform.ge_name.value='';
		document.myform.search_by_company.style.visibility = 'hidden';
	}

	if(document.myform.search_by_stand.checked==false)
	{
		document.myform.p_id.value=0;
		getStandsInput();
		document.myform.search_by_stand.style.visibility = 'hidden';
	}

  	if(document.getElementById("search_by_product"))
	{
		if(document.myform.search_by_product.checked==false)
		{
			clearProduct();
			document.myform.search_by_product.style.visibility = 'hidden';
		}
	}

	if(document.getElementById("search_by_trade"))
	{
		if(document.myform.search_by_trade.checked==false)
		{
		  if(typeof(document.forms["myform"].elements["td_id[]"].length)=="undefined")// if there is only one
		  {
				document.forms["myform"].elements["td_id"].checked=false;
			}
		  else// if there are more than one
		  {
		    for (var i=0; i < document.forms["myform"].elements["td_id[]"].length; i++)
		 		{
		    	document.forms["myform"].elements["td_id[]"][i].checked=false;
				}
		  }
 		  document.myform.search_by_trade.style.visibility = 'hidden';
		}
	}

	if(document.myform.search_by_country.checked==false)
	{
		document.myform.ctry_id.value=0;
		document.myform.search_by_country.style.visibility = 'hidden';
	}

	if(document.myform.search_by_keywords &&
       document.myform.search_by_keywords.checked==false)
	{
		document.myform.keywords.value='';
		document.myform.search_by_keywords.style.visibility = 'hidden';
	}
}



// --== checkAllElementsSearchForm ==--
// @Access : public ;;
// @role   : automaticly set the checkboxs' status in the search form
function checkAllElementsSearchForm()
{
	var form = document.myform;
	if (form.search_by_company.checked = (TrimString(form.ge_name.value) != '')) 
	{
    	Layer_Show('search_by_company');
  	}

  	var stand_group_checked_1=false;
  	if(typeof(document.forms["myform"].elements["stand_group[]"])!="undefined")
	{
	    for (var i=0; i < document.forms["myform"].elements["stand_group[]"].length; i++)
	 	{
	 		//alert(document.forms["myform"].elements["stand_group[]"][i].value);
	 		if(document.forms["myform"].elements["stand_group[]"][i].value != 0)
	    	{
				stand_group_checked_1=true;
	  			break;  		
	    	}
		}
	}

  	
	if(typeof(form.st_id)!="undefined")
	{
		stand_group_checked_2= (form.st_id.value!=0 || form.p_id.value!=0);
	} 
	else 
	{
		//if there is only one plan and no stand were selected, the box is not checked
		stand_group_checked_2= (form.one_plan == undefined && form.p_id.value != 0);
	}

	form.search_by_stand.checked=(stand_group_checked_1 || stand_group_checked_2);
	if (form.search_by_stand.checked)
	{
		Layer_Show('search_by_stand');
	}



	/*if(document.getElementById("search_by_product"))

	{

		form.search_by_product.checked=(last_chosen_categories!='');

	}*/

  

  if (form.search_by_country.checked = (form.ctry_id.value!=0)) {

    Layer_Show('search_by_country');

  }

	
  if (form.keywords) {
    if (form.search_by_keywords.checked = (TrimString(form.keywords.value)!='')) { 

      Layer_Show('search_by_keywords');
    }
  }

  

	

 // clear the checkbox of trade

	if(typeof(document.forms["myform"].elements["td_id[]"])!="undefined")

	{

	  if(typeof(document.forms["myform"].elements["td_id[]"].length)=="undefined")// if there is only one

	  {

			form.search_by_trade.checked=document.forms["myform"].elements["td_id"].checked;

		}

	  else// if there are more than one

	  {

			td_checked=false;

	    for (var i=0; i < document.forms["myform"].elements["td_id[]"].length; i++)

	 		{

	    	if(document.forms["myform"].elements["td_id[]"][i].checked)

	    	{

					td_checked=true;

	  			break;  		

	    	}

			}

			form.search_by_trade.checked=td_checked;

		}

    if (form.search_by_trade.checked) {

      Layer_Show('search_by_trade');

    }

	}

}



// --== sendSearchForm ==--

// @Access : public ;;

// @role   : validate and send the form to find the correspond exhibitors;;

//					 note that the default research is just by keywords, if we change the profil to advance research,

//					 just by clicking the button "advance research";

function sendSearchForm(adv)

{

	if(adv == 1)

	  add_params='&advanced=1';

	else

	  add_params='';

  add_params += "&mode=advanced_search";

	//test weither is some condition, if no, we don't need starting a research

	has_condition=false;	

	checkAllElementsSearchForm();

	

	//depend on the status of the checkbox, set the color of the titles

	/*if(document.getElementById("products_only"))

		title_new_product.className=document.myform.products_only.checked?"title_checkbox":'';

	if(document.getElementById("title_company"))

		title_company.className=document.myform.search_by_company.checked?"title_checkbox":'';

	title_stand.className=document.myform.search_by_stand.checked?"title_checkbox":'';

	//if(document.getElementById("products_only"))

		title_product.className=document.myform.search_by_product.checked?"title_checkbox":'';

	if(typeof(document.forms["myform"].elements["td_id[]"])!="undefined")

		title_trade.className=document.myform.search_by_trade.checked?"title_checkbox":'';

	

	title_ctry.className=document.myform.search_by_country.checked?"title_checkbox":'';

	title_keywords.className=document.myform.search_by_keywords.checked?"title_checkbox":'';*/



	if(research_profil=="advance")

	{

		if(document.myform.search_by_company.checked)

		{

			has_condition=true;	

			add_params+="&ge_name="+document.myform.ge_name.value.replace(/&/g,"%26");	// transform the '&' in the company name

		}

		if(document.myform.search_by_stand.checked)
		{
			has_condition=true;	
			
			stand_group_value="";
			if(typeof(document.forms["myform"].elements["stand_group[]"])!="undefined")
			{
			    for (var i=0; i < document.forms["myform"].elements["stand_group[]"].length; i++)
			 	{
			 		//alert(document.forms["myform"].elements["stand_group[]"][i].value);
			 		if(document.forms["myform"].elements["stand_group[]"][i].value != 0)
			    	{
						stand_group_value+=document.forms["myform"].elements["stand_group[]"][i].value+','; 		
			    	}
				}
				stand_group_value=stand_group_value.substring(0,stand_group_value.length-1);
				add_params+="&stand_group_value="+stand_group_value;	
				
			}
			
			if(typeof(document.myform.st_id)!="undefined")
			{
				if(document.myform.st_id.value!=0)
				{
					add_params+="&st_id="+document.myform.st_id.value;	
				}
			}

			if(document.myform.p_id.value!=0)
			{
				add_params+="&p_id="+document.myform.p_id.value;	
			}
		}

		

		//if(document.getElementById("search_by_product"))

		//{

			if(document.myform.search_by_product.checked)

			{

				has_condition=true;	

				//add_params+="&c_id="+document.myform.c_id.value;

				if(selected_categories_array.length > 0)

				{

					add_params+="&c_id="+selected_categories_array.join(',');

				}

			}

		//}

				

		if(typeof(document.forms["myform"].elements["td_id[]"])!="undefined")

		{

			if(document.myform.search_by_trade.checked)

			{

				// gereration the string of the selected trades seprating by ','

				has_condition=true;	

				td_ids_checked='';

			  if(typeof(document.forms["myform"].elements["td_id[]"].length)=="undefined")// if there is only one

		    {

		    	if(document.forms["myform"].elements["td_id[]"].checked)

		    	{

		    		td_ids_checked+=document.forms["myform"].elements["td_id"].value;

		    	}

		  	}

			  else// if there are more than one

			  {

			    for (var i=0; i < document.forms["myform"].elements["td_id[]"].length; i++)

			 		{

			    	if(document.forms["myform"].elements["td_id[]"][i].checked)

			    	{

			    		td_ids_checked+=document.forms["myform"].elements["td_id[]"][i].value+',';

			    	}

					}

					td_ids_checked=td_ids_checked.substring(0,td_ids_checked.length-1);

				}

				add_params+="&td_id="+td_ids_checked;	

			}

		}

		if(document.myform.search_by_country.checked)

		{

			has_condition=true;	

			if(document.myform.ctry_id.value!=0)

			{

				add_params+="&ctry_id="+document.myform.ctry_id.value;	

			}

		}

	}



	if(document.myform.search_by_keywords &&
       document.myform.search_by_keywords.checked)

	{

		has_condition=true;	

		add_params+="&keywords="+document.myform.keywords.value.replace(/&/g,"%26");// transform the '&' in the keywords

	}



	if(typeof(document.myform.products_only)!="undefined")

	{

		has_condition=true;	

		add_params+="&products_only="+(document.myform.products_only.checked?1:0);

	}



	/* if (search_mode=="products")

	{

		has_condition=true;

		add_params+="&list_style=products";

	} else{if (search_mode=="exhibitors") {

    has_condition=true;

    add_params+="&list_style=&products_only=";

  }} */



	if(has_condition)

	{

		add_params=add_params.replace('&','?'); // replace the first '&' to '?'

		//alert(add_params);

		List(url_encode("/visitors/exhibitor_list.php"+add_params));

	}

	else

	{

		//alert("pas de condition?");	

	}

	//alert(add_params);
}



// --== printExhibitorInfos ==--

// @Access : public ;;

// @Arg    : id of a exhibitor; id of a exhibtion (int);;

// @role   : pop a window for showing the infos of a exhibitor and print them;;

function printExhibitorInfos(ge_id)/*, ge_s_id*/

{

  var sIdStr = (arguments.length > 1 ? ("&ge_s_id=" + arguments[1]) : "");

	new_window=window.open("/visitors/exhibitor_infos_printable.php?mode=with_guide_info&info_ge_id="+ge_id + sIdStr, null,"scrollbars=1,toolbar=0,menubar=0,resizable=1,dependent=0,status=1,width=800,height=640,left=25,top=25");

}



// --== setStandsList ==--

// @Access : public ;;

// @Arg    : id of a plan

// @role   : get the list of stand who are in the same plan;;

function setStandsList(p_id,begin_letters)

{

	begin_letters=begin_letters.replace(/'/g, '');

	if((typeof(document.myform.st_id)=='undefined') || (typeof(document.myform.st_id)!='undefined' && document.myform.st_id.value==0))

	{

		document.myform.search_by_stand.checked=(this.value!=0);

	}



	if(typeof(document.myform.st_id)!="undefined")

	{

		GetStandsList_DIV("/visitors/search_form.php?stand_div_mode=stand_list&begin_letters="+begin_letters+"&p_id="+p_id);

	}

}



// --== setCategories ==--
// @Access : public ;;
// @Arg    : id of a category
// @role   : get the list of categories;;

function setCategories(cList,alert_1,alert_2)

{
	if(cList.value==-1)

	{

		// if we click on "up"

		//if(last_chosen_categories.length>1)

		{

			//parent_categories = last_chosen_categories.substring(0, last_chosen_categories.length-2);

			//last_chosen_categories = last_chosen_categories.substring(0, last_chosen_categories.length-1);

      lastChosenCategories.pop();

      lastChosenCategoryTexts.pop();

      lastChosenCategoryCodes.pop();

			document.getElementById("selected_category").innerHTML='&#160;';

      if (lastChosenCategories.length > 0) {

        SetCategoriesList_DIV("/visitors/search_form.php?list_categories_mode=change_categories_list&c_id="+lastChosenCategories.getLast());

      } else {

        SetCategoriesList_DIV("/visitors/search_form.php?list_categories_mode=change_categories_list");

      }

			return;

		}

	}

	else

	{

    //get the category codes for the current category list

    var cScript = document.getElementById("categoryCodes");

    var cCodes = new Function(cScript.innerHTML);

    var cCodes = cCodes();

    

		cList.options[cList.selectedIndex].text = cList.options[cList.selectedIndex].text.replace(/"/g, "'");

		document.getElementById("selected_category").innerHTML =

      (cList.value > 0)?

        ( cList.options[cList.selectedIndex].text.substring(0,20)

          +"...<a class=\"pluts_p\" href='JavaScript:addCategory();' title=\""+alert_1+" "+cList.options[cList.selectedIndex].text+" "+alert_2+"\">+</a>")

        :'';

		//last_chosen_categories = cList.value;

    lastChosenCategories.push(cList.value);

		//last_chosen_categories_text = cList.options[cList.selectedIndex].text;

    lastChosenCategoryTexts.push(cList.options[cList.selectedIndex].text);

    lastChosenCategoryCodes.push(cCodes['id' + cList.value]);

		SetCategoriesList_DIV("/visitors/search_form.php?list_categories_mode=change_categories_list&c_id=" + cList.value);

	}

}



// --== addCategory ==--

// @Access : public ;;

// @role   : add a category in the list;;

function addCategory()

{

  var lastCId = lastChosenCategories.getLast();

  

	if(indexOfArray(selected_categories_array, lastCId) == -1)

	{

    var newCode = lastChosenCategoryCodes.getLast();

    var parentSelected = false;

    var childrenSelected = false;

    var accept = false;

    var cCode;

    for (var i = 0; i < selected_categories_code_array.length; i++) {

      cCode = selected_categories_code_array[i];

      

      //if the code of the newly selected category begins by the code of one of the previously selected category then ...

      if (newCode.substr(0, cCode.length) == cCode) {

        parentSelected = true;

        accept = confirm(MSG__HIGHER_CATEGORY_TO_LOWER);

        break;

      } else {

        if (cCode.substr(0, newCode.length) == newCode) {

          childrenSelected = true;

          accept = confirm(MSG__LOWER_CATEGORY_TO_HIGHER);

          break;

        }

      }

    }



    if (!parentSelected && !childrenSelected) {

  		selected_categories_array.push(lastCId);

  		selected_categories_text_array.push(lastChosenCategoryTexts.getLast());

      selected_categories_code_array.push(newCode);

    } else {

      if (accept) {

        if (parentSelected) {

          for (i = 0; i < selected_categories_code_array.length; i++) {

            cCode = selected_categories_code_array[i];

            if (newCode.substr(0, cCode.length) == cCode) {

              deleteCategory(i);

              i--;

            }

          }

        } else {

          for (i = 0; i < selected_categories_code_array.length; i++) {

            cCode = selected_categories_code_array[i];

            if (cCode.substr(0, newCode.length) == newCode) {

              deleteCategory(i);

              i--;

            }

          }

        }

        selected_categories_array.push(lastCId);

    		selected_categories_text_array.push(lastChosenCategoryTexts.getLast());

        selected_categories_code_array.push(newCode);

      }

    }

	}

  if (document.forms.myform.search_by_product.checked = (selected_categories_array.length > 0)) {

    Layer_Show("search_by_product");

  }

	setListSelectedCategories();

}



// --== deleteCategory ==--

// @Access : public ;;

// @Arg    : index of a category to delete

// @role   : delete a category form the list;;

function deleteCategory(index) /*, refresh = true*/

{

	selected_categories_array.splice(index, 1);

	selected_categories_text_array.splice(index, 1);

  selected_categories_code_array.splice(index, 1);

  document.forms.myform.search_by_product.checked = (selected_categories_array.length > 0);



  if (arguments.length == 1 || (arguments.length > 1 && arguments[1])) {

    setListSelectedCategories();

  }

}



// --== setListSelectedCategories ==--

// @Access : public ;;

// @role   : list the selected categories;;

function setListSelectedCategories()

{

	str="<table><tr><td colspan='2'><b>"+LABEL__SEARCH_ON+"</b></td></tr>";

	for(i=0;i<selected_categories_array.length;i++)

	{

		//str+="<tr><td nowrap='1'>"+selected_categories_array[i]+' '+selected_categories_text_array[i].substring(0,20)+"...</td><td><a href='JavaScript:deleteCategory("+i+");' title=\"retirer la sélection\">-</a></td></tr>";

		str += "<tr><td>"+selected_categories_text_array[i].substring(0, 20)+"...</td><td><a href='JavaScript:deleteCategory("+i+");' title=\""+BUTTON__REMOVE_FROM_SEL+"\">-</a></td></tr>";

	}

	str+="</table>"

	document.getElementById("list_selected_categories").innerHTML=str;

}



// --== setListSelectedCategories ==--

// @Access : public ;;

// @role   : clear the selected categories;;

function clearProduct()

{

	selected_categories_array=new Array();

	selected_categories_text_array=new Array();

  selected_categories_code_array = new Array();

	document.getElementById("selected_category").innerHTML='&#160;';

	document.getElementById("list_selected_categories").innerHTML='';

	last_chosen_categories='';

	last_chosen_categories_text='';

	SetCategoriesList_DIV("/visitors/search_form.php?list_categories_mode=change_categories_list");

}



// --== setListSelectedCategories ==--

// @Access : public ;;

// @role   : send the simple search;;

function sendSimpleSearch(event)

{

	if(getEvent(event).keyCode ==13) {

    List('/visitors/exhibitor_list.php?mode=simple_search&keywords='+document.myform.keywords_simple.value.replace(/&/g,"%26"));

    selectM2Link(null);

  }

}



function myshowthediv(name,id)

{

  var nom = name+'-'+id;

  var d = document.getElementById(nom);

  if (d)

  {

     var status = d.style.display;

  }

  for (var i = 1; i<=10; i++)

  {

    if (document.getElementById(name+'-'+i) && (d && status!='block')) 

    {

      document.getElementById(name+'-'+i).style.display='none';

    }

  }



 if (d)

 {

  if (status!='block')

  {

     d.style.display='block';



     if(document.getElementById('buttons-bottom'))

     {

      document.getElementById('buttons-bottom').style.position = 'absolute';

      document.getElementById('buttons-bottom').style.position = 'relative';

     }

     

     id++;

     for (var i = id; i<=10; i++) 

     {

	     if(document.getElementById(name+'-'+i))

	     {

	       document.getElementById(name+'-'+i).style.position = 'absolute';

	       document.getElementById(name+'-'+i).style.position = 'relative';

	     }

     }

          

   }

   else

   {

   	d.style.display='none';

   }

 	}

}



//@args: a HTML link reference(Object); name of the css class for the selected links (string);;

//@role: change the style of the current menu link to the selected style and remove the selected style from the other links;;

//@note: if the link argument is null, the function will only unselect the currently selected menu item;;

function selectM2Link(link) {

  //var menuLinks = link.parentNode.parentNode.getElementsByTagName("dd");

  /* for(var i = 0; i < menuLinks.length; i++) {

    lk = menuLinks.item(i).firstChild;

    if (lk != undefined) {

      if (lk.tagName == "A") {

        if (lk.className == className) {

          lk.className = "";

          break;

        }

      }

    }

  } */

  var currentLink = document.getElementById('selectedM2Link');
  if (currentLink != undefined) {
  	
    currentLink.className = "";

    currentLink.id = undefined;

  }

  if (link != null) {

    link.className = 'nav002-focus';

    link.id = "selectedM2Link";

  }
  

}


function selectMLink(link) {
  var currentLink = document.getElementById('selectedMLink');
  if (currentLink != undefined) {
    currentLink.className = "";
    currentLink.id = undefined;
  }

  if (link != null) {
    link.className = 'nav001-focus';
    link.id = "selectedMLink";
  }
}



function selectTargetLink(link) {
  var currentLink = document.getElementById('selectedMLink');
  if (currentLink != undefined) {
    currentLink.className = "";
    currentLink.id = undefined;
  }

  if (link != null) {
  	
  	floor_link = document.getElementsByName(link);
    floor_link[0].className = 'nav001-focus';
    floor_link[0].id = "selectedMLink";
  }
}

// --== showResultOfProducts ==--

// @Access : public ;;

// @role   : switch the mode of the list of exhibitors, in the "products mode";;

function showResultOfProducts()

{

	if(search_mode=="products")

	{

    document.getElementById("nav001").className = "nfrProds";

		search_mode="exhibitors";

		document.myform.products_only.checked=false;

		sendSearchForm("exhibitors");

		document.getElementById("switch_mode").innerHTML= LINK__TO_PRODUCT_LIST;

	}

	else

	{

    document.getElementById("nav001").className = "nfr";

		search_mode="products";

    document.myform.products_only.checked=true;

		sendSearchForm("products");

		document.getElementById("switch_mode").innerHTML= LINK__TO_EXHIBITOR_LIST;

	}

}



//@args: id of a layer (String), new value for the display property;;

//@role: try to set the display value of the given layer if it exists;;

function trySetDisplay(layerId, value) {

  var layerObj = document.getElementById(layerId);

  if (layerObj != undefined) {

    layerObj.style.display = value;

  }

}



//@args: a select list object;;

//@role: change the given select list size when the mouse come over;;

function fixSelectIE(selId) {

  var selObj = document.getElementById(selId);

  

  function selMouseOver() {

    this.oldPosition = selObj.style.position != '' ? selObj.style.position : getObjectStyle(selObj, 'position');

    this.oldWidth = selObj.style.width != '' ? selObj.style.width : getObjectStyle(selObj, 'width');

    var selHeight = selObj.style.height != '' ? selObj.style.height : getObjectStyle(selObj, 'height');

    

    //create a dummy list at the same place as the current list 

    //It act as a placeholder which  avoids the parent div to retract itself when the current list position will be set to absolute.

    this.dummyList = document.createElement("select");

    with (this.dummyList.style) {

      height = selHeight;

      width = "0px";

      visitbility = "hidden";

    }

    selObj.parentNode.appendChild(this.dummyList);

    

    this.style.width = 'auto';

	  this.style.position = 'absolute';

    var selRight = this.offsetLeft + this.offsetWidth;

    var selTop = this.offsetTop;

    

    //An invisible div is created to the left of the list, it is used to detect when the mouse get out of the list.

    //This trick was used because the onmouseout event is somewhat bugged for the selection lists.

    this.dummyDiv = document.createElement("div");

    //dummyDiv.setAttribute("style", "z-index: 10;");

    with (this.dummyDiv.style) {

      position = "absolute";

      top = "-1000px";

      left = selRight + "px";

      width = "100px";

      height = (1000 + selTop + 50) + "px";

      backgroundColor = "transparent";

    }

    this.parentNode.appendChild(this.dummyDiv);

    

    this.onmouseover = function() {}

    

    var sel1 = this;

    this.oldOnchange = this.onchange;

    this.onchange = function() { this.oldOnchange(); selChange.call(sel1); } ;

    //document.getElementById("main_content").onmouseover = function() { selChange.call(sel1); } ;

    //document.getElementById("list").onmouseover = function() { selChange.call(sel1); } ;

    this.dummyDiv.onmouseover = function() { selChange.call(sel1); } ;

  }

  

  function selChange() {

    this.style.position = this.oldPosition;

    this.style.width = this.oldWidth;

    this.parentNode.removeChild(this.dummyList);

    this.parentNode.removeChild(this.dummyDiv);

    this.onmouseover = selMouseOver;

    this.onchange = this.oldOnchange;

    //document.getElementById("main_content").onmouseover = function() {};

    //document.getElementById("list").onmouseover = function() {};

  }

  selObj.onmouseover = selMouseOver;

  //alert("ok");

}


function sendSimpleSearchForm()
{
	var stand_group_value="";
	if (document.forms["myform"].keywords_simple.value.split(" ").length > MAX_KEY_WORDS ||
	    (document.forms["myform"].keywords &&
         document.forms["myform"].keywords.value.split(" ").length > MAX_KEY_WORDS)) {
	  alert(MSG__TOO_MANY_KEYWORDS);
	  return;
	}
	if(typeof(document.forms["myform"].elements["stand_group[]"])!="undefined")
	{
		for (var i=0; i < document.forms["myform"].elements["stand_group[]"].length; i++)
		{
			//alert(document.forms["myform"].elements["stand_group[]"][i].value);
			if(document.forms["myform"].elements["stand_group[]"][i].value != 0)
			{
				stand_group_value+=document.forms["myform"].elements["stand_group[]"][i].value+',';
			}
		}
		stand_group_value=stand_group_value.substring(0,stand_group_value.length-1);

	}
	List(url_encode('/visitors/exhibitor_list.php?mode=simple_search&keywords='+document.myform.keywords_simple.value.replace(/&/g,'%26')+'&stand_group_value='+stand_group_value));
	document.myform.keywords_simple.value = ""; // added by JFG
}


function clearSimpleSearchForm()
{
	List("/visitors/exhibitor_list.php?mode=simple_search");
}


function url_encode(string)
{
	var string;
	var safechars = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz/-_.&?=|";//
	var hex = "0123456789ABCDEF";
	var encoded_string = "";
	for(var i = 0; i < string.length; i++)
	{
		var character = string.charAt(i);
		if(character == " ")
		{
			encoded_string += "+";
		}
		else if(safechars.indexOf(character) != -1)
		{
			encoded_string += character;
		}
		else
		{
			var hexchar = character.charCodeAt(0);
			if(hexchar > 255)
			{
				encoded_string += "+";
			}
			else
			{
				encoded_string += "%";
				encoded_string += hex.charAt((hexchar >> 4) & 0xF);
				encoded_string += hex.charAt(hexchar & 0xF);
			}
		}
	}
	return encoded_string;
}
