PageSourceSearch

https://www.rufflefabric.com/a/j/javascripts_6_5_7.216.7.4880.js

js rufflefabric.com collected 2026-09-26 21:39:57 UTC 28,845 bytes, 1,048 lines download raw bytes

1/*
2function submitform(formName, buttonName) {
3	document.forms[formName].elements['submitbuttonname'].value = buttonName;
4	document.forms[formName].elements['submitbuttonname'].checked = true;
5	document.forms[formName].submit();
6}
7*/
8
9function DropDown_ShopBy_Price_onChange(element) {
10	var selectedValue = element.options[element.selectedIndex].value;
11	if (selectedValue != '') {
12		window.location.href = '/SearchResults.asp?RefineBy_Price=' + selectedValue;
13	}
14}
15
16function DropDown_ShopBy_Category_onChange(element) {
17	var selectedValue = element.options[element.selectedIndex].value;
18	if (selectedValue != '') {
19		window.location.href = selectedValue;
20	}
21}
22
23var function_protect_images2_msg = "Sorry, our images are copyrighted.";
24function ClearForm()
25{
26	var FieldType;
27	for (var i = 0; i < document.EditForm.length; i++) {
28		FieldType = document.EditForm.elements[i].type
29		if (FieldType == "text" || FieldType == "textarea") {
30			document.EditForm.elements[i].value = ""
31		}
32		if (FieldType == "select-one") {
33			document.EditForm.elements[i].options.selectedIndex = 0
34		}
35	}
36}
37
38function OpenNewWindow(url, width, height)
39{
40	var randomnumber=Math.floor(Math.random()*5001)
41	window.open(url, randomnumber, "top=10,left=10,toolbar=no,titlebar=no,location=no,directories=no,status=no,menubar=no,resizable=1,scrollbars=1,width=" + width + ",height=" + height)
42}
43
44function OpenWindowNoScroll(url, width, height) { 
45	window.open(url, 'popup_noscroll',
46	  "top=10,left=10,menubar=0,resizable=0,scrollbars=0,width=" + width + ",height=" + height)
47}
48
49function protect_images2(e) {
50if (navigator.appName == 'Netscape' && e.which == 3) {
51	alert(function_protect_images2_msg);
52	return false;
53}
54if (navigator.appName == 'Microsoft Internet Explorer' && event.button==2) {
55	alert(function_protect_images2_msg);
56	return false;
57}
58else return true;
59}
60
61function protect_images1() {
62	if(document.images) {
63	    for(i=0;i<document.images.length;i++) {
64			document.images[i].onmousedown = protect_images2;
65			document.images[i].onmouseup = protect_images2;
66		}
67	}
68}
69
70function OpenSideWindow(url){
71	rightwidth=300;
72	if (document.all) {
73		windowheight = screen.availHeight;		
74		leftwidth=screen.availWidth-rightwidth-11;
75		SideWindow=window.open(url,'SideWindow','width='+rightwidth+',height='+(windowheight-60)+',screenX='+leftwidth+',screenY=0,top=0,left=' +leftwidth+',toolbar=0,location=0,status=1,menubar=0,resizable=1');
76		SideWindow.focus();
77	} else {
78		SideWindow=window.open(url,'','width=280,height=480,toolbar=0,location=0,status=1,menubar=0,resizable=1');
79	}
80}
81
82function PageName() {
83	var pageName = window.location.href.toLowerCase();
84	if (pageName.indexOf('_p/') != -1 || pageName.indexOf('-p/') != -1) {
85		pageName = 'productdetails.asp';
86	}
87	else if (pageName.indexOf('_s/') != -1 || pageName.indexOf('-s/') != -1) {
88		pageName = 'searchresults.asp';
89	}
90	else {
91		pageName = pageName.substr(pageName.lastIndexOf("/") + 1).replace(/\?[\s\S]*/, "");
92	}
93	return pageName;
94}
95
96function PagePath() {
97	return window.location.href.toLowerCase().replace(/http[s]?:\/\/[^\/]*\/?/, "").replace(/\?[\s\S]*/, "");
98}
99
100function QueryString(name) {
101	var qsRE = new RegExp("[?&]" + name + "=([^&]*)", "i");
102	var value = qsRE.exec(location.href);
103	return (value) ? decode(value[1]) : "";
104}
105
106function GetCookieArray() {
107	if (document.cookie.length > 0) {
108		var cookieRE = new RegExp("(?:^|;)[\\s]*([^=]*)=([^;]*)", "gi");
109		var cookie, cookieArray = new Array();
110		cookie = cookieRE.exec(unescape(document.cookie.toString()))
111		while (cookie) {
112			cookieArray[cookie[1]] = cookie[2];
113			cookie = cookieRE.exec(unescape(document.cookie.toString()))
114		}
115		return cookieArray;
116	}
117	return "";
118}
119
120function GetCookie(name, key, encoded) {
121	var value = '', cookies = ';' + document.cookie;
122	if (cookies.length > 1) {
123		if (key) {
124			var cookieRE = new RegExp(';[\\s]*' + name + '=[^;]*' + key + '=([^&;]*)[^;]*', 'i')
125		}
126		else {
127			var cookieRE = new RegExp(';[\\s]*' + name + '=([^;]*)', 'i');
128		}
129		value = cookieRE.exec(cookies);
130		value = (value) ? value[1] : '';
131		if (!encoded) {
132			value = decode(value);
133		}
134	}
135	return value;
136}
137
138var c_minutes = 1, c_hours = 60, c_days = 1440, c_years = 525600;
139function SetCookie(name, value, duration, key) {
140	var cookie = '';
141	if (key) {
142		cookie = GetCookie(name, '', true);
143		if (cookie != '') {
144			cookie = '&' + cookie;
145			var keyRE = new RegExp('([\\s\\S]*?)(&' + key + '=)[^&]*([\\s\\S]*)', 'i');
146			if (keyRE.test(cookie)) {
147				if (value == '') {
148					cookie = cookie.replace(keyRE, '$1$3');
149				}
150				else {
151					cookie = cookie.replace(keyRE, '$1$2' + encode(value) + '$3');
152				}
153			}
154			else if (value != '') {
155				cookie += '&' + key + '=' + encode(value);
156			}
157			cookie = cookie.substr(1);
158		}
159		else if (value == '') {
160				cookie = '';
161		}
162		else {
163			cookie = key + '=' + encode(value);
164		}
165	}
166	else if (value != '') {
167		cookie = encode(value);
168	}
169	if (cookie == '') {
170		duration = -1000;
171	}
172	cookie = name + '=' + cookie + ';path=/';
173
174	if (duration) {
175		var expireDate = new Date();
176		expireDate.setMinutes(expireDate.getMinutes() + parseInt(duration));
177		cookie = cookie + ';expires=' + expireDate.toGMTString();
178	}
179	document.cookie = cookie;
180	return value;
181}
182
183function encode(value) {
184	value = escape(value);
185	value = value.replace(/@/gi, "%40");
186	value = value.replace(/\*/gi, "%2A");
187	value = value.replace(/_/gi, "%5F");
188	value = value.replace(/-/gi, "%2D");
189	value = value.replace(/\+/gi, "%2B");
190	value = value.replace(/\./gi, "%2E");
191	value = value.replace(/\//gi, "%2F");
192	value = value.replace(/%20/gi, "+");
193	return value;
194}
195
196function decode(value) {
197	value = value.replace(/\+/g, " ");
198	value = unescape(value);
199	return value;
200}
201
202function v$(id) {
203    return typeof id === 'string' ? document.getElementById(id) : id;
204}
205
206function FixEvent(event) {
207	if (window.event) {
208		var event = window.event;
209		event.target = event.srcElement;
210	}
211	else {
212		var event = event;
213	}
214	return event;
215}
216
217function AttachEvent(element, event, func) {
218	if (element) {
219        if (element.addEventListener) {
220		    element.addEventListener(event.toLowerCase(), func, false);
221	    }
222	    else {
223		    element.attachEvent('on' + event.toLowerCase(), func);
224	    }
225    }
226}
227
228function DetachEvent(element, event, func) {
229    if (element) {
230        if (element.removeEventListener) {
231		    element.removeEventListener(event.toLowerCase(), func, false);
232	    }
233	    else {
234		    element.detachEvent('on' + event.toLowerCase(), func);
235	    }
236    }
237	
238}
239
240function ShowHide(Element_ID, Show) {
241	var Element = v$(Element_ID);
242	var elementDisplay = '';
243	if (Element) {
244		Show = eval(Show)
245		elementDisplay = Element.style['display'];
246		if (elementDisplay == '') {
247			elementDisplay = computedStyle(Element, 'display', 'display');
248		}
249		if (typeof(Show) == 'undefined' && elementDisplay != 'none' || Show == false) {
250			Element.style['display'] = 'none';
251			return false;
252		}
253		else {
254			Element.style['display'] = '';
255			return true;
256		}
257	}
258}
259
260function vTrim(arg_value) {
261    return arg_value ? arg_value.toString().replace(/^[\s]+|[\s]+$/g, '') : '';
262}
263
264function commaTrim(arg_value) {
265    return arg_value ? arg_value.toString().replace(/[,]/g, '') : '';
266}
267
268function addToDropdown(element,newText) {
269	newText = vTrim(newText);
270	if (newText != '') {
271		//make sure it is not already in the list
272		for (var i=0; i<element.options.length; i++) {
273			if (element.options[i].value == newText) {
274				element.selectedIndex = i;
275				return;
276			}
277		}
278		element.options[element.options.length] = new Option(newText);
279		element.selectedIndex = element.options.length-1;
280	}
281}
282
283
284
285																									//COORDINATES                                                                                                           
286var Coordinates = {
287	create : function(x, y) {
288		return new Coordinate(x, y);
289	},
290
291	_offset : function(element) {
292		return this.create(element.offsetLeft, element.offsetTop);
293	},
294
295	topLeftOffset : function(element) {
296		var offset = this._offset(element);
297		var parent = element.offsetParent;
298		while (parent) {
299			offset = offset.plus(this._offset(parent));
300			parent = parent.offsetParent;
301		}
302		delete(parent);
303		return offset;
304	},
305
306	bottomRightOffset : function(element, topLeftOffset) {
307		if (topLeftOffset) return topLeftOffset.plus(this.create(element.offsetWidth, element.offsetHeight));
308		return this.topLeftOffset(element).plus(this.create(element.offsetWidth, element.offsetHeight));
309	},
310	
311	relativeOffset : function(element) {
312		var x = parseInt(element.style["left"]);
313		var y = parseInt(element.style["top"]);
314		x = isNaN(x) ? 0 : x;
315		y = isNaN(y) ? 0 : y;
316		return this.create(x, y);
317	},
318
319	mouseOffset : function(event) {
320		if (event.pageX >= 0 || event.pageX < 0) {
321			return this.create(event.pageX, event.pageY);
322		} else if (event.clientX >= 0 || event.clientX < 0) {
323			return this.create(event.clientX, event.clientY).plus(this.scrollOffset());
324		}
325	},
326	
327	scrollOffset : function() {
328		if (window.pageXOffset) {
329			return this.create(window.pageXOffset, window.pageYOffset);
330		} else if (document.documentElement) {
331			return this.create(
332					document.body.scrollLeft + document.documentElement.scrollLeft, 
333					document.body.scrollTop + document.documentElement.scrollTop);
334		} else if (document.body.scrollLeft >= 0) {
335			return this.create(document.body.scrollLeft, document.body.scrollTop);
336		} else {
337			return this.create(0, 0);
338		}
339	}
340}
341
342function vPlacement(element) {
343	var offset = jQuery(element).offset();
344	var left = offset.left;
345	var top = offset.top;
346	
347	return {'left':left, 'top':top, 'width':element.offsetWidth, 'height':element.offsetHeight}
348}
349
350function IEVersion() {
351   var rv = 0;
352   if (navigator.appName == 'Microsoft Internet Explorer')
353   {
354      var ua = navigator.userAgent;
355      var re  = new RegExp("MSIE ([0-9]{1,}[\.0-9]{0,})");
356      if (re.exec(ua) != null)
357         rv = parseFloat( RegExp.$1 );
358   }
359   return rv;
360}
361
362
363function computedStyle(element, ieStyle, ffStyle) {
364		if (element.currentStyle) {
365			return element.currentStyle[ieStyle];
366		}
367		else if (document.defaultView && document.defaultView.getComputedStyle) {
368            // fixes an issue with Firefox and iFrames
369		    return (document.defaultView.getComputedStyle(element, null)) ? document.defaultView.getComputedStyle(element, null).getPropertyValue(ffStyle) : "";
370		}
371		else {
372			return element.style[ieStyle];
373		}
374}
375
376
377function this_AttachEvent(element, eventName, handlerName, handlerReference) {
378	eventName = eventName.toLowerCase();
379	element[handlerName] = handlerReference;
380
381	if (element.addEventListener) {
382		element.addEventListener(eventName, function(e) {element[handlerName](e);}, false);
383	}
384	else if (element.attachEvent) {
385		element.attachEvent('on' + eventName, function(e) {element[handlerName](e);});
386	}
387	else { 
388		var originalHandler = target['on' + eventName];
389		if (originalHandler) { 
390			element['on' + eventName] = function(e) {originalHandler(e); element[handlerName](e);}; 
391		}
392		else { 
393			element['on' + eventName] = element[handlerName]; 
394		} 
395	} 
396}
397
398function uniquetoggleme(id, style) {
399	if(v$(id)) {
400		if (style) {
401			v$(id).style.backgroundColor = '';
402			//v$(id).className=style;
403		}
404		else {
405			v$(id).style.backgroundColor = '#ececec';
406			//v$(id).className+=' hover';
407		}
408	}
409}
410
411function Search_For_Products(element) {
412	while (element && element.nodeName.toLowerCase() != 'form') {
413		element = element.parentNode;
414	}
415	if (element) {
416		if (element.nodeName.toLowerCase() == 'form') {
417			element.submit();
418		}
419	}
420}
421
422function addbookmark() {
423	var bookmarkurl=window.location.href.substr(0, window.location.href.indexOf('/', 8) + 1) + '';
424
425	if (document.title) {
426		var bookmarktitle=document.title;
427	}
428	else {
429			var bookmarktitle="";
430	}
431	
432	if (window.sidebar) {
433		window.sidebar.addPanel(bookmarktitle, bookmarkurl, "");
434	}
435	else if (window.external) {
436		window.external.AddFavorite(bookmarkurl, bookmarktitle);
437	}
438}
439
440function IsReturnKey(evt) {
441	return (evt.which && evt.which == 13) || (evt.keyCode && evt.keyCode == 13);
442}
443
444function CancelEvent(evt)
445{
446	evt.cancelBubble = true;
447	evt.returnResult = false;
448	if (evt.preventDefault)
449	{
450		evt.preventDefault();
451	}
452	if (evt.stopPropagation)
453	{
454		evt.stopPropagation();
455	}
456	return false;
457}
458
459var textAreaContent = ""
460function textAreaKeyDown(elem, limitNum){
461	
462    if (elem.value.length > limitNum) 
463		elem.value = textAreaContent;
464	else
465		textAreaContent = elem.value;
466}
467
468function textAreaKeyUp(elem, limitNum){
469	
470    if (elem.value.length > limitNum) 
471		elem.value = textAreaContent;
472	else	
473		textAreaContent = elem.value;	
474}
475
476// escape() will _not_ encode: @*/+
477// encodeURI() will _not_ encode: ~!@#$&*()=:/,;?+'
478// encodeURIComponent() will _not_ encode: ~!*()'
479function isvalidfield(fieldname)
480{
481	if(fieldname === "")
482		return false;
483	if(fieldname.toLowerCase()==="cvv2" || fieldname.toLowerCase()==="creditcardnumber")
484		return false;
485	return true;
486}
487
488function serialize(form) {
489	var serialString = '', serialObject = {}, name, element, type, options;
490
491	var addValue = function(objName, objValue) {
492	    //serialString += '&' + encodeURI(objName) + '=' + encodeURI(objValue);
493	    serialString += '&' + escape(objName) + '=' + escape(objValue);
494	}
495
496	var elements = form.getElementsByTagName('input');
497	for (var i = 0; i < elements.length; i++) {
498		element = elements[i];
499		name = element.name;
500		if (name && isvalidfield(name)) {
501			type = element.type;
502			if (type != 'button' && type != 'submit' && type != 'image') {
503				if ((type != 'checkbox' && type != 'radio') || element.checked === true) {
504					addValue(name, element.value);
505				}
506			}
507		}
508	}
509
510	var elements = form.getElementsByTagName('select');
511	for (var i = 0; i < elements.length; i++) {
512		element = elements[i];
513		name = element.name;
514		if (name) {
515			var options = element.options;
516			for (var x = 0; x < options.length; x++) {
517				if (options[x].selected === true) {
518					addValue(name, options[x].value);
519				}
520			}
521		}
522	}
523
524	var elements = form.getElementsByTagName('textarea');
525	for (var i = 0; i < elements.length; i++) {
526		element = elements[i];
527		name = element.name;
528		if (name) {
529			addValue(name, element.value);
530		}
531	}
532
533  for (var i = 1; i < arguments.length; i += 2) {
534		addValue(arguments[i], arguments[i + 1]);
535	}
536
537	addValue = null;
538	addValue = null;
539
540	serialString = serialString.substr(1);
541	return serialString;
542}
543
544function getElementsByClassName(clsName) {
545    var retVal = new Array();
546    var elements = document.getElementsByTagName("*");
547    for (var i = 0; i < elements.length; i++) {
548        if (elements[i].className.indexOf(" ") >= 0) {
549            var classes = elements[i].className.split(" ");
550            for (var j = 0; j < classes.length; j++) {
551                if (classes[j] == clsName)
552                    retVal.push(elements[i]);
553            }
554        }
555        else if (elements[i].className == clsName)
556            retVal.push(elements[i]);
557    }
558    return retVal;
559}
560
561var agt = '';
562if (navigator.userAgent) { agt=navigator.userAgent.toLowerCase(); }
563var is_major = parseInt(navigator.appVersion); 
564var is_minor = parseFloat(navigator.appVersion); 
565var is_nav  = ((agt.indexOf('mozilla')!=-1) && (agt.indexOf('spoofer')==-1) 
566			&& (agt.indexOf('compatible') == -1) && (agt.indexOf('opera')==-1) 
567			&& (agt.indexOf('webtv')==-1)); 
568var is_nav4 = (is_nav && (is_major == 4)); 
569var is_nav4up = (is_nav && (is_major >= 4)); 
570var is_navonly      = (is_nav && ((agt.indexOf(";nav") != -1) || 
571					  (agt.indexOf("; nav") != -1)) ); 
572var is_nav5 = (is_nav && (is_major == 5)); 
573var is_nav5up = (is_nav && (is_major >= 5)); 
574var is_ie   = (agt.indexOf("msie") != -1); 
575var is_ie3  = (is_ie && (is_major < 4)); 
576var is_ie4  = (is_ie && (is_major == 4) && (agt.indexOf("msie 5.0")==-1) ); 
577var is_ie4up  = (is_ie  && (is_major >= 4)); 
578var is_ie5  = (is_ie && (is_major == 4) && (agt.indexOf("msie 5.0")!=-1) ); 
579var is_ie5up  = (is_ie  && !is_ie3 && !is_ie4);
580
581
582
583//facebook like button
584
585if (document.namespaces) {
586	var FacebookNS = 'http://www.facebook.com/2008/fbml';
587	document.namespaces.add('fb', FacebookNS);
588}
589
590jQuery(document).ready(function() {
591	var el = null;
592	var facebookApiVersion;
593
594	if (jQuery('.fb-like').length !== 0) {
595	    el = jQuery('.fb-like')[0];
596	}
597
598	jQuery.ajax({
599	    url: '/net/ConfigurationSettingProvider.ashx?setting=FacebookGraphApiVersion',
600	    type: 'GET',
601	    success: function (response) {
602	        facebookApiVersion = 'v' + response;
603	    }
604	});
605
606	//facebook button found	- even if multiple instances, create only one instance of script element
607	if (el) {
608
609		if (el.parentNode && el.parentNode['id'] && el.parentNode['id'] == 'FacebookLikeButtonDiv') {
610			el = el.parentNode;
611		}
612
613		var fbDiv = document.createElement('div');
614		jQuery(fbDiv).attr('id', 'fb-root');
615		jQuery(el).after(fbDiv);
616
617
618
619		//original fb init code
620	    window.fbAsyncInit = function () {
621		    // TODO: move this code out of javascripts.js; we don't want to hardcode the below app ID everywhere.
622		    var args = {
623		        appId: '183622035018280',
624		        status: true,
625		        cookie: true,
626		        version: facebookApiVersion,
627		        xfbml: true
628		    };
629		    FB.init(args);
630		};
631		(function() {
632			var e = document.createElement('script'); e.async = true;
633			e.src = document.location.protocol + 'https://connect.facebook.net/en_US/all.js';
634			document.getElementById('fb-root').appendChild(e);
635		} ());
636
637	}
638
639});
640
641//facebook like button - end
642
643
644
645//predictive search
646
647
648jQuery(document).ready(function() {
649
650	if (!window['Config_Search_Auto_Complete']) {
651		return;
652	}
653
654	jQuery('form[name="SearchBoxForm"] input[name="Search"]').each(function() {
655
656		//remove click handler
657		this.onclick = '';
658
659		var value = this.value;
660		jQuery(this).focus(function() {
661			if (this.value == value) {
662				this.value = '';
663			}
664		});
665		jQuery(this).blur(function() {
666			if (this.value == '') {
667				this.value = value;
668			}
669		});
670
671		//pass through {enter} to submit search
672		jQuery(this).keydown(function(event) {
673			if (event.keyCode == '13') {
674				if (this.value == '') {
675					event.preventDefault();
676					return;
677				}
678				this.form.submit();
679			}
680		});
681
682		jQuery(this).autocomplete({
683			source: [],
684			delay: 0,
685			minLength: 0,
686			select: function(event, ui) {
687				window.setTimeout(function() {
688					var url = '/ProductDetails.asp?ProductCode=' + ui.item.desc;
689					location.href = url;
690				}, 50);
691			},
692			search: function(event, ui) {
693
694				if (this.value == '' || this.value.length < 3) {
695					jQuery(this).autocomplete('close');
696					predictiveSearch_Dispose();
697					return false;
698				}
699				if (predictiveSearch_Initialized(this.value)) {
700					return; //already initialized - no pre-search tasks
701				}
702				predictiveSearch_Init(this, this.value);
703				return false; //cancel search - retrieve values then display with search = ''
704			},
705			open: function(event, ui) {
706				//left align
707				jQuery.fn.setEllipses = setEllipses;
708				jQuery('ul.ui-autocomplete').css({ 'white-space': 'nowrap', 'max-width': '330px', 'overflow': 'hidden' });
709				jQuery('ul.ui-autocomplete li.ui-menu-item').css({ 'text-align': 'left', 'white-space': 'nowrap', 'max-width': '330px', 'overflow': 'hidden' });
710
711			    //not a great fix, but better than moving the functionality (?) to a separate CSS file.
712				jQuery('ul.ui-autocomplete li.ui-menu-item a').css({ 'overflow-x': 'hidden', 'text-overflow': 'ellipsis' })
713
714			    //We can do this in CSS now :)   http://caniuse.com/#feat=text-overflow
715			    //jQuery('ul.ui-autocomplete li.ui-menu-item').setEllipses();
716			}
717		});
718		
719		jQuery(this).data("autocomplete")._renderItem = function(ul, item) {
720			return jQuery( "<li></li>" )
721				.data( "item.autocomplete", item )
722				.append( "<a>" + item.label + "</a>" )
723				.appendTo( ul );
724		};
725
726	});
727});
728
729
730
731var predictiveSearch = null;
732
733function predictiveSearch_Dispose() {
734	if (predictiveSearch) {
735		predictiveSearch.Disposed = true;
736	}
737}
738
739function predictiveSearch_Init(source, search) {
740	predictiveSearch_Dispose();
741	predictiveSearch = new PredictiveSearch();
742	predictiveSearch.source = source;
743	predictiveSearch.search = search;
744	predictiveSearch.Init();
745}
746
747function predictiveSearch_Initialized(search) {
748	if (predictiveSearch) {
749		//if search event for current search, return status
750		if (predictiveSearch.search == search) {
751			return predictiveSearch.Initialized;
752		}
753	}
754	return false;
755}
756
757function PredictiveSearch() { }
758PredictiveSearch.prototype.Initialized = false;
759PredictiveSearch.prototype.Disposed = false;
760PredictiveSearch.prototype.source = null;
761PredictiveSearch.prototype.search = '';
762PredictiveSearch.prototype.result = '';
763PredictiveSearch.prototype.Init = function() {
764
765    var instance = this;
766
767    //get cached item
768    if (window.sessionStorage && false) {
769        var result = sessionStorage[this.search];
770        if (result) {
771            this.result = result;
772            this.Complete();
773            return;
774        }
775    }
776
777    window.setTimeout(function() {
778        //retrieve data
779        instance.RetrieveData();
780    }, 200);
781
782};
783
784PredictiveSearch.prototype.RetrieveData = function() {
785
786    if (this.Disposed) {
787        return;
788    }
789
790    var instance = this;
791    var url = '/searchsuggest.asp?s=' + encodeURIComponent(this.search);
792
793    jQuery.ajax({
794        url: url,
795        dataType: 'text',
796        success: function(data, textStatus, XMLHttpRequest) {
797            jQuery(instance.source).autocomplete('close');
798            if (/^\{[\w\W]*\}$/m.test(data)) {
799                instance.result = data;
800                instance.Continue();
801            }
802        },
803        error: function() {
804            jQuery(instance.source).autocomplete('close');
805            return false;
806        }
807    });
808};
809
810PredictiveSearch.prototype.Continue = function() {
811
812    //set cached item
813    if (window.sessionStorage) {
814        sessionStorage[this.search] = this.result;
815    }
816
817    if (this.Disposed) {
818        return;
819    }
820
821    this.Complete();
822
823};
824
825PredictiveSearch.prototype.Complete = function() {
826
827    var json = eval('(' + this.result + ')');
828
829    var s = [];
830    var t = '';
831
832    if (json['s']) {
833        for (var i = 0, l = json['s'].length; (i < l && i < 10); i++) {
834            s[i] = {};
835            t = json['s'][i]['ProductName'].replace(/<[^>]*>/g, '');
836            s[i].value = s[i].label = jQuery('<div>').html(t).text();
837            s[i].label = highlightSearchText(this.search, s[i].value);
838            s[i].desc = json['s'][i]['ProductCode'];
839        }
840
841        //initialized
842        this.Initialized = true;
843        jQuery(this.source).autocomplete('option', 'source', s);
844        jQuery(this.source).autocomplete('search', '');
845    }
846};
847
848// Function that returns the result with the search text highlighted using html tags.
849// Input Params - search text, result text.
850// Output       - result with search text highlighted wherever it occurs.
851function highlightSearchText(search, result) {
852	
853	var regex = new RegExp(search,"gi");
854	var startIndex, startIndices = [];
855	
856	// Find all the start indices of the search text in the result
857	while ( (startIndex = regex.exec(result)) ) 
858	{
859		startIndices.push(startIndex.index);
860	}
861
862	var originalResultLength = result.length; 
863	
864	for (var i = 0; i < startIndices.length; i++) 
865	{
866		result = result.substring(0, startIndices[i]) +
867		         "<b>" + result.substring(startIndices[i], (startIndices[i] + search.length)) + "</b>" +  // Text to be highlighted
868		         result.substring(startIndices[i] + search.length);
869
870		// Find out the number of characters (in html tags) that has been added to the result.
871		// This value need only be calculated once.
872		if (i == 0)
873			htmlStylingTagsLength = result.length - originalResultLength;
874			
875		// In each iteration, the length of result text increases because of the insertion of the html tags. 
876		// So, the subsequent start indices must also be updated.
877		if (i < (startIndices.length - 1))
878			startIndices[i + 1] += htmlStylingTagsLength + (htmlStylingTagsLength * i);
879	}
880	return result;	
881}
882
883function setEllipses() {
884
885    //This is no longer needed. We can do this in CSS. Kept for legacy reasons http://caniuse.com/#feat=text-overflow
886	this.each(function(index, Element) {
887		var li = jQuery(Element);
888
889		var width = li.width();
890		var text = jQuery(Element).text();
891
892		var el = document.getElementById('ellipses_div');
893		if (!el) {
894			var fontSize = li.css('font-size');
895			var fontFamily = li.css('font-family');
896			el = document.createElement('div');
897			jQuery(el).css({ 'visibility': 'hidden', 'float': 'left', 'font-size': fontSize, 'font-family': fontFamily }).attr('id', 'ellipses_div');
898			jQuery('body').append(el);
899		}
900		var hidden_div = jQuery(el);
901		hidden_div.text(text);
902        
903		while (text.length > 0 && hidden_div.width() >= width) {
904			text2 = text.substr(0, text.length - 4) + '...';
905			text2 = text2.replace(' ...', '...')
906			li.html(li.html().replace(text, text2));
907			hidden_div.text(text);
908			text = text2;
909		}
910	});
911}
912
913jQuery.fn.setEllipses = setEllipses;
914
915//predictive search - end
916
917function DisplayLocalDate(value, ServerUTCOffset) {
918	var d = new Date();
919	var o = ServerUTCOffset - d.getTimezoneOffset();
920	d = new Date(value);
921	d.setMinutes(d.getMinutes() + o);
922	return d.toString();
923}
924
925function isValidStoreVersion(value) {
926	var validFloatRegex = /^\d?\.{1}\d+$/;
927	return validFloatRegex.test(value) && (parseFloat(value) > 1);
928}
929
930//polyfill for Array.filter() - IE8 and older
931if (!Array.prototype.filter) {
932    Array.prototype.filter = function (fun /*, thisp*/) {
933        'use strict';
934
935        if (!this) {
936            throw new TypeError();
937        }
938
939        var t = Object(this),
940        len = t.length >>> 0,
941        res, thisp, i, val;
942        if (typeof fun !== 'function') {
943            throw new TypeError();
944        }
945
946        res = [];
947        thisp = arguments[1];
948        for (i = 0; i < len; i++) {
949            if (i in t) {
950                val = t[i]; // in case fun mutates this
951                if (fun.call(thisp, val, i, t)) {
952                    res.push(val);
953                }
954            }
955        }
956
957        return res;
958    };
959}
960
961// Update MDL components
962function updateMDLComponents() {
963  if (!(typeof (componentHandler) == 'undefined')) {
964      setTimeout(function () {
965        componentHandler.upgradeAllRegistered();
966      },200);    
967  }
968}
969
970//escapes string when using innerHTML
971function escapeString(s) {
972    var n = s;
973    n = n.replace(/&/g, "&amp;");
974    n = n.replace(/</g, "&lt;");
975    n = n.replace(/>/g, "&gt;");
976    n = n.replace(/"/g, "&quot;");
977    n = n.replace(/\'/g, '&#39;')
978    n = n.replace(/\//g, '&#x2F;')
979
980    return n;
981}
982
983(function () {
984    var onDomReadyIdentifier = 'vjsReady',
985        isBound = false,
986        readyList = [];
987    if (window[onDomReadyIdentifier] && typeof window[onDomReadyIdentifier] == 'function') {
988        return;
989    }
990    var whenReady = function () {
991        if (!document.body) {
992            return setTimeout(whenReady, 13);
993        }
994        for (var i = 0; i < readyList.length; i++) {
995            readyList[i]();
996        }
997        readyList = [];
998    };
999    var bindReady = function () {
1000        if (document.addEventListener) {
1001            var DOMContentLoaded = function () {
1002                document.removeEventListener("DOMContentLoaded", DOMContentLoaded, false);
1003                whenReady();
1004            };
1005            document.addEventListener("DOMContentLoaded", DOMContentLoaded, false);
1006            window.addEventListener("load", whenReady, false); // fallback
1007        } else if (document.attachEvent) {
1008
1009            var onreadystatechange = function () {
1010                if (document.readyState === "complete") {
1011                    document.detachEvent("onreadystatechange", onreadystatechange);
1012                    whenReady();
1013                }
1014            };
1015            document.attachEvent("onreadystatechange", onreadystatechange);
1016            window.attachEvent("onload", whenReady); // fallback
1017            var toplevel = false;
1018
1019            try {
1020                toplevel = window.frameElement == null;
1021            } catch (e) { }
1022            if (document.documentElement.doScroll && toplevel) {
1023                var doScrollCheck = function () {
1024                    if (readyList.length == 0) {
1025                        return;
1026                    }
1027                    try {
1028                        document.documentElement.doScroll("left");
1029                    } catch (e) {
1030                        setTimeout(doScrollCheck, 1);
1031                        return;
1032                    }
1033                    whenReady();
1034                }
1035                doScrollCheck();
1036            }
1037        }
1038    };
1039    window[onDomReadyIdentifier] = function (callback) {
1040        readyList.push(callback);
1041        if (document.readyState == "complete") {
1042            whenReady();
1043        } else if (!isBound) {
1044            bindReady();
1045            isBound = true;
1046        }
1047    };
1048})();

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.