var dom_browser = (document.getElementById)?true:false;
var ie4_browser = (document.all && !document.getElementById)?true:false;
var old_browser = ( (!dom_browser && !ie4_browser) || (navigator.userAgent.toLowerCase().indexOf("opera") != -1) )?true:false;

var gAnchorHighlighted = "";
var gAnchorSelected    = "";

var gToolBox = null;

var menu_hTimer              = null;
var menu_nActiveMenu         = -1;
var menu_sActiveMenuOldClass = "";

/***********************************************************************************************************************/

var tabTranslation = new Array();       /* US, UK, AU, FR, DE, IT, ES, PT */

tabTranslation["form-salutation"]         = ["Salutation","Salutation","Salutation","Civilité","Salutation","Salutation","Sr./Sra.","Salutation"];
tabTranslation["form-first_name"]         = ["First Name","First Name","First Name","Prénom","Vorname","Nome","Nombre","Nome Próprio"];
tabTranslation["form-last_name"]          = ["Last Name","Last Name","Last Name","Nom","Name","Cognome","Apellido(s)","Apelido(s)"];
tabTranslation["form-job_title"]          = ["Job Title","Job Title","Job Title","Fonction","Titel/Funktion","Titolo","Cargo","Função"];
tabTranslation["form-departement"]        = ["Department/Function","Department/Function","Department/Function","Département","Abteilung/Funktion","Dipartimento/Funzione","Departamento","Departamento"];
tabTranslation["form-organization"]       = ["Organization","Organisation","Organisation","Société","Firma","Società","Enpresa","Enpresa"];
tabTranslation["form-email"]              = ["Email","Email","Email","Email","E-Mail","E-mail","Email","Email"];
tabTranslation["form-address"]            = ["Address","Address","Address","Adresse","Straße","Indirizzo","Dirección","Morada da Empresa"];
tabTranslation["form-city"]               = ["City","City","City","Ville","Ort","Città","Ciudad","Cidade"];
tabTranslation["form-state"]              = ["State","County","State/Territory","État/Région","Bundesland","Provincia","Provincia","Localidade"];
tabTranslation["form-zip"]                = ["Zip","Postcode","Postcode","Code postal","PLZ","Codice postale","Código postal","Código postal"];
tabTranslation["form-country"]            = ["Country","Country","Country","Pays","Land","Nazione","País","Pais"];
tabTranslation["form-phone"]              = ["Phone","Phone","Phone","Téléphone","Telefon","Telefono","Teléfono","Telefone"];
tabTranslation["form-fax"]                = ["Fax","Fax","Fax","Fax","Fax","Fax","Fax","Fax"];
tabTranslation["form-comments"]           = ["Comments","Comments","Comments","Commentaire","Kommentar","Commenti","Comentarios","Comentários"];
tabTranslation["form-industry"]           = ["Industry","Industry","Industry","Secteur d'activité","Branche","Settore","Sector de Actividad","Sector de Actividad"];
tabTranslation["form-annual_revenue"]     = ["Annual Revenue","Annual Revenue","Annual Revenue","Chiffre d'affaire","Jährlicher Umsatz","Fatturato","Volumen de negocio","Volume de negócios"];
tabTranslation["form-employees"]          = ["Employees","Employees","Employees","Nombre de salari&eacute;s","Anzahl Mitarbeiter","Numero di dipendenti","N&uacute;mero de epleados","Numero de empregados"];
tabTranslation["form-erp"]                = ["Primary business application","Primary business application","Primary business application","ERP","ERP","ERP","ERP","ERP"];
tabTranslation["form-existing_customer"]  = ["Existing customer","Existing customer","Existing customer","Client Esker","Kunden","Clienti Esker","Cliente de Esker","Cliente da Esker"];

tabTranslation["val-not_empty"]   = ["must not be empty","must not be empty","must not be empty","ne doit pas être vide","Bitte machen Sie eine Angabe!","non deve essere vuoto","debe ser cumplimentado","dever ser preenchido"];
tabTranslation["val-number"]      = ["must be a number","must be a number","must be a number","doit contenir un nombre","Bitte geben Sie eine Zahl ein!","non deve essere vuoto","introduzca un número","introduza um numero"];
tabTranslation["val-email"]       = ["must be a valid email address","must be a valid email address","must be a valid email address","doit contenir une adresse email valide","Bitte geben Sie eine gültige E-Mail-Adresse ein!","deve contenere un indirizzo e-mail valido","debe contener una dirección de email válida","deve ter um endereço de correio válido"];
tabTranslation["val-url"]         = ["must be a valid HTTP URL address","must be a valid HTTP URL address","must be a valid HTTP URL address","doit contenir une adresse HTTP valide","Bitte geben Sie eine gültige http-Adresse ein!","deve contenere un indirizzo HTTP valido","debe contener una dirección HTML válida","deve ter um endereço HTML válido"];
tabTranslation["val-range-1"]     = ["must be a number between","must be a number between","must be a number between","doit contenir un nombre entre","Bitte geben Sie eine Zahl von","deve contenere un numero tra","debe ser un número entre","deve ser um numero entre"];
tabTranslation["val-range-2"]     = ["and","and","and","et","bis","e","y","e"];
tabTranslation["val-not_valid"]   = ["is not a valid entry","is not a valid entry","is not a valid entry","n'est pas valide","Eingabe nicht gültig!","non è valido","entrada no válida","não é uma entrada válida"];
tabTranslation["val-not_checked"] = ["must be specified","must be specified","must be specified","n'est pas indiqué(e)","","","debe estar indicado","deve ser especificado"];


tabTranslation["search-default"]     = ["Search...","Search...","Search...","Rechercher...","Suchen...","Cerca...","Buscar..."];
tabTranslation["search-err_keyword"] = ["You must enter at least one keyword","You must enter at least one keyword","You must enter at least one keyword","Saisissez d'abord le texte à rechercher","Sie müssen mindestens einen Suchbegriff eingeben","Immettere almeno una parola chiave","Debe especificar al menos una palabra clave"];
tabTranslation["search-err_section"] = ["You must select at least one section","You must select at least one section","You must select at least one section","Vous devez inclure au moins une section","Sie müssen mindestens einen Bereich wählen","Specificare almeno una sezione","Debe especificar al menos una sección"];

/*---------------------------------------------------------------------------------------------------------------------*/
function Translate(sToken, sLanguage)
{
  var nIndex;

  if (! sLanguage)
    if ( document.formular && document.formular["_PF_Form_Language"] )
      sLanguage = document.formular["_PF_Form_Language"].value
    else
      sLanguage = gLanguage

  //sLanguage = "FR"

  switch (sLanguage)
  {
    case "US" : nIndex = 0; break;
    case "UK" : nIndex = 1; break;
    case "AU" : nIndex = 2; break;
    case "FR" : nIndex = 3; break;
    case "DE" : nIndex = 4; break;
    case "IT" : nIndex = 5; break;
    case "ES" : nIndex = 6; break;
    case "PT" : nIndex = 7; break;
    default: nIndex = 0;
  }
  
  if ( tabTranslation[sToken] )
      return tabTranslation[sToken][nIndex];

  return sToken;
}

function pg_InitPage()
{
  
  if (window.hl_Highlight)
    hl_Highlight();  
    
	if (window.AdditionnalInit)
		AdditionnalInit();
}


/*-----------------------------------------------------------------------------------------------------------------*/

var form_has_been_submitted_bool;
form_has_been_submitted_bool=false;

function SubmitForm()
{
  var sStr = ""

	if ( (document.formular["First name"]) && (gMandatoryFields & 0x00000001) )
		sStr += IsValidString(document.formular["First name"].value, Translate("form-first_name") );

	if ( (document.formular["Last name"]) && (gMandatoryFields & 0x00000002) )
		sStr += IsValidString(document.formular["Last name"].value, Translate("form-last_name") );

	if ( (document.formular["Title"]) && (gMandatoryFields & 0x00000004) )
	  sStr += IsValidString(document.formular["Title"].value, Translate("form-job_title") );
	  
	  if ( (document.formular["Salutation"]) && (gMandatoryFields & 0x00000006) )
	  sStr += IsValidString(document.formular["Salutation"].value, Translate("form-salutation") );

	if ( (document.formular["Departement"]) && (gMandatoryFields & 0x00001000) )
	  sStr += IsValidString(document.formular["Departement"].value, Translate("form-departement") );

	if ( (document.formular["Company"]) && (gMandatoryFields & 0x00000008) )
	  sStr += IsValidString(document.formular["Company"].value, Translate("form-organization") );

	if ( (document.formular["Email"]) && (gMandatoryFields & 0x00000010) )
	  sStr += IsValidEmail(document.formular["Email"].value, Translate("form-email") );

	if ( (document.formular["Street"]) && (gMandatoryFields & 0x00000020) )
	  sStr += IsValidString(document.formular["Street"].value, Translate("form-address") );

	if ( (document.formular["City"]) && (gMandatoryFields & 0x00000040) )
	  sStr += IsValidString(document.formular["City"].value, Translate("form-city") );

	if ( (document.formular["State"]) && (gMandatoryFields & 0x00000080) )
	  sStr += IsValidString(document.formular["State"].value, Translate("form-state") );

	if ( (document.formular["Zip"]) && (gMandatoryFields & 0x00000100) )
	  sStr += IsValidString(document.formular["Zip"].value, Translate("form-zip") );

	if ( (document.formular["Country"]) && (gMandatoryFields & 0x00000200) )
	  sStr += IsValidString(document.formular["Country"].value, Translate("form-country") );

	if ( (document.formular["Phone"]) && (gMandatoryFields & 0x00000400) )
	  sStr += IsValidString(document.formular["Phone"].value, Translate("form-phone") );

	if ( (document.formular["Fax"]) && (gMandatoryFields & 0x00000800) )
	  sStr += IsValidString(document.formular["Phone"].value, Translate("form-fax") );


	if ( (document.formular["Existing customer"]) && (gMandatoryFields & 0x00002000) )
	  sStr += IsRadioChecked(document.formular["Existing customer"], Translate("form-existing_customer") );


	if ( (document.formular["Comments"]) && (gMandatoryFields & 0x00010000) )
	  sStr += IsValidString(document.formular["Comments"].value, Translate("form-comments") );

	if ( (document.formular["Industry"]) && (gMandatoryFields & 0x00020000) )
	  sStr += IsValidString(document.formular["Industry"].value, Translate("form-industry") );

	if ( (document.formular["Annual revenue"]) && (gMandatoryFields & 0x00040000) )
	  sStr += IsValidString(document.formular["Annual revenue"].value, Translate("form-annual_revenue") );

	if ( (document.formular["Employees"]) && (gMandatoryFields & 0x00080000) )
	  sStr += IsValidString(document.formular["Employees"].value, Translate("form-employees") );

	if ( (document.formular["ERP"]) && (gMandatoryFields & 0x00100000) )
	  sStr += IsValidString(document.formular["ERP"].value, Translate("form-erp") );

	if (window.AdditionnalCheck)
		sStr = AdditionnalCheck(sStr)

  if (sStr != "")
  {
    alert(sStr)
  }
  else
  {
    document.formular.submit();
	form_has_been_submitted_bool=true;
	}
}


/*---------------------------------------------------------------------------------------------------------------------*/
function ClearForm()
{
  var i;

  document.formular.reset()

  for (i = 0 ; i < document.formular.length ; i++)
    if (document.formular[i].name.indexOf("_PF_") != 0)
      document.formular[i].value = "";
}

/*---------------------------------------------------------------------------------------------------------------------*/
function SetLowerCase(oField)
{
  if (oField.value != "")
    oField.value = oField.value.toLowerCase();
}

/*---------------------------------------------------------------------------------------------------------------------*/
function SetUpperCase(oField)
{
  if (oField.value != "")
    oField.value = oField.value.toUpperCase();
}

/*---------------------------------------------------------------------------------------------------------------------*/
function SetCapital(oField)
{
  var sTemp;
  var sChar;
  var bToCapital;

  if (oField.value != "")
  {
    sTemp = '';
    bToCapital = true;

    for (i=0; i < oField.value.length ; i++)
    {
      sChar = oField.value.charAt(i);

      if (bToCapital)
        sTemp += sChar.toUpperCase();
      else
        sTemp += sChar.toLowerCase();

      bToCapital = ( (sChar == ' ') || (sChar == '-') );
    }

    oField.value = sTemp;
  }
}



/*---------------------------------------------------------------------------------------------------------------------*/

function IsValidNumber(sValue, sName)
{
  if ( (sValue == null) || (sValue == "") )
    return "[" + sName + "] " + Translate("val-not_empty") + "\n";

  if (isNaN(sValue))
    return "[" + sName + "] " + Translate("val-number") + "\n";

  return "";
}

/*---------------------------------------------------------------------------------------------------------------------*/

function IsValidString(sValue, sName)
{
  if ( (sValue == null) || (sValue == "") )
    return "[" + sName + "] " + Translate("val-not_empty") + "\n";

  return "";
}

/*---------------------------------------------------------------------------------------------------------------------*/

function IsValidEmail(sValue, sName)
{
  if (sValue == null)
      return "[" + sName + "] " + Translate("val-email") + "\n";

  var pos = sValue.indexOf('@');

  if (pos < 1 || pos == (sValue.length-1))
     return "[" + sName + "] " + Translate("val-email") + "\n";

  return "";
}

/*---------------------------------------------------------------------------------------------------------------------*/

function IsValidHTTPURL(sValue, sName)
{
  if (sValue == null)
    return "[" + sName + "] " + Translate("val-not_empty") + "\n";

  var pos1 = sValue.indexOf('http://');
  var pos2 = sValue.lastIndexOf('.');

  if (pos1 != 0 || pos2 < 8 || pos2 > (sValue.length-3))
     return "[" + sName + "] " + Translate("val-url") + "\n";

  return "";
}

/*---------------------------------------------------------------------------------------------------------------------*/

function IsInRange(sValue, min, max, sName)
{
  if ((sValue == null) || isNaN(sValue) || (sValue < min || max < sValue))
      return "[" + sName + "] " + Translate("val-range-1") + " " + min + " " + Translate("val-range-2") + " " + max + "\n";

  return "";
}

/*---------------------------------------------------------------------------------------------------------------------*/

function IsMatchingRegEx(sValue, sPattern, sFlag,  sName)
{
  if (sValue == null)
      return "[" + sName + "] " + Translate("val-not_valid") + "\n";

  var rRegEx = new RegExp(sPattern, sFlag);

  if (! rRegEx.test(sValue))
      return "[" + sName + "] " + Translate("val-not_valid") + "\n";

  return "";
}

/*---------------------------------------------------------------------------------------------------------------------*/

function IsRadioChecked(oRadioGroup,  sName)
{
  var i;

  if (! oRadioGroup)
      return "";

  if (! oRadioGroup.length)
      return "";

  if (oRadioGroup.length == 0)
      return "";
  
  for (i = 0 ; i < oRadioGroup.length ; i++)
    if (oRadioGroup[i].checked)
      break;


  if (i == oRadioGroup.length)   
    return "[" + sName + "] " + Translate("val-not_checked") + "\n";

  return "";
}


function lon(cellid){document.getElementById(cellid).className='clon';}
function loff(cellid){document.getElementById(cellid).className='cloff';}



function onQuickSearch_Submit(obj)
{
	obj.action=obj.action+'?search='+obj.search.value;

}
 function DoSearch()
{
	var sStr = "";
  var oForm;

  oForm = document.forms["formular"];

	sStr = IsValidString(oForm.search.value, "***");
	if (sStr != "")
    sStr = Translate("search-err_keyword");

  if (   ( (oForm.include_eds)   && (oForm.include_eds.type   == "checkbox") && (! oForm.include_eds.checked)   )
      && ( (oForm.include_efss)  && (oForm.include_efss.type  == "checkbox") && (! oForm.include_efss.checked)  )
      && ( (oForm.include_ehas)  && (oForm.include_ehas.type  == "checkbox") && (! oForm.include_ehas.checked)  )
      && ( (oForm.include_corpo) && (oForm.include_corpo.type == "checkbox") && (! oForm.include_corpo.checked) ) )
    sStr += Translate("search-err_section");


	if (sStr != "")
		alert(sStr);
	else
		oForm.submit();
}
