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;
   }
};

function popupWindow( pURL, pWindowName, pWindowFeatures ){
    closePoppedWindow();
    poppedWindow = window.open( "", pWindowName, pWindowFeatures  );
    poppedWindow.location.href = pURL;
    poppedWindow.focus();
}

function popup( pURL ){
    popupWindow( pURL, "popup", "left=50,top=50,status=yes,dependent=yes,scrollbars=auto,resizable=1,width=780,height=400" );
}

function closePoppedWindow() {
    if ( navigator.appName != "Microsoft Internet Explorer" || parseInt( navigator.appVersion ) >= 4 ) {
        if( poppedWindow != null ) {
            if( !poppedWindow.closed ) {
                poppedWindow.close();
            }
        }
    }
}

function textCounter( field, maxlimit ) {
  if ( field.value.length > maxlimit )
  {
    field.value = field.value.substring( 0, maxlimit );
    return false;
  }

}


function notYou(){
    var wForm = findObject('notyou');
    wForm.submit();
}

function findObject( pElementId ) {
    if ( document.getElementById ) {
        return document.getElementById( pElementId );
    } else if ( document.all ) {
        return document.all[ pElementId ];
    } else {
        return { style: {} };
    }
}

function findObject( pElementId, pSpecificForm ) {

    if ( pSpecificForm.getElementById ) {
        return pSpecificForm.getElementById( pElementId );
    } else if ( pSpecificForm.all ) {
        return pSpecificForm.all[ pElementId ];
    } else {
        return { style: {} };
    }
}

function findObjectOrNull( pElementId ) {
    if ( document.getElementById ) {
        return document.getElementById( pElementId );
    } else if ( document.all ) {
        return document.all[ pElementId ];
    } else {
        return null;
    }
}

function setFocusOnElement ( pElementId ) {
  if ( document.getElementById( pElementId ) ) {
    if ( document.getElementById( pElementId ).disabled == false ) {
      document.getElementById( pElementId ).focus();
    }
  }
}

function toggleStateProvinceLabel( pPrefix ) {
    var wLabel = findObject( pPrefix + 'LblStateProvince' );
    var wCountry = findObject( pPrefix + 'Country' ).value;

    if ( wCountry == 'US' || wCountry == 'CA' || wCountry == 'GB' ) {
        wLabel.style.display = 'inline';
    } else {
        wLabel.style.display = 'none'
    }
}

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';
    }
}


function toggleStateProvinceCanadaMessage( 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' ) {
        hidediv( 'divcanada' );
        showdiv( 'divuserinfo' );
        showdiv( 'divmessagebutton' );

        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' ) {
        showdiv( 'divcanada' );
        hidediv( 'divuserinfo' );
        hidediv( 'divmessagebutton' );
        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' ) {
        hidediv( 'divcanada' );
        showdiv( 'divuserinfo' );
        showdiv( 'divmessagebutton' );

        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 {
        hidediv( 'divcanada' );
        showdiv( 'divuserinfo' );
        showdiv( 'divmessagebutton' );

        wState.style.display = 'none';
        wProvince.style.display = 'none';
        wCounty.style.display = 'none';
        wStateProvCode.style.display = 'none';
        wStateProvText.style.display = 'inline';
    }
}

function populateStateProvinceText( pSelect, pPrefix ) {
    findObject( pPrefix + 'StateProvinceCode' ).value = pSelect.value;
}

function populateMainBusinessActivityText( pSelect, pPrefix ) {
    findObject( pPrefix + 'BusinessActivityCode' ).value = pSelect.value;
}

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;
			}
		}
	}
}

function addPhone( pSufix ) {
    var wPhonesDiv = findObject( 'companyPhones' ).innerHTML;
    var wPhoneLabel = new String( findObject( 'phone_label0' ).innerHTML );
    wPhoneLabel = wPhoneLabel.substr( 0, wPhoneLabel.length - 1 );
    wPhonesDiv += '<br />\n'
    wPhonesDiv += '<label for="phone_number' + pSufix + '">' + wPhoneLabel + '</label>\n';
    wPhonesDiv += '<input id="phone_number' + pSufix + '" maxlength="12" name="Client.Phones.Phone[' + pSufix + '].PhoneNumber" size="30" tabindex="7" type="text"/>\n';
    wPhonesDiv += '<label class="extension" for="extension' + pSufix + '">Extension</label>\n';
    wPhonesDiv += '<input id="extension' + pSufix + '" maxlength="20" name="Client.Phones.Phone[' + pSufix + '].Extension" size="10" tabindex="8" type="text"/>\n';
    wPhonesDiv += '<button id="addPhone' + pSufix + '" onclick="addPhone( ' + ( Number( pSufix ) + 1 ) + ' )" type="button">' + findObject( 'addPhone0' ).innerHTML + '</button>\n';
    findObject( 'companyPhones' ).innerHTML = wPhonesDiv;
    findObject( 'addPhone' + ( Number( pSufix ) - 1 ) ).style.display = 'none';
}


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';
}

function referredByOther() {
  if(findObject('ReferredByCbo').value == 'OTHER'){
    findObject('ReferredByCode').style.display = 'inline';
  }else{
    findObject('ReferredByCode').style.display = 'none';
    findObject('ReferredByCode').value = '';
  }
}

function targetWin(anchor) {
window.open(anchor.href);
return false;
}

function checkMaxLength(tag,size) {
  var child = 	findObject('area_size_label');
  if (child != null)  {
    if (tag.value.length > 1)
      child.childNodes[0].nodeValue = 'Length: ' + tag.value.length+ ' characters (' + size + ' Max.)';
      else
          child.childNodes[0].nodeValue = 'Length: ' + tag.value.length+ ' character (' + size + ' Max.)';
  }
}

function selectSearchBoxIfSearchWasDone() {
  url = new String( location.href );
  if ( url.indexOf( 'main.search' ) >= 0 ) {
    findObject( 'search1' ).select();
  }
}

function selectSearchBoxIfSearchWasDone2( pElementId ) {
  url = new String( location.href );
  if ( url.indexOf( 'main.search' ) >= 0 ) {
    findObject( pElementId ).select();
  }
}

function sendFreeRFQ( pRfqNumber, pNumberOfRecords ) {
  var i = 1;
  while( findObject( 'item' + i ) ) {
    findObject( 'item' + i ).value = '';
    i ++;
  }
  findObject( 'item' + pRfqNumber ).value = 1;
  findObject( 'SubmitFreeRfq' ).submit();
}

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();
    }
  }
}

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();

}

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();
}

function switchSectionsSimple( sectionToHide, sectionToShow ) {
  var wSectionToHide = document.getElementById( sectionToHide );
  var wSectionToShow = document.getElementById( sectionToShow );
  wSectionToHide.style.display = "none";
  wSectionToShow.style.display = "";
}

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 hintBoxWithDisplacement(pElementId,pHintText,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).innerHTML=pHintText;
      document.getElementById(pElementId).style.top=(posy - eval(pDisplacementY)) + 'px';
      document.getElementById(pElementId).style.left=(posx + eval(pDisplacementX)) + '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);
}

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();
}


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 );
}

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();
  }
}

function disableAfterSingleClick ( pButtonId, pForm, controller ) {
  var wButtonToDisable = document.getElementById( pButtonId );
  wButtonToDisable.disabled = true;
  submitAction(pForm, controller);
}

function showChildList ( pPrefix, pPreviouslySelectedParent, pElementId, pNoChildMessage ) {

  wObj = document.getElementById( pPreviouslySelectedParent );

  if ( wObj != null ) {
    var wPreviouslySelectedParent = wObj.value;
    var wCurrentlySelectedParent = document.getElementById( pElementId ).value;

    wObj = document.getElementById( pPrefix + wPreviouslySelectedParent );

    if ( wObj != null ) {

        if( wPreviouslySelectedParent != wCurrentlySelectedParent ) {
            for (i=0; i<wObj.length; i++) {
                if (wObj.options[i].selected) {
                    wObj.options[i].selected = false;
                }
            }
        }

      wObj.style.display='none';
    }

    wObj = document.getElementById( pPrefix + wCurrentlySelectedParent );
    if ( wObj != null ) {
      document.getElementById( pNoChildMessage ).style.display = 'none';
      wObj.style.display='inline';
    } else {
      document.getElementById( pNoChildMessage ).style.display = 'inline';
    }

    var wNewlySelectedParent = '<input type="hidden" id="previouslySelectedParent" value="' + wCurrentlySelectedParent + '"/>';

    findObject( 'hiddenDiv' ).innerHTML = wNewlySelectedParent;
  }
}

function saveSearchType( type ) {
  document.cookie = "SearchType=" + type + "; path=/";
}

function loadSearchType() {

  var name = "SearchType=";
  var value = "";
  var cookieArray = document.cookie.split(';');
  for( var i=0; i < cookieArray.length; i++ ) {
    var cookie = cookieArray[i];
    while (cookie.charAt( 0 ) == ' ') {
      cookie = cookie.substring( 1, cookie.length );
    }
    if ( cookie.indexOf( name ) == 0 ) {
      value = cookie.substring( name.length, cookie.length );
    }
  }
  if ( value == "" ) {
    value = "wine"
  }
  document.getElementById( value ).checked = "checked";
  return value;
}

function toggleDivDisplay( pDivName ){
	if( findObject( pDivName ).style.display == 'none' ){
		showdiv(pDivName);
	}else{
		hidediv( pDivName );
	}			
}
			
function hidediv( layername ) {
	if (document.getElementById( layername )) {
		document.getElementById( layername ).style.display = 'none';
	}
}

function showdiv( layername ) {
	if ( document.getElementById( layername ) ) {
		document.getElementById( layername ).style.display = 'block';
	}
}

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);
  }
}

    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';
        }
    }

function enableComponent ( pSelectedComponentId, pConditionToEnable, pComponentToEnable ) {
	var wSelected = document.getElementById(pSelectedComponentId).value;
	if ( wSelected == pConditionToEnable ) {
		document.getElementById( pComponentToEnable ).disabled = false;
	} else {
		document.getElementById( pComponentToEnable ).disabled = true;
	}
}

function validateBrowseEntry( pMessage ) {
  alert(pMessage);
}

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));
		}
	}
}

function removeZZCountry() {
	var wCountryCombo = findObject( 'mainCountry' );
	for ( var i=0; i < wCountryCombo.options.length; i++ ) {
		if ( wCountryCombo.options[i].value == 'ZZ' ) {
				wCountryCombo.options[i] = null;
		}
	}
}

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';
			}
		}
	}
}


function selectAllCheckBox( pFormId, pElementName, pCheckBoxAllId ) {
	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.substring(0,(wForm[x].name).length-1) == pElementName) && (wForm[x].name != pCheckBoxAllId) ) {
				wForm[x].checked=false;
			}
		}
	}
}

function uncheckAllCheckBox( pCheckBoxAllId ) {
	document.getElementById(pCheckBoxAllId).checked = false;
}

function selectNone( 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=false;
			}
		}
	}
}

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';
			}
		}
	}
}

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;
			}
		}
	}
}

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';
			}
		}
	}
}

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;
			}
		}
	}
}


function displayNote ( pElementId ) {
	var spans = document.getElementsByTagName("span");
	for (var i = 0; i < spans.length; i++) {
		if ( spans[i].id.substring(0,4) == 'note' ) {
			document.getElementById(spans[i].id).style.display = 'none';
		}
	}

	if ( document.getElementById( pElementId ) != null ) {
		document.getElementById( pElementId ).style.display = 'inline';
	}
}


function windowSize ( pElementId ) {
	var height;
	if ( window.innerHeight ) {
		/* Non IE */
		height = window.innerHeight - 114;
	} else if ( document.documentElement && document.documentElement.clientHeight ) {
		/* IE 6+ in 'standards compliant mode' */
		height = document.documentElement.clientHeight - 114;
	} else if ( document.all ) {
		/* IE 4+ compatible or IE6+ transitional */
		height = document.body.clientHeight - 103;
	}
	document.getElementById( pElementId ).style.height = height+'px' ;
}

function closeList( pId ) {
	if ( document.getElementById(pId) != null ) {
		document.getElementById(pId).style.display = 'none';
	}
}

function showHiddenList( pId, pIdToClose1, pIdToClose2 ) {
	closeList( pIdToClose1 );
	closeList( pIdToClose2 );
	if ( document.getElementById(pId) != null ) {
		document.getElementById(pId).style.display = 'inline';
	}
}

function openDisclaimer(pLangID) {
	var myWindow="";

	if (pLangID == "1") {
		myWindow=window.open("/cgi/en/tendering/AbstractDisclaimerEng.html", "engDisclaimer", "width=500, height=200, fullscreen=no, resizable=yes, toolbar=no, location=no, directories=no, status=no, menubar=no, copyhistory=no");
	} else {
		myWindow=window.open("/cgi/en/tendering/AbstractDisclaimerFre.html", "freDisclaimer", "width=500, height=200, fullscreen=no, resizable=yes, toolbar=no, location=no, directories=no, status=no, menubar=no, copyhistory=no");
	}
	myWindow.focus();
}

function findObject( pElementId ) {
    if ( document.getElementById ) {
        return document.getElementById( pElementId );
    } else if ( document.all ) {
        return document.all[ pElementId ];
    } else {
        return { style: {} };
    }
}

function loadBannerPopUp( pServlet, pLanguage, pURL ) {

    var screenHeight = (screen.availHeight / 2) - 190;
    var screenWidth  = (screen.availWidth  / 2) - 225;

    if (navigator.appName == "Netscape") {
        doc = window.open( pServlet + "?" + pLanguage + pURL,"BannerPopUp","scrollbars=1,resizable=0,height=380,width=450,left=" + screenWidth + ",top=" + screenHeight );
    } else {
        doc = window.open( pServlet + "?" + pLanguage + pURL,"BannerPopUp","scrollbars=yes,resizable=false,height=380,width=450,left=" + screenWidth + ",top=" + screenHeight );
    }
}

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;
	}
   }
}

function displayPhoneCode(phoneCodeNumbers,countryCode,phoneCodeNumber,emptyValue) {
   var st=document.getElementById(phoneCodeNumbers).value;
   var countryCode=document.getElementById(countryCode).value;
   if( countryCode != '' ) {
       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;
    	}
       }
   } else {
       document.getElementById(phoneCodeNumber).value=emptyValue;
   }
}

function displayCountryCode(phoneCodeNumbers,countryCode,phoneCodeNumber,tollFreeCodeNumber,faxCodeNumber) {
   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];
           document.getElementById(tollFreeCodeNumber).value=codeNum[1];
           document.getElementById(faxCodeNumber).value=codeNum[1];
	   break;
	}
   }
}

function disableLinkAfterClick( pLink, pId, pMessage ) {
	document.location = pLink;
	document.getElementById(pId).innerHTML = pMessage;
}

function displaySystemMessage( pId ) {
	var height;
	if ( window.innerHeight ) {
		/* Non IE */
		height = window.innerHeight;
		document.getElementById(pId).style.MozOpacity=30/100;
	} else if ( document.documentElement && document.documentElement.clientHeight ) {
		/* IE 6+ in 'standards compliant mode' */
		height = document.documentElement.clientHeight;
	} else if ( document.all ) {
		/* IE 4+ compatible or IE6+ transitional */
		height = document.body.clientHeight;
	}
	document.getElementById( pId ).style.height = height+'px' ;
	document.getElementById( pId ).style.display = 'block';
}

// Display Phone Code value associated to a country code
function displayPhoneCodeValue(phoneCodeNumbers,countryCode,phoneCodeNumber) {

   var st=document.getElementById(phoneCodeNumbers).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;
	}
   }
}

// Get id attribute from the selected option
function getOptionId(pObj) {

    var optionsList = document.getElementById(pObj);
    var selectedIndex = optionsList.selectedIndex;
    var idValue = optionsList.options[selectedIndex].id;

    return idValue;

}

function switchList ( pListToClose, pListToOpen ) {
	document.getElementById(pListToClose).style.display = 'none';
	document.getElementById(pListToOpen).style.display = 'block';
	document.getElementById(pListToClose+'Li').style.display = 'none';
	document.getElementById(pListToOpen+'Li').style.display = 'block';
}

function showOrHideElement ( pId ) {
	var wElement = findObjectOrNull( pId );

	if ( wElement != null ) {
		if ( wElement.style.display == 'none' ) {
			wElement.style.display = '';
		} else {
			wElement.style.display = 'none';
		}
	}
}

function addMoreLines( pTableId, pSelectDivId, pNumberOfRowsToDisplay ) {

	if ( document.getElementById("numberOfRowsDisplayed") != null ) {
		var wNumberOfRowsDisplayed = document.getElementById( "numberOfRowsDisplayed" ).value;
		var wMaxNumberOfRows = document.getElementById( "maxNumberOfRows" ).value;
		var wRowItemsSubmitted = document.getElementById( "numberOfItemsSubmitted" ).value;

		table = document.getElementById( pTableId );
		rows = table.getElementsByTagName( "tr" );

		if ( eval(wRowItemsSubmitted) > eval(pNumberOfRowsToDisplay) ) {
			pNumberOfRowsToDisplay = wRowItemsSubmitted;
		}

        var wIndex = 0;
		for( var i=1; i<=pNumberOfRowsToDisplay*2; i++  ) {
			wIndex = eval(i) + eval(wNumberOfRowsDisplayed*2);
			rows.item(wIndex+2).style.display = "";
		}


		var wRowsAllowed = 0;
		if ( pNumberOfRowsToDisplay > 0 ) {
			wRowsAllowed = eval(wMaxNumberOfRows) - eval(wIndex/2);
		} else {
			wRowsAllowed = eval(wMaxNumberOfRows) - 1;
		}

		var wSelect = '';
		if ( wRowsAllowed ) {
			wSelect += 'Add <select tabindex="800" onchange="javascript:addMoreLines(&#39;' + pTableId + '&#39;,&#39;' + pSelectDivId + '&#39;, document.getElementById(&#39;moreRowsSelect&#39;).value );" id="moreRowsSelect">';
			wSelect += '  <option value="0">&#160</option>';

			for ( var j=1; j<=wRowsAllowed; j++ ) {
				wSelect += '  <option value="' + j + '">' + j + '</option>';
			}
			wSelect += '</select> more lines. (You can submit up to 5 items in your Posting)';
		}

		var wNumberOfRowsDisplayed = 0;
		if ( pNumberOfRowsToDisplay > 0 ) {
			wNumberOfRowsDisplayed = eval((wIndex/2));
		} else {
			wNumberOfRowsDisplayed = 1;
		}

		wSelect += '<input type="hidden" id="numberOfRowsDisplayed" value="' + wNumberOfRowsDisplayed +'" />';
		wSelect += '<input type="hidden" id="maxNumberOfRows" value="' + wMaxNumberOfRows + '" />';
		wSelect += '<input type="hidden" id="numberOfItemsSubmitted" value="0" />';

		findObject( 'addMoreDiv' ).innerHTML = wSelect;
	}
}

function showSubMenu( pId) {
	if ( document.getElementById( pId ) != null ) {
		var wStyle = document.getElementById( pId ).style;
		wStyle.display = "block";
	}
}

function hideSubMenu( pId) {
	if ( document.getElementById( pId ) != null ) {
		var wStyle = document.getElementById( pId ).style;
		wStyle.display = "";
	}
}

function loadPostingPage ( pId1, pId2 ) {
	var radio1 = document.getElementById(pId1);
	var radio2 = document.getElementById(pId2);

	if (radio1.checked) {
		window.location.href = "/cgi/en/posting.addWantToBuyMultiItem.prep";
	}

	if (radio2.checked) {
		window.location.href = "/cgi/en/posting.addForSaleMultiItem.prep";
	}
}

function countAreaChars(areaId,counter,limit){
  var areaName = document.getElementById( areaId );
  if (areaName.value.length>limit){
    areaName.value=areaName.value.substring(0,limit);
  }else{
    counter.value = limit - areaName.value.length;
  }
}

function setRating( pId, pLinkBaseId, pRating, pMaxRating ) {
	// Set hidden element with value
	document.getElementById( pId ).value = pRating;
	clearStars( pLinkBaseId, pRating, pMaxRating);
}

function clearStars( pLinkBaseId, pRating, pMaxRating ) {
	for ( x = 1; x <= pMaxRating; x++ ){
		var wLink = document.getElementById( pLinkBaseId + '_' + x );
		wLink.style.background = "";
		wLink.style.zIndex = "";
		wLink.style.left = "";
		wLink.style.width = "";
	}

	var wClickedLink = document.getElementById( pLinkBaseId + '_' + pRating );
	if ( wClickedLink ) {
		if ( pRating > 0 ) {
			wClickedLink.style.background = "url(/cgi/en/img/stars.gif) " + "-" + ((pMaxRating - pRating) * 12) + "px 0";
			wClickedLink.style.zIndex = "1";
			wClickedLink.style.left = "12px";
			wClickedLink.style.width = (pRating * 12) + "px";
		}
	}
	document.getElementById( pLinkBaseId + '_text' ).value = wClickedLink.innerHTML;

}

function setStars( pId, pLinkBaseId, pMaxRating ) {
	var wRating = document.getElementById( pId ).value;
	clearStars( pLinkBaseId, wRating, pMaxRating);
}

 function clearField( pId, pCompare ) {
	var wObj = 	document.getElementById( pId );
	if ( wObj.value == pCompare ) {
		wObj.value='';
	}
}

function switchManufaturer(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)';
		}
}

function expand(divToShow){

	var i=0;

	while(document.getElementsByTagName("dd")[i]){
		document.getElementById("description"+i).style.display='none';
		document.getElementById("imgExpand"+i).src='url(/cgi/en/img/bg_plus.gif';
		i++ ;
	}
	if(divToShow){
		document.getElementById("imgExpand"+divToShow).src='url(/cgi/en/img/bg_minus.gif';
		document.getElementById("description"+divToShow).style.display='block';
	}
}

function calltxt (url, id_container) {
    var page = false;
    if (window.XMLHttpRequest)
    {
        page = new XMLHttpRequest ();
    } else if (window.ActiveXObject)
    {
        try
        {
            page = new ActiveXObject ("Msxml2.XMLHTTP");
        }
        catch (e)
        {
            try
            {
                page = new ActiveXObject ("Microsoft.XMLHTTP");
            }
            catch (e)
            {
            }
        }
    }
    else
    return false;
    page.onreadystatechange = function ()
    {
        loadpage (page, id_container);
    }
    page.open ('GET', url, true);
    page.send (null);
}


function loadpage (page, id_container) {
    if (page.readyState == 4 && (page.status == 200 || window.location.href.indexOf ("http") == - 1))
    document.getElementById (id_container).innerHTML = page.responseText;
}

function countEnteredChars(areaId, counterId, limit)
{
    var areaName = document.getElementById( areaId );
     var counter = document.getElementById(counterId);
      if (areaName.value.length>limit){
      areaName.value = areaName.value.substring(0,limit);

      }

        counter.value = areaName.value.length;

}

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;
    }
}

/******************************************************************
			 IMPORTED FROM PogUtil.js
*******************************************************************/

function popNewMessageWindowParam( pController, pUnique ) {

	//alert( "test" );

	var id = 'writeWindow';

	if( pUnique == 'YES' ){

		day = new Date();
		id = day.getTime();

		eval("var page" + id + " = window.open(pController, '" + id + "', 'toolbar=no,status=yes,resizable=yes,scrollbars=yes,height=600,width=870,left=0,top=0');");


	} else {

		openPopWindow( pController, id,'toolbar=no,status=yes,resizable=yes,scrollbars=yes,height=600,width=870,left=0,top=0');

	}
}

var popWin = null;
function openPopWindow( pWinURL, pWinName, pWinFeatures ){
    closePopWin();
    popWin = window.open( "", pWinName, pWinFeatures  );
    popWin.opener = window;
    popWin.opener.name = "opener";
    popWin.location.href=pWinURL;
}

function closePopWin(){
  if ( navigator.appName != "Microsoft Internet Explorer" || parseInt( navigator.appVersion ) >= 4 ) {
    if( popWin != null ) {
      if( !popWin.closed ) {
        popWin.close();
      }
    }
  }
}
/******************************************************************/

function getItemUrl(pLang)
{
    var elm = document.getElementById( pLang );
    var wJsa ='.jsa';
    var wCgi ='/cgi/';
    var wIndexPage ='/index.prep';
    var wlocLength = this.document.location.href.length;
    var wJsaUrl=this.document.location.href.indexOf(wJsa); 
    var wAllInOneUrl =this.document.location.href.indexOf(wCgi);
    var wWxUrl =this.document.location.href.lastIndexOf('/wx/');
    
    /* test if the url is a JSA Url*/
    if(wJsaUrl != -1 )
    {
          
        var wUrl = this.document.location.href.substring(this.document.location.href.lastIndexOf('/'), wlocLength);
        elm.href = wUrl.substring(0, (wUrl.length-6))+pLang+wJsa;
        
    }
    else
    {
          /* test if the url is a 6.0 Url*/
         if(wAllInOneUrl != -1 )
        {
         
           var wPreUrl =this.document.location.href.substring(0,wAllInOneUrl);  
           var wUrl = this.document.location.href.substring(wAllInOneUrl+8 , wlocLength);
           
           elm.href = wPreUrl+wCgi+pLang+'/'+wUrl;
           
        }
        else
        {
              /* test if the url is a 5.9 Url*/
            if(wWxUrl != -1 )
            {
                
                var wPreUrl =this.document.location.href.substring(0,wWxUrl);  
                var wUrl = this.document.location.href.substring((wWxUrl+7),wlocLength);
                elm.href = wPreUrl+'/wx/'+pLang+'/'+wUrl; 
            
            }
            /* if we are on the main page redirect to index.prep page in the adequate language*/
            else
            {
                elm.href =this.document.location.href+'cgi/'+pLang+wIndexPage;
            }
        }
    }
   
   
}


function addClass( elm, nwCl ){

	var clsNm = elm.className;
	var clsNms = clsNm.split(" ");
	var finalClsNm = nwCl;
	for( i = 0; i < clsNms.length; i++ ){

		if( clsNm[i] != nwCl ){
			finalClsNm += " "+clsNms[i];
		}

	}

	elm.className = finalClsNm;

}

function removeClass( elm, nwCl ){
 
 var clsNm = elm.className;
 var clsNms = clsNm.split(" ");
 var finalClsNm = "";
 for( i = 0; i < clsNms.length; i++ ){
 
  if( clsNm[i] != nwCl ){
   finalClsNm += " "+clsNms[i];
  }
 
 }
 
 elm.className = finalClsNm;
 
}

function showMessageLight( pBoxId, pMessageId, pSwitch ) {

	if ( pSwitch == 'show' ) {
		var height;
		if ( window.innerHeight ) {
			/* Non IE */
			height = window.innerHeight;
		} else if ( document.documentElement && document.documentElement.clientHeight ) {
			/* IE 6+ in 'standards compliant mode' */
			height = document.documentElement.clientHeight;
			width = document.documentElement.clientWidth;
			document.getElementById( pBoxId ).style.width = width+'px' ;
			document.getElementById( pMessageId ).style.position = 'absolute' ;
			document.getElementById( pMessageId ).style.top = 200+'px';
		} else if ( document.all ) {
			/* IE 4+ compatible or IE6+ transitional */
			height = document.body.clientHeight;
			width = document.body.clientWidth;
			document.getElementById( pBoxId ).style.width = width+'px' ;
		}
		if ( height < 850 ) {
			height = 850;
		}
		document.getElementById( pBoxId ).style.height = height+'px' ;
		document.getElementById(pBoxId).style.display='';
		document.getElementById(pMessageId).style.display='';
	} else {
		document.getElementById(pBoxId).style.display='none';
		document.getElementById(pMessageId).style.display='none';
	}
}

function showRangeTable( pTableIdToShow, pTableIdToHide ) {
	document.getElementById(pTableIdToShow).style.display='block';
	document.getElementById(pTableIdToHide).style.display='none';
}

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;
    }	
}

function externalLinks() {

	if (!document.getElementsByTagName) return;

		var anchors = document.getElementsByTagName("a");
		for (var i=0; i<anchors.length; i++) {
		var anchor = anchors[i];
		var relvalue = anchor.getAttribute("rel");

		if (anchor.getAttribute("href")) {
			var external = /external/;
			var relvalue = anchor.getAttribute("rel");
			if (external.test(relvalue)) { anchor.target = "_blank"; }
		}
	}
}

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 broke!");
				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);
}

/*
*	Will display desired image with text on the side inside a target div.
*
*	Perfect for an animated loading gif file with text on the side.
*
*	@param pImageToDisplayLocation (ex. '/cgi/en/img/loading.gif')
*	@param pTextToDisplay	(ex. 'loading')
*	@param pTargetDiv	(ex. 'myTargetDiv')
*/
function displayLoadingMessageWithImageInDiv( pImageToDisplayLocation, pTextToDisplay, pTargetDiv ){
	findObject( pTargetDiv ).innerHTML="<img id='loadingMessageImage' src='" + pImageToDisplayLocation +"'/> <span id='loadingMessageText'>" + pTextToDisplay + "</span>";
}
