PageSourceSearch

https://arquivo.nitroimagens.com.br/js/APP/1788533357/0.6/PS.js

js nitroimagens.com.br collected 2026-09-30 22:52:05 UTC 31,727 bytes, 1,275 lines download raw bytes

1if (typeof(PS) == 'undefined') {
2	PS = {};
3}
4
5if (typeof(PS.com) == 'undefined') PS.com = {};
6
7if (typeof(PS.utl) == 'undefined') {
8	PS.utl = {};
9
10	PS.utl._IMG = {}
11	PS.utl._IMG.spinner = new Image();
12	PS.utl._IMG.spinner.src = '/img/BS.com/spinner.gif';
13	PS.utl._IMG.spinnerBig = new Image();
14	PS.utl._IMG.spinnerBig.src = '/img/BS.com/spinner-big.gif';
15};
16
17PS.App = function ()
18{
19};
20
21PS.App.prototype = {
22	pv:		[],
23	orgPerm:	null,
24
25	pvSet: function (n, v) { this.pv[n] = v; },
26
27	pvGet: function (n)
28	{
29		return (isset(this.pv[n])) ? this.pv[n] : null;
30	},
31
32	realmPath: function ()
33	{
34		var area = this.pvGet('area');
35
36		switch (area) {
37		case 'adm':
38		case 'cli':
39		case 'mem':
40		case 'mu':
41			return '/' + area;
42		default:
43			return '';
44		}
45	},
46
47	imgGet: function (id, t, host, qry, f_auth)
48	{
49		if (host && (host = this.pvGet('server.' + host)));
50		else host = '';
51
52		t = (t) ? ('/' + t) : '/s';
53		qry = (qry) ? '?' + qry: '';
54
55		var iget = '/img-get';
56		if (f_auth) {
57				var area = this.pvGet('area');
58				if (area == 'mu' || area == 'mem') {
59					iget = '/' + area + iget;
60
61					// don't use caching hostname
62					// (potential security hole)
63					host = '';
64				}
65		}
66
67		return host + iget + '/' + id + t + qry;
68	},
69
70	videoGet: function (id, t, host, fname, qry, f_auth)
71	{
72		if (host && (host = this.pvGet('server.' + host)));
73		else host = '';
74
75		t = (t) ? t : 'hls'; //defaults to HLS playlist
76
77		if (fname) {
78			//HACK: remove file extension
79			fnA = fname.split('.');
80			fnA.pop();
81			// escape string
82			fname = PS.utl.tplescape(fnA.join('.'));
83		} else fname = id; //default file name is id
84
85		switch (t) {
86		case 'hls':
87			fname += '.m3u8';
88			break;
89		case 'poster':
90		case 'thumb':
91			fname += '.jpg';
92			break;
93		}
94
95		return host + '/video-get/' + id + '/fmt=' + t + '/' + fname;
96	},
97
98	mediaGet: function (id, t, fname, qry, f_auth)
99	{
100		if (!id) throw new Error('Media id not set');
101
102		// process args to for imgGet interface
103		switch (id.substr(0, 5)) {
104		case 'I0000':
105			t = (t == 'thumb') ? 't/150' :t;
106			return this.imgGet(id, t, 'img', qry, f_auth);
107		case 'VD000':
108			return this.videoGet(id, t, 'vid', fname);
109		default:
110			throw new Error('Media type not reached');
111		}
112	},
113
114	imgSzCalc: function (dim, sz, f_upscale)
115	{
116		if (!is_array(sz)) sz = [sz, sz];
117
118		if (!f_upscale && (dim[0] <= sz[0] && dim[1] <= sz[1]))
119			return dim;
120		
121		var szar = sz[0]/sz[1];
122		var dimarr = dim[0]/dim[1]
123		if (szar > dimarr) return [Math.floor(sz[1]*dimarr), sz[1]];
124		else return [sz[0], Math.floor(sz[0]/dimarr)];
125	},
126
127	orgPermLoad: function (str)
128	{
129		this.orgPerm = str.split(' ');
130	},
131
132	orgPermCheck: function (perm)
133	{
134		if (!this.orgPerm || !perm) return true;
135
136		for (var i = 0; i < this.orgPerm.length; i++) {
137			if (this.orgPerm[i] == 'F_ADM') return true;
138			if (this.orgPerm[i] == perm) return true;
139		}
140
141		return false;
142	},
143
144	orgPermAlert: function (perm)
145	{
146		if (!this.orgPermCheck(perm)) {
147			BS.utl.alert.show('Error', 'You do not have permission to perform this action.\nPlease contact your site administrator for access.');
148			return false;
149		}
150
151		return true;
152	},
153
154	orgPermHref: function (perm, url)
155	{
156		if (this.orgPermAlert(perm)) location = url;
157	}
158};
159
160PS.utl.qryData = {};
161
162PS.utl.qryData.flatten = function (data, n, v)
163{
164	var arr = [];
165
166	for (var i = 0, l = data.length; i<l; i++) {
167		data[i] = BS.utl.array.reduce(data[i]);
168		arr.push([data[i][n], data[i][v]]);
169	}
170
171	return arr;
172};
173
174PS.com.Keypress = function ()
175{
176	this.keyA = [];
177};
178
179PS.com.Keypress.prototype = {
180	kp:		null,
181	ce:		null,
182
183	_ce: function (type, data, args)
184	{
185		var		e = args[0];
186		var		code = BS.utl.event.getKeyCode(e);
187		var		c = null;
188
189		if (e.metaKey || e.altKey || e.ctrlKey)
190			return false;
191
192		try {
193			switch (code) {
194			case 39:			// RIGHT Arrow
195			case 107:			// NUM +
196				c = 'RIGHT'; break;
197			case 37:			// LEFT Arrow
198			case 109:			// NUM -
199				c = 'LEFT'; break;
200			case 33: 			// Page UP
201				c = 'UP'; break;
202			case 36:			// HOME
203				c = 'HOME'; break;
204			case 35:			// END
205				c = 'END'; break;
206			case 27:			// ESC
207				c = 'ESC'; break;
208				
209			}
210
211			if (c && e.shiftKey)
212				c += '2';
213			else if (!c)
214				c = (String.fromCharCode(code)).toUpperCase();
215
216			if (isset(this.keyA[c])) this.keyA[c]();
217		}
218		catch (e) {alert(e);}
219	},
220
221	register: function (keys, f)
222	{
223		if (!this.kp) {
224			this.kp = BS.utl.mm.oNew(BS.com.Keypress);
225			this.ce = BS.utl.mm.ceNew('Keypress', this);
226			this.ce.addCB(this._ce);
227			this.kp.addGlobal(this.ce);
228		}
229
230		for (var i = 0; i < keys.length; i++) {
231			this.keyA[keys[i]] = f;
232		}
233	}
234};
235
236PS.utl.keypress = BS.utl.mm.oNew(PS.com.Keypress);
237
238PS.com.Prompt = function (title, submitE, cname, zindex)
239{
240	if (!cname) cname = 'PsPrompt';	
241	if (!zindex) zindex = null;
242
243	BS.com.Prompt.call(this, null, null, cname, zindex);
244
245	if (submitE) this.submitE = submitE;
246
247	this.mask = _bsObj.cache('PS.com.MaskCache');
248	this.xA = this.mm.domNew(this.obj, 'a', 'PsPromptClose');
249	this.xA.innerHTML = 'X';
250	this.xA.href = 'javascript:void(0);';
251	_bsDom.setDisplay(this.xA, false);
252	this.titleH = this.mm.domNew(this.obj, 'h1');
253	this.bodyDIV = this.mm.domNew(this.obj, 'div', 'body');
254	this.form = this.mm.domNew(this.bodyDIV, 'form');
255	this.form.onsubmit = function () { return false; };
256
257	this.footerDIV = this.mm.domNew(this.obj, 'div', 'footer');
258	this.cancelINP = this.mm.domNew(null, 'input', 'button');
259	this.cancelINP.setAttribute('type', 'button');
260	this.cancelINP.value = "Cancel";
261	this.submitINP = this.mm.domNew(null, 'input', 'button');
262	this.submitINP.setAttribute('type', 'button');
263	this.submitINP.value = "Submit";
264
265	this.footerDIV.appendChild(this.submitINP);
266	this.footerDIV.appendChild(this.cancelINP);
267
268	BS.utl.dom.setStyle(this.mm.domNew(this.footerDIV, 'br'), 'clear', 'both');
269
270	if (title) {
271		this.titleH.innerHTML = title;
272		this._setSubmitVal(title);
273	}
274
275	BS.utl.event.attach(this.cancelINP, 'click', this.cancel, this);
276	BS.utl.event.attach(this.xA, 'click', this.cancel, this);
277	BS.utl.event.attach(this.submitINP, 'click', this._submit, this);
278	BS.utl.event.attach(this.form, 'submit', this._submit, this);
279
280	BS.utl.dom.setStyle(this.bodyDIV, 'display', 'none');
281};
282
283PS.com.Prompt.prototype = {
284	f_submit:	false,
285	submitE: 	null,
286
287	_delete: function ()
288	{
289		this.form.onsubmit = null;
290		this.mask = null;
291		this.submitE = null;
292
293		BS.utl.event.detach(this.cancelINP, 'click', this.cancel);
294		BS.utl.event.detach(this.submitINP, 'click', this._submit);
295		BS.utl.event.detach(this.form, 'submit', this._submit);
296
297		BS.com.Prompt.prototype._delete.call(this);
298	},
299
300	_submit: function (arr)
301	{
302		if (this.submitE) 
303			this.submitE.exec(this.type, arr);
304		else this.form.submit();
305	},
306
307	_setSubmitVal: function (val)
308	{
309		BS.utl.dom.setDisplay(this.submitINP, (val != null));
310		if (val != null) this.submitINP.value = val;
311	},
312
313	_setCancelVal: function (val) { this.cancelINP.value = val; },
314
315	show: function (mode)
316	{
317		if (mode == this.f_show)
318			return false;
319
320		this.f_show = mode;
321		this.mask.show(mode);
322
323		if (mode) {
324			this.f_submit = false;
325
326			BS.utl.dom.setStyle(this.bodyDIV, 'display', 'block');
327
328			if (this.form) this.form.reset();
329			
330		} else {
331			BS.utl.dom.setStyle(this.bodyDIV, 'display', 'none');
332		}
333
334		BS.com.Prompt.prototype.show.call(this, mode);
335	},
336
337	reset: function () { this.f_submit = false; },
338
339	cancel: function () { this.show(false); }
340};
341
342BS.utl.object.inherit(BS.com.Prompt, PS.com.Prompt);
343
344PS.com.LoginPrompt = function (extBsapiCE, bsPath, bsP)
345{
346	var tmp, li;
347
348	this.gvStr = BS.utl.mkGvStr(this);
349	this.URL_PATH =(PS.app.pvGet('custom_path')) ? PS.app.pvGet('custom_path') : '';
350
351	this.extBsapiCE = extBsapiCE;
352	this.bsPath = bsPath;
353	this.bsP = bsP;
354
355	BS.com.Prompt.call(this, null, null, 'PsLoginPrompt', 6000);
356
357	if (this.extBsapiCE && this.bsPath) {
358		this.bsapi = this.mm.oNew(BS.com.BSApi);
359		this.bsapiE = this.mm.ceNew('bsapiE', this);
360		this.bsapiE.addCB(this._bsapiCB);
361	}
362
363	this.mask = this.mm.oNew(BS.com.Mask, null, 0.5, '5999');
364
365	this.titleH = this.mm.domNew(this.obj, 'h1');
366	this.titleH.innerHTML = 'Login Required';
367
368	this.bodyDIV = this.mm.domNew(this.obj, 'div', 'body');
369	this.cntDIV = this.mm.domNew(this.bodyDIV, 'div', 'cnt')
370
371	this.msgDIV = this.mm.domNew(this.bodyDIV, 'div');
372	this.msgDIV.innerHTML = 'Please log into PhotoShelter to access this feature.';
373
374	this.footerDIV = this.mm.domNew(this.obj, 'div', 'footer')
375	this.cancelINP = this.mm.domNew(null, 'input', 'button')
376	this.cancelINP.setAttribute('type', 'button');
377	this.cancelINP.value = "Cancel";
378	this.footerDIV.appendChild(this.cancelINP);
379	BS.utl.dom.setStyle(this.mm.domNew(this.footerDIV, 'br'), 'clear', 'both');
380
381	BS.utl.event.attach(this.cancelINP, 'click', this.cancel, this);
382
383	// iframe
384	this.iframe = this.mm.domNew(null, 'iframe', 'psLoginPromptFrame');
385	this.iframe.setAttribute('frameBorder', '0');
386	this.iframe.setAttribute('scrolling', 'no');
387	this.bodyDIV.appendChild(this.iframe);
388	this.iframe.src = PS.app.pvGet('server.sec') + this.URL_PATH + '/login/ajax/' + escape(this.gvStr);
389
390	BS.utl.dom.setStyle(this.bodyDIV, 'display', 'none');
391};
392
393PS.com.LoginPrompt.prototype = {
394
395	_delete: function ()
396	{
397		this.mask = null;
398		this.extBsapiCE = this.bsPath = this.bsP = null;
399
400		BS.utl.event.detach(this.cancelINP, 'click', this.cancel);
401
402		BS.com.Prompt.prototype._delete.call(this);
403	},
404
405	loginCB: function ()
406	{
407		if (this.extBsapiCE && this.bsapi) {
408			this.bsapi.post(this.bsPath, this.bsP, this.extBsapiCE);
409			this.cancel();
410		} else if (this.extBsapiCE) {
411				this.extBsapiCE.exec();	
412		} else {
413			location.reload();
414		}
415	},
416
417	show: function (mode)
418	{
419		this.f_show = mode;
420		this.mask.show(mode);
421		BS.utl.dom.setDisplay(this.bodyDIV, mode);
422		BS.com.Prompt.prototype.show.call(this, mode);
423	},
424
425	setMsg: function (str) { this.msgDIV.innerHTML = str; },
426
427	cancel: function (type, data, args) { this.show(false); }
428};
429
430if (BS.com.Prompt)
431	BS.utl.object.inherit(BS.com.Prompt, PS.com.LoginPrompt);
432
433PS.com.ConfPrompt = function (submitE, cname)
434{
435	if (!cname) cname = 'PsPrompt PsConfPrompt';	
436
437
438	BS.com.Prompt.call(this, null, null, cname, '9999');
439
440	if (submitE) this.submitE = submitE;
441
442	this.mask = _bsObj.cache('PS.com.MaskCacheHigh');
443	this.bodyDIV = this.mm.domNew(this.obj, 'div', 'body');
444	this.footerDIV = this.mm.domNew(this.obj, 'div', 'footer');
445	this.cancelINP = this.mm.domNew(null, 'input', 'button');
446	this.cancelINP.setAttribute('type', 'button');
447	this.cancelINP.value = "Cancel";
448	this.footerDIV.appendChild(this.cancelINP);
449	this.submitINP = this.mm.domNew(null, 'input', 'button');
450	this.submitINP.setAttribute('type', 'button');
451	this.submitINP.value = "Okay";
452	this.footerDIV.appendChild(this.submitINP);
453	_bsDom.setStyle(this.mm.domNew(this.footerDIV, 'br'), 'clear', 'both');
454
455	_bsEvt.attach(this.cancelINP, 'click', this.cancel, this);
456	_bsEvt.attach(this.submitINP, 'click', this._submit, this);
457	_bsDom.setStyle(this.bodyDIV, 'display', 'none');
458};
459
460PS.com.ConfPrompt.prototype = {
461	f_submit:	false,
462	submitE: 	null,
463
464	_delete: function ()
465	{
466		this.mask = null;
467		this.submitE = null;
468
469		_bsEvt.detach(this.cancelINP, 'click', this.cancel);
470		_bsEvt.detach(this.submitINP, 'click', this._submit);
471
472		BS.com.Prompt.prototype._delete.call(this);
473	},
474
475	show: function (mode)
476	{
477		if (!!mode == this.f_show)
478			return false;
479
480		this.f_show = !!mode;
481		this.mask.show(!!mode);
482
483		if (mode) {
484			this.f_submit = false;
485
486			if (typeof(mode) == 'object') this.bodyDIV.innerHTML = mode.msg;
487			else this.bodyDIV.innerHTML = mode;
488
489			this.ctype = (mode.ctype ? mode.ctype : 'conf');
490
491			try {
492				this.submitINP.value = (mode.yes ? mode.yes : 'Okay');
493				this.cancelINP.value = (mode.no ? mode.no : 'Cancel');
494				_bsDom.setDisplay(this.submitINP, !mode.f_cancel_only);
495			} catch (e) {alert(e);} //hai IE
496
497			_bsDom.setStyle(this.bodyDIV, 'display', 'block');
498			
499		} else {
500			_bsDom.setStyle(this.bodyDIV, 'display', 'none');
501		}
502
503		BS.com.Prompt.prototype.show.call(this, !!mode);
504	},
505	
506	_submit: function (arr) { this._confirm(arr, true); },
507	cancel: function (arr) { this._confirm(arr, false); },
508
509	_confirm: function (arr, f_confirm)
510	{
511		this.submitE.exec(arr, this.ctype, f_confirm);
512		this.show(false);
513	}
514};
515
516_bsObj.inherit(BS.com.Prompt, PS.com.ConfPrompt);
517
518PS.com.DlType = function (obj, form, key, first, maxKey)
519{
520	var li, tmp, id;
521
522	this.form = form;
523	this.key = key;
524
525	if (!first) first = null;
526
527	this.mm = new BS.com.Delete('DlType');
528	this.UL = this.mm.domNew(obj, 'ul');
529
530	li = this.mm.domNew(this.UL, 'li');
531	this.dlLABEL = this.mm.domNew(li, 'label', 'float');
532	this.dlLABEL.innerHTML = 'Allow Download:';
533	this.typeSEL = this.mm.oNew(BS.com.Form.Select, li, this.key + '_TYPE', first)
534	this.typeSEL.load(this.DLTYPE_TYPE, true);
535
536	this.sizeLI = this.mm.domNew(this.UL, 'li');
537	tmp = this.mm.domNew(this.sizeLI, 'label', 'float');
538	tmp.innerHTML = 'Image Size:';
539	this.sizeSEL = this.mm.oNew(BS.com.Form.Select, this.sizeLI, this.key + '_SIZE')
540	this.sizeSEL.load(this.DLTYPE_SIZE, true);
541
542	this.size2LI = this.mm.domNew(this.UL, 'li', 'DlTypeSize2');
543	this.size2LI.innerHTML = '<label class="float">&nbsp;</label><span><input name="' + this.key + '_SIZE2" size="5" maxlength="5"> pixels</span>';
544
545	this.optLI = this.mm.domNew(this.UL, 'li');
546	this.optLI.innerHTML = '<label class="float">&nbsp;</label><input type="checkbox" name="' + this.key + '_EMBED" value="t">Embed updated metadata';
547
548	if (maxKey) {
549		this.maxKey = maxKey;
550		this.maxLI = this.mm.domNew(this.UL, 'li', 'DlTypeMax');
551		this.maxLI.innerHTML = '<label class="float">Max # of downloads:</label><span><input name="' + this.maxKey + '" size="5" maxlength="5"> (leave blank for no limit)</span>';
552	}
553
554	this.selCE = this.mm.ceNew('sel', this);
555	this.selCE.addCB(this._select);
556	this.selCE.attach(this.typeSEL.sel, 'change');
557	this.selCE.attach(this.sizeSEL.sel, 'change');
558};
559
560PS.com.DlType.prototype = {
561	DLTYPE_TYPE:	[['ORIG', 'Original file format and size'],
562			 ['JPG', 'JPEG file']],
563	DLTYPE_SIZE:	[['', 'Original size'],
564			 ['4800', '4800 pixels'],
565			 ['2400', '2400 pixels'],
566			 ['1200', '1200 pixels'],
567			 ['600', '600 pixels'],
568			 ['-', 'Custom size...']],
569
570	maxKey:		null,
571	maxLI:		null,
572
573	_delete: function ()
574	{
575		this.form = null;
576		this.mm._delete();
577	},
578
579	_select: function (type, data, args)
580	{
581		PS.com.DlType.typeSelect(this.form, this.key, null,
582					 [this.sizeLI, this.size2LI,
583					  this.optLI, this.maxLI]);
584	},
585
586	load: function (arr, key, feKey)
587	{
588		if (!key) key = this.key;
589		if (!feKey) feKey = key;
590
591		var embedINP = BS.utl.form.getElem(this.form, feKey + '_EMBED');
592		var size2INP = BS.utl.form.getElem(this.form, feKey + '_SIZE2');
593
594		if (this.maxKey)
595			var maxINP = BS.utl.form.getElem(this.form, this.maxKey);
596
597		if (arr) {
598			if (isset(arr[key + '_TYPE']))
599				this.typeSEL.setVal(arr[key + '_TYPE']);
600			if (isset(arr[key + '_SIZE']))
601				this.sizeSEL.setVal(arr[key + '_SIZE']);
602			if (isset(arr[key + '_SIZE2']))
603				size2INP.value = arr[key + '_SIZE2'];
604			if (isset(arr[key + '_EMBED']))
605				embedINP.checked = (arr[key + '_EMBED'] == 't');
606
607			if (maxINP && isset(arr[this.maxKey]))
608				maxINP.value = arr[this.maxKey];
609		}
610		else {
611			this.typeSEL.reset();
612			embedINP.checked = true;
613			if (maxINP) maxINP.value = '';
614		}
615
616		this._select();
617	},
618
619	reset: function () { this.load(null); },
620
621	setLabel: function (str)
622	{
623		this.dlLABEL.innerHTML = str;
624	},
625
626	disable: function (mode)
627	{
628		if (mode)
629			this.load(null);
630
631		this.sizeSEL.disable(mode);
632	}
633};
634
635/*!\brief	static methods for handling DLTYPE;
636		needed for legacy page support
637*/
638PS.com.DlType.typeSelect = function (fObj, key, lbl, objA)
639{
640	var typeSEL = BS.utl.form.getElem(fObj, key + '_TYPE');
641	var sizeSEL = BS.utl.form.getElem(fObj, key + '_SIZE');
642	var size2INP = BS.utl.form.getElem(fObj, key + '_SIZE2');
643	var embedINP = BS.utl.form.getElem(fObj, key + '_EMBED');
644
645	if (!typeSEL) return;
646
647	if (!lbl) lbl = 'dltype';
648
649	var sizeDIV, size2DIV, optDIV, maxDIV;
650
651	if (objA) {
652		sizeDIV = objA[0];
653		size2DIV = objA[1];
654		optDIV = objA[2];
655		maxDIV = objA[3];
656	}
657	else {
658		sizeDIV = BS.utl.dom.get(lbl + 'Size');
659		size2DIV = BS.utl.dom.get(lbl + 'Size2');
660		optDIV = BS.utl.dom.get(lbl + 'Opt');
661	}
662
663	BS.utl.dom.setDisplay(sizeDIV, !empty(BS.utl.form.getValue(typeSEL)));
664
665	switch (BS.utl.form.getValue(typeSEL)) {
666	case 'JPG':
667		BS.utl.dom.setDisplay(sizeDIV, true);
668		BS.utl.dom.setDisplay(optDIV, true);
669		if (maxDIV) BS.utl.dom.setDisplay(maxDIV, true);
670		break;
671	case 'ORIG':
672		BS.utl.dom.setDisplay(sizeDIV, false);
673		BS.utl.dom.setDisplay(optDIV, true);
674		if (maxDIV) BS.utl.dom.setDisplay(maxDIV, true);
675		sizeSEL.selectedIndex = 0;
676		break;
677	default:
678		BS.utl.dom.setDisplay(sizeDIV, false);
679		BS.utl.dom.setDisplay(optDIV, false);
680		if (maxDIV) BS.utl.dom.setDisplay(maxDIV, false);
681		sizeSEL.selectedIndex = 0;
682		embedINP.checked = true;
683	}
684
685	if (BS.utl.form.getValue(sizeSEL) == '-') {
686		BS.utl.dom.setDisplay(size2DIV, true);
687	}
688	else {
689		BS.utl.dom.setDisplay(size2DIV, false);
690		size2INP.value = '';
691	}
692
693	if (PS.com.DlType.typeSelect.ce)
694		PS.com.DlType.typeSelect.ce.exec();
695};
696
697PS.com.DlType.typeSelect.ce = null;
698
699PS.com.DlType.typeCheck = function (fObj, key)
700{
701	var sizeSEL = BS.utl.form.getElem(fObj, key + '_SIZE');
702	if (!sizeSEL) return true;
703
704	if (BS.utl.form.getValue(sizeSEL) != '-') return true;
705
706	var val = BS.utl.form.getElem(fObj, key + '_SIZE2').value;
707	if (!val.match(/^[0-9]{1,5}$/)) {
708		alert('Please enter a valid custom image size.');
709		BS.utl.form.getElem(fObj, key + '_SIZE2').focus();
710		return false;
711	}
712	else if (parseInt(val) < 500) {
713		alert('The minimum image size is 500 pixels. Please enter a larger size.');
714		BS.utl.form.getElem(fObj, key + '_SIZE2').focus();
715		return false;
716	}
717
718	return true;
719};
720
721
722/*!\brief	error response handler; meant to be passed in as 2nd argument
723		to BS.com.BSApi.responseParse()
724*/
725PS.utl.responseErr = function (d)
726{
727	for (var i=0; i < d.length; i++) {
728		switch (d[i]['class']) {
729		case 'SessionRequiredErr':
730			location.reload();
731			throw false;
732		}
733	}
734
735	// signals BS.com.BSApi.responseParse() to still throw the err msg
736	return true;
737}
738
739PS.utl.responseErr.login = function (d)
740{
741	for (var i=0; i < d.length; i++) {
742		switch (d[i]['class']) {
743		case 'SessionRequiredErr':
744			var lp = BS.utl.mm.oNew(PS.com.LoginPrompt);
745			lp.show(true);
746			throw false;
747		}
748	}
749
750	// signals BS.com.BSApi.responseParse() to still throw the err msg
751	return true;
752}
753
754PS.com.BusyPrompt = function (parent, opacity)
755{
756	this.parent = parent;
757
758	opacity = (opacity) ? opacity : 0.6;
759	
760	this.mm = new BS.com.Delete('PSBusyPrompt');
761	this.mask = this.mm.oNew(BS.com.Mask, parent, opacity, '7999');
762
763	this.spinnerDIV = this.mm.domNew(document.body, 'div');
764
765	// stupid safari has issues with asynchrnous calls being interrupted
766	// by user events, so best not to delay the busyPrompt too much
767	if (_bsBrowser.isSafari) this.T_DELAY = 50;
768};
769
770PS.com.BusyPrompt.prototype = {
771	f_show: 		false,
772	T_DELAY:		200,
773	
774	_delete: function () 
775	{
776		this.parent = null;
777		this.mm._delete();
778	},
779	
780	_resize: function ()
781	{
782		var pos = _bsDom.pageOfs(this.parent);
783		var size = _bsDom.size(this.parent);
784		size[0] /= 2;
785		size[1] /= 2;
786		_bsXy.add(pos, size);
787		
788		var divsize = _bsDom.size(this.spinnerDIV);
789		divsize[0] /= 2;
790		divsize[1] /= 2;
791		_bsXy.sub(pos, divsize);
792		
793		_bsDom.setPageOfs(this.spinnerDIV, pos);
794	},
795
796	_show: function ()
797	{
798		if (!this.f_show) return;
799
800		this.mask.show(true);
801		_bsDom.setDisplay(this.spinnerDIV, true);
802		this._resize();
803		_bsDom.setVis(this.spinnerDIV, true);
804		BS.utl.globalEvent.addCB('resize', this._resize, this);
805	},
806
807	show: function (mode)
808	{
809		if (this.f_show == mode) return;
810		this.f_show = mode;
811				
812		if (mode) {
813			_bsEvt.setTimeout(this.T_DELAY, this._show, this);
814		} else {
815			this.mask.show(mode);
816			BS.utl.globalEvent.delCB('resize', this._resize, this);
817			_bsDom.setVis(this.spinnerDIV, false);
818			_bsDom.setDisplay(this.spinnerDIV, false);
819		}
820	}
821};
822
823PS.com.Balloon = function (obj, width)
824{
825	var mm = this.mm = new BS.com.Delete;
826	this.gvStr = BS.utl.mkGvStr(this);
827	this.width = (width) ? width : 300;
828
829	if (!obj) obj = document.body;
830
831	var t, t2;
832
833	this.container = mm.domNew(obj, 'div', 'PsBalloon');
834
835	this.pad = mm.domNew(this.container, 'div', 'psbPad');
836
837	this.tick = [];
838	for (var i = 0; i < 4; i++)
839		this.tick[i] = mm.domNew(this.pad, 'div', 'psbTick i'+i);
840
841	this.header = mm.domNew(this.pad, 'div', 'psbHeader');
842	this.content = mm.domNew(this.pad, 'div', 'psbContent');
843	this.footer = mm.domNew(this.pad, 'div', 'psbFooter');
844
845	//only needed for stupid IE6
846	if (_bsBrowser.isIE && _bsBrowser.version < 7) {
847		_bsDom.setStyle(this.content, 'width', this.width + 'px');
848		var iframe = mm.domNew(this.container, 'iframe');
849		_bsDom.setVis(iframe, false);
850	}
851	
852	_bsGlobalEvt.addCB('resize', this._resizeE, this);
853};
854
855PS.com.Balloon.prototype = {
856	curObj: 		null,
857	f_show:			false,
858	OFS_Y:			[20, 20],
859
860	_delete: function ()
861	{
862		this.curObj = this.mask = null;
863		this.mm._delete();
864	},
865
866	_resizeE: function ()
867	{
868		if (!this.f_show) return;
869
870		this._position();
871		_bsDom.setDisplay(this.container, true);
872	},
873
874	_position: function () 
875	{
876		_bsDom.setVis(this.container, false);
877		_bsDom.setDisplay(this.container, true);
878
879		if (!this.curObj) {
880			_bsDom.clientCenter(this.container);
881			_bsDom.setVis(this.container, true);
882			_bsDom.setDisplay(this.container, false);
883			this._setTick(-1);
884			return;
885		}
886
887		var mySize = _bsDom.fullsize(this.container);
888		var size = _bsDom.fullsize(this.curObj);
889		var pos = _bsDom.pageOfs(this.curObj);
890		var csize = _bsDom.clientSize();
891		var scroll = _bsDom.scrollOfs();
892
893		var pos2 = _bsArr.copy(pos);
894		pos2 = BS.utl.xy.sub(pos2, scroll);
895
896		// margin around curObj (CSS box format)
897		var margin = [pos2[1], csize[0]-(pos2[0]+size[0]),
898			      csize[1]-(pos2[1]+size[1]), pos2[0]];
899
900		var tick = 0;
901		if (margin[1] > margin[3]) {
902			pos[0] += size[0];
903			tick += 1;
904		} else {
905			pos[0] -= mySize[0];
906		}
907
908		if (margin[2] > margin[0]) {
909			pos[1] -= this.OFS_Y[1];
910			tick += 2;
911		} else {
912			pos[1] -= (mySize[1]-size[1]-this.OFS_Y[0]);
913		}
914
915		this._setTick(tick);
916		_bsDom.setPos(this.container, pos);
917		_bsDom.setVis(this.container, true);
918		_bsDom.setDisplay(this.container, false);
919	},
920
921	_setTick: function (pos)
922	{
923		var ie6 = (_bsBrowser.isIE && _bsBrowser.version < 7);
924		for (var i = 0; i < this.tick.length; i++)
925			_bsDom.setVis(this.tick[i], (i==pos) && !ie6);
926	},
927
928	setContent: function (str) { this.content.innerHTML = str; },
929	setHeader: function (str) { this.header.innerHTML = str; },
930	setFooter: function (str) { this.footer.innerHTML = str; },
931
932	defaultFooter: function (img)
933	{
934		var str = '<div style="text-align:center;">' + 
935			  '<a href="javascript:void(0)" onClick="' + this.gvStr + '.cancel();">' + 
936			  '<img src="/img/button/close.gif" border="0" alt="Close"></a></div>';
937
938		this.setFooter(str);
939	},
940
941	show: function (mode, obj, f_mask)
942	{
943		if (mode) {
944			this.curObj = (obj) ? obj : null;
945			this._position();
946
947			if (f_mask) {
948				if (!this.mask)
949					this.mask = BS.utl.object.cache('BS.com.Mask');
950				this.mask.show(true);
951			}
952		} else if (this.mask)
953			this.mask.show(false);
954
955		_bsDom.setDisplay(this.container, mode);
956		this.f_show = mode;
957	},
958	
959	cancel: function () { this.show(false); }
960};
961
962PS.com.BalloonHover = function (rootElement, f_sticky) 
963{
964	PS.com.Balloon.call(this,rootElement);
965
966	this.hoverCE = this.mm.ceNew('hover', this);
967	this.hoverCE.addCB(this._hover, this);
968	if (f_sticky) {
969		this.f_sticky = f_sticky;
970		this.hoverCE.attach(this.container, 'mouseover', 'cont');
971		this.hoverCE.attach(this.container, 'mouseout', 'cont');
972	}
973};
974
975PS.com.BalloonHover.prototype = {
976	STICKY_DUR:250,
977	F_ON_CONTENT: false,
978
979	attach: function (obj, data)
980	{
981		this.hoverCE.attach(obj, 'mouseover', data);
982		this.hoverCE.attach(obj, 'mouseout');
983	},
984
985	_hover: function (type, data, args) 
986	{
987		var e = args[0];
988
989		switch(e.type) {
990		case "mouseover":
991			if (this.f_sticky && args[1] == 'cont') {
992					this.F_ON_CONTENT = true;
993					break;
994			}
995			this._setData(args[1]);
996			this.show(true, e.target);
997			break;
998		case "mouseout":
999			if (this.f_sticky && args[1] == 'cont') {
1000					this.F_ON_CONTENT = false;
1001					_bsEvt.setTimeout(this.STICKY_DUR, this._showTO, this);
1002					break;
1003			}
1004		default:
1005			if (this.f_sticky) _bsEvt.setTimeout(this.STICKY_DUR, this._showTO, this);
1006			else this.show(false);
1007			break;
1008		}
1009	},
1010
1011	_setData: function (data)
1012	{
1013		this.header.innerHTML = data.header;
1014		this.content.innerHTML = data.content;
1015		this.footer.innerHTML = data.footer;
1016	},
1017
1018	_showTO: function ()
1019	{
1020		if (this.F_ON_CONTENT) return;
1021		this.show(false);
1022	}
1023};
1024
1025BS.utl.object.inherit(PS.com.Balloon, PS.com.BalloonHover);
1026
1027PS.com.LoginBalloon = function ()
1028{
1029	var tmp, str;
1030	var gvStr = BS.utl.mkGvStr(this);
1031
1032	PS.com.Balloon.apply(this);
1033	
1034	this.clickCE = this.mm.ceNew('click', this);
1035	this.clickCE.addCB(this.cancel);
1036	
1037	this.mask = this.mm.oNew(BS.com.Mask, null, 0.5, '4999');
1038	var maskObj = (_bsBrowser.isIE) ? this.mask.obj.contentWindow.document : this.mask.obj;
1039	this.clickCE.attach(maskObj, 'click');
1040	this.setHeader('<h3>PhotoShelter Member Login</h3>');
1041
1042	this.form = this.mm.domNew(this.content, 'form')
1043	this.cntDIV = this.mm.domNew(this.content, 'div', 'cnt')
1044
1045	this.form.action = PS.app.pvGet('server.sec') + '/login';
1046	this.form.method = 'post';
1047
1048	str =	'<div style="text-align:center;">' +
1049		'<input type="button" value="   Log In   " onClick="' + gvStr + '._submit();" class="heavy">' +
1050		'<input type="button" value="Cancel" onClick="' + gvStr + '.cancel();" style="margin-left:5px;" class="heavy">' +
1051		'</div>';
1052	this.setFooter(str);
1053
1054	BS.utl.event.attach(this.form, 'submit', this._submit, this);
1055	
1056	this.form.innerHTML = 'Please log into your PhotoShelter account below.';
1057
1058	tmp = this.mm.domNew(this.form, 'fieldset');
1059	this.inputUL = this.mm.domNew(tmp, 'ul');
1060
1061	li = this.mm.domNew(this.inputUL, 'li');
1062	tmp = this.mm.domNew(li, 'label', 'float');
1063	tmp.innerHTML = 'Email:';
1064	
1065	this.emailINP = this.mm.domNew(null, 'input');
1066	with (this.emailINP) {
1067		setAttribute('type', 'text'); setAttribute('name', 'U_EMAIL');
1068		setAttribute('size', 20); setAttribute('maxlength', 50);
1069	}
1070	li.appendChild(this.emailINP);
1071
1072	li = this.mm.domNew(this.inputUL, 'li');
1073	tmp = this.mm.domNew(li, 'label', 'float');
1074	tmp.innerHTML = 'Password:';
1075	this.passINP = this.mm.domNew(null, 'input');
1076	with (this.passINP) {
1077		setAttribute('type', 'password'); setAttribute('name', 'U_PASSWORD');
1078		setAttribute('size', 20); setAttribute('maxlength', 35);
1079	}
1080	li.appendChild(this.passINP);
1081
1082	li = this.mm.domNew(this.inputUL, 'li');
1083
1084	tmp = this.mm.domNew(this.form, 'div', 'sm');
1085	_bsDom.setStyle(tmp, 'padding', '0 20px');
1086	str = 'Forget your password? <a href="';
1087	if (window.opener) str += 'javascript:window.opener.location=\'/usr/usr-password-reset\';window.close();';
1088	else str += '/usr/usr-password-reset';
1089	str += '" class="bold">Click here.</a><br>Not a member? ';
1090	str += '<a href="';
1091	if (window.opener) str += 'javascript:_bsWin.openLink(\'' + PS.app.pvGet('server.sec') + '/signup?ref=' + escape(location.protocol + '//' + location.host) + '/com/shared/windowOpenerRefresh.html\', [600,500]);';
1092	else str += '/signup';
1093	str += '" class="bold">Join!</a>';
1094
1095	// stupid hack so return key works
1096	str += '<input type="submit" value="" style="display:none;">';
1097
1098	tmp.innerHTML = str;
1099
1100	tmp = this.mm.domNew(this.form, 'span');
1101	tmp.innerHTML = '<input type="hidden" name="_ACT" value="login">' + 
1102			'<input type="hidden" name="ref" value="">';
1103};
1104
1105PS.com.LoginBalloon.prototype = {
1106	f_submit:	false,
1107
1108	_delete: function ()
1109	{
1110		this.form.onsubmit = null;
1111		BS.utl.event.detach(this.form, 'submit', this._submit);
1112		PS.com.Balloon.prototype._delete.call(this);
1113	},
1114
1115	_submit: function (arr)
1116	{
1117		var p = _bsForm.toArray(this.form);
1118
1119		if (empty(p.U_EMAIL)) {
1120			alert('Please enter your Email Address.');
1121			this.form.U_EMAIL.focus();
1122			return;
1123		}
1124		if (empty(p.U_PASSWORD)) {
1125			alert('Please enter your Password.');
1126			this.form.U_PASSWORD.focus();
1127			return;
1128		}
1129		
1130		this.form.submit();
1131	},
1132
1133	show: function (mode, obj, f_noref) 
1134	{
1135		this.form.ref.value = (f_noref) ? 
1136			'' : location.pathname + location.search + location.hash;
1137		this.mask.show(mode);
1138		PS.com.Balloon.prototype.show.call(this, mode, obj);
1139		if (mode) this.emailINP.focus();
1140	}
1141};
1142
1143BS.utl.object.inherit(PS.com.Balloon, PS.com.LoginBalloon);
1144
1145_balloon = function (obj, header, content, f_mask) 
1146{
1147	if (!PS.utl.balloon)
1148		PS.utl.balloon = _bsMm.oNew(PS.com.Balloon);
1149
1150	PS.utl.balloon.defaultFooter();
1151	PS.utl.balloon.setHeader(header ? header : '')
1152	PS.utl.balloon.setContent(content ? content : '');
1153	
1154	PS.utl.balloon.show(true, obj, f_mask);
1155};
1156
1157_loginBalloon = function (obj, f_noref)
1158{
1159	if (!PS.utl.LoginBalloon)
1160		PS.utl.LoginBalloon = _bsMm.oNew(PS.com.LoginBalloon);
1161
1162	PS.utl.LoginBalloon.show(true, obj, f_noref);
1163};
1164
1165_collapseBlock = function (id, f)
1166{
1167	_bsDom.setDisplay(_bsDom.get(id + '_show'), f);
1168	_bsDom.setDisplay(_bsDom.get(id + '_hide'), !f);
1169};
1170
1171PS.com.ToolTip = function (hint_obj, tip_obj, show_mode, class_name, alignment)
1172{
1173	var mm = this.mm = new BS.com.Delete;
1174	
1175	this.hint_obj = hint_obj;
1176	this.tip_obj = tip_obj;
1177	this.show_mode = (show_mode ? show_mode : 'mouseover');
1178	this.class_name = (class_name ? class_name : 'psTT');
1179	this.alignment = (alignment ? alignment : 'top_left');
1180
1181	this.mCE = mm.ceNew("mouse", this);
1182	this.mCE.addCB(this.mCB, this);
1183	this.mCE.attach(this.hint_obj, this.show_mode);
1184	this.mCE.attach(this.tip_obj, 'mouseout');
1185};
1186
1187PS.com.ToolTip.prototype = {
1188	_delete: function ()
1189	{
1190		this.hint_obj = this.tip_obj = null;
1191		this.mm._delete();
1192	},
1193
1194	mCB: function (type, data, args)
1195	{
1196		var e = args[0];
1197		switch(e.type) {
1198		case this.show_mode:
1199			this.show(true);
1200			break;
1201		case "mouseout":
1202			var r = (e.relatedTarget) ? e.relatedTarget : e.toElement;
1203			while (r != this.tip_obj && r.nodeName != 'BODY')
1204					r = r.parentNode
1205
1206			if (r.nodeName != 'BODY') break;
1207			this.show(false);
1208			break;
1209		}
1210	},
1211	
1212	show: function (f_show)
1213	{
1214		_bsDom.setDisplay(this.tip_obj, f_show);
1215		var pos = _bsDom.pageOfs(this.hint_obj);
1216		var size = _bsDom.fullsize(this.hint_obj);
1217		var tsize = _bsDom.fullsize(this.tip_obj);
1218		switch (this.alignment) {
1219		case 'center':
1220			pos[0] += Math.round((size[0] - tsize[0])/2);
1221			pos[1] += Math.round((size[1] - tsize[1])/2);
1222			break;
1223		case 'top_right':
1224			pos[0] += (size[0] - tsize[0]);
1225			break;
1226		case 'top_left':
1227		default:
1228				break;
1229		}
1230		_bsDom.setPos(this.tip_obj, pos);
1231	}
1232};
1233
1234//example  cfg array {hint_obj: obj, tip_msg: "Here's a tip!", tip_class: 'psTT', align: 'center'}
1235_addToolTip = function (cfg)
1236{
1237	if (cfg.tip_msg) {
1238		var tip_obj = _bsMm.domNew(document.body, "div", (cfg.tip_class ? cfg.tip_class : 'psTT'));
1239		tip_obj.innerHTML = cfg.tip_msg;
1240		_bsDom.setDisplay(tip_obj, false);
1241		_bsDom.setStyle(tip_obj, 'position', 'absolute');
1242	}
1243	_bsMm.oNew(PS.com.ToolTip, cfg.hint_obj, tip_obj, null, null, (cfg.align ? cfg.align : null));
1244};
1245
1246// cached objects
1247
1248PS.com.BusyPromptCache = function ()
1249{
1250	BS.com.BusyPrompt.call(this, '<img src="/img/spinner.gif" vspace="3"><br>Please wait...', '');
1251};
1252
1253_bsObj.inherit(BS.com.BusyPrompt, PS.com.BusyPromptCache);
1254
1255
1256PS.com.MaskCache = function ()
1257{
1258	BS.com.Mask.call(this, null, 0.5);
1259};
1260
1261_bsObj.inherit(BS.com.Mask, PS.com.MaskCache);
1262
1263//for layered prompts
1264PS.com.MaskCacheHigh = function ()
1265{
1266	BS.com.Mask.call(this, null, 0.5, 9998);
1267};
1268
1269_bsObj.inherit(BS.com.Mask, PS.com.MaskCacheHigh);
1270
1271// to escape HTML strings
1272// copied from bslite, O_O
1273PS.utl.tplescape = function(string) {
1274	return ('' + string).replace(/&(?!\w+;|#\d+;|#x[\da-f]+;)/gi, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/"/g, '&quot;').replace(/'/g, '&#x27;').replace(/\//g,'&#x2F;');
1275};

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.