var poppedWindow = null;
var http_request = false;

var PageInfo = {
   getPageSizeWithScroll:
   function (){
    if (window.innerHeight && window.scrollMaxY) {// Firefox
     yWithScroll = window.innerHeight + window.scrollMaxY;
     xWithScroll = window.innerWidth + window.scrollMaxX;
    } else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
     yWithScroll = document.body.scrollHeight;
     xWithScroll = document.body.scrollWidth;
    } else { // works in Explorer 6 Strict, Mozilla (not FF) and Safari
     yWithScroll = document.body.offsetHeight;
     xWithScroll = document.body.offsetWidth;
    }
    arrayPageSizeWithScroll = new Array(xWithScroll,yWithScroll);
    return arrayPageSizeWithScroll;
   },
 
   getViewPortSize:
   function (){
    var xViewPort = self.innerWidth || (document.documentElement.clientWidth || document.body.clientWidth);
    var yViewPort = self.innerHeight || (document.documentElement.clientHeight || document.body.clientHeight);
    arrayViewPortSize = new Array(xViewPort,yViewPort);
    return arrayViewPortSize;
   },
 
   getPageCornerCoord:
   function (){
    var pageSizeWithScroll = this.getPageSizeWithScroll()
    var xCornerCoord = pageSizeWithScroll[0] - pageSizeWithScroll[0] + document.body.scrollLeft + document.documentElement.scrollLeft;
    var yCornerCoord = pageSizeWithScroll[1] - pageSizeWithScroll[1] + document.body.scrollTop + document.documentElement.scrollTop;
    arrayPageCornerCoord = new Array(xCornerCoord,yCornerCoord);
    return arrayPageCornerCoord;
   }
};

/** Generate a browser popup window **/
function popupWindow( pURL, pWindowName, pWindowFeatures ){
    closePoppedWindow();
    poppedWindow = window.open( "", pWindowName, pWindowFeatures  );
    poppedWindow.location.href = pURL;
    poppedWindow.focus();
}

/** Close previously opened browser popup window **/
function closePoppedWindow() {
    if ( navigator.appName != "Microsoft Internet Explorer" || parseInt( navigator.appVersion ) >= 4 ) {
        if( poppedWindow != null ) {
            if( !poppedWindow.closed ) {
                poppedWindow.close();
            }
        }
    }
}

/** Generate a browser popup window **/
function popup( pURL ){
    popupWindow( pURL, "popup", "left=50,top=50,status=yes,dependent=yes,scrollbars=auto,resizable=1,width=780,height=400" );
}

/** Return an object by id, all browser supported **/
function findObject( pElementId ) {
    if ( document.getElementById ) {
        return document.getElementById( pElementId );
    } else if ( document.all ) {
        return document.all[ pElementId ];
    } else {
        return { style: {} };
    }
}

/** Set focus on a specific element of page **/
function setFocusOnElement ( pElementId ) {
  if ( document.getElementById( pElementId ) ) {
    if ( document.getElementById( pElementId ).disabled == false ) {
      document.getElementById( pElementId ).focus();
    }
  }
}

/* Decides which combo box will be displayed - Used in most template with country/state fields */
function toggleStateProvince( pPrefix ) {
    var wCountry = findObject( pPrefix + 'Country' ).value;
    var wStateProvText = findObject( pPrefix + 'StateProvince' );
    var wStateProvCode = findObject ( pPrefix + 'StateProvinceCode');
    var wState = findObject( pPrefix + 'State' );
    var wCounty = findObject( pPrefix + 'County' );
    var wProvince = findObject( pPrefix + 'Province' );


    wStateProvCode.value = '';

    if ( wCountry == 'US' ) {

        wState.style.display = 'inline';
        wProvince.style.display = 'none';
        wCounty.style.display = 'none';
        wStateProvText.style.display = 'none';
        wStateProvText.value = '';
        wStateProvCode.style.display = 'none';
        wStateProvCode.value = wState.value;
    } else if ( wCountry == 'CA' ) {

        wState.style.display = 'none';
        wProvince.style.display = 'inline';
        wCounty.style.display = 'none';
        wStateProvText.style.display = 'none';
        wStateProvText.value = '';
        wStateProvCode.style.display = 'none';
        wStateProvCode.value = wProvince.value;
    } else if ( wCountry == 'GB' ) {

        wState.style.display = 'none';
        wProvince.style.display = 'none';
        wCounty.style.display = 'inline';
        wStateProvText.style.display = 'none';
        wStateProvText.value = '';
        wStateProvCode.style.display = 'none';
        wStateProvCode.value = wCounty.value;
    } else {

        wState.style.display = 'none';
        wProvince.style.display = 'none';
        wCounty.style.display = 'none';
        wStateProvCode.style.display = 'none';
        wStateProvText.style.display = 'inline';
    }
}
				
/** Small helping method used by more than a dozen of templates  **/
function populateStateProvinceText( pSelect, pPrefix ) {
    findObject( pPrefix + 'StateProvinceCode' ).value = pSelect.value;
}

/** Used in subscribe process **/
function setQuestionCodeValue(pSelect, pTable, pField) {

  var wSelectedObj = document.getElementById(pSelect);
  if ( wSelectedObj != null ) {
		var wSelectedCodeValue = wSelectedObj.value;
		var wTable = findObject( pTable );
		var wField = findObject( pField );
		for (var i=0; i<wTable.length; i++) {
			if (wTable[i].name == wSelectedCodeValue) {
				wField.value = wTable[i].value
				return;
			}
		}
	}
}

/** Used in ClientProfile.xsl **/  
function addPhoneWithFormat( pSufix ) {
    var wPhonesDiv = findObject( 'companyPhones' ).innerHTML;
    var wPhoneLabel = new String( findObject( 'phone_label2' ).innerHTML );
    wPhoneLabel = wPhoneLabel.substr( 0, wPhoneLabel.length - 1 );
    wPhonesDiv += '<div class="row">';
    wPhonesDiv += '    <input name="Client.Phones.Phone[' + Number( pSufix ) + '].TypeCode" type="hidden" value="OFFICE"/>';
    wPhonesDiv += '    <label id="phone_label' + pSufix + '" for="phone_number' + pSufix + '" class="col1">' + wPhoneLabel + '</label>';
    wPhonesDiv += '    <input id="phone_number' + pSufix + '" name="Client.Phones.Phone[' + pSufix + '].PhoneNumber" size="30" maxlength="30" tabindex="2" type="text"/>';
    wPhonesDiv += '    <label class="extension" for="extension' + pSufix + '">Extension</label>';
    wPhonesDiv += '    <input id="extension' + pSufix + '" name="Client.Phones.Phone[' + pSufix + '].Extension" size="10" tabindex="3" maxlength="30" type="text"/>';
    wPhonesDiv += '    <button id="addPhone' + pSufix + '" onclick="addPhoneWithFormat( ' + (  Number( pSufix )  + 1 ) + ' )" type="button">' + findObject( 'addPhone' + ( Number(pSufix) - 1 ) ).innerHTML + '</button>';
    wPhonesDiv += '</div>';
    findObject( 'companyPhones' ).innerHTML = wPhonesDiv;
    findObject( 'addPhone' + ( ( pSufix - 1 ) ) ).style.display = 'none';
}

/** Prepare RFQ page **/
function sendFreeRFQ( pRfqNumber, pNumberOfRecords ) {
  var i = 1;
  while( findObject( 'item' + i ) ) {
    findObject( 'item' + i ).value = '';
    i ++;
  }
  findObject( 'item' + pRfqNumber ).value = 1;
  findObject( 'SubmitFreeRfq' ).submit();
}

/** Prepare RFQ page **/
function checkedRFQ() {
  wChecked = false;
  wInputs = document.getElementsByTagName( "input" );
  for( i = 0; i < wInputs.length; i++ ) {
    wId = new String( wInputs[i].id );
    if ( wInputs[i].type == 'checkbox' ) {
      if ( wId.indexOf( 'item' ) >= 0 ) {
        if ( wInputs[i].checked ) {
          wChecked = true;
          break;
        }
      }
    }
  }
  if ( !wChecked ) {
    findObject( 'NoItemSelected' ).style.display = 'block';
  } else {
    findObject( 'NoItemSelected' ).style.display = 'none';
    if ( findObject( 'SubmitQuote' ) ) {
      findObject( 'SubmitQuote' ).submit();
    } else {
      findObject( 'SubmitRfq' ).submit();
    }
  }
}

/** Submit a form from a page and set the action if a controller is specified **/
function submitAction(pForm,controller) {
  var forms = document.forms;
  var form = null;
  for (var i = 0; i < forms.length; i++) {
    if (forms[i].id == pForm) {
      form = forms[i];
    }
  }
  if ( controller != null ) {
    form.action=controller;
  }
  form.target=window.name;
  form.submit();

}

/** Close a poped-up browser window and refresh it's parent  **/
function closeAndReloadOpener() {
  var wReferer = new String( window.opener.location.href );
  var wStart = wReferer.indexOf( 'SearchRequest.ResultSetId=' );
  var wEnd;
  if ( wStart > -1 ) {
    wEnd = wReferer.indexOf( '&', wStart );
    if ( wEnd <= 0 ) {
      wEnd = wReferer.indexOf( '/', wStart );
    }
    if ( wEnd <= 0 ) {
      wReferer = wReferer.substring( 0, wStart - 1 );
    } else {
      wReferer = wReferer.substring( 0, wStart - 1 ) + wReferer.substring( wEnd );
    }
  }
  wStart = wReferer.indexOf( 'SearchRequest.QueryCriteria.PageNumber=' );
  if ( wStart > -1 ) {
    wEnd = wReferer.indexOf( '&', wStart );
    if ( wEnd <= 0 ) {
      wEnd = wReferer.indexOf( '/', wStart );
    }
    if ( wEnd <= 0 ) {
      wReferer = wReferer.substring( 0, wStart - 1 );
    } else {
      wReferer = wReferer.substring( 0, wStart - 1 ) + wReferer.substring( wEnd );
    }
  }
  window.opener.location.replace( wReferer );
  window.close();
}

/** Hide a page component and display another **/
function switchSectionsSimple( sectionToHide, sectionToShow ) {
  var wSectionToHide = document.getElementById( sectionToHide );
  var wSectionToShow = document.getElementById( sectionToShow );
  wSectionToHide.style.display = "none";
  wSectionToShow.style.display = "";
}

/** Hide a page component + a button and display another (component and button) **/
function switchSections( sectionToHide, sectionToShow, buttonToHide, buttonToShow ) {
  var wSectionToHide = document.getElementById( sectionToHide );
  var wSectionToShow = document.getElementById( sectionToShow );
  var wButtonToHide = document.getElementById( buttonToHide );
  var wButtonToShow = document.getElementById( buttonToShow );

  if ( wSectionToHide ) {
  	wSectionToHide.style.display = "none";
  }

  if ( wButtonToHide ) {
  wButtonToHide.style.display = "none";
  }

  if ( wSectionToShow ) {
  wSectionToShow.style.display = "";
  }

  if ( wButtonToShow ) {
  wButtonToShow.style.display = "";
  }
}

function hintBox(pElementId,pHintText,e)
  {
		var posx	= 0;
    var posy	= 0;
    if(!e) var e	= window.event;
    if(e.pageX || e.pageY) {
      posx	= e.pageX;
      posy	= e.pageY;
    }	else if(e.clientX || e.clientY)	{
      posx = e.clientX + document.documentElement.scrollLeft;
      posy = e.clientY + document.documentElement.scrollTop;
    }
    var state 	= document.getElementById(pElementId).style.display;
    if(document.getElementById)	{
      if (state=='none') {
        state = 'inline';
      }	else	{
         state = 'none';
      }
      document.getElementById(pElementId).innerHTML=pHintText;
      document.getElementById(pElementId).style.top=(posy - 10) + 'px';
      document.getElementById(pElementId).style.left=(posx + 20) + 'px';
      document.getElementById(pElementId).style.display=state;
    }
}

function hintBox2(pElementId,pHintText,e)
  {
    var posx	= 0;
    var posy	= 0;
    if(!e) var e	= window.event;

    if(e.pageX || e.pageY) {
      posx	= e.pageX;
    	posy	= e.pageY;
    }	else if(e.clientX || e.clientY)	{

      posx = e.clientX + document.documentElement.scrollLeft;
      posy = e.clientY + document.documentElement.scrollTop;

    }
    var state 	= document.getElementById(pElementId).style.display;
    if(document.getElementById)	{
      if (state=='none') {
        state = 'inline';
      }	else	{
         state = 'none';
      }
      document.getElementById(pElementId).innerHTML=pHintText;
      document.getElementById(pElementId).style.top=(posy + 25) + 'px';
      document.getElementById(pElementId).style.left=(posx - 300) + 'px';
      document.getElementById(pElementId).style.display=state;
    }
}

function setValueAndSubmit(forms,field,value) {
    var wForm  = findObject(forms);
    var wField = findObject(field);
    wField.value = value;
    openTarget(wForm, 'width=600,height=350,resizable=1,scrollbars=1');
    wForm.submit();
}

function openTarget (form, features, windowName) {
    if (!windowName){
      windowName = 'formTarget' + (new Date().getTime());
    }
    form.target = windowName;
    open ('', windowName, features);
}

/** Browser pop up **/
function openWindow( pURL, pWidth, pHeight ) {
    popWin = window.open( "", "Agreement", "width=" + pWidth + ",height=" +  pHeight + ",dependent=yes,scrollbars=auto,resizable=1" );
    popWin.location.replace( pURL );
    popWin.focus();
}

/**	Log action to database when a user displays the expanded section / Supplier expandable section of search/posting results **/
function logClickOnExpandButton( wClientId ) {
  if ( window.XMLHttpRequest ) { // Mozilla, Safari,...
    http_request = new XMLHttpRequest();
    if ( http_request.overrideMimeType ) {
      http_request.overrideMimeType( 'text/xml' );
    }
  } else if (window.ActiveXObject) { // IE
    try {
      http_request = new ActiveXObject( "Msxml2.XMLHTTP" );
    } catch (e) {
      try {
        http_request = new ActiveXObject( "Microsoft.XMLHTTP" );
      } catch (e) {}
    }
  }

  if (!http_request) {
    return false;
  }

  http_request.open( 'GET', '/cgi/en/client.information.tracker?Info.ClientId=' + wClientId, true );
  http_request.send( null );
}

/** Submit a specific form to a controller on the press of the enter key. **/
function submitFormOnEnter( pFormId, pController, e ) {

  if (!e) {
    var e = window.event;
  }

  var code;
  if (e.keyCode) {
    code = e.keyCode;
  }	else if (e.which) {
    code = e.which;
  }

  if (code == 13) {
    var form = null;
    form = document.getElementById( pFormId );

    if ( pController != null ) {
      form.action=pController;
    }
    form.target=window.name;
    form.submit();
  }
}

/** enabled display of an hidden div **/
function showdiv( layername ) {
	if ( document.getElementById( layername ) ) {
		document.getElementById( layername ).style.display = 'block';
	}
}

/** Add new field and attributes to specific form **/
function addFieldToForm (formName, fieldType, fieldName, fieldValue) {
    var wForm = findObject(formName);

  if (document.getElementById) {
    var input = document.createElement('INPUT');
      if (document.all) { // what follows should work
                          // with NN6 but doesn't in M14
        input.type = fieldType;
        input.name = fieldName;
        input.id = fieldName;
        input.value = fieldValue;
      }
      else if (document.getElementById) { // so here is the
                                          // NN6 workaround
        input.setAttribute('type', fieldType);
        input.setAttribute('name', fieldName);
        input.setAttribute('id', fieldName);
        input.setAttribute('value', fieldValue);
      }

    wForm.appendChild(input);
  }
}

/** Remove field from form **/
function removeFieldFromForm (formName, fieldId) {

    var input = document.getElementById(fieldId);
    if ( input != null ) {
    	input.parentNode.removeChild(input);
    }
}

/** Disable all fields from a form **/
function disableForm( pFormId ) {

    var wForm = document.getElementById( pFormId );

    // Disable all <input> fields
    wInputs = wForm.getElementsByTagName( 'input' );

    for( i = 0; i < wInputs.length; i++ ) {
        wInputs[i].disabled='disabled';
    }

    // Disable all <button> fields
    wButtons = wForm.getElementsByTagName( 'button' );

    for( i = 0; i < wButtons.length; i++ ) {
        wButtons[i].disabled='disabled';
    }

    // Disable all <select> fields
    wSelects = wForm.getElementsByTagName( 'select' );

    for( i = 0; i < wSelects.length; i++ ) {
        wSelects[i].disabled='disabled';
    }

    // Disable all <textbox> fields
    wTextboxes = wForm.getElementsByTagName( 'textarea' );

    for( i = 0; i < wTextboxes.length; i++ ) {
        wTextboxes[i].disabled='disabled';
    }
}

/** Display Message in an alert box **/
function validateBrowseEntry( pMessage ) {
  alert(pMessage);
}

/** Validate max characters of a field **/
function maxCharacters( pId, pMaxLength ) {
	if ( document.getElementById( pId ) != null ) {
		var wStr = document.getElementById( pId ).value;
		if ( wStr.length >= pMaxLength ) {
			document.getElementById( pId ).value = wStr.substring(0,parseInt(pMaxLength-1));
		}
	}
}

/**  Select all checkboxes with the same name of a form **/ 
function selectAll( pFormId, pElementName ) {
	if ( document.getElementById(pFormId) != null ) {
		var wForm = document.getElementById(pFormId);
		for ( var x=0; x < wForm.length; x++ ) {
			if ( wForm[x].type == 'checkbox' && wForm[x].name == pElementName ) {
				wForm[x].checked='checked';
			}
		}
	}
}

/** Select all checkboxes of a form **/
function selectAll( pFormId ) {
	if ( document.getElementById(pFormId) != null ) {
		var wForm = document.getElementById(pFormId);
		for ( var x=0; x < wForm.length; x++ ) {
			if ( wForm[x].type == 'checkbox' ) {
				wForm[x].checked='checked';
			}
		}
	}
}

/** Unselect all checkboxes of a form **/
function selectNone( pFormId ) {
	if ( document.getElementById(pFormId) != null ) {
		var wForm = document.getElementById(pFormId);
		for ( var x=0; x < wForm.length; x++ ) {
			if ( wForm[x].type == 'checkbox' ) {
				wForm[x].checked=false;
			}
		}
	}
}

/** Select all checkboxes in a given form by their classname **/
function selectAllByClassName(pFormId, pElementClassName) { 
	if ( document.getElementById(pFormId) != null ) {
		var wForm = document.getElementById(pFormId);
		for ( var x=0; x < wForm.length; x++ ) {
			if ( wForm[x].type == 'checkbox' && wForm[x].className == pElementClassName ) {
				wForm[x].checked='checked';
			}
		}
	}
}

/** Unselect all checkboxes in a given form by their classname **/
function selectNoneByClassName(pFormId, pElementClassName) { 
	if ( document.getElementById(pFormId) != null ) {
		var wForm = document.getElementById(pFormId);
		for ( var x=0; x < wForm.length; x++ ) {
			if ( wForm[x].type == 'checkbox' && wForm[x].className == pElementClassName ) {
				wForm[x].checked=false;
			}
		}
	}
}

/** DEPRECATED - Only 1 ID should exist on a page - USE selectAllByClassName instead - DO NOT USE THIS METHOD **/
function selectAllById( pFormId, pElementId ) {
	if ( document.getElementById(pFormId) != null ) {
		var wForm = document.getElementById(pFormId);
		for ( var x=0; x < wForm.length; x++ ) {
			if ( wForm[x].type == 'checkbox' && wForm[x].id == pElementId ) {
				wForm[x].checked='checked';
			}
		}
	}
}

/** DEPRECATED - Only 1 ID should exist on a page - USE selectNoneByClassName instead - DO NOT USE THIS METHOD **/
function selectNoneById( pFormId, pElementId ) {
	if ( document.getElementById(pFormId) != null ) {
		var wForm = document.getElementById(pFormId);
		for ( var x=0; x < wForm.length; x++ ) {
			if ( wForm[x].type == 'checkbox' && wForm[x].id == pElementId ) {
				wForm[x].checked=false;
			}
		}
	}
}

/** Helps to display phone number correctly in a field **/
function displayPhoneCode(phoneCodeNumbers,countryCode,phoneCodeNumber) {
   var st=document.getElementById(phoneCodeNumbers).value;
   var countryCode=document.getElementById(countryCode).value;
   var bar = st.split("|");
   for(var i = 0;i<bar.length;i++){
	if(countryCode==bar[i].match(countryCode)){
	   var codeNum = bar[i].split("=");
           document.getElementById(phoneCodeNumber).value=codeNum[1];
	   break;
	}
   }
}

/**	Disable an href after onclick and display a custom message instead of the link **/
function disableLinkAfterClick( pLink, pId, pMessage ) {
	document.location = pLink;
	document.getElementById(pId).innerHTML = pMessage;
}

/**	Show hidden sub menu option. - Used with the dynamic menu header **/
function showSubMenu( pId) {
	if ( document.getElementById( pId ) != null ) {
		var wStyle = document.getElementById( pId ).style;
		wStyle.display = "block";
	}
}

/**	Hide displayed sub menu option. - Used with the dynamic menu header **/
function hideSubMenu( pId) {
	if ( document.getElementById( pId ) != null ) {
		var wStyle = document.getElementById( pId ).style;
		wStyle.display = "";
	}
}

/** Switch content of central section of homepage **/
function switchHomePageMiddleContent(divToShow){

	for(var i=1;i<=3;i++){

		document.getElementById('switch'+i).style.display = 'none';

		if(document.getElementById('menuManufac'+i)){
			document.getElementById('menuManufac'+i).style.backgroundImage = 'url(/cgi/en/img/menu.png)';
			document.getElementById('menuManufac_a_'+i).style.fontWeight = 'normal';
		}
	}

	document.getElementById('menuManufac1').style.backgroundImage = 'url(/cgi/en/img/menug2.png)';
	document.getElementById('switch'+divToShow).style.display = 'block';
	document.getElementById('menuManufac_a_'+divToShow).style.fontWeight = 'bold';

	if(divToShow!=3){
		document.getElementById('menuManufac'+divToShow).style.backgroundImage = 'url(/cgi/en/img/menug.png)';
	}
	else{
		document.getElementById('menuManufac'+divToShow).style.backgroundImage = 'url(/cgi/en/img/menud.png)';
		}
}

/**	Display an hidden div from a page at a specific location (width, height) **/
function divPopUp(pElementId, pHeight, pWidth){
    var state 	= document.getElementById(pElementId).style.display;
    if(document.getElementById)	{
      if (state == 'none') {
        state = 'block';
      }	else	{
         state = 'none';
      }
		document.getElementById(pElementId).style.left = (PageInfo.getPageCornerCoord()[0] + ((PageInfo.getViewPortSize()[0] - pWidth)/2))+'px';
		document.getElementById(pElementId).style.top = (PageInfo.getPageCornerCoord()[1] + ((PageInfo.getViewPortSize()[1] - pHeight)/2))+'px';
		document.getElementById(pElementId).style.display = state;
    }
}

/* Display an hidden div from a page at a specific location where click happened */
function displayHintBox(pElementId,e,pDisplacementY,pDisplacementX)
  {
    var posx	= 0;
    var posy	= 0;
    if(!e) var e	= window.event;
    if(e.pageX || e.pageY) {
      posx	= e.pageX;
      posy	= e.pageY;
    }	else if(e.clientX || e.clientY)	{
      posx = e.clientX + document.documentElement.scrollLeft;
      posy = e.clientY + document.documentElement.scrollTop-20;
    }
    var state 	= document.getElementById(pElementId).style.display;
    if(document.getElementById)	{
      if (state=='none') {
        state = 'inline';
      }	else	{
         state = 'none';
      }
      document.getElementById(pElementId).style.top=(posy - eval(pDisplacementY)) + 'px';
      document.getElementById(pElementId).style.left=(posx + eval(pDisplacementX)) + 'px';
      document.getElementById(pElementId).style.display=state;
    }
}

/**	Change a displayed image source at runtime - Avoid is possible... use CSS instead **/
function changeImage(pFieldId, pImageToShow){
	var wField = findObject(pFieldId);
	wField.src = pImageToShow;
}

/**	Recent searches - Open Collapse section that displays list of recent searches **/
function openCollapseRecentSearches( pListId, pImgId ) {
	var wList = document.getElementById(pListId);
	var wImage = document.getElementById(pImgId);

	if ( wList.style.display=="none" ) {
		wList.style.display="inline";
		wImage.src="/cgi/${locale}/img/selectBox_arrowUp.gif";
		document.getElementById('relativeContainer').style.height = '';
	} else {
		wList.style.display="none";
		wImage.src="/cgi/${locale}/img/selectBox_arrowDown.gif";
		document.getElementById('relativeContainer').style.height = '0px';		
	}
}

/**	Recent searches - Toggle section that displays list of recent searches **/
function toggleRecentSearchesDiv(pListId, pImgId) {
	var wList = document.getElementById(pListId);
	var wImage = document.getElementById(pImgId);
	wList.style.display = "none";
	wImage.src="/cgi/${locale}/img/selectBox_arrowDown.gif";
	document.getElementById('relativeContainer').style.height = '0px';		
}

/**	Recent searches - Reinitialize list of recent searches **/
function reinitializeInput( pInputId, pNewValue ) {
	var wInput = document.getElementById(pInputId);
	if( wInput != null ) {
		wInput.value = pNewValue;
	}
}

/** Recent searches - Process Ajax request **/
function getInnerHtmlForDivByJsa(pTargetDiv, pController) {
	var xmlHttp;
	try {
		// Opera 8.0+, Firefox, Safari
		xmlHttp = new XMLHttpRequest();
	} catch (e) {
		// Internet Explorer Browsers
		try {
			xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try {
				xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e) {
				// Something went wrong
				alert("Your browser does not support AJAX requests. Please update your browser.");
				return false;
			}
		}
	}

	xmlHttp.onreadystatechange=function() {
		if ((xmlHttp.readyState==4) && (xmlHttp.status == 200)) {
			document.getElementById(pTargetDiv).innerHTML = xmlHttp.responseText;
		}
	}

	xmlHttp.open("POST",pController ,true);
	xmlHttp.send(null);
}

function removeFreeTextSpecialChars( pInputElementId ) {
	var text = document.getElementById( pInputElementId ).value;
	text = text.replace( /[^A-Za-z0-9_\-\+\\/\= \,\.]+/g, "" );
	document.getElementById( pInputElementId ).value = text;
}