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-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()
{
  gToolBox = dom_GetObject("Toolbox");

  if ( (gToolBox != null) && (window.tb_Display) )
  {
    tb_Display("init");
    dom_Show(gToolBox);

    window.onresize = function() { tb_Display("resize"); };
    window.onscroll = function() { tb_Display("scroll"); };
  }

  if (window.hl_Highlight)
    hl_Highlight();  
    
	if (window.AdditionnalInit)
		AdditionnalInit();
}


/***********************************************************************************************************************/
/***********************************************************************************************************************/
/***********************************************************************************************************************/
/***********************************************************************************************************************/

function ddmenu_SetTimeout()
{
  menu_hTimer = setTimeout("ddmenu_Hide()", 250);
}

/*-----------------------------------------------------------------------------------------------------------------*/
function ddmenu_ClearTimeout()
{
  if (menu_hTimer != null)
  {
    clearTimeout(menu_hTimer);
    menu_hTimer = null;
  }
}

/*-----------------------------------------------------------------------------------------------------------------*/
function ddmenu_Hide()
{
  if (menu_nActiveMenu != -1)
  {
    var oMenuItem  = dom_GetObject('Tab_' + menu_nActiveMenu);
    var oMenuTable = dom_GetObject('Menu' + menu_nActiveMenu + "_table");

    dom_Hide(oMenuTable);
    oMenuItem.className = menu_sActiveMenuOldClass;
    menu_nActiveMenu   = -1;
  }
}

/*-----------------------------------------------------------------------------------------------------------------*/
function ddmenu_Show(nTab, nDirection)
{
  var oMenuTable = null;
  var oMenuItem  = null;
  var oMenuBar   = null;

  // When switching from one Tab to another/same, we need to cancel the timeout
  ddmenu_ClearTimeout();

  // If the right dropdown menu is already displayed, do nothing
  // This happens with IE when the mouse move over a link: ddmenu_Show() is called twice
  if (nTab == menu_nActiveMenu)
    return;

  // When switching from one Tab to another, we need to hide previous menu (if any)
  ddmenu_Hide();

  // Get needed objects
  oMenuBar   = dom_GetObject('MenuBar');
  oMenuItem  = dom_GetObject('Tab_' + nTab);
  oMenuTable = dom_GetObject('Menu' + nTab + "_table");

  // Highlight the menu tab
  menu_sActiveMenuOldClass = oMenuItem.className;
  oMenuItem.className      = "Selected";
  menu_nActiveMenu         = nTab;

  // Check if a DropDown menu is defined... (Career tab has no dropdown menu!)
  if (oMenuTable == null)
    return;

  // Yes : display it
  switch (nDirection)
  {
    case -1:    dom_SetLeft(oMenuTable, dom_GetLeft(oMenuBar) + dom_GetLeft(oMenuItem) );  break;
    case  1:    dom_SetLeft(oMenuTable, dom_GetLeft(oMenuBar) + dom_GetLeft(oMenuItem) + dom_GetWidth(oMenuItem) - dom_GetWidth(oMenuTable) - 8 );  break;
  }
  dom_SetTop(oMenuTable, dom_GetTop(oMenuBar) + 25);
  dom_Show(oMenuTable);
}

/***********************************************************************************************************************/
/***********************************************************************************************************************/
/***********************************************************************************************************************/
/***********************************************************************************************************************/

function dom_GetObject(sID)
{
  if (dom_browser)
    return document.getElementById(sID);
  if (ie4_browser)
    return document.all[sID];

  return null;
}

/*---------------------------------------------------------------------------------------------------------------------*/
function dom_GetTop(oElement)
{
  if (dom_browser)
    return oElement.offsetTop;
  else
    return 0;
}
function dom_SetTop(oElement, nValue)
{
  if (dom_browser)
    oElement.style.top = nValue;
}

/*---------------------------------------------------------------------------------------------------------------------*/
function dom_GetLeft(oElement)
{
  if (dom_browser)
    return oElement.offsetLeft;
  else
    return 0;
}
function dom_SetLeft(oElement, nValue)
{
  if (dom_browser)
    oElement.style.left = nValue;
}

/*---------------------------------------------------------------------------------------------------------------------*/
function dom_GetWidth(oElement)
{
  if (dom_browser)
    return oElement.clientWidth;
  else
    return 0;
}
function dom_SetWidth(oElement, nValue)
{
  if (dom_browser)
    oElement.style.width = nValue;
}

/*---------------------------------------------------------------------------------------------------------------------*/
function dom_GetHeight(oElement)
{
  if (dom_browser)
    return oElement.clientHeight;
  else
    return 0;
}
function dom_SetHeight(oElement, nValue)
{
  if (dom_browser)
    oElement.style.height = nValue;
}

/*---------------------------------------------------------------------------------------------------------------------*/
function dom_GetScrollX(oElement)
{
  if (dom_browser)
 	  return oElement.scrollLeft;
  else
    return 0;
}
function dom_GetScrollY(oElement)
{
  if (dom_browser)
 	  return oElement.scrollTop;
  else
    return 0;
}

/*---------------------------------------------------------------------------------------------------------------------*/
function dom_Show(oElement)
{
  if (oElement)
  {
    oElement.style.visibility = "visible";
    oElement.style.zIndex     = 10;
  }
    
}

function dom_Hide(oElement)
{
  if (oElement)
  {
    oElement.style.visibility = "hidden";
    oElement.style.zIndex     = -10;
  }
}

/*---------------------------------------------------------------------------------------------------------------------*/
function dom_Enable(oElement)
{
  if (oElement)
    oElement.style.display = "auto";
}
function dom_Disable(oElement)
{
  if (oElement)
    oElement.style.display = "none";
}

/*---------------------------------------------------------------------------------------------------------------------*/
function dom_GetInnerHTML(oElement)
{
  if (oElement)
    return oElement.innerHTML;
}
function dom_SetInnerHTML(oElement, sValue)
{
  if (oElement)
    oElement.innerHTML = sValue;
}


/***********************************************************************************************************************/
/***********************************************************************************************************************/
/***********************************************************************************************************************/
/***********************************************************************************************************************/
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["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 onQuickSearch_Submit()
{
	if (document.quicksearch.search.value == Translate("search-default"))
		 document.quicksearch.search.value = ""
}

function onQuickSearch_Click()
{
  document.quicksearch.submit();
}

function onQuickSearch_Focus()
{
	if (document.quicksearch.search.value == Translate("search-default"))
		 document.quicksearch.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();
}

/***********************************************************************************************************************/
/***********************************************************************************************************************/
/***********************************************************************************************************************/
/***********************************************************************************************************************/

function swf_DisplayFlash(sSWFPath, nWidth, nHeight, sNodeToKill)
{
	var UseFlash = 0;


	if (navigator.mimeTypes && navigator.mimeTypes["application/x-shockwave-flash"] )	// Check for Flash version 4 or greater in Netscape
	{
		var plugin = navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin;
		if (plugin && parseInt(plugin.description.substring(plugin.description.indexOf(".")-1))>=4)
			UseFlash = 1;
	}
	else if (navigator.appName && navigator.appName.indexOf("Microsoft") != -1 && navigator.userAgent.indexOf("Windows") != -1 && navigator.userAgent.indexOf("Windows 3.1") == -1) 		// Assume any Windows IE except for Windows 3.1 supports the OBJECT tag
	{
		UseFlash = 1;
	}

	if (window.gUserAgent && gUserAgent.indexOf("CLICKTRACKS") != -1)
		UseFlash = 0;

	if (window.location.href.indexOf("swf=no") != -1)
		UseFlash = 0;


	if ( UseFlash )  // Use Flash player
	{
		document.write('<OBJECT classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" width="' + nWidth + '" + height="' + nHeight + '">\n');
		document.write(' <param name="movie" value="' + sSWFPath + '">\n');
		document.write(' <param name="quality" value="high">\n');
		document.write(' <param name="wmode" value="opaque">\n');
		document.write(' <embed src="' + sSWFPath + '" width="' + nWidth + '" height="' + nHeight + '" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash"></embed>\n');
		document.write('</OBJECT>');

		if (sNodeToKill)
		{
			var oNode   = dom_GetObject(sNodeToKill);
			var oParent = oNode.parentNode;

			oParent.removeChild(oNode);
		}
	}

	return UseFlash;
}


/***********************************************************************************************************************/
/***********************************************************************************************************************/
/***********************************************************************************************************************/
/***********************************************************************************************************************/

function hl_Highlight(sID)
{
	var i;


	if (! sID)
		sID = window.location.hash;

	i = sID.indexOf("#");
	if (i == -1)
		return;

	sID = sID.substring(i);
	if (sID == gAnchorSelected)
		return;

	if (document.getElementById(sID))
	{
		hl_UnHighlight(gAnchorHighlighted);
		document.getElementById(sID).className = "AnchorHighlighted";
		gAnchorHighlighted = sID;
	}
}


/*---------------------------------------------------------------------------------------------------------------------*/
function hl_Select(sID)
{
	var i;

	if (! sID)
		sID = window.location.hash;

	i = sID.indexOf("#");

	if (i == -1)
		return;

	sID = sID.substring(i);

	if (document.getElementById(sID))
	{
		hl_UnSelect(gAnchorSelected);
		document.getElementById(sID).className = "AnchorSelected";
		gAnchorSelected = sID;
	}
}

/*---------------------------------------------------------------------------------------------------------------------*/
function hl_UnHighlight(sID)
{
	if (! sID)
		sID = gAnchorHighlighted;

	if (sID == gAnchorSelected)
		return;

	if (document.getElementById(sID))
		document.getElementById(sID).className = "";
}

/*---------------------------------------------------------------------------------------------------------------------*/
function hl_UnSelect(sID)
{
	if (! sID)
		sID = gAnchorSelected;

	if (document.getElementById(sID))
		document.getElementById(sID).className = "";
}

/***********************************************************************************************************************/
/***********************************************************************************************************************/
/***********************************************************************************************************************/
/***********************************************************************************************************************/

function l_DisplayLayer(oLayer, nOffsetX, nOffsetY, nWidth, nHeight)
{
  if (oLayer)
  {
    if (nOffsetY)
    {
       if (nOffsetY >=0)
           dom_SetTop(oLayer, nOffsetY);
       else
           dom_SetBottom(oLayer, -nOffsetY);
    }

    if (nOffsetX)
    {
      if (nOffsetX >=0)
          dom_SetLeft(oLayer, nOffsetX);
      else
          dom_SetRight(oLayer, -nOffsetX);
    }

    if (nWidth)
      dom_SetWidth(oLayer, nWidth);

    if (nHeight)
      dom_SetHeight(oLayer, nHeight);

    dom_SetZIndex(oLayer, 5);
    dom_Show(oLayer);
  }
}

/**********************************************KEYWORD HIGHLIGHTING************************************************/
/***********************************************************************************************************************/
/***********************************************************************************************************************/
/***********************************************************************************************************************/
/***********************************************************************************************************************/

function KeyWordGetColor(idx)
{
    var color = '#FFF600';
    return color;
}  

function KeyWordGetKeyWordsFromQueryString()
{
   
   var keywords = new Array();
   var ref = document.location.href.toUpperCase();
   
   
     qIndex = ref.indexOf('?SEARCH=');

     if (qIndex < 1) { return keywords; }
     
     ref = KeyWordReplace(ref,'%22','');
	 
     qs = ref.substring(qIndex + 8,ref.length);

     prm = qs.split('%20');

     for (i=0;i<prm.length;i++)
     {
		
		keywords[i]=prm[i];  	 
	 }      
   
   return keywords;
}

function KeyWordHiLite()
{ 
  var Links;
  var rng;
  var before = '<font style="color: #000000;text-decoration:none;background-color: ';
  var after = '</b></font>';

  try
  {
     
    keywords = KeyWordGetKeyWordsFromQueryString();

    if (keywords.length < 1) { return true; }
 
       for(k=0;k<keywords.length;k++)
    {
		rng = document.body.createTextRange();  
  
      for (i=0;rng.findText(keywords[k])!=false; i++)
      { 
 
        try       { rng.pasteHTML(before + KeyWordGetColor(k) + ';"><b>' +  rng.text + after);   }
        catch (e) { KeyWordProcessError('KeyWordHiLite Text Range',e);    }	
        finally   { rng.collapse(false); }
      
      }

      rng.collapse(true);
    }
  
  }
  catch (exception) { KeyWordProcessError('KeyWordHiLite',exception); }
  
}



function KeyWordGetLinks()
{

   var Links = new Array();
   
   for (i=0;i<document.body.getElementsByTagName('A').length;i++)
   {
	  Links[i] = new Array (document.body.getElementsByTagName('A')[i].href, document.body.getElementsByTagName('A')[i].innerHTML); 
   }

   return Links;
}



function KeyWordCleanLinks(Links)
{
  for (i=0;i<document.body.getElementsByTagName('A').length;i++)
  { 
    document.body.getElementsByTagName('A')[i].href = Links[i][0]; 
    document.body.getElementsByTagName('A')[i].innerHTML = Links[i][1];
  }
}


function KeyWordProcessError(functionName,e)
{
  if (e.description == null)
  {
//	  alert(functionName + ' ' + e.message); 
  }
  else
  { 
	//  alert(functionName + ' ' + e.description);
  }
}

function KeyWordReplace(OrgVal,SearchVal,ReplaceVal)
{
  var Val;
  var RegExp = eval("/" + SearchVal + "/g");
  if (OrgVal.indexOf(SearchVal) <1) {  return OrgVal; }
  Val = OrgVal.replace(RegExp,ReplaceVal);
  return Val;
}


