PageSourceSearch

https://galleries.lakesuperiorphoto.com/js/APP/1788533357/util.js

js lakesuperiorphoto.com collected 2026-09-26 07:09:59 UTC 16,565 bytes, 759 lines download raw bytes

1/* some constants required for pathInfo escaping */
2var PI_D_ESC_CHAR = '%';
3var PI_D_ESC_CHARS = '\/=';
4var PI_KV_DELIM = '=';
5var PI_SPACE_SUB = '-';
6
7var UNITED_STATES = {
8	'AL': 'Alabama',
9	'AK': 'Alaska',
10	'AZ': 'Arizona',
11	'AR': 'Arkansas',
12	'CA': 'California',
13	'CO': 'Colorado',
14	'CT': 'Connecticut',
15	'DE': 'Delaware',
16	'DC': 'District of Columbia',
17	'FL': 'Florida',
18	'GA': 'Georgia',
19	'HI': 'Hawaii',
20	'ID': 'Idaho',
21	'IL': 'Illinois',
22	'IN': 'Indiana',
23	'IA': 'Iowa',
24	'KS': 'Kansas',
25	'KY': 'Kentucky',
26	'LA': 'Louisiana',
27	'ME': 'Maine',
28	'MD': 'Maryland',
29	'MA': 'Massachusetts',
30	'MI': 'Michigan',
31	'MN': 'Minnesota',
32	'MS': 'Mississippi',
33	'MO': 'Missouri',
34	'MT': 'Montana',
35	'NE': 'Nebraska',
36	'NV': 'Nevada',
37	'NH': 'New Hampshire',
38	'NJ': 'New Jersey',
39	'NM': 'New Mexico',
40	'NY': 'New York',
41	'NC': 'North Carolina',
42	'ND': 'North Dakota',
43	'OH': 'Ohio',
44	'OK': 'Oklahoma',
45	'OR': 'Oregon',
46	'PA': 'Pennsylvania',
47	'RI': 'Rhode Island',
48	'SC': 'South Carolina',
49	'SD': 'South Dakota',
50	'TN': 'Tennessee',
51	'TX': 'Texas',
52	'UT': 'Utah',
53	'VT': 'Vermont',
54	'VA': 'Virginia',
55	'WA': 'Washington',
56	'WV': 'West Virginia',
57	'WI': 'Wisconsin',
58	'WY': 'Wyoming',
59	'AA': 'Armed Forces Americas',
60	'AE': 'Armed Forces',
61	'AP': 'Armed Forces Pacific'
62};
63
64var AUSTRALIA =  {
65	'NSW': 'New South Wales',
66	'QLD': 'Queensland',
67	'SA' : 'South Australia',
68	'TAS': 'Tasmania',
69	'VIC': 'Victoria',
70	'WA' : 'Western Australia',
71	'ACT': 'Australian Capital Territory',
72	'NT' : 'Northern Territory'
73};
74
75var CANADA = {
76	'AB': 'Alberta',
77	'BC': 'British Columbia',
78	'MB': 'Manitoba',
79	'NB': 'New Brunswick',
80	'NL': 'Newfoundland/Labrador',
81	'NS': 'Nova Scotia',
82	'NT': 'Northwest Territories',
83	'NU': 'Nunavut',
84	'ON': 'Ontario',
85	'PE': 'Prince Edward Island',
86	'QC': 'Quebec',
87	'SK': 'Saskatchewan',
88	'YT': 'Yukon'
89};
90
91//Returns the ascii value of a character
92function ord (string) {
93	var str = string + '',
94	code = str.charCodeAt(0);
95	if (0xD800 <= code && code <= 0xDBFF) { 
96		var hi = code;
97		if (str.length === 1) {
98			return code; 
99		}
100		var low = str.charCodeAt(1);
101		return ((hi - 0xD800) * 0x400) + (low - 0xDC00) + 0x10000;
102	}
103	if (0xDC00 <= code && code <= 0xDFFF) { 
104		return code; 
105	}
106	return code;
107}
108
109//Converts a decimal to a hexadecimal
110function dechex (number) {
111	if (number < 0) {
112		number = 0xFFFFFFFF + number + 1;
113	}
114	return parseInt(number, 10).toString(16);
115}
116
117// URL encoding as cloase as possible to match the PHP version of this function
118// see RFC 3986
119function rawurlencode (str) {
120	str = (str + '').toString();
121  // Tilde should be allowed unescaped in future versions of PHP (as reflected below), but if you want to reflect current
122  // PHP behavior, you would need to add ".replace(/~/g, '%7E');" to the following.
123	return encodeURIComponent(str).replace(/!/g, '%21').replace(/'/g, '%27').replace(/\(/g, '%28').
124	replace(/\)/g, '%29').replace(/\*/g, '%2A');
125}
126
127//encodes a string in a manner such that it is suitable for use as a path element
128function _pathInfoEncodeData(str)
129{
130	s = str;
131	var replF = [PI_SPACE_SUB, ' ', '%']
132	var replR = [PI_D_ESC_CHAR + dechex(ord(PI_SPACE_SUB)),
133			PI_SPACE_SUB,
134			'%25'];
135            
136	var sA = s.split('');
137	s = '';
138	for (a=0; a<sA.length; a++) {
139		nc = sA[a];
140		for (r=0; r<replF.length; r++) {
141			if (sA[a] == replF[r])
142				nc = replR[r];
143		}
144		s += nc;
145	}
146
147	replF = PI_D_ESC_CHARS.split('');
148	replR = [];
149	for (i=0; i<replF.length; i++) {
150		replR[i] = PI_D_ESC_CHAR + dechex(ord(replF[i]));
151	}
152    
153	sA = s.split('');
154	s = '';
155	for (a=0; a<sA.length; a++) {
156		nc = sA[a];
157		for (r=0; r<replF.length; r++) {
158		    if (sA[a] == replF[r])
159			nc = replR[r];
160		}
161		s += nc;
162	}
163
164	rEnc = rawurlencode(s);
165
166	return rEnc;
167}
168
169//Encode specified array or associatiave array(obj) to a URL path
170function pathInfoEncode(arr)
171{
172	rA=[];
173	p=0;
174    
175	for (var i in arr) {
176		if (!isNaN(i)) {
177			rA[p] = _pathInfoEncodeData(arr[i]);
178		}
179		else
180		{
181		    rA[p] = _pathInfoEncodeData(i) + PI_KV_DELIM + _pathInfoEncodeData(arr[i]);
182		}
183		p++;
184	}
185
186	return rA.join('/');
187}
188
189// ##########################################
190// primitives
191// ##########################################
192
193function isArray(variable) { return Boolean( typeof variable == 'object' && variable.length >= 0 ); }
194
195// a "proper" implementation of the escape() routine; 
196function httpEscape(str)
197{
198
199	var		i, c;
200	var		output = "";
201
202	if (!str || (typeof str != "string"))
203		return str;
204
205	for (i = 0; i < str.length; i++) {
206		c = str.charAt(i);
207		if (c.match(/[a-z0-9\/-]/i)) {
208			output += c;
209			continue;
210		}
211		c = str.charCodeAt(i);
212		output += "%" + c.toString(16);
213	}
214
215	return output;
216}
217
218// returns number of elements in a formvar multiple
219function getElementLength(fVar)
220{
221	if (!fVar)
222		return 0;
223	else
224		return (fVar.length) ? fVar.length : 1;
225}
226
227//checks that a single email address conforms to basic format constraints
228function isValidEmail(email) {
229        var rgx = /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
230        return rgx.test(email);
231}
232
233// checks if a formvar is blank or whitespace;
234function checkBlank(fVar, message)
235{
236	if (fVar.value.search(/^ *$/) == -1)
237		return true;
238	
239	if (message) alert("Please enter " + message + ".");
240	return false;
241}
242
243// returns number of items that are checked
244function checkCount(fVar)
245{
246
247	if (!fVar)
248		return false;
249
250	var count = 0;
251	var n = getElementLength(fVar);
252
253	switch (n) {
254		case 0:
255			return 0;
256		case 1:
257			return (fVar.checked) ? 1 : 0;
258		default:
259			for (var i = 0; i < n; i++) {
260				count += ((fVar[i].checked) ? 1 : 0);
261			}
262			return count;
263	}
264}
265
266function checkSize(fVar, maxsize, name)
267{
268	if (!fVar) return true;
269
270	var		n = fVar.value.length;
271	if (n > maxsize) {
272		var diff = n - maxsize;
273		alert("The maximum size of the field \"" + name + "\" is " + maxsize +
274		      " characters; you have entered " + n + " characters.\n" +
275		      "Please reduce your entry by at least " + diff + " characters.");
276		fVar.focus();
277		return false;
278	} else return true;
279}
280
281// sets all checkboxes from element[0] to the specified value
282function cbSet(fVar, value)
283{
284	var n = getElementLength(fVar);
285
286	switch (n) {
287		case null:
288		case false:
289		case 0:
290			return;
291		case true:
292		case 1:	
293			fVar.checked = value;
294			break;
295		default:
296			for (var i = 0; i < n; i++) {
297				fVar[i].checked = value;
298			}
299	}
300}
301
302
303// returns value of the specified fVar
304// NOTE: it returns an ARRAY, not a single value
305// skipHidden determines if getVal retrieves hidden variables or not
306function getVal(fVar, skipHidden)
307{
308	var		val = new Array();
309	var		type = null;
310
311	if (!fVar) return null;
312
313	if (!skipHidden) skipHidden = false;
314	
315	if (fVar.type) type = fVar.type;
316	else if (getElementLength(fVar)) type = fVar[0].type;
317
318	switch (type) {
319	case "select-one":
320		val.push(fVar.options[fVar.selectedIndex].value);
321		break;
322	case "select-multiple":
323		for (var i = 0; i < fVar.length; i++) {
324			if (fVar.options[i].selected)
325				val.push(fVar.options[i].value);
326		} 
327		break;
328	case "checkbox":
329	case "radio":
330		if (getElementLength(fVar) > 1) {
331			for (var i = 0; i < fVar.length; i++) {
332				if (fVar[i].checked)
333					val.push(fVar[i].value);
334			}
335		} else 
336			val.push((fVar.checked) ? fVar.value : null);
337		break;
338	case "text":
339	case "textarea":
340	case "password":
341		val.push(fVar.value);
342		break;
343	case "hidden":
344		val.push((skipHidden) ? null : fVar.value);
345		break;
346	default:
347		val.push(null);
348	}
349
350	return val;
351}
352
353// single variable wrapper for getVal
354function getValSingle(fVar, skipHidden)
355{
356	if (!skipHidden) skipHidden = false;
357
358	var		val = getVal(fVar, skipHidden);
359	
360	if (val) return val[0];
361	else return null;
362}
363
364function setVal(fVar, val)
365{
366// attempts to set a fVar's value to the value specified by "val";
367// NOTE: val must be an array!!! for non-multiple formvars, pass the
368// desired value in val[0].
369	var		i, j;
370
371	if (!fVar) return;
372	
373	if ((typeof val) != 'object')
374		val = [val];
375
376	switch (fVar.type) {
377		case "select-one":
378		case "select-multiple":
379			if (!val || !val.length) {
380				fVar.selectedIndex = 0;
381				break;
382			}
383			for (i = 0; i < val.length; i++) {
384				for (j = 0; j < fVar.length; j++) {
385					if (fVar.options[j].value == val[i]) {
386						fVar.options[j].selected = true;
387						break;
388					}
389				}
390			}
391			break;
392		case "checkbox":
393		case "radio":
394			if (!val || !val.length) {
395				fVar.checked = false;
396			} else {
397				for (i = 0; i < val.length; i++) {
398					if (fVar.value == val[i]) {
399						fVar.checked = true;
400						break;
401					} else {
402						fVar.checked = false;
403					}
404				}
405			}
406			break;
407		case "text":
408		case "textarea":
409		case "password":
410			fVar.value = (val && val.length) ? val[0] : "";
411			break;
412	}
413	return;
414}
415
416function getCookieData(labelName)
417{
418	 var labelLen = labelName.length;
419	 var cookieData = document.cookie;
420	 var cLen = cookieData.length;
421	 var i = 0;
422	 var cEnd;
423	 while (i < cLen) {
424		  var j = i + labelLen;
425		  if (cookieData.substring(i,j+1) == labelName + '=') {
426			   cEnd = cookieData.indexOf(";",j);
427			   if (cEnd == -1) {
428				    cEnd = cookieData.length;
429			   }
430			   return unescape(cookieData.substring(j+1, cEnd));
431		  }
432		  i++;
433	 }
434	 return "";
435}
436
437// convenience method added for use in js/jquery/pub2014/jquery.pub2014.js
438// based on similar in js/1.0/bsLite.js
439function setCookie(name, value, days)
440{
441	var expStr = '';
442
443	// set expiration
444	if (days && (days = parseInt(days)) != NaN) {
445		var exp = new Date();
446		exp.setDate(exp.getDate() + days);
447		expStr = '; expires=' + exp.toGMTString();
448	}
449
450	document.cookie = name + '=' + escape(value) + expStr;
451}
452
453
454// ##########################################
455// more specific form handling functions...
456// ##########################################
457
458function detectSelect(formName, varName) 
459{
460	var objCheckbox = document.forms[formName].elements[varName];
461
462	var objArray = new Array();
463
464	if (objCheckbox.length && objCheckbox.length >= 0) {
465		for (i=0; i < objCheckbox.length; i++) {
466			if (objCheckbox[i].checked == true) {
467				objArray.push(objCheckbox[i].value);
468			}
469		}
470	} else {
471		objArray.push(objCheckbox.value);
472	}
473	return objArray;
474}
475
476function toggle(divname)
477{
478	if (document.all) {
479		if (document.all[divname].style.display==''||document.all[divname].style.display=='block'){
480			document.all[divname].style.display='none';
481		} else {
482			document.all[divname].style.display='';
483		}
484	} else if (document.getElementById) {
485		if (document.getElementById(divname).style.display=='block'||document.getElementById(divname).style.display=='') {
486			document.getElementById(divname).style.display='none';
487		} else {
488			document.getElementById(divname).style.display='block';
489		}
490 	}
491}
492
493function checkSel(fVar) {
494	if (!fVar)
495		return false;
496		
497	var count = 0;
498	var n = getElementLength(fVar);
499	
500	switch(n) {
501		case 0:
502			return false;
503			break;
504		case 1: 
505			return (fVar.checked) ? true : false;
506			break;
507		default: 
508			for (var i = 0; i < n; i++) {
509				count += ((fVar[i].checked) ? 1 : 0);
510			}
511			if (count > 0) return true; else return false;
512			break;
513	}
514}
515
516var SUBMIT_ONCE_FLAG = false;
517
518function submitOnce(fObj, f_nosubmit)
519{
520    if (!SUBMIT_ONCE_FLAG) {
521	SUBMIT_ONCE_FLAG = true;
522	try {
523		fObj.submitButton.value = " Please wait... ";
524		fObj.submitButton.disabled = true;
525	} catch (e) {}
526	if (!f_nosubmit) fObj.submit();
527    }
528
529    return false;
530}
531
532function isCanProvince (s)
533{
534	return Objects.keys(CANADA).includes(s)
535}
536
537function selectState(state, country)
538{
539	var s = _bsForm.getValue(state);
540
541	if (isCanProvince(s))
542		_bsForm.setValue(country, 'CAN');
543	else if (!empty(s))
544		_bsForm.setValue(country, 'USA');
545}
546// Generic function to empty all options out of
547// a select
548function removeOptions(select) {
549	for(var i = select.options.length - 1; i >= 0; i--) {
550	   select.remove(i);
551	}
552}
553
554// Generic function to fill options on a select, receives an object
555// with property keys as values, and property values a labels
556function fillOptions(options, select ) {
557	removeOptions(select);
558
559	var addOption = function (value, label, select) {
560		var opt = document.createElement("option");
561		opt.value= value;
562		opt.innerHTML = label;
563		select.appendChild(opt);
564	}
565
566	//add empty option first
567	addOption('', '', select)
568	for (const value in options) {
569		if (options.hasOwnProperty(value)) {
570			addOption(value, options[value], select);
571		}
572	}
573}
574
575// Old SelectCountry to be used in places that are not a cart checkout
576function selectCountry(country, state)
577{
578	if (!state) return;
579	var s = _bsForm.getValue(state);
580
581	switch (_bsForm.getValue(country)) {
582	case 'USA':
583		if (isCanProvince(s))
584			_bsForm.setValue(state, '');
585		break;
586	case 'CAN':
587		if (!isCanProvince(s))
588			_bsForm.setValue(state, '');
589	default:
590		_bsForm.setValue(state, '');
591	}
592}
593
594// Specialized SelectCountry that does the usual
595// first select the country, then get valid state options
596function selectCountryAutoFill(country, state)
597{	
598	var c = _bsForm.getValue(country)
599	if (['USA', 'CAN', 'AUS'].includes(c)){
600		switch (c) {
601		case 'USA':
602			fillOptions(UNITED_STATES, state);
603			break;
604		case 'AUS':
605			fillOptions(AUSTRALIA, state);
606			break;
607		case 'CAN':
608			fillOptions(CANADA, state);
609			break;
610		}
611	} else {
612		removeOptions(state);
613	}
614}
615
616function clearDateVal(fVar)
617{
618	 if (!fVar.value.match(/[0-9]{1,}/))
619		  fVar.value = '';
620}
621
622function catBillDate(fObj, alias)
623{
624	if (!alias) alias = 'BI';
625
626	// skip for invoice type - kind of a hack for BI_METHOD radio
627	if (fObj.BI_METHOD && fObj.BI_METHOD.length > 1 && fObj.BI_METHOD[1].checked)
628		return true;
629
630	// set CC_EXP
631	if (!fObj.elements[alias + '_CC_EXP__MM'].selectedIndex ||
632	    !fObj.elements[alias + '_CC_EXP__YY'].selectedIndex) {
633		alert('Please select your credit card expiration date.');
634		return false;
635	} else
636		fObj.elements[alias + '_CC_EXP'].value = getValSingle(fObj.elements[alias + '_CC_EXP__MM']) + getValSingle(fObj.elements[alias + '_CC_EXP__YY']);
637
638	return true;
639}
640
641
642// ##########################################
643// misc. front-end stuff
644// ##########################################
645
646var             ACT_SRC_DIR = "/img/act/";
647
648function actImgOver(imgName,imgSrc,mode) {
649	if (mode == 1) {
650    		document[imgName].src = ACT_SRC_DIR + imgSrc + "-over.gif";
651	} else {
652    		document[imgName].src = ACT_SRC_DIR + imgSrc + ".gif"; 
653	}
654}
655
656var splashMe = null;
657function splash()
658{
659	 var w = 500;
660	 var h = 100;
661	 var win1 = ((screen.width - w) / 2);
662	 var win2 = ((screen.height - h) / 2);
663	 var url = '/mem/upload_splash.html';
664	 var settings = 'height='+h+',';
665	     settings += 'width='+w+',';
666	     settings += 'top='+win2+',';
667	     settings += 'left='+win1+','
668	     settings += 'resizable=no,scrollbars=no';
669	 splashMe = window.open(url,"",settings);
670	 return true;	      
671}
672
673function closeSplash()
674{
675	if(window.splashMe) {
676	 	splashMe.close();
677	}
678}
679
680function popupWin(url, width, height, name)
681{
682	if (!name) name = "popup";
683
684	var foo = window.open(url, name, "resizable=yes,scrollbars=yes,location=no,menubar=no,width=" 
684+ width + ",height=" + height);
685	if (foo) foo.focus();
686}
687
688function convertBytes(bytes)
689{
690	var			unit;
691	var			n;
692	
693	if (bytes/(1024) < 1) {
694		unit = 'bytes';
695		n = Math.floor(bytes);
696	} else if (bytes/(1024*1024) < 1) {
697		unit = 'KB';
698		n = Math.floor(10*bytes/(1024))/10;
699	} else if (bytes/(1024*1024*1024) < 1) {
700		unit = 'MB';
701		n = Math.floor(10*bytes/(1024*1024))/10;
702	} else {
703		unit = 'GB';
704		n = Math.floor(10*bytes/(1024*1024*1024))/10;
705	}
706	
707	n = n.toString();
708	if (n.indexOf('.') < 0) n += '.0';
709
710	return n + unit;
711}
712
713function blockToggle (obj, cn)
714{
715	if (!isset(cn)) cn = 'open';
716
717	var div = obj.parentNode;
718	var f = _bsDom.hasClass(div, cn);
719	if (!f) _bsDom.addClass(div, cn);
720	else _bsDom.delClass(div, cn);
721};
722
723function _seoIcon (obj)
724{
725	var str = "This field can affect your search engine optimization (SEO).<br><b>&raquo;</b> <a href=\"https://support.photoshelter.com/hc/en-us/articles/203375220-SEO-On-Page-Factors\" class=\"bold\" target=\"_blank\">Learn More</a>";
726	_balloon(obj, '<h3>SEO</h3>', str)
727}
728
729function seoIcon (f_write, style)
730{
731	var str = '<a href="javascript:void(0);" onClick="_seoIcon(this);"';
732	if (style) str += ' style="' + style + '"';
733	str += ' class="seoIcon">';
734	str += '<img src="/img/icon/seo.gif" width="24" height="11" alt="SEO" border="0">';
735	str += '</a>';
736
737	if (f_write) document.write(str);
738	else return str;
739}
740
741function makeRTE(obj)
742{
743	var editor = new nicEditor({
744		buttonList: [
745			'fontSize',
746			'bold',
747			'italic',
748			'underline',
749			'ul',
750			'ol',
751			'link',
752			'image',
753			'xhtml'
754		],
755		iconsPath: '/img/nicEditorIcons.gif'
756	});
757	editor.panelInstance(obj);
758}
759

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.