// ----------------------------------------------------------------------------
// Lauyan Software Javascript Search Engine 2.0
//
// This file is the JavaScript search engine for a website created by TOWeb
//
// Copyright (C) LAUYAN SOFTWARE 2006
// web: http://www.lauyan.com
// ----------------------------------------------------------------------------

STR_SEARCH_QUERY_MSG = "Résultats de la recherche pour";
STR_NO_RESULT = "Aucun résultat trouvé";
LBL_QUERY_RESULT = "résultat(s) trouvé(s) pour :&nbsp";
LBL_ITREFERENCE  = "Référence";
LBL_ITPRICE = 'Prix';
LBL_PRICEERROR = "Erreur de prix";
MIN_WORD_LEN = 2;
DISPLAY_SRCH_INFO = 1;
USE_UTF8 = 0;
REMOVE_ACCENTS = 1;
BOLD_LINKS = 0;
ONLINE_WEBSITE = 1;
ALLWORDSONLY = 0;
SHOWREFERENCES = 0;
BORDERCOLOR = "#FF9900";
SORTCOMPARE = 2;
itNamesArray = new Array("8-001",
"8-002",
"8-003",
"8-004",
"8-005",
"8-006",
"8-007",
"8-008",
"8-009",
"8-010",
"8-011",
"8-012",
"8-013",
"8-014",
"8-015",
"8-016",
"8-017",
"8-018",
"8-019",
"8-020",
"8-021",
"8-022",
"8-023",
"8-024",
"9-001",
"9-002",
"9-003",
"9-004",
"9-005",
"9-006",
"9-007",
"9-008",
"10-001 nouveau disponible logiciel cartographie permettant preparer randonnees trace mesure denivele distance visualisation l'aide photo aerienne donnees numeriques ign contenues dans dvd sont issues d'un assemblage cartes photographies aeriennes plus recentes disponibles 1er decembre 2007 georando decouverte necessite aucun enregistrement connexion internet chaque fonctionne maniere independante france metropolitaine traces sentiers club vosgien inclus choisir zone randonnee carte 000 	pour rejoindre lieu 250 randonner velo 100 pixel represente couverture departements 90 ",
"10-002 disponible jusqu'a epuisement stocks logiciel cartographie permettant preparer randonnees trace mesure denivele distance visualisation l'aide photo aerienne donnees numeriques ign contenues dans dvd sont issues d'un assemblage cartes photographies aeriennes plus recentes disponibles 1er decembre 2007 georando decouverte necessite aucun enregistrement connexion internet chaque fonctionne maniere independante france metropolitaine traces sentiers club vosgien inclus choisir zone randonnee carte 000 	pour rejoindre lieu 250 randonner velo 100 pixel represente couverture departements 88 ",
"11-001 ensemble volumes guide club vosgien  ",
"11-002 volume cotes lorraine vosges nord ",
"11-003 volume vosges moyennes plateau lorrain sud ",
"11-004 volume alsace centrale hautes vosges ",
"11-005 volume vosges sud trouee belfort sundgau ",
"12-001 valable permet recevoir numeros trimestriels fur mesure leur parution  ",
"12-002",
"12-003",
"12-004",
"12-005",
"12-006",
"12-007",
"12-008",
"12-009",
"12-010",
"12-011",
"13-001 balades variantes 853 promenades randonnees ",
"13-002 sarrebourg-belfort versant ouest vosges ",
"13-003 soultz-sous-forets leymen l'outre-foret jura alsacien ",
"13-004 bilingue francais allemand ",
"13-005",
"13-006",
"13-007",
"13-008",
"13-009",
"13-010",
"13-011",
"13-012",
"13-013",
"13-014",
"13-015",
"13-016",
"13-017",
"13-018 saisissez description article ici ");
itUrlsArray = new Array("../cartesau125000e/page1.html",
"../cartesau125000e/page2.html",
"../cartesau125000e/page3.html",
"../cartesau125000e/page4.html",
"../cartesau125000e/page5.html",
"../cartesau125000e/page6.html",
"../cartesau125000e/page7.html",
"../cartesau125000e/page8.html",
"../cartesau125000e/page9.html",
"../cartesau125000e/page10.html",
"../cartesau125000e/page11.html",
"../cartesau125000e/page12.html",
"../cartesau125000e/page13.html",
"../cartesau125000e/page14.html",
"../cartesau125000e/page15.html",
"../cartesau125000e/page16.html",
"../cartesau125000e/page17.html",
"../cartesau125000e/page18.html",
"../cartesau125000e/page19.html",
"../cartesau125000e/page20.html",
"../cartesau125000e/page21.html",
"../cartesau125000e/page22.html",
"../cartesau125000e/page23.html",
"../cartesau125000e/page24.html",
"../cartesau150000e/page1.html",
"../cartesau150000e/page2.html",
"../cartesau150000e/page3.html",
"../cartesau150000e/page4.html",
"../cartesau150000e/page5.html",
"../cartesau150000e/page6.html",
"../cartesau150000e/page7.html",
"../cartesau150000e/page8.html",
"../cartesnumeriques/page1.html",
"../cartesnumeriques/page2.html",
"../divers/page1.html",
"../divers/page2.html",
"../divers/page3.html",
"../divers/page4.html",
"../divers/page5.html",
"../revuelesvosges/page1.html",
"../revuelesvosges/page2.html",
"../revuelesvosges/page3.html",
"../revuelesvosges/page4.html",
"../revuelesvosges/page5.html",
"../revuelesvosges/page6.html",
"../revuelesvosges/page7.html",
"../revuelesvosges/page8.html",
"../revuelesvosges/page9.html",
"../revuelesvosges/page10.html",
"../revuelesvosges/page11.html",
"../publicationsdive/page1.html",
"../publicationsdive/page2.html",
"../publicationsdive/page3.html",
"../publicationsdive/page4.html",
"../publicationsdive/page5.html",
"../publicationsdive/page6.html",
"../publicationsdive/page7.html",
"../publicationsdive/page8.html",
"../publicationsdive/page9.html",
"../publicationsdive/page10.html",
"../publicationsdive/page11.html",
"../publicationsdive/page12.html",
"../publicationsdive/page13.html",
"../publicationsdive/page14.html",
"../publicationsdive/page15.html",
"../publicationsdive/page16.html",
"../publicationsdive/page17.html",
"../publicationsdive/page18.html");
itTitlesArray = new Array("3613ET SARREGUEMINES",
"3713ET PAYS DE BITCHE",
"3614ET SARRE-UNION / PHALSBOURG",
"3714ET LA PETITE PIERRE",
"3814ET HAGUENAU / WISSEMBOURG",
"3914OT WISSEMBOURG",
"3715OT SAVERNE / SARREBOURG",
"3616OT LE DONON",
"3716ET MONT SAINTE-ODILE",
"3617OT SAINT-DIE-DES-VOSGES",
"3617ET SAINTE-MARIE-AUX-MINES",
"3717ET SELESTAT / RIBEAUVILLE",
"3518OT EPINAL",
"3618OT LE HOHNECK / GERARDMER",
"3718OT COLMAR / KAYSERSBERG",
"3519OT REMIREMONT",
"3619OT BUSSANG / LA BRESSE",
"3719OT GRAND BALLON",
"3520ET BALLON D'ALSACE",
"3620ET THANN / MASEVAUX",
"3720ET MULHOUSE",
"3621OT BELFORT",
"3621ET ALTKIRCH",
"3721ET HUNINGUE / BÂLE",
"1/8 SARREGUEMINES / BITCHE / SAINT-AVOLD / SARREBOURG / SAVERNE / WASSELONNE",
"2/8 WISSEMBOURG / NIEDERBRONN / HAGUENAU / STRASBOURG",
"3/8 NANCY / LE LUNEVILLOIS / RAON-L'ETAPE",
"4/8 STRASBOURG / MONT-SAINTE-ODILE / DONON / HAUT-KOENIGSBOURG",
"5/8 EPINAL / REMIREMONT / LUXEUIL-LES-BAINS",
"6/8 COLMAR / MUNSTER / HOHNECK / GERARDMER / BALLONS DES VOSGES",
"7/8 MULHOUSE / MASEVAUX / BELFORT / MONTBELLIARD / SUNDGAU",
"8/8 METZ / THIONVILLE / LONGUYON / SIERK-LES-BAINS",
"GEORANDO Maxi Découverte ALSACE-VOSGES",
"GEORANDO Découverte ALSACE-VOSGES",
"Guide du Club Vosgien - Collection",
"Guide du Club Vosgien 1/4",
"Guide du Club Vosgien 2/4",
"Guide du Club Vosgien 3/4",
"Guide du Club Vosgien 4/4",
"Abonnement",
"N°02/2010",
"N° 01/2010",
"N° 04/2009",
"N° 03/2009",
"N° 02/2009",
"N° 01/2009",
"N° 04/2008",
"N° 03/2008",
"N° 02/2008",
"N° 01/2008",
"Balades dans le Pays de Bitche",
"Topoguide GR 533",
"Topoguide GR 531",
"Le Tres Tabernae (topoguide)",
"Topoguide Strasbourg à pied",
"Topoguide Mulhouse et environs",
"Topoguide TER",
"Le Hohwald",
"Haute vallée de la Sauer",
"Saverne, centre de randonnées",
"Barr et sa région",
"Fermes-auberges de Haute-Alsace",
"Phalsbourg / Lutzelbourg",
"Découvrir la vallée de Munster 1",
"Découvrir la vallée de Munster 2",
"Découvrir la vallée de Munster 3",
"Passion Vosges spécial Vosges du Nord",
"Passion Vosges  Spécial La Haute-Bruche");
itDescArray = new Array("",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"+NOUVEAU ! +disponible  Logiciel de cartographie pour PC permettant de préparer des randonnées (tracé, mesure de dénivelé et de distance, visualisation à l'aide de photo aérienne).  Les données numériques IGN contenues dans ce DVD sont issues d'un assemblage de cartes ou photographies aériennes les plus récentes disponibles au 1er décembre 2007. -Géorando Découverte ne nécessite aucun enregistreme...",
"+Disponible jusqu'à épuisement des stocks ! Logiciel de cartographie pour PC permettant de préparer des randonnées (tracé, mesure de dénivelé et de distance, visualisation à l'aide de photo aérienne).  Les données numériques IGN contenues dans ce DVD sont issues d'un assemblage de cartes ou photographies aériennes les plus récentes disponibles au 1er décembre 2007. -Géorando Découverte ne nécessit...",
"Ensemble des 4 volumes du Guide du Club Vosgien",
"Volume 1 : Côtes de Lorraine et Vosges du Nord",
"Volume 2 : Vosges moyennes et Plateau Lorrain du Sud",
"Volume 3 : Alsace Centrale et Hautes Vosges",
"Volume 4 : Vosges du Sud, Trouée de Belfort et Sundgau",
"valable un an, permet de recevoir les 4 numéros trimestriels au fur et à mesure de leur parution.",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"- 25 balades et 41 variantes - 853 km de promenades et randonnées",
"Sarrebourg-Belfort par le versant Ouest des Vosges",
"Soultz-sous-Forêts / Leymen De l'outre-forêt au jura alsacien",
"bilingue français/allemand",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"Saisissez la description  de votre article ici");
itImgArray = new Array("../cartesau125000e/bv000003.thumb.jpg",
"../cartesau125000e/bv000006.thumb.jpg",
"../cartesau125000e/bv000009.thumb.jpg",
"../cartesau125000e/bv000012.thumb.jpg",
"../cartesau125000e/bv000016.thumb.jpg",
"../cartesau125000e/bv000070.thumb.jpg",
"../cartesau125000e/bv000019.thumb.jpg",
"../cartesau125000e/bv000022.thumb.jpg",
"../cartesau125000e/bv000025.thumb.jpg",
"../cartesau125000e/bv000028.thumb.jpg",
"../cartesau125000e/bv000031.thumb.jpg",
"../cartesau125000e/bv000034.thumb.jpg",
"../cartesau125000e/bv000014.thumb.jpg",
"../cartesau125000e/bv000037.thumb.jpg",
"../cartesau125000e/bv000040.thumb.jpg",
"../cartesau125000e/bv000043.thumb.jpg",
"../cartesau125000e/bv000046.thumb.jpg",
"../cartesau125000e/bv000049.thumb.jpg",
"../cartesau125000e/bv000052.thumb.jpg",
"../cartesau125000e/bv000055.thumb.jpg",
"../cartesau125000e/bv000058.thumb.jpg",
"../cartesau125000e/bv000061.thumb.jpg",
"../cartesau125000e/bv000064.thumb.jpg",
"../cartesau125000e/bv000067.thumb.jpg",
"../cartesau150000e/bv000006.thumb.jpg",
"../cartesau150000e/bv000001.thumb.jpg",
"../cartesau150000e/bv000007.thumb.jpg",
"../cartesau150000e/bv000010.thumb.jpg",
"../cartesau150000e/bv000013.thumb.jpg",
"../cartesau150000e/bv000016.thumb.jpg",
"../cartesau150000e/bv000019.thumb.jpg",
"../cartesau150000e/bv000022.thumb.jpg",
"../cartesnumeriques/bv000003.thumb.jpg",
"../cartesnumeriques/bv000014.thumb.jpg",
"../divers/bv000008.thumb.jpg",
"../divers/bv000014.thumb.jpg",
"../divers/bv000002.thumb.jpg",
"../divers/bv000004.thumb.jpg",
"../divers/bv000006.thumb.jpg",
"../revuelesvosges/bv000017.thumb.jpg",
"../revuelesvosges/bv000021.thumb.jpg",
"../revuelesvosges/bv000019.thumb.jpg",
"../revuelesvosges/bv000015.thumb.jpg",
"../revuelesvosges/bv000012.thumb.jpg",
"../revuelesvosges/bv000010.thumb.jpg",
"../revuelesvosges/bv000008.thumb.jpg",
"../revuelesvosges/bv000006.thumb.jpg",
"../revuelesvosges/bv000004.thumb.jpg",
"../revuelesvosges/bv000002.thumb.jpg",
"../revuelesvosges/bv000014.thumb.jpg",
"../publicationsdive/bv000035.thumb.jpg",
"../publicationsdive/bv000014.thumb.jpg",
"../publicationsdive/bv000002.thumb.jpg",
"../publicationsdive/bv000004.thumb.jpg",
"../publicationsdive/bv000006.thumb.jpg",
"../publicationsdive/bv000008.thumb.jpg",
"../publicationsdive/bv000010.thumb.jpg",
"../publicationsdive/bv000012.thumb.jpg",
"../publicationsdive/bv000015.thumb.jpg",
"../publicationsdive/bv000017.thumb.jpg",
"../publicationsdive/bv000019.thumb.jpg",
"../publicationsdive/bv000021.thumb.jpg",
"../publicationsdive/bv000023.thumb.jpg",
"../publicationsdive/bv000025.thumb.jpg",
"../publicationsdive/bv000027.thumb.jpg",
"../publicationsdive/bv000029.thumb.jpg",
"../publicationsdive/bv000031.thumb.jpg",
"../publicationsdive/bv000033.thumb.jpg");
itRefArray = new Array("8-001",
"8-002",
"8-003",
"8-004",
"8-005",
"8-006",
"8-007",
"8-008",
"8-009",
"8-010",
"8-011",
"8-012",
"8-013",
"8-014",
"8-015",
"8-016",
"8-017",
"8-018",
"8-019",
"8-020",
"8-021",
"8-022",
"8-023",
"8-024",
"9-001",
"9-002",
"9-003",
"9-004",
"9-005",
"9-006",
"9-007",
"9-008",
"10-001",
"10-002",
"11-001",
"11-002",
"11-003",
"11-004",
"11-005",
"12-001",
"12-002",
"12-003",
"12-004",
"12-005",
"12-006",
"12-007",
"12-008",
"12-009",
"12-010",
"12-011",
"13-001",
"13-002",
"13-003",
"13-004",
"13-005",
"13-006",
"13-007",
"13-008",
"13-009",
"13-010",
"13-011",
"13-012",
"13-013",
"13-014",
"13-015",
"13-016",
"13-017",
"13-018");
itPricesArray = new Array(10.40,
10.40,
10.40,
10.40,
10.40,
10.40,
10.40,
10.40,
10.40,
10.40,
10.40,
10.40,
10.40,
10.40,
10.40,
10.40,
10.40,
10.40,
10.40,
10.40,
10.40,
10.40,
10.40,
10.40,
10.15,
10.15,
9.10,
10.15,
9.10,
10.15,
10.15,
9.10,
59.90,
39.90,
55.00,
12,
12,
23,
12,
7,
3.81,
3.81,
3.81,
3.81,
3.81,
3.81,
3.81,
3.81,
3.81,
3.81,
13.00,
3.80,
5.70,
7.60,
12.95,
12.00,
8.00,
5.35,
7.65,
8.00,
7.65,
8.00,
3.00,
12,
13,
13,
7,
7);
var itemsCount = 68;
var catalogdirs = new Array("/cartesau125000e/",
"/cartesau150000e/",
"/cartesnumeriques/",
"/divers/",
"/revuelesvosges/",
"/publicationsdive/");
var catalognames = new Array("Cartes 1 / 25 000",
"Cartes 1 / 50 000",
"Cartes Géorando",
"Guides du Club Vosgien",
"Revue \"Les Vosges\"",
"Publications diverses");

			
function SubmitSearch(n)
{
	var p = document.getElementsByName("jse_query");
	if( p < 0) return false;
	if( p && p[n] && p[n].value != "" ) 
	{
	  if( (p[n].value).replace(/^\s+|\s+$/g, '') != "" ) 
	  {
		var idx = 0;
		p = document.getElementsByName("minprice");
		if( p && p[idx] )
		{
			if( p[idx].value != "" && isNaN(p[idx].value) )
			{
				if( LBL_PRICEERROR != "" )
					alert( LBL_PRICEERROR );
				return false;
			}
		}
		p = document.getElementsByName("maxprice");
		if( p && p[idx] )
		{
			if( p[idx].value != "" && isNaN(p[idx].value) )
			{
				if( LBL_PRICEERROR != "" )
					alert( LBL_PRICEERROR );
				return false;
			}
		}
		p = document.getElementsByName("jse_form");
		if( p && p[n] )
			p[n].submit();
		return true;
	  }
	}
	return false;
}
function switchSearchLang(lang,emptycart)
{
	var params = "";
	var currURL = document.location.href;
	var newURL = (currURL.lastIndexOf('_frame/search2') >= 0) ? "search2":"search";
	if( lang != "" )
		newURL += "-"+lang;
	newURL += ".html";
	var paramIndex = currURL.lastIndexOf('?');
	if( paramIndex > -1 )
		newURL += "?" + currURL.substr( paramIndex + 1 );
	if( emptycart && typeof(CleanShopcart) != "undefined" )
		CleanShopcart();
	document.location.href = newURL;
	return false;
}
			
// getParam returns the value of the specified GET parameter
function getParam(paramName)
{
    paramStr = document.location.search;
    if( paramStr == "" )
        return "";
    if( paramStr.charAt(0) == "?" )
        paramStr = paramStr.substr(1);
    arg = (paramStr.split("&"));
    for( i=0; i<arg.length; i++ ) 
    {
      arg_values = arg[i].split("=")
      if( unescape(arg_values[0]) == paramName ) 
      {
         if( USE_UTF8 == 1 && self.decodeURIComponent ) // check if decodeURIComponent() is defined
            ret = decodeURIComponent(arg_values[1]);
         else
            ret = unescape(arg_values[1]);  // IE 5.0 and older does not have decodeURI
         return ret;
      }
    }
    return "";
}

function getQueryParam()
{
  var query = getParam("jse_query");
  query = query.replace(/[\++]/g, " ");  // replace any '+' with spaces
  query = query.replace(/\</g, "&lt;");
  query = query.replace(/[\"+]/g, " ");
	return query;
}

function replaceAll(str,from,to) 
{
    var idx = str.indexOf(from);
    while( idx > -1 ) {
        str = str.replace(from, to); 
        idx = str.indexOf(from);
    }
    return str;
}

// lowercase, remove quotes and accents
function formatChars(str) 
{
    str = str.toLowerCase();
    if( REMOVE_ACCENTS ) 
    {
      var a = "àáâãäåòóôõöèéêëçìíîïùúûüÿñ";
      var b = "aaaaaaoooooeeeeciiiiuuuuyn";
      for( i=0; i<a.length; i++ )
        str = replaceAll( str, a.charAt(i), b.charAt(i) );
    }
    str = replaceAll( str, "'", " " );
    return str;
}

function SortCompare2(a, b)
{
	if( SORTCOMPARE == 1 ) 
	{
	    if (a[3] < b[3]) return 1;
	    else if (a[3] > b[3]) return -1;
	    else return 0;
	}
	else if( SORTCOMPARE == 0 )
	{
	    if (a[3] > b[3]) return 1;
	    else if (a[3] < b[3]) return -1;
	    else return 0;
	}
	return -1;
}

function jseSearch2( internal )
{
  // get params
  var rootURL = '';
	var SelfURL = document.location.href;
  var paramIndex = SelfURL.indexOf("?");    
  if (paramIndex > -1)
     SelfURL = SelfURL.substr(0, paramIndex);
  paramIndex = SelfURL.indexOf("#");
  if (paramIndex > -1)
    SelfURL = SelfURL.substr(0, paramIndex);        
	if (ONLINE_WEBSITE) 
	{
		paramIndex = SelfURL.lastIndexOf('/');
		if (paramIndex > -1) 
		{
			rootURL = SelfURL.substr(0, paramIndex);
			paramIndex = rootURL.lastIndexOf('/');
			if (paramIndex > -1) {
				rootURL = SelfURL.substr(0, paramIndex+1);
			} else
			  rootURL = '';
		}
	}	
  SelfURL = SelfURL.replace(/\</g, "&lt;");
  SelfURL = SelfURL.replace(/\"/g, "&quot;");

  var query = getQueryParam();
  var sortp = getParam("sort");
  if( sortp == "0" ) {
	SORTCOMPARE = 0;
  } else if( sortp == "1" ) {
	SORTCOMPARE = 1;
  } else if( sortp == "2" )
	SORTCOMPARE = 2;
  var catfilterp = getParam("cat");
  var minPrice = getParam("minprice");
  var maxPrice = getParam("maxprice");
 
  // display the search form
  var lnktarget = "";
	query = formatChars(query);
  if( query.length == 0 ) return;
  
  var found=0, t=0, k=0, score=0, i=0;
  var keyword = "", tmp = "";
  var searchWords = new Array();

  // split search query by spaces
  searchWords = query.split(" ");
  // init result table information
  res_table = new Array(itemsCount);
  for( t=0; t<itemsCount; t++ )
  {
    res_table[t] = new Array(3);
    res_table[t][0] = 0;  // index
    res_table[t][1] = 0;  // score
    res_table[t][2] = 0;  // words found
    res_table[t][3] = 0;  // price
  }

  var significantwords = 0;

  // begin search ...
  for( i=0; i<searchWords.length; i++ )
  {
    keyword = searchWords[i];
    if( keyword.length > MIN_WORD_LEN ) // skip small words
	{
	  significantwords++;
	  for(var q=0; q<itemsCount; q++ )
	  {
		// catalog filter verification
	    if( catfilterp != "" && catfilterp != "allcat" && itUrlsArray[q].indexOf(catfilterp) == -1 ) 
			continue;
		// min and max price filter
	    if( minPrice > 0 && itPricesArray[q] < minPrice )
			continue;
	    if( maxPrice > 0 && itPricesArray[q] > maxPrice )
			continue;
		// search for keywords (an exact word doubles the score)
		score = 0;
		tmp = formatChars(itDescArray[q]);
	    if( tmp.indexOf(keyword) != -1 ) score++;
	    if( tmp.indexOf(' '+keyword+' ') != -1 ) score+=2;
		  tmp = formatChars(itTitlesArray[q]);
	  	if( tmp.indexOf(keyword) != -1 ) score++;
		  if( tmp.indexOf(' '+keyword+' ') != -1 ) score+=2;
		  tmp = formatChars(itNamesArray[q]);
	    if( tmp.indexOf(keyword) != -1 ) score++;
	    if( tmp.indexOf(' '+keyword+' ') != -1 ) score+=2;
			
	    if( score > 0 ) // && itPricesArray[q] > 0 )  // add this test in order not to display 0.00 prices 
	    {
		  if( res_table[q][1] <= 0 ) 
			found++;	// increment only if not already found with a previous keyword
	      res_table[q][0] = q;
	      res_table[q][1] = 1; // itPricesArray[q];
	      res_table[q][2]++;
	      res_table[q][3] = itPricesArray[q];
	    }
	  }
	}
  }
  if( found == 0 ) {
    document.write("<br><p class='wg-paragraph'><b>" + STR_NO_RESULT + "</b></p>");
  } 
  else 
  {
	if( ALLWORDSONLY )
	{
		//  if all words only then we recount and filter amoung the results to get the total of found items
		found = 0;
		for( var z=0; z<itemsCount; z++ )
			if( res_table[z][1] > 0 ) // display only results with a positive score
			if( !ALLWORDSONLY || (ALLWORDSONLY && res_table[z][2] == significantwords) )
				found++;
	}
	if( internal == null || internal != 1 ) {
		document.writeln( "<span class='wg-paragraph'>" + found + " " + LBL_QUERY_RESULT + "<strong>" +query+"</strong></span>" );
	}
	// sort by words found and scores
	if( SORTCOMPARE >= 0 && SORTCOMPARE <= 1 )
		res_table.sort(SortCompare2);	
    // display the results
	document.writeln("<table border='1' class='wg-paragraph' bordercolor='"+BORDERCOLOR+"' style='border-collapse:collapse;margin:4px;' cellspacing='2' cellpadding='2' >");

	for( var q=0; q<itemsCount; q++ )
	{
      if( res_table[q][1] > 0 ) // display only results with a positive score
	  if( !ALLWORDSONLY || (ALLWORDSONLY && res_table[q][2] == significantwords) )
	  {
        t = res_table[q][0];    // get page index
		document.writeln("<tr valign='top'><td>");
		if( itImgArray[t] != "" ) {
			document.writeln("<a href=\"" + itUrlsArray[t] + lnktarget + "\">" + "<img src='"+itImgArray[t]+"' border='0' width=\"48\" height=\"48\" /></a>" );
		}
		document.writeln("</td><td>");
		if( 1 ) { //BOLD_LINKS ) {
          document.writeln("<b><a href=\"" + itUrlsArray[t] + lnktarget + "\">" + itTitlesArray[t] + "</a></b><br>" );
        } else
          document.writeln("<a href=\"" + itUrlsArray[t] + lnktarget + "\">" + itTitlesArray[t] + "</a><br>" );
		if( SHOWREFERENCES && itRefArray[t] != "" ) {
			var ref = itRefArray[t].split(' ');
			if( ref && ref[0] != "" ) 
				document.writeln( LBL_ITREFERENCE+" : "+ref[0]+"<br>" );
		}
        if( itDescArray[t].length > 2 )
			document.writeln( itDescArray[t]);
		document.writeln("</td><td nowrap>");
		if( itPricesArray[t] != ""  && itPricesArray[t] > 0 )
			document.writeln( LBL_ITPRICE+"<br><b>"+AddMonetarySymbol(moneyFormat(itPricesArray[t]))+"</b>" );
		else
			document.writeln( "&nbsp;" );
		document.writeln("</td></tr>");
      }
	}
	document.writeln("</table>");			
  }
  document.writeln("<br>");
}
