
function showhide(szDivID, iState, HideMethod) {
	
	// 1 visible, 0 hidden
	
	var obj;
	
	if (document.getElementById) {
		obj = document.getElementById(szDivID).style;
	} else if (document.all) {
		obj = document.all[szDivID].style;
	} else {
		obj = document.layers[szDivID].style;
	}
	
	if (HideMethod == 1) {
		obj.visibility = iState ? "visible" : "hidden";
	} else {
		obj.display = iState ? "block" : "none";
	}
}

function findaddress() {
	
	if (document.form.postcode.value.length > 0) {
		document.form.address_click.value=1;
		document.form.submit();
	} else {
		alert("Please enter your postcode.");
	}
}

function check_field(element) {
	
	if (document.getElementById(element).value.length > 0) {
		return true;
		
	} else {
		alert("Please enter your email address.");
		
		return false;
		
	}
	
	
	return true;
}

function filladdress() {
	
	var selindex = document.form.address_list.selectedIndex;
	
	var line1, line2, line3, line4, line5;
	var address = document.form.address_list.options[selindex].value;
	var line = new Array(5);
	
	for (var i = 0; i < 5; i++) {
		line[i] = '';
	}
	
	addarray = address.split(", ");
	size = addarray.length;
	
	if (size <= 6) {
		
		for (var i = 0; i < (size - 1); i++)
			line[i] = addarray[i];
		
	} else {
		
		var end;
		
		var last = addarray[size - 2];
		var last2 = addarray[size - 3];
		
		if (last.length + last2.length <= 28) {
			line[4] = last2 + ', ' + last;
			end = size - 3;
		} else {
			line[4] = last;
			end = size - 2;
		}
		
		var line_i = 0;
		
		for (var i = 0; i < end; i++) {
			
			var thisline = addarray[i];
			
			var nextline = '';
			if (i < (end - 1)) {
				nextline = addarray[i + 1];
			}
			
			if (nextline != '' && (thisline.length + nextline.length <= 28)) {
					line[line_i] = thisline + ', ' + nextline;
					i++;
			} else {
				line[line_i] = addarray[i];
			}
			
			line_i++;
			
			if (line_i == 4) {
				break;
			}
			
		}
	}
	
	for (var i = 0; i < 4; i++) {
		if (line[i] == '') {
			line[i] = line[4];
			line[4] = '';
			break;
		}
	}
	
	document.form.address1.value = line[0];
	document.form.address2.value = line[1];
	document.form.address3.value = line[2];
	document.form.address4.value = line[3];
	document.form.address5.value = line[4];
	document.form.realpostcode.value = addarray[size - 1];
}

function open_popup(URLlink, windowname, features) {
	
	if (!window.focus)
		return true;
	
	var href;
	
	if (typeof(URLlink) == 'string')
		href=URLlink;
	else
		href=URLlink.href;
	
	window.open(href, windowname, features+" scrollbars=yes");
	
	return false;
}

function right(e) {
	
	var msg = 'This image is copyright protected';
	
	var r = true;
	
	if (navigator.appName == 'Netscape' && e.which == 3) {
		r = false;
	} else if (navigator.appName == 'Microsoft Internet Explorer' && event.button==2) {
		r = false;
	}
	
	if (!r)
		alert(msg);
	
	return r;
}

var runfirst = []; // array of functions to call on page onload event

function initpage() {
	
	if (document.images) {
		// copyright message on images
		for (i = 0; i < document.images.length; i++) {
			document.images[i].onmousedown = right;
			document.images[i].oncontextmenu = new Function("return false;")
		}
	}
	
	noSelect(); // disable selection
	
//	for (i = 0; i < runfirst.length; i++) {
//		//alert(runfirst[i]);
//		runfirst[i]();
//	}
	
	try {
		initDropDown();
	} catch (e) {}
	
	try {
		initDropDown2();
	} catch (e) {}
	
	try {
		pageInit();
	} catch (e) {}
}

/***********************************************
* Disable select-text script- © Dynamic Drive (www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit http://www.dynamicdrive.com/ for full source code
* Modified here to exclude form tags properly and cross browser by jscheuer1
***********************************************/

 var omitformtags = ['input', 'textarea', 'select'];

function disableselect(e) {
	for (i = 0; i < omitformtags.length; i++) {
		if (omitformtags[i]==(e.target.tagName.toLowerCase()))
			return;
	}
	
	return false
}

function reEnable() {
	return true
}

function noSelect(){
	
	if (typeof document.onselectstart != 'undefined'){
		
		document.onselectstart = new Function ("return false")
		
		if (document.getElementsByTagName){
			
			var tags = document.getElementsByTagName('*')
			
			for (var j = 0; j < tags.length; j++){
				for (var i = 0; i < omitformtags.length; i++) {
					
					if (tags[j].tagName.toLowerCase() == omitformtags[i]) {
						
						tags[j].onselectstart=function(){
							document.onselectstart=new Function ('return true')
						}
						
						tags[j].onmouseup=function(){
							document.onselectstart=new Function ('return false')
						}
					}
				}
			}
		}
	} else{
		document.onmousedown = disableselect
		document.onmouseup = reEnable
	}
}


/* Email a friend link */

function emailLink(subject, display) {
	
	if (display == null) {
		display = 'Email a Friend';
	}
	
	document.write('<a href="mailto:?subject=' + subject + '&body=' + window.location + '">' + display + '</a>');
}

/***********************************************
* Bookmark site script- © Dynamic Drive DHTML code library (www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit Dynamic Drive at http://www.dynamicdrive.com/ for full source code
***********************************************/

function bookmarksite(title, url){
	if (document.all)
		window.external.AddFavorite(url, title);
	else if (window.sidebar)
		window.sidebar.addPanel(title, url, "")
}

/*************** Brands JS **************************************/

/**
 *
 * From http://www.webreference.com/programming/javascript/ncz/
 *
 */

/**
 * Provides suggestions for brands
 * @class
 * @scope public
 */
 
function BrandSuggestions() {
    this.brands = ["2-Power","3","3M","5 Star","A/S Vestfrost","Aaeon","ABC Products","Absolute","Acctim","Accuview","Acec","Acer","Acorn","Acoustic Energy","Acoustic Solutions","Acute","Addonics","ADI","Admiral","Advan","Advantech","Advent","Advueu","Adyson","AEG","AET","AF International","Affirmative Computer Products","AG","Again & Again","Agfa","AGN","Ahtec","Ainsley Harriott","Aiostay","Air cooler","Airflow","Airfree","Airis","Airlux","AIS","Aiwa","AJP","Akai","Akira","Akita","Akura/Akura","Aladdin","Alaska","Alba","Albatron","Alcatel","Alco","Alderbrook","Alfatec","Algor","Alien","Allen-Bradley","Allorgan","Allsat","Allstar","Alno","Alphatop","Alpina","Altai","Altec Lansing","Altima","Amadeus","Amana","Amber","Amcol","Amdek","American Dynamics","Amitech","Amptron","Amstrad","Amuscus","Amway","AMX","Anam","Andrew Collinge","Anhui","Anitech","Ankaro","Ansonic","Answercall","Antec","Antex","Antiference","Antony Worrall Thompson","AOC","AOpen","Appelsound","Apple","Applesound","Appliance 365","Aquavac","Araldite","Arc En Ciel","Arcelik","Archos","Archtech","Arctic","Ardem","Ardo Merloni","Arena","Argos","Argos Value","Arista","Aristo","Ariston","Aristona","ARM","Armorall","Arrow","ASA","Asberg","Asco","Ascom","AseV","Ashton Digital","Asko","Asora","AST","Astar","Astra","Astratec","Astro","Astrosound","Asuka","Asus","Aswo","AT&T","ATAG","Atari","Athena","Atlant","Atlantic","Atlas","Auchan","Audioline","Audiosonic","Audiovox","Aura","Aurora","Ausind","Authentic","Autovox","Aver","Averatec","AVF","AVF eco-mount","AVF Nexus","Avix","Avocent","Awa","Awatron","Axiom","Axiotron","Axis","Axxion","Aydin","B&Q","BaByliss","Baier","Baird","Balay","Bang & Olufsen","Banquet Cuisine","Barco","BASF","Basic Line","Batron","Battech","Batteries R Us","Bauknecht","Baumatic","Baur","Baycom","Baysonic","BBC","Beaulieu","Becker","Becosil Valor","beFLAT","Beijing","Beko","Belkin","Bell & Howell","Belling","Belstar","Belview","Bendix","Benk","BenQ","BenQ Siemens","Bernard Loisirs","Berry","Best","Best Spa","Bestar","Bestgreen","Betacom","Beurer","Beurer Monogram","BigTime","Binatone","Bira","Birum","Bissell","Black & Decker","Black Diamond","Black Panther","Blackberry","Blanco","Blaupunkt","Blomberg","Blue disk","Blue Sky","Blue Star","Bluemedia","Bluetrek","BMW","Bomann","Bompani","Bond-It","Bondstec","Bosch","Bosch Neff Siemens","Bostik","BPL","Brand UK","Brandt","Braun","Breadman","Breville","Bricorama","Bridge","Brionvega","Briovega","Brita","Britannia","BRK Electronics","Broksonic","Brondi","Brother","Bruns","BSR","BT","BTD","Buffalo","Bullman","Burco","Bush","Busicom","Buyspares Approved","Cabel","Cable & Wireless","Cabo Visao","Calgon","California Access","Caltron","Cambridge","Camedia","Camper","Canal +","Canal Digital","Candy","Cannon","Canon","Caple","Capri Electrical","Car Plan","Caravan","Caravel","Carlton","Carmen","Carmen Girls","Carpoint","Carrera","Carron","Caselogic","Casio","Castor","Cata","Cathay","CDA","Cellnet","Cello","Centon","Centrum","Century","CeroView","CGE","CGM","Challenge","Challenge Extreme","Chem USA","Chicony","ChiliGreen","ChiMei","Chinon","Christensen","Christie","Chromamaxx","Chunhua","Cie","Cieos","Cillit Bang","Cinergy","Cinex","Cinteli","Circulon","Citizen","Citycom","Clarity","Clarivox","Clarke","Classic","Clatronic","Clearit","Clevo","Clorox","CME","CMS","Cobra","Coby","Colclene","Colston","Comark","Comet","Commodore","Commtel","Compal","Companion","Compaq","Computek","Computer 2000","Computers Unlimited","Comtec","Concord","Condor","Conrad Electronic","Constructa","Contax","Contec","Conti","Contico","Continental","Continental Edison","Cookworks","Coolworks","Coolzone","CoPilot","Corbero","Cornea","Cornerstone","Corsair","Corvett","Corvus","Cosmo","Cosmos","Cosycomfort","Craftsman","Creative","Creda","Cresta","Crestron","Crosley","Crosslee","Crown","Crusader","Crystal Displays","Crystal Visions","CS-Electronics","CTC","CTL","CTX","Cuisina","Cullmann","Current Costs","Curry's","Currys Essentials","Curtis","Cyber Acoustics","Cyber Power","Cybercom","Cyberdine","Cybernet","Cyberpix","CyberTouch","Cyfra +","Cygnet","Cygnett","Cylinda","D-Vision","Daewoo","Daigo","Dainichi","Daktronics","Dancall","Dansai","Dansat","Dantax","Darwin","Data Check","Data General","Data Ray","Data View ","Datalux","Datascope","Datus","Daysha","Daytek","Daytron","DBI","DBTEL","DCLCD","De Graaf","Dec","DecaView","Decca","Deccavideo","Deco","DeDietrich","Defy","Delco","Dell","Delonghi","Delta","Delton","Denon","Densitron","Denver","Desmet","Dettol","Dewalt","DFI","Dialatron","Dialatron Geemarc","Diamond H","DiBoss","DiCON","Dicon Safety","Digicom","Digifusion","Digihome","Digilogic","Digimum","Digital Tech","Digital View","DigitalDream","Digitrex","Digitron","Digix","Dijam","Dimension","Dimplex","Diplomat","Dirt Devil","Discrite","Dishmatique","Disk Express","Disney Ariete","Ditronic","Dmtech","DNT","Dolch","Dolmar","Dome","Domestics Direct","Dometic","Domotec","Domus","Donlert","Dopod","Doro","Doro Matra","Double Black Imaging","DPI","dpiX","Dragon","Drainer","Draper","Dreamclean","Dreamland","Dremel","DSG","DTK","Dual","Dualit","Dumont","Durabrand","Duracell","Duracraft","Duraplug","Durgol","Dust Off","Dylon","Dynamac","Dynapro","Dynatron","Dynex","Dyson","E-Cloth","E-Machines","Earlex","EarthLCD","Easy-Do","Ebac Ltd","EBD","EC Refrigeration","Echo","Ecoforce","eCopy","Ecosavers","Ecozone","ECS","EDC","EDC Quest","Edifier","Edison","Edison Minerva","EDL Displays","Edmund Optics","Efbe-Schott","Efco","Efergy","EI systems","Eiki","EIZO","ELBA","Elbe","Elbit","Elcit","Elec-tech","Elecom","Electra","Electrix","Electrograph","Electrohome","Electrolux","Electrolux Loisirs","Electrovaya","Electruepart","Elekta","Elektra","Elektra Beckum","Elektro Helios","Elektroferm","Elektronika","Element","Elemis","Elica Cooker Hoods","Elin","Elmak","Elman","Elmo","Elo TouchSystems","ELSA","Elta","Elta Sat","EM","Emerson","Emme Esse","Emotion","Empire","Emprex","Eneloop","Energizer","English Electric","Enie","Enlight","Ensign","Envision","Epsilon","Epson","Erae","Ergo","Ericson","Ericsson","Erma","Erres","ESC","Escom","ESP","Esprit","Esselte","Estec","ETA","Eterna","Etna","Eton","Etric","Etron","Eugster Frismag","Euna","EUP","Eurax","Eureka","Eurocom","Euroline","Euromac","Europhon","Eurotech","Evelux","Everest","Everready","Evesham","Evolution","Ewbank","Exacta","Excel","Excelsior","Expert","Exspect","Ezscreen","Facit","Fagor","Fakir","Falco","Falcon","Falk","Falmec","Fame Art","Fameart","FastPoint","Faure","FCUK","Fellowes","Fenner","Ferguson","Fersen","FIC","Fidelis","Fidelity","Filter-Flo","Finish","Finish Powerball","Finlandia","Finlux","Firenzi","Firex","First Alert","First Line","Fisher","Fisher & Paykel","Fitre","Flavel","Flint","Floor Maintenance","Fly","Flymo","Foehn","Fonetag","Formac","Formenti","Fornair","Fortune","Fosa","Fox","Foxconn","Fraba","Franke","Fratelli Onofri","Freecom","Freeloader","Freeplay","Fresh Aer","Freud","Fridgemaster","Friedland","Frigidaire","Friwo","Frontech","FTE","Fuba","FUI","Fuji","FujiPlus","Fujitsu","Fujitsu General","Fujitsu Siemens","Fujix","Funai","Fusion","Futura","G-Tech","Gaggenau","Gainsborough","Gala","Galanz","Galaxi","Galaxis","Galaxy","Galeria","Garant","Gardena","Gardenferr","Gardol","Garmin","Gateway","GBC","GDA","GE Medical Systems","Gear4","GEC","Geemarc","Geemark","Gefen","Geloso","GEM","Genelec","General Digital","General Dynamics","General Electric","General Technic","Genex","George Foreman","Gericom","Germanvox","GES Singapore","Getac","GHD","Gias","Gigabyte","Gizmo","Glen","Glen Dimplex","Global Display Solutions","Goblin","Goldair","Goldbox","Goldfunk","Goldhand","Goldline","Goldmedal","Goldstar","Goodmans","Gorenje","Gorfer X","GP","GP Batteries","GPM","GQ","Graetz","Granada","Grandin","GrandView","Great","Great Neck","Great Wall","Griffin Technology","Grundig","GTE","Guangoang Shunde Shunyi","Guardsman","Gvision","GXK","H&B","Haden","Hagenuk","Haier","Halco","Hama","Hampton","Hanns.G","Hansa","Hanseatic","Hansol","Hantarex","Hantor","Harman","Harman/Kardon","Haropa","Harsper","Hasee","Hatteland","Haus","Haynes","HCM","Heatrae Sadia","Heiru","Hemmermann","Henkel","Hewlett Packard","Hi Grade","Hi-Tech","Hi-Tel","Hifivox","Highlander","Highscreen","Hinari","Hirschmann","Hirundo","Hisawa","Hisense","Hit","Hitachi","Hitsu","Hoher","Holts","Homark","Home - tek","Homebase","Homecare","Homedics","Homelite","Homepure","Honeywell","Hoover / Candy","Hoover 100 years","Hoshai","Hotpoint","HQ","HTC","Hualing","hugin","Humax","Hummer","Hurricane","Hurseal","Husquvarna","Husqvarna Electrolux","Hyberdata","Hygena","Hyper","Hyperdata","Hypson","Hyundai","Hyundai ImageQuest","I-Inc Display","I-magine Systems","Iberna","Ibervisao","IBM","ICE","Iceline","Icetech","ICL","ICS","Ideal","iFrogz","Ignis","IGO","Iicon","Iiyama","Ikra","Il Shin","iLO","iLuv","Image Systems","iMate","Imetec","Imperial","Impression","IMRI","Indesit","Indesit Group","Indiana","Inducomp","Industrial Image","Inelco","Infiniti","InFocus","Ingelen","Ingersoll","Ink Again","Inkrite","Inland","Inmotion","Inno Hit","Insignia","Intas","Intecolor","Integra","Intel","Intempo","Interbuy","Intercord","Interfunk","Intergarden","Intergraph","Intermec","Intervideo","Intervision","Inverto","Iomega","IPC","IRE","Iridium","iRiver","iRobot","Irradio","IRTS Display","Irwin Jack","Iskra","Issam","ITC","ITD","ITS","ITT","Ixion","Ixos","Jaba","Jabra","Jack Lalanne","Jackson","Jacob Jensen","James Martin","Jamo","Javelin","Jayvac","JBC","JBL","JCB","Jenoptic","Jet","Jetphone","Jetpoint","Jetta","Jewel","Jeyes","JIS","Jivo","JMB","Jo Jo","Jocel","John Lewis","Jonsered","Joytech","Jumbo","Juno","Just Refill","JVC","Kaido","Kaiser","Kaisui","Kamasa","Kapok","Kapsch","Karcher","Kashima","Kaspersky","Kathrein","Kawa","KDS","Kelco","Kelvinator","Kendo","Kenlon","Kenmark","Kennedy","Kennex","Kensington","Kenwood","Kerstar","Kew","KFC","Kidde","King","King Post","Kingavon","Kingfisher","Kingston","Kirby","Kirk","Kitchen Aid","Kiton","Kitt","Klipsch","Kneissel","Koda","Kodak","Koenig","Koerting","Kogi","Kolster","Kondor","Konica","Konica Minolta","Konka","Korea Computer","Korry","Korting","Kosmos Sat","Koto","Kotron","Kreiselmeyer","Kreisen","Krups","Kuba","Kuba Electronic","Kube","Kuppersbusch","Kyocera","Kyoto","Labgear","LaCie","Landi","Lasat","Laser","Lawnchief","Lec","Lecson","Ledco","Leica","Leisure","Lenco","LENDI","Lenmar","Lennox","Lenoir","Lenovo","Lever","Lexar","Lexmark","Lexsor","LG","Liberty","Liebherr","Liesenkoetter","Liesenkotter","Life","Lifetec","Lifetech","Light 'n' Easy","Lincat","Linde","Linsar","Lion","LiquidVideo","LiteOn","Lloyd","Lloytron","Lodos","Loewe","Lofra","Logic 3","Logik","Logitech","Lord Sheraton","Luce","Luma","Lumatron","Luxair","Luxman","Luxor","Lyvia","Macallister","Macally","Macrom","Mag Innovision","Magellan","Magimix","Maglite","Maglite LED","Magnadyne","Magnafon","Magnasonic","Magnavox","Magnet","Magnum","Major","Makita","Makro","Manhattan","Maplin","Marantz","Marcrist","Mark","Mark Hill","Marleton Cross Ltd","Marquant","Marshall","Martin Dawes","Marware","Marynen","Mascom","Maspro","Mass Multimedia","Masters","Matra","Matsui","Matsunichi","Matsushita","Max Computer","Max Group","Max Pack","Maxdata","Maxell","Maxent","Maxim","Maxon","Maxtech","Maxview","Mazda","McCulloch","Mecer","Media Box","Mediabook","Medion","MegaBook","Meiling","Mellerware","Memorex","Meneghetti","MEP","Mercedes","Mercury","Mercury Appliances","Mercury Telecraft","Mermaid Technology","Merrit","Merry","Mertz","Metabo","Meteor","Metronic","Metz","Meyer","MFI","MGC Technologies","Mico","Microlive","Micromark","Micromaxx","Micron Electronics","Microseeds","Microsoft","Microtek","MicroTouch","Miele","Migros","Mikomi","Minerva","Minolta","MiNote","Mintek","Mintronix","Mio","Miracle Business Inc.","Miro Displays","Mirror","Mitac","Mitsai","Mitsubishi","Mitsubishi-NEC","Mitsutech","Mivar","Mivvy","MK","ModuloPhone","Moffat","Mogo","Mondia","Monorail","Montenz Wertheim","Morava","Moreli","Morgans","Morphy Richards","Mors","Mosaic","Moser","Moti","Motion Computing","Motorola","Moulinex","Mountain Breeze","Mouse Computer","Mowerland","MPC (MicronPC)","Mr. Bricolage","MSI","Mtc","Mtech","Multiproget","MultiQ","Multitech","Muraphone","Murphy","Muryuana","Mustek","MWC","Mybelle","MyBook","Myvu","Naiko","Naonis","Napa","Nardi","Narita","Natcomp","National","National Display Systems","Navigon","Navman","NavPix","NCR","Nec","Neckermann","Necola","Nedis","Neff","NEI","NemAcom","Nematron","Neovia","Neovo","Neoware","Nesco","NESO","Network","Neufunk","Neuro Logic Systems","Nevada","New World","Newpol","Newteam","Nikkai","Nikkei","Nikko","NIKO","Nikon","Nilco","Nilfisk","Nintendo","NIS","Nishden","Nissan","NITEIZE","Nobike","Nobliko","Nobu","Nogmatic","Nokia","Noma","Norcent Technology","Nordmende","Nordway","Norfrost","Norlett","Norm N","Nortech Engineering","Nortek","Nortel","North Western Bell","Northgate","Norwood Micro","Nova","Novascotia","Novatech","Novum","NTL","Numatic","NuVision","nView","NVR","O2","Oakey","OBI","Ocean","Oceanic","Office Style","Ofmar","Okano","Okay","OKI","Oleo-Mac","Olevia","Olivetti","Olympic","Olympus","Olympyk","Omega","Omnimount","Omron","OMT","One for All","One Tel","One-For-All","Oneclick","Onkyo","Onn","Onwa","Opedys","Oppex","Optex","Optoma","Opus","Oral B","Orange","Orava","Orbitech","Orbitel","Orbiter","Oreck","Oregon","Oregon Scientific","Orion","Osaki","Osat","Osio","Oster","Otake","Otava","Otf","Otto Versand","Otto-Versand","Oust","Ovp","Pace","Pacific","Packard Bell","Palladium","Palm","palmOne","Panasonic","Panorama","Papillon","Park","Parkinson Cowan","Parnall","Parry","Partmaster","Partner","Pasolde","Pathe Cinema","Pathe Marconi","Patriot","PC Club","PCW Essentials","PDi Communications Systems","Peacick","Peacock","Pelco","Pelgrim","Pelham Sloane","PenRad","Pentasonic","Pentax","Peony","Pepsi","Pepsimax","PerComm","Performance Power","Performance Power Pro","Pershin","Pest Stop","Philco","Philex","Philips","Phoenix","Phonemate","Phonestones","Phonola","Pifco","Pilot","Pioneer","Pioneer Gardening","Pionex","Piranah","Pixelink ","PixelVision","Planar","Plantron","Plantronics","Playsonic","Pocket","Pointer Systems","Polar","Polar King","Polaroid","Policom","Polsat","Polti","Poole","Poole Heating","Portland","Poseidon Systems","Posiflex","Poulan","Poulan Pro","Power Breaker","Power Devil","Powerbreaker","Powercraft","Powermonkey","Powerplus","Powerpoint","Praktica","Preh Electronics","Premier","Premio","Pressit","Prestige","Prestigio","Prima","Prime","Primus","Princess","Princeton Graphic Systems","Printemps","Pro-Vision","Proaction","Probrand","Profex","Profilo","Profitronic","Profoon","Program 2000","Progress","Proline","Promedion","Prosat","Prosco","Prosonic","Prostar","Protech","Protron","Proview","Provision","Pure Digital","Pye","Q2","QDI","QTEK","Quadral","Qualcast","Quantex","Quasar","Quatographic Technology","Quelle","Quest International","Questar","Quintek","Qume","RAC","Radex","Radiator Booster","Radiola","Radiomarelli","Radiomette","Radiotone","Radix","Radsil","Rally","Ramon","Ranchero","Rangemaster","Ranger","Rank","Rank/Bush/Murphy","Raylec","Rayovac","RDI","Recor","Record Power","Recortec","Red Star","Rediffusion","Redring","Reflex International","Regale","Regina","Relisys","Remington","Renata","Reoc","Repaircare","Respekta","Revlon","Revolution","Revox","Revue","Rex","Rexon","RF System Lab","RFT","Riber","Ricoh","Rima","Ring","Ritar","Rm 2000","Roadstar","Roberts","Rock","Rockwell Automation","Rockworth","Rollei","Rolson","Romton","Rose & Holiet","Rosetti","Rosewill","Rosieres","Rosita","Ross","ROTARY","Rotel","Rotozip","Route 66","Rover Book","Rowa","Rowenta","Rownsonic","Royal","Royal Lux","RTF","Rumbelows","Russell Hobbs","Ryobi","Ryobi One Plus","Saba","Sabichi","Sagem","Sager","SAIC","Saisho","Sakio","Sakura","Salamini","Salora","Salter","Salton","Samber","Sambers","Sampo","Samson","Samsung","Samurai","San Giorgio","Sandisk","Sandstrom","Sansui","Sany","Sanyo","Satec","Sauter","Saxon","Scandinova","Scanport","Sceptre","Schaub Lorenz","Scheppach","Scherna","Schneider","Schneider (F)","Scholl","Scholtes","Schreiber","Schwaiger","Sealey","Seanix","Sears","Sebo","SeeReal Technologies","SEG","Sega","Sei-Sinudyne","Seiko","Seleco","Select","Senao","Senco","Sendo","Sennheiser","Sentra","Serif","Serino","Servis","Servisol","Setanta","Setcom","Setron","Sewland","Shark","Sharp","Shindaiwa","Shintom","Shintoshi","Shivaki","Shure","Shuttle","Siarem","Siarems","Sibir","SIDEX","Siemens","Siera","Sigma","Silicon Graphics","Silva","Silva Schneider","Silverline","Sim2","Simac","Simfer","Sincoa","Singer","Sinudyne","Sipix","Sirius","Skandiluke","Skantic","Skil","Sky","SKY Digital","Skymaster","Skyphone","Skytronic","Slemcka","Slim Save","SLX Gold","Smaragd","Smart Technologies","Smc","Smeg","Smile","Smith Corona","Smithlite","Smiths Timeguard","Snowcap","Soaring Technology","Sofono","Solar","Solaris","Solarism Display","Solavox","Solo","solus","Sona","Sonamec","Sonitron","Sonix","Sonoko","Sonolor","Sontec","Sony","Sony Ericsson","Sotec","Soundcolor","Soundwave","South Western Bell","Southwing","Sovereign","Sovereign Garden","Soyo","Spacelabs Medical","Spectra","Spinney","Spire Controls","Springfield","Stamp","Standard","Standby Buster","Stanley","Starlight","Starlite","Starlux","Startech","Status","Stealth","Steamworks","Steepletone","Stern","Stiga","Stihl","Stimvac","Stoves","Strato","Strong","Stryker","STX","Suffolks","Sun","Sun Microsystems","Sunbeam","Sunflex","Sunhouse","Sunkai","Sunpak","Sunstar","Sunway","Super Talent","Superfone","SuperScan","Supertech","Supra","Suprema","Sure Time","SVA","Swan","Swarofski","Swatch","Swisstec","Swordfish","Sylvania","Symbol Technologies","Syntax","Sys","Systel","System 600","Systemax","Tabar","Tacima","Tack","Tactics","Tadistar","Talon","Tamron","Tandberg","Tangent","Tansun","Targa","Targus","Tashiko","Tatung","Tauras","Taxan","TCL","TCM","Td Design","TDK","Teac","Team International","Teba","TEC","Techline","Techmedia","Technics","Technika","Technisat","Technomate","Technosonic","Tecnik","Tecnimagen","Tecnison","Tecnowind","Tefal","Tek Panel","Teka","Teknika","Teknique","Tekon","Tekvisions","TelCom","Teleavia","Telecam","Telefunken","Telegames","Teleka","Teleopta","Telerent","Telestar","Telesys","Teletech","Teleton","Televideo","Teleview","Telmar","Telra","Tensai","Tenson","Terim","Terra Anima","Tesco","Tesla","Tevion","Texas Industrial Peripherals","Texas Instruments","Thermodore","Thin Labs","Thompson","Thomson","Thor","Thorn","Thorn-Ferguson","THTF","TICO","Time Guard","Timex","Titan","Tobo","Tokyo","TomTom","Toni and Guy","Topfield","Topline","Topvision","Tornado","Toshiba","ToteVision","Totoku","TouchSystems","Towada","Tower","Track","Traveler","Traveller","Trend","Trend T-Tech","Trendnet","Tresemme","Triano","Triax","Tricity","Tricity Bendix","Trident Displays","Trilux","Tristar","Triton","Triumph","Tronic","Trust","Truvox","Tsann-Kuen","Tsunami Moover","TTX","Tucano","Tulip Computer","Turbo Silent","Turboair (Elica)","Tv Cabo","TV One","TVLogic","TVOnics","TVR","TWF Digital","Twinhead","Typhoon","UBM Computer","Ucar","Ufesa","Uher","Ultrasonex","Ultravox","Uma","UMAX","UMC","Uni-Lok","Unidare","Uniden","Unimor","Unipart","Uniross","Unison","United","United Micro","Universal Outdoor Accessories","Universum","Univox","Uniwill Computer","Unknown","Uno Uno","Unomat","UnyTouch","Upo","Urban Choice","User Easy","V Three","Valor","Vanish","Varta","VarTech Systems","Vax","Vax Commercial","Vector","Veet","Vega","Vendomatic","Ventura","Venturer","Vermont","Via Digital","Vic Hi-Tech Corporation","Vicks","Victor","Vidal Sassoon","Videosat","VideoSeven","Videotel","Videoton","Vidor","View and View Technologies","ViewEra","Viewpia","Viewsonic","ViewTek","Viewtronix","Vim","Vinco","VIP","Virgin Media","Visa","Visible Interactive","Vision","Visionbank","VisionQuest","Vivitar","Vizio","VK","VO5","Vobis","Vodafone","Vogels","Volta","Volund","Vortec","Vortice","Vorwerk","Voxson","VPR Matrix","VTech","VTS Medical","Wacom","Wagner","Wahl","Waitec","WalkAbout Computers","Wallis","Waltham","Watson","Watt Radio","Webtech","Weedeater","Wega","Wegavox","Wellco","Wellco Professional","WEN Technology","Western Digital","Westinghouse","Weston","Wharfedale","Whirlpool","White Knight","White Westinghouse","Wide","Winataglow","Winbook","Wincor Nixdorf","Windsor","Wisi","Wistron","Wolfcraft","Woodshark","Workmate","Worten","Wortmann","Worx","Wpro","Wylex","Wyse","X Technology","X2GEN","Xcel","Xenarc","Xenius","Xenon","Xeron","Xerox","Xinbao","Xingbang","Xitel","Xterasys","Xtrememac","Xycom","Yaesu","Yakumo","Yamada","Yamaha","Yamsan","Yashica","Yoko","Zanela","Zanker","Zanussi","Zehnder","Zelmer","Zenith","Zerowatt","Zoppas","ZTE"];
}

/**
 * Request suggestions for the given autosuggest control. 
 * @scope protected
 * @param oAutoSuggestControl The autosuggest control to provide suggestions for.
 */
BrandSuggestions.prototype.requestSuggestions = function (oAutoSuggestControl /*:AutoSuggestControl*/,
                                                          bTypeAhead /*:boolean*/) {
    var aSuggestions = [];
    var sTextboxValue = oAutoSuggestControl.textbox.value.toLowerCase();
    
    if (sTextboxValue.length > 0){
        
        var count = 0;
        
        //search for matching brands
        for (var i=0; i < this.brands.length; i++) { 
            if (this.brands[i].toLowerCase().indexOf(sTextboxValue) == 0) {
                aSuggestions.push(this.brands[i]);
                
                count++;
                if (count == 10) break;	//limit to 10 in list
            }
	    
	    if (this.brands[i].toLowerCase().charCodeAt(0) > sTextboxValue.charCodeAt(0)) {
			break;
		}
	    
	    
        }
    }
    
    //provide suggestions to the control
    oAutoSuggestControl.autosuggest(aSuggestions, bTypeAhead);
};



/**
 * An autosuggest textbox control.
 * @class
 * @scope public
 */
function AutoSuggestControl(oTextbox /*:HTMLInputElement*/, 
                            oProvider /*:SuggestionProvider*/) {
    
    /**
     * The currently selected suggestions.
     * @scope private
     */   
    this.cur /*:int*/ = -1;

    /**
     * The dropdown list layer.
     * @scope private
     */
    this.layer = null;
    
    /**
     * Suggestion provider for the autosuggest feature.
     * @scope private.
     */
    this.provider /*:SuggestionProvider*/ = oProvider;
    
    /**
     * The textbox to capture.
     * @scope private
     */
    this.textbox /*:HTMLInputElement*/ = oTextbox;
    
    //initialize the control
    this.init();
    
}

/**
 * Autosuggests one or more suggestions for what the user has typed.
 * If no suggestions are passed in, then no autosuggest occurs.
 * @scope private
 * @param aSuggestions An array of suggestion strings.
 * @param bTypeAhead If the control should provide a type ahead suggestion.
 */
AutoSuggestControl.prototype.autosuggest = function (aSuggestions /*:Array*/,
                                                     bTypeAhead /*:boolean*/) {
    
    //make sure there's at least one suggestion
    if (aSuggestions.length > 0) {
        //if (bTypeAhead) { //removed to solve wrong completion bug
           //this.typeAhead(aSuggestions[0]);
        //}
        
        this.showSuggestions(aSuggestions);
    } else {
        this.hideSuggestions();
    }
};

/**
 * Creates the dropdown layer to display multiple suggestions.
 * @scope private
 */
AutoSuggestControl.prototype.createDropDown = function () {

    var oThis = this;

    //create the layer and assign styles
    this.layer = document.createElement("div");
    this.layer.className = "suggestions";
    this.layer.style.visibility = "hidden";
    this.layer.style.width = this.textbox.offsetWidth;
    
    //when the user clicks on the a suggestion, get the text (innerHTML)
    //and place it into a textbox
    this.layer.onmousedown = 
    this.layer.onmouseup = 
    this.layer.onmouseover = function (oEvent) {
        oEvent = oEvent || window.event;
        oTarget = oEvent.target || oEvent.srcElement;

        if (oEvent.type == "mousedown") {
            oThis.textbox.value = oTarget.firstChild.nodeValue;
            oThis.hideSuggestions();
        } else if (oEvent.type == "mouseover") {
            oThis.highlightSuggestion(oTarget);
        } else {
            oThis.textbox.focus();
        }
    };
    
    document.body.appendChild(this.layer);
};

/**
 * Gets the left coordinate of the textbox.
 * @scope private
 * @return The left coordinate of the textbox in pixels.
 */
AutoSuggestControl.prototype.getLeft = function () /*:int*/ {

    var oNode = this.textbox;
    var iLeft = 0;
    
    while(oNode.tagName != "BODY") {
        iLeft += oNode.offsetLeft;
        oNode = oNode.offsetParent;        
    }
    
    return iLeft;
};

/**
 * Gets the top coordinate of the textbox.
 * @scope private
 * @return The top coordinate of the textbox in pixels.
 */
AutoSuggestControl.prototype.getTop = function () /*:int*/ {

    var oNode = this.textbox;
    var iTop = 0;
    
    while(oNode.tagName != "BODY") {
        iTop += oNode.offsetTop;
        oNode = oNode.offsetParent;
    }
    
    return iTop;
};

/**
 * Handles three keydown events.
 * @scope private
 * @param oEvent The event object for the keydown event.
 */
AutoSuggestControl.prototype.handleKeyDown = function (oEvent /*:Event*/) {
	
    switch(oEvent.keyCode) {
        
        case 27: //escape
            this.hideSuggestions();
            break;
        case 38: //up arrow
            this.previousSuggestion();
            break;
        case 40: //down arrow 
            this.nextSuggestion();
            break;
        case 13: //enter
            this.hideSuggestions();
            break;
    }

};

/**
 * Handles keyup events.
 * @scope private
 * @param oEvent The event object for the keyup event.
 */
AutoSuggestControl.prototype.handleKeyUp = function (oEvent /*:Event*/) {

    var iKeyCode = oEvent.keyCode;

    //for backspace (8) and delete (46), shows suggestions without typeahead
    if (iKeyCode == 8 || iKeyCode == 46) {
        this.provider.requestSuggestions(this, false);
        
    //make sure not to interfere with non-character keys
    } else if (iKeyCode < 32 || (iKeyCode >= 33 && iKeyCode < 46) || (iKeyCode >= 112 && iKeyCode <= 123)) {
        //ignore
    } else {
        //request suggestions from the suggestion provider with typeahead
        this.provider.requestSuggestions(this, true);
    }
};

/**
 * Hides the suggestion dropdown.
 * @scope private
 */
AutoSuggestControl.prototype.hideSuggestions = function () {
    this.layer.style.visibility = "hidden";
};

/**
 * Highlights the given node in the suggestions dropdown.
 * @scope private
 * @param oSuggestionNode The node representing a suggestion in the dropdown.
 */
AutoSuggestControl.prototype.highlightSuggestion = function (oSuggestionNode) {
    
    for (var i=0; i < this.layer.childNodes.length; i++) {
        var oNode = this.layer.childNodes[i];
        if (oNode == oSuggestionNode) {
            oNode.className = "current"
        } else if (oNode.className == "current") {
            oNode.className = "";
        }
    }
};

/**
 * Initializes the textbox with event handlers for
 * auto suggest functionality.
 * @scope private
 */
AutoSuggestControl.prototype.init = function () {

    //save a reference to this object
    var oThis = this;
    
    //assign the onkeyup event handler
    this.textbox.onkeyup = function (oEvent) {
    
        //check for the proper location of the event object
        if (!oEvent) {
            oEvent = window.event;
        }    
        
        //call the handleKeyUp() method with the event object
        oThis.handleKeyUp(oEvent);
    };
    
    //assign onkeydown event handler
    this.textbox.onkeydown = function (oEvent) {
    
        //check for the proper location of the event object
        if (!oEvent) {
            oEvent = window.event;
        }    
        
        //call the handleKeyDown() method with the event object
        oThis.handleKeyDown(oEvent);
    };
    
    //assign onblur event handler (hides suggestions)    
    this.textbox.onblur = function () {
        oThis.hideSuggestions();
    };
    
    //create the suggestions dropdown
    this.createDropDown();
};

/**
 * Highlights the next suggestion in the dropdown and
 * places the suggestion into the textbox.
 * @scope private
 */
AutoSuggestControl.prototype.nextSuggestion = function () {
    var cSuggestionNodes = this.layer.childNodes;

    if (cSuggestionNodes.length > 0 && this.cur < cSuggestionNodes.length-1) {
        var oNode = cSuggestionNodes[++this.cur];
        this.highlightSuggestion(oNode);
        this.textbox.value = oNode.firstChild.nodeValue; 
    }
};

/**
 * Highlights the previous suggestion in the dropdown and
 * places the suggestion into the textbox.
 * @scope private
 */
AutoSuggestControl.prototype.previousSuggestion = function () {
    var cSuggestionNodes = this.layer.childNodes;

    if (cSuggestionNodes.length > 0 && this.cur > 0) {
        var oNode = cSuggestionNodes[--this.cur];
        this.highlightSuggestion(oNode);
        this.textbox.value = oNode.firstChild.nodeValue;   
    }
};

/**
 * Selects a range of text in the textbox.
 * @scope public
 * @param iStart The start index (base 0) of the selection.
 * @param iLength The number of characters to select.
 */
AutoSuggestControl.prototype.selectRange = function (iStart /*:int*/, iLength /*:int*/) {

    //use text ranges for Internet Explorer
    if (this.textbox.createTextRange) {
        var oRange = this.textbox.createTextRange(); 
        oRange.moveStart("character", iStart); 
        oRange.moveEnd("character", iLength - this.textbox.value.length);      
        oRange.select();
        
    //use setSelectionRange() for Mozilla
    } else if (this.textbox.setSelectionRange) {
        this.textbox.setSelectionRange(iStart, iLength);
    }     

    //set focus back to the textbox
    this.textbox.focus();      
}; 

/**
 * Builds the suggestion layer contents, moves it into position,
 * and displays the layer.
 * @scope private
 * @param aSuggestions An array of suggestions for the control.
 */
AutoSuggestControl.prototype.showSuggestions = function (aSuggestions /*:Array*/) {
    
    var oDiv = null;
    this.layer.innerHTML = "";  //clear contents of the layer
    
    for (var i=0; i < aSuggestions.length; i++) {
        oDiv = document.createElement("div");
        oDiv.appendChild(document.createTextNode(aSuggestions[i]));
        this.layer.appendChild(oDiv);
    }
    
    this.layer.style.left = this.getLeft() + "px";
    this.layer.style.top = (this.getTop()+this.textbox.offsetHeight) + "px";
    this.layer.style.visibility = "visible";
    
};

/**
 * Inserts a suggestion into the textbox, highlighting the 
 * suggested part of the text.
 * @scope private
 * @param sSuggestion The suggestion for the textbox.
 */
AutoSuggestControl.prototype.typeAhead = function (sSuggestion /*:String*/) {

    //check for support of typeahead functionality
    if (this.textbox.createTextRange || this.textbox.setSelectionRange){
        var iLen = this.textbox.value.length; 
        this.textbox.value = sSuggestion; 
        this.selectRange(iLen, sSuggestion.length);
    }
};

