// ----------------------------------------------------------------------------
// 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 = 1;
DISPLAY_SRCH_INFO = 1;
USE_UTF8 = 0;
REMOVE_ACCENTS = 1;
BOLD_LINKS = 1;
ONLINE_WEBSITE = 1;
ALLWORDSONLY = 0;
SHOWREFERENCES = 0;
BORDERCOLOR = "#FFB200";
SORTCOMPARE = 2;
itNamesArray = new Array("7-001 650mhz pa-8700 or the 750mhz some of industry's fastest risc processors available with one two 128mb to 8gb sdram memory up 72gb internal disk built in 100base-t support  ",
"7-002 processor speeds from 360mhz to 750 mhz processors 256mb 16gb of memory available internal disk bays support up 584gb built in 100base-t  ",
"7-003 to processors of 800 mhz up 6gb memory available internal disk bays support 900gb pci slots  ",
"7-004 processors speeds of 800 mhz and 1ghz to up 32gb memory available internal disk bays support 900gb pci slots  ",
"7-005 to processors of 800 mhz and 1ghz up 128gb memory available internal disk bays support 6000gb pci slots  ",
"7-006 processors speeds of 800 mhz and 1ghz to up 32gb memory available internal disk bays support 6000gb pci slots  ",
"7-007 processor speeds from 650mhz to 875mhz cpus available supports up 64gb of memory internal hot-plug disk drive slots support 584gb storage  ",
"7-008 processor speeds 900mhz to 1ghz 16 cpus available supports up 128gb internal hot-plug disk drive slots support 2tb of storage  ",
"7-009 processor speeds from 650mhz to 875mhz 16 cpus available supports up 64gb of memory internal hot-plug disk drive slots support 584gb storage for vpars  ",
"7-010 processor speeds from 900mhz to 1ghz 32 cpus available supports up 256gb internal hot-plug disk drive slots support 2tb of storage for 16 vpars  ",
"8-001 intel itanium 0ghz processors one or two up to 16gb memory 292gb disk space pci slots  ",
"8-002 intel itanium 3ghz or 6ghz processors one two up to 16gb memory 600gb disk space pci slots ",
"8-003 intel itanium 0ghz 3ghz 4ghz or 5ghz one two processors up to 24gb memory 438gb disk space pci slots  ",
"8-004 intel itanium or 6ghz ghz processors one two up to 32gb memory 900gb disk space pci slots  ",
"8-005 processor cores 2-4 chipset hp zx2 system bus bandwidth gb dual-core modules type intel® itanium® speeds 6ghz or ghz level cache 32 kb 256 data mb instruction 12 per at 18  ",
"8-006 intel itanium 5ghz or 6ghz processors one to eight up 128gb memory 600gb disk space pci slots  ",
"8-007 intel itanium 3ghz or 5ghz processors one to four up 96gb memory 584gb disk space 10 pci slots  ",
"8-008 processor cores 2–8 modules 1–4 chipset hp zx2 system bus bandwidth gb dual-core type intel® itanium® speed ghz or level cache 32 kb 256 per core data mb instruction 12 at 18 24 ",
"8-009 5ghz or 6ghz intel® itanium® processors two to sixteen up 128gb memory 584gb disk space 15 pci expansion slots  ",
"8-010 6ghz intel itanium processors two to eight up 16 using dual modules 64gb memory 1200gb disk space pci expansion slots ",
"8-011 5ghz or 6ghz intel itanium processors two to thirty up 256gb memory 584gb disk space 16 pci expansion slots  ",
"8-012 6ghz intel itanium processors two to sixteen up 32 using dual modules 1200gb memory 584gb disk space 16 pci expansion slots ",
"9-001 specifications processor pa-8500 at 400mhz 4gb maximum memory graphics accelerators visualize-fxe visualize-fx5pro 45gb internal storage  ",
"9-002 specifications 500mhz pa-8600 processor up to gb of pc120 sdram dimm slots two 36 or 146 10k rpm 73 15k ultra2 scsi drives 292 max hp fxe fx5pro graphics options hp-ux operating system total half-length 32-bit 33 mhz pci full-length 64-bit 66 pci-x  ",
"9-003 specifications single pa-8600 processor running at 400mhz supports 512mb 8gb 120mhz sdram main memory ultra2 scsi lvd 80-pin sca connector 9gb or 146gb drives max nse scsi external mass storage connections  ",
"9-004 specifications single pa-8600 processor running at 552mhz supports 512mb 8gb 120mhz sdram main memory ultra2 scsi lvd 80-pin sca connector 9gb or 18gb drives max nse scsi external mass storage connections ",
"9-005 specifications pa-8700 625mhz processor supports 512mb 8gb 120mhz sdram main memory up to ultra2 scsi lvd 18gb-73gb nse scsi external mass storage connections hp fxe fx5 pro or fx10 graphics ",
"9-006 specifications single 750mhz pa-8700 processor up to 8gb pc120 sdram ultra scsi lvd hard-disk drive 18gb-73gb drives nse ultra2 external mass storage connections via pci card hp fire gl-ux fxe fx5 pro or fx10 graphics hp-ux operating system ",
"9-007 specifications pa-8700 processor at 875 mhz with 25 mb on-chip l1 cache up to gb of pc120 sdram dimm slots two 36 146 10k rpm or 73 15k ultra2 scsi lvd drives 292 max half length 32-bit 33 pci full 64-bit 100 pci-x hp fire gl-ux fxe fx5 pro fx10 graphics ",
"9-008 specifications hp pa-8600 processors running at 552mhz max memory j5600 8gb j5000 4gb maximum disk storage 72gb lvd ",
"9-009 specifications dual hp pa-risc 8600 552mhz processors 1gb 8gb 120mhz sdram up to hot pluggable ultra2 scsi lvd 80-pin sca connector hard disk drives 18gb-73gb nse scsi external mass storage connections fxe or fx10 pro graphics hp-ux operating system ",
"9-010 specifications two 64-bit pa-8600 processors running at 552mhz up to 16gb 120mhz sdram 2gb sec performance for optimal data transfer ultra2 scsi lvd 80-pin sca connector hot pluggable requires hp mirrordisk ux 18gb drives max nse scsi external mass storage connections ",
"9-011 specifications dual pa-8700 750mhz or 875mhz processors up to 16 gb sdram memory 292 of ultra2 scsi internal disk storage 64 bit operating system and microprocessor hp fire gl-ux fx10 pro fxe graphics ",
"9-012  ",
"10-001  ",
"10-002  ",
"10-003  ");
itUrlsArray = new Array("../serveurs_hp9000/page1.html",
"../serveurs_hp9000/page2.html",
"../serveurs_hp9000/page3.html",
"../serveurs_hp9000/page4.html",
"../serveurs_hp9000/page5.html",
"../serveurs_hp9000/page6.html",
"../serveurs_hp9000/page7.html",
"../serveurs_hp9000/page8.html",
"../serveurs_hp9000/page9.html",
"../serveurs_hp9000/page10.html",
"../hp_server_integrity/page1.html",
"../hp_server_integrity/page2.html",
"../hp_server_integrity/page3.html",
"../hp_server_integrity/page4.html",
"../hp_server_integrity/page5.html",
"../hp_server_integrity/page6.html",
"../hp_server_integrity/page7.html",
"../hp_server_integrity/page8.html",
"../hp_server_integrity/page9.html",
"../hp_server_integrity/page10.html",
"../hp_server_integrity/page11.html",
"../hp_server_integrity/page12.html",
"../stations_de_travail_hp9000/page1.html",
"../stations_de_travail_hp9000/page2.html",
"../stations_de_travail_hp9000/page3.html",
"../stations_de_travail_hp9000/page4.html",
"../stations_de_travail_hp9000/page5.html",
"../stations_de_travail_hp9000/page6.html",
"../stations_de_travail_hp9000/page7.html",
"../stations_de_travail_hp9000/page8.html",
"../stations_de_travail_hp9000/page9.html",
"../stations_de_travail_hp9000/page10.html",
"../stations_de_travail_hp9000/page11.html",
"../stations_de_travail_hp9000/page12.html",
"../tape/page1.html",
"../tape/page2.html",
"../tape/page3.html");
itTitlesArray = new Array("rp24xx Series",
"rp54xx Series",
"rp3410 Server",
"rp3440 Server",
"rp4410 Server",
"rp4440 Server",
"RP7410-8",
"RP7420-16",
"RP8400",
"RP8420",
"rx1600",
"rx1620",
"rx2600",
"rx2620",
"rx3600",
"rx4640",
"rx5670",
"rx6600",
"rx7620",
"rx7640",
"rx8620",
"rx8640",
"HP Visualize B2000 Workstation",
"HP Visualize B2600 Workstation",
"HP Visualize C3000 Workstation",
"HP Visualize C3600 Workstation",
"HP Visualize C3650 Workstation",
"HP Visualize c3700 Workstation",
"HP Visualize c3750 Workstation",
"HP Visualize J5000 Workstation",
"HP Visualize J5600 Workstation",
"HP Visualize J6000 Workstation",
"HP Visualize j6750 Workstation",
"HP Visualize C8000 Workstation",
"DDS 2 Drive",
"DDS 3 Drive",
"DDS 4 Drive");
itDescArray = new Array("650MHz PA-8700 or the 750MHz PA-8700 - some of the industry's fastest RISC processors   Available with one or two processors  128MB to 8GB of SDRAM memory  Up to 72GB of internal disk  Built in 100Base-T support",
"Processor speeds from 360MHz to 750 MHz  1 to 4 processors  256MB to 16GB of memory available  4 internal disk bays support up to 584GB of internal disk  Built in 100Base-T support",
"1 to 2 Processors of 800 MHz  Up to 6GB of memory available  3 internal disk bays support up to 900GB of internal disk  2 PCI slots",
"Processors speeds of 800 MHz and 1GHz  1 to 4 processors  Up to 32GB of memory available  3 internal disk bays support up to 900GB of internal disk  4 PCI slots",
"1 to 4 Processors of 800 MHz and 1Ghz  Up to 128GB of memory available  2 internal disk bays support up to 6000GB of internal disk  6 PCI slots",
"Processors speeds of 800 MHz and 1GHz  1 to 8 processors  Up to 32GB of memory available  2 internal disk bays support up to 6000GB of internal disk  6 PCI slots",
"Processor speeds from 650MHz to 875Mhz  2 to 8 CPUs available  Supports up to 64GB of memory  4 internal hot-plug disk drive slots support up to 584GB of internal disk storage",
"Processor speeds 900Mhz to 1GHz  2 to 16 CPUs available  Supports up to 128GB  4 internal hot-plug disk drive slots support up to 1.2TB of internal disk storage",
"Processor speeds from 650MHz to 875Mhz  2 to 16 CPUs available  Supports up to 64GB of memory  4 internal hot-plug disk drive slots support up to 584GB of internal disk storage  Support for up to 16 vPars",
"Processor speeds from 900Mhz to 1GHz  2 to 32 CPUs available  Supports up to 256GB  4 internal hot-plug disk drive slots support up to 1.2TB of internal disk storage  Support for up to 16 vPars",
"Intel Itanium 1.0GHz processors One or two processors Up to 16GB memory Up to 292GB disk space 2 PCI slots",
"Intel Itanium 1.3GHz or 1.6GHz processors One or two processors Up to 16GB memory Up to 600GB disk space 2 PCI slots",
"Intel Itanium 1.0GHz, 1.3GHz, 1.4GHz or 1.5GHz  One or two processors Up to 24GB memory Up to 438GB disk space 4 PCI slots",
"Intel Itanium 1.3 or 1.6GHz GHz processors One or two processors Up to 32GB memory Up to 900GB disk space 4 PCI slots",
"Processor cores:2-4  Chipset: HP zx2  System bus bandwidth: 8.5 GB/s  Dual-core processor modules Type: Intel® Itanium® 2 processor  Speeds: 1.6GHz or 1.4 GHz  Level 1 cache: 32 KB  Level 2 cache: 256 KB (data) 1 MB (instruction)  Level 3 cache: 12 MB per processor at 1.4 GHz; 18 MB per processor at 1.6 GHz",
"Intel Itanium 1.5GHz or 1.6GHz processors One to eight processors Up to 128GB memory Up to 600GB disk space 6 PCI slots",
"Intel Itanium 1.3GHz or 1.5GHz processors One to four processors Up to 96GB memory Up to 584GB disk space 10 PCI slots",
"Processor cores:2–8  Processor modules: 1–4  Chipset: HP zx2  System bus bandwidth: 8.5 GB/s     Dual-core processor modules Type: Intel® Itanium® 2 processor; dual-core processor  Speed: 1.6 GHz or 1.4 GHz  Level 1 cache: 32 KB  Level 2 cache: 256 KB per core (data); 1 MB per core (instruction)  Level 3 cache: 12 MB per processor at 1.4 GHz; 18 MB or 24 MB per processor at 1.6 GHz",
"1.5GHZ or 1.6GHZ Intel® Itanium® Processors two to sixteen processors up to 128GB memory up to 584GB disk space 15 PCI expansion slots",
"1.6GHZ Intel Itanium Processors two to eight processors (up to 16 processors using dual modules) up to 64GB memory up to 1200GB disk space 16 PCI expansion slots",
"1.5GHZ or 1.6GHZ Intel Itanium Processors two to thirty two processors up to 256GB memory up to 584GB disk space 16 PCI expansion slots",
"1.6GHZ Intel Itanium Processors two to sixteen processors (up to 32 processors using dual modules) up to 1200GB memory up to 584GB disk space 16 PCI expansion slots",
"Specifications   * Processor: PA-8500 at 400MHz * 4GB maximum memory * Graphics accelerators: visualize-fxe, visualize-fx5pro * 45GB maximum internal storage",
"Specifications  * 500MHz PA-8600 processor * Up to 4 GB of PC120 SDRAM (4 DIMM slots) * Up to two 36 or 146 GB (10K rpm), or 73 GB (15K rpm) Ultra2 SCSI drives, 292 GB max. * HP fxe or fx5pro graphics options * HP-UX Operating System * 4 total: 2 half-length 32-bit 33 MHz PCI; 2 full-length 64-bit 66 MHz PCI-X",
"Specifications  *Single PA-8600 processor running at 400MHz  *Supports 512MB - 8GB 120MHz SDRAM main memory  *Ultra2 SCSI LVD (80-pin SCA connector) – 2 x 9GB or 146GB drives max * NSE SCSI, Ultra2 SCSI LVD external mass storage connections",
"Specifications   * Single PA-8600 processor running at 552MHz * Supports 512MB - 8GB 120MHz SDRAM main memory * Ultra2 SCSI LVD (80-pin SCA connector) – 2 x 9GB or 18GB drives max. * NSE SCSI, Ultra2 SCSI LVD external mass storage connections",
"Specifications  * PA-8700 625MHz processor * Supports 512MB - 8GB 120MHz SDRAM main memory * Up to 2 Ultra2 SCSI LVD 18GB-73GB * NSE SCSI, Ultra2 SCSI LVD external mass storage connections * HP fxe, fx5 pro or fx10 pro graphics",
"Specifications * Single 750MHz PA-8700 processor * Up to 8GB PC120 SDRAM * 2 x Ultra 2 SCSI LVD hard-disk drive (18GB-73GB drives) * NSE SCSI, Ultra2 SCSI LVD external mass storage connections (via PCI card) * hp Fire GL-UX, fxe, fx5 pro or fx10 pro graphics * HP-UX Operating System",
"Specifications  * PA-8700+ processor at 875 MHz with 2.25 MB on-chip L1 cache * Up to 8 GB of PC120 SDRAM (8 DIMM slots) * Up to two 36 GB, 146 GB (10K rpm) or 73 GB (15K rpm) Ultra2 SCSI LVD drives (292 GB max.) * 2 half length 32-bit 33 MHz PCI, 3 full length 64-bit 33 MHz PCI, 1 full length 64-bit 100 MHz PCI-X * hp Fire GL-UX, fxe, fx5 pro or fx10 pro graphics",
"Specifications  * 2 x HP PA-8600 processors running at 552MHz * Max memory: j5600 8GB, j5000 4GB * Maximum Disk Storage 72Gb LVD",
"Specifications  * Dual HP PA-RISC 8600 552MHz processors * 1GB - 8GB 120MHz SDRAM * Up to 4 hot pluggable Ultra2 SCSI LVD (80-pin SCA connector) hard disk drives (18GB-73GB drives) * NSE SCSI, Ultra2 SCSI LVD external mass storage connections * HP fxe or fx10 pro graphics * HP-UX Operating System",
"Specifications  * Two 64-bit PA-8600 processors running at 552MHz * Up to 16GB 120MHz SDRAM * 2GB/sec I/O performance for optimal data transfer * Ultra2 SCSI LVD (80-pin SCA connector) hot pluggable (requires hp MirrorDisk/UX) 18GB. 2 drives max. * NSE SCSI, Ultra2 SCSI LVD external mass storage connections",
"Specifications  * Dual PA-8700 750MHZ or PA-8700+ 875MHz processors * Up to 16 GB SDRAM memory * Up to 292 GB of Ultra2 SCSI internal disk storage * 64 bit x 64 bit - operating system and microprocessor * hp Fire GL-UX, hp fx10 pro or hp fxe graphics",
"",
"",
"",
"");
itImgArray = new Array("../serveurs_hp9000/bv000001.thumb.jpg",
"../serveurs_hp9000/bv000002.thumb.jpg",
"../serveurs_hp9000/bv000005.thumb.jpg",
"../serveurs_hp9000/bv000007.thumb.jpg",
"../serveurs_hp9000/bv000013.thumb.jpg",
"../serveurs_hp9000/bv000009.thumb.jpg",
"../serveurs_hp9000/bv000011.thumb.jpg",
"../serveurs_hp9000/bv000015.thumb.jpg",
"../serveurs_hp9000/bv000017.thumb.jpg",
"../serveurs_hp9000/bv000019.thumb.jpg",
"../hp_server_integrity/bv000002.thumb.jpg",
"../hp_server_integrity/bv000003.thumb.jpg",
"../hp_server_integrity/bv000001.thumb.jpg",
"../hp_server_integrity/bv000004.thumb.jpg",
"../hp_server_integrity/bv000031.thumb.jpg",
"../hp_server_integrity/bv000005.thumb.jpg",
"../hp_server_integrity/bv000006.thumb.jpg",
"../hp_server_integrity/bv000034.thumb.jpg",
"../hp_server_integrity/bv000013.thumb.jpg",
"../hp_server_integrity/bv000017.thumb.jpg",
"../hp_server_integrity/bv000015.thumb.jpg",
"../hp_server_integrity/bv000019.thumb.jpg",
"../stations_de_travail_hp9000/bv000001.thumb.jpg",
"../stations_de_travail_hp9000/bv000002.thumb.jpg",
"../stations_de_travail_hp9000/bv000003.thumb.jpg",
"../stations_de_travail_hp9000/bv000004.thumb.jpg",
"../stations_de_travail_hp9000/bv000005.thumb.jpg",
"../stations_de_travail_hp9000/bv000006.thumb.jpg",
"../stations_de_travail_hp9000/bv000013.thumb.jpg",
"../stations_de_travail_hp9000/bv000015.thumb.jpg",
"../stations_de_travail_hp9000/bv000017.thumb.jpg",
"../stations_de_travail_hp9000/bv000019.thumb.jpg",
"../stations_de_travail_hp9000/bv000021.thumb.jpg",
"../stations_de_travail_hp9000/bv000023.thumb.jpg",
"../tape/bv000001.thumb.jpg",
"../tape/bv000002.thumb.jpg",
"../tape/bv000003.thumb.jpg");
itRefArray = new Array("7-001",
"7-002",
"7-003",
"7-004",
"7-005",
"7-006",
"7-007",
"7-008",
"7-009",
"7-010",
"8-001",
"8-002",
"8-003",
"8-004",
"8-005",
"8-006",
"8-007",
"8-008",
"8-009",
"8-010",
"8-011",
"8-012",
"9-001",
"9-002",
"9-003",
"9-004",
"9-005",
"9-006",
"9-007",
"9-008",
"9-009",
"9-010",
"9-011",
"9-012",
"10-001",
"10-002",
"10-003");
itPricesArray = new Array(0.00,
0.00,
0.00,
0.00,
0.00,
0.00,
0.00,
0.00,
0.00,
0.00,
0.00,
0.00,
0.00,
0.00,
0.00,
0.00,
0.00,
0.00,
0.00,
0.00,
0.00,
0.00,
0.00,
0.00,
0.00,
0.00,
0.00,
0.00,
0.00,
0.00,
0.00,
0.00,
0.00,
0.00,
0.00,
0.00,
0.00);
var itemsCount = 37;
var catalogdirs = new Array("/serveurs_hp9000/",
"/hp_server_integrity/",
"/stations_de_travail_hp9000/",
"/tape/");
var catalognames = new Array("Serveurs HP9000",
"Serveurs HP Integrity",
"Stations de travail HP9000",
"Tape");

			
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>");
}
