PageSourceSearch

https://escueladesurflasdunas.com/wp-content/themes/briny/js/theme-utils.js

js escueladesurflasdunas.com collected 2026-10-02 14:05:43 UTC 48,302 bytes, 1,454 lines download raw bytes

1/**
2 * Javascript utilities
3 *
4 * @package WordPress
5 * @subpackage BRINY
6 * @since BRINY 1.0
7 */
8
9/* global jQuery:false */
10/* global BRINY_STORAGE:false */
11
12/* Global variables manipulations
13---------------------------------------------------------------- */
14
15(function(){
16	"use strict";
17
18	// Global variables storage
19	if (typeof BRINY_STORAGE == 'undefined') {
20		window.BRINY_STORAGE = {};
21	}
22
23	// Get global variable
24	window.briny_storage_get = function(var_name) {
25		return briny_isset( BRINY_STORAGE[var_name] ) ? BRINY_STORAGE[var_name] : '';
26	};
27
28	// Set global variable
29	window.briny_storage_set = function(var_name, value) {
30		BRINY_STORAGE[var_name] = value;
31	};
32
33	// Inc/Dec global variable with specified value
34	window.briny_storage_inc = function(var_name) {
35		var value                  = arguments[1] === undefined ? 1 : arguments[1];
36		BRINY_STORAGE[var_name] += value;
37	};
38
39	// Concatenate global variable with specified value
40	window.briny_storage_concat = function(var_name, value) {
41		BRINY_STORAGE[var_name] += '' + value;
42	};
43
44	// Get global array element
45	window.briny_storage_get_array = function(var_name, key) {
46		return briny_isset( BRINY_STORAGE[var_name][key] ) ? BRINY_STORAGE[var_name][key] : '';
47	};
48
49	// Set global array element
50	window.briny_storage_set_array = function(var_name, key, value) {
51		if ( ! briny_isset( BRINY_STORAGE[var_name] )) {
52			BRINY_STORAGE[var_name] = {};
53		}
54		BRINY_STORAGE[var_name][key] = value;
55	};
56
57	// Inc/Dec global array element with specified value
58	window.briny_storage_inc_array = function(var_name, key) {
59		var value                       = arguments[2] === undefined ? 1 : arguments[2];
60		BRINY_STORAGE[var_name][key] += value;
61	};
62
63	// Concatenate global array element with specified value
64	window.briny_storage_concat_array = function(var_name, key, value) {
65		BRINY_STORAGE[var_name][key] += '' + value;
66	};
67
68	/* PHP-style functions
69	---------------------------------------------------------------- */
70	window.briny_isset = function(obj) {
71		return typeof(obj) != 'undefined';
72	};
73
74	window.briny_empty = function(obj) {
75		return typeof(obj) == 'undefined' || (typeof(obj) == 'object' && obj == null) || (typeof(obj) == 'array' && obj.length == 0) || (typeof(obj) == 'string' && briny_alltrim( obj ) == '') || obj === 0;
76	};
77
78	window.briny_is_array = function(obj)  {
79		return typeof(obj) == 'array';
80	};
81
82	window.briny_is_object = function(obj)  {
83		return typeof(obj) == 'object';
84	};
85
86	window.briny_clone_object = function(obj) {
87		if (obj == null || typeof(obj) != 'object') {
88			return obj;
89		}
90		var temp = {};
91		for (var key in obj) {
92			temp[key] = briny_clone_object( obj[key] );
93		}
94		return temp;
95	};
96
97	window.briny_merge_objects = function(obj1, obj2)  {
98		for (var i in obj2) {
99			obj1[i] = obj2[i];
100		}
101		return obj1;
102	};
103
104	window.briny_array_merge = function(a1, a2) {
105		for (var i in a2) {
106			a1[i] = a2[i];
107		}
108		return a1;
109	};
110
111	window.briny_array_first_key = function(arr) {
112		var rez = null;
113		for (var i in arr) {
114			rez = i;
115			break;
116		}
117		return rez;
118	};
119
120	window.briny_array_first_value = function(arr) {
121		var rez = null;
122		for (var i in arr) {
123			rez = arr[i];
124			break;
125		}
126		return rez;
127	};
128
129	// Generates a storable representation of a value
130	window.briny_serialize = function(mixed_val) {
131		var obj_to_array = arguments.length == 1 || argument[1] === true;
132
133		switch (typeof(mixed_val)) {
134
135			case "number":
136				if (isNaN( mixed_val ) || ! isFinite( mixed_val )) {
137					return false;
138				} else {
139					return (Math.floor( mixed_val ) == mixed_val ? "i" : "d") + ":" + mixed_val + ";";
140				}
141
142			case "string":
143				return "s:" + mixed_val.length + ":\"" + mixed_val + "\";";
144
145			case "boolean":
146				return "b:" + (mixed_val ? "1" : "0") + ";";
147
148			case "object":
149				if (mixed_val == null) {
150					return "N;";
151				} else if (mixed_val instanceof Array) {
152					var idxobj = { idx: -1 };
153					var map    = [];
154					for (var i = 0; i < mixed_val.length; i++) {
155						idxobj.idx++;
156						var ser = briny_serialize( mixed_val[i] );
157						if (ser) {
158							map.push( briny_serialize( idxobj.idx ) + ser );
159						}
160					}
161					return "a:" + mixed_val.length + ":{" + map.join( "" ) + "}";
162				} else {
163					var class_name = briny_get_class( mixed_val );
164					if (class_name == undefined) {
165						return false;
166					}
167					var props = new Array();
168					for (var prop in mixed_val) {
169						var ser = briny_serialize( mixed_val[prop] );
170						if (ser) {
171							props.push( briny_serialize( prop ) + ser );
172						}
173					}
174					if (obj_to_array) {
175						return "a:" + props.length + ":{" + props.join( "" ) + "}";
176					} else {
177						return "O:" + class_name.length + ":\"" + class_name + "\":" + props.length + ":{" + props.join( "" ) + "}";
178					}
179				}
180
181			case "undefined":
182				return "N;";
183		}
184		return false;
185	};
186
187	// Returns the name of the class of an object
188	window.briny_get_class = function(obj) {
189		if (obj instanceof Object && ! (obj instanceof Array) && ! (obj instanceof Function) && obj.constructor) {
190			var arr = obj.constructor.toString().match( /function\s*(\w+)/ );
191			if (arr && arr.length == 2) {
192				return arr[1];
193			}
194		}
195		return false;
196	};
197
198	/* String functions
199	---------------------------------------------------------------- */
200
201	window.briny_in_list = function(str, list) {
202		var delim  = arguments[2] !== undefined ? arguments[2] : '|';
203		var icase  = arguments[3] !== undefined ? arguments[3] : true;
204		var retval = false;
205		if (icase) {
206			if (typeof(str) == 'string') {
207				str = str.toLowerCase();
208			}
209			list = list.toLowerCase();
210		}
211		var parts = list.split( delim );
212		for (var i = 0; i < parts.length; i++) {
213			if (parts[i] == str) {
214				retval = true;
215				break;
216			}
217		}
218		return retval;
219	};
220
221	window.briny_alltrim = function(str) {
222		var dir      = arguments[1] !== undefined ? arguments[1] : 'a';
223		var rez      = '';
224		var i, start = 0, end = str.length - 1;
225		if (dir == 'a' || dir == 'l') {
226			for (i = 0; i < str.length; i++) {
227				if (str.substr( i,1 ) != ' ') {
228					start = i;
229					break;
230				}
231			}
232		}
233		if (dir == 'a' || dir == 'r') {
234			for (i = str.length - 1; i >= 0; i--) {
235				if (str.substr( i,1 ) != ' ') {
236					end = i;
237					break;
238				}
239			}
240		}
241		return str.substring( start, end + 1 );
242	};
243
244	window.briny_ltrim = function(str) {
245		return briny_alltrim( str, 'l' );
246	};
247
248	window.briny_rtrim = function(str) {
249		return briny_alltrim( str, 'r' );
250	};
251
252	window.briny_padl = function(str, len) {
253		var ch  = arguments[2] !== undefined ? arguments[2] : ' ';
254		var rez = str.substr( 0,len );
255		if (rez.length < len) {
256			for (var i = 0; i < len - str.length; i++) {
257				rez += ch;
258			}
259		}
260		return rez;
261	};
262
263	window.briny_padr = function(str, len) {
264		var ch  = arguments[2] !== undefined ? arguments[2] : ' ';
265		var rez = str.substr( 0,len );
266		if (rez.length < len) {
267			for (var i = 0; i < len - str.length; i++) {
268				rez = ch + rez;
269			}
270		}
271		return rez;
272	};
273
274	window.briny_padc = function(str, len) {
275		var ch  = arguments[2] !== undefined ? arguments[2] : ' ';
276		var rez = str.substr( 0,len );
277		if (rez.length < len) {
278			for (var i = 0; i < Math.floor( (len - str.length) / 2 ); i++) {
279				rez = ch + rez + ch;
280			}
281		}
282		return rez + (rez.length < len ? ch : '');
283	};
284
285	window.briny_replicate = function(str, num) {
286		var rez = '';
287		for (var i = 0; i < num; i++) {
288			rez += str;
289		}
290		return rez;
291	};
292
293	window.briny_prepare_macros = function(str) {
294		return str
295			.replace( /\{\{/g, "<i>" )
296			.replace( /\}\}/g, "</i>" )
297			.replace( /\(\(/g, "<b>" )
298			.replace( /\)\)/g, "</b>" )
299			.replace( /\|\|/g, "<br>" );
300	};
301
302	/* Numbers functions
303	---------------------------------------------------------------- */
304
305	// Round number to specified precision.
306	// For example: num=1.12345, prec=2,  rounded=1.12
307	//              num=12345,   prec=-2, rounded=12300
308	window.briny_round_number = function(num) {
309		var precision = arguments[1] !== undefined ? arguments[1] : 0;
310		var p         = Math.pow( 10, precision );
311		return Math.round( num * p ) / p;
312	};
313
314	// Clear number from any characters and append it with 0 to desired precision
315	// For example: num=test1.12dd, prec=3, cleared=1.120
316	window.briny_clear_number = function(num) {
317		var precision = arguments[1] !== undefined ? arguments[1] : 0;
318		var defa      = arguments[2] !== undefined ? arguments[2] : 0;
319		var res       = '';
320		var decimals  = -1;
321		num           = "" + num;
322		if (num == "") {
323			num = "" + defa;
324		}
325		for (var i = 0; i < num.length; i++) {
326			if (decimals == 0) {
327				break;
328			} else if (decimals > 0) {
329				decimals--;
330			}
331			var ch = num.substr( i,1 );
332			if (ch == '.') {
333				if (precision > 0) {
334					res += ch;
335				}
336				decimals = precision;
337			} else if ((ch >= 0 && ch <= 9) || (ch == '-' && i == 0)) {
338				res += ch;
339			}
340		}
341		if (precision > 0 && decimals != 0) {
342			if (decimals == -1) {
343				res     += '.';
344				decimals = precision;
345			}
346			for (i = decimals; i > 0; i--) {
347				res += '0';
348			}
349		}
350		//if (isNaN(res)) res = clearNumber(defa, precision, defa);
351		return res;
352	};
353
354	// Convert number from decimal to hex
355	window.briny_dec2hex = function(n) {
356		return Number( n ).toString( 16 );
357	};
358
359	// Convert number from hex to decimal
360	window.briny_hex2dec = function(hex) {
361		return parseInt( hex,16 );
362	};
363
364	/* Array manipulations
365	---------------------------------------------------------------- */
366
367	window.briny_in_array = function(val, thearray)  {
368		var rez = false;
369		for (var i = 0; i < thearray.length - 1; i++) {
370			if (thearray[i] == val) {
371				rez = true;
372				break;
373			}
374		}
375		return rez;
376	};
377
378	window.briny_sort_array = function(thearray)  {
379		var caseSensitive = arguments[1] !== undefined ? arguments[1] : false;
380		var tmp           = '';
381		for (var x = 0; x < thearray.length - 1; x++) {
382			for (var y = (x + 1); y < thearray.length; y++) {
383				if (caseSensitive) {
384					if (thearray[x] > thearray[y]) {
385						tmp         = thearray[x];
386						thearray[x] = thearray[y];
387						thearray[y] = tmp;
388					}
389				} else {
390					if (thearray[x].toLowerCase() > thearray[y].toLowerCase()) {
391						tmp         = thearray[x];
392						thearray[x] = thearray[y];
393						thearray[y] = tmp;
394					}
395				}
396			}
397		}
398		return thearray;
399	};
400
401	/* Date manipulations
402	---------------------------------------------------------------- */
403
404	// Return array[Year, Month, Day, Hours, Minutes, Seconds]
405	// from string: Year[-/.]Month[-/.]Day[T ]Hours:Minutes:Seconds
406	window.briny_parse_date = function(dt) {
407		dt      = dt.replace( /\//g, '-' ).replace( /\./g, '-' ).replace( /T/g, ' ' ).split( '+' )[0];
408		var dt2 = dt.split( ' ' );
409		var d   = dt2[0].split( '-' );
410		var t   = dt2[1].split( ':' );
411		d.push( t[0], t[1], t[2] );
412		return d;
413	};
414
415	// Return difference string between two dates
416	window.briny_get_date_difference = function(dt1) {
417		var dt2        = arguments[1] !== undefined ? arguments[1] : '';
418		var short_date = arguments[2] !== undefined ? arguments[2] : true;
419		var sec        = arguments[3] !== undefined ? arguments[3] : false;
420		var a1         = briny_parse_date( dt1 );
421		dt1            = Date.UTC( a1[0], a1[1], a1[2], a1[3], a1[4], a1[5] );
422		if (dt2 == '') {
423			dt2    = new Date();
424			var a2 = [dt2.getFullYear(), dt2.getMonth() + 1, dt2.getDate(), dt2.getHours(), dt2.getMinutes(), dt2.getSeconds()];
425		} else {
426			var a2 = briny_parse_date( dt2 );
427		}
428		dt2         = Date.UTC( a2[0], a2[1], a2[2], a2[3], a2[4], a2[5] );
429		var diff    = Math.round( (dt2 - dt1) / 1000 );
430		var days    = Math.floor( diff / (24 * 3600) );
431		diff       -= days * 24 * 3600;
432		var hours   = Math.floor( diff / 3600 );
433		diff       -= hours * 3600;
434		var minutes = Math.floor( diff / 60 );
435		diff       -= minutes * 60;
436		var rez     = '';
437		if (days > 0) {
438			rez += (rez !== '' ? ' ' : '') + days + ' day' + (days > 1 ? 's' : '');
439		}
440		if (( ! short_date || rez == '') && hours > 0) {
441			rez += (rez !== '' ? ' ' : '') + hours + ' hour' + (hours > 1 ? 's' : '');
442		}
443		if (( ! short_date || rez == '') && minutes > 0) {
444			rez += (rez !== '' ? ' ' : '') + minutes + ' minute' + (minutes > 1 ? 's' : '');
445		}
446		if (sec || rez == '') {
447			rez += rez !== '' || sec ? (' ' + diff + ' second' + (diff > 1 ? 's' : '')) : 'less then minute';
448		}
449		return rez;
450	};
451
452	/* Colors functions
453	---------------------------------------------------------------- */
454
455	window.briny_hex2rgb = function(hex) {
456		hex = parseInt( ((hex.indexOf( '#' ) > -1) ? hex.substring( 1 ) : hex), 16 );
457		return {r: hex >> 16, g: (hex & 0x00FF00) >> 8, b: (hex & 0x0000FF)};
458	};
459
460	window.briny_hex2rgba = function(hex, alpha) {
461		var rgb = briny_hex2rgb( hex );
462		return 'rgba(' + rgb.r + ',' + rgb.g + ',' + rgb.b + ',' + alpha + ')';
463	};
464
465	window.briny_rgb2hex = function(color) {
466		var aRGB;
467		color = color.replace( /\s/g,"" ).toLowerCase();
468		if (color == 'rgba(0,0,0,0)' || color == 'rgba(0%,0%,0%,0%)') {
469			color = 'transparent';
470		}
471		if (color.indexOf( 'rgba(' ) == 0) {
472			aRGB = color.match( /^rgba\((\d{1,3}[%]?),(\d{1,3}[%]?),(\d{1,3}[%]?),(\d{1,3}[%]?)\)$/i );
473		} else {
474			aRGB = color.match( /^rgb\((\d{1,3}[%]?),(\d{1,3}[%]?),(\d{1,3}[%]?)\)$/i );
475		}
476
477		if (aRGB) {
478			color = '';
479			for (var i = 1; i <= 3; i++) {
480				color += Math.round( (aRGB[i][aRGB[i].length - 1] == "%" ? 2.55 : 1) * parseInt( aRGB[i] ) ).toString( 16 ).replace( /^(.)$/,'0$1' );
481			}
482		} else {
483			color = color.replace( /^#?([\da-f])([\da-f])([\da-f])$/i, '$1$1$2$2$3$3' );
484		}
485		return (color.substr( 0,1 ) != '#' ? '#' : '') + color;
486	};
487
488	window.briny_components2hex = function(r,g,b) {
489		return '#' +
490			Number( r ).toString( 16 ).toUpperCase().replace( /^(.)$/,'0$1' ) +
491			Number( g ).toString( 16 ).toUpperCase().replace( /^(.)$/,'0$1' ) +
492			Number( b ).toString( 16 ).toUpperCase().replace( /^(.)$/,'0$1' );
493	};
494
495	window.briny_rgb2components = function(color) {
496		color       = briny_rgb2hex( color );
497		var matches = color.match( /^#?([\dabcdef]{2})([\dabcdef]{2})([\dabcdef]{2})$/i );
498		if ( ! matches) {
499			return false;
500		}
501		for (var i = 1, rgb = new Array( 3 ); i <= 3; i++) {
502			rgb[i - 1] = parseInt( matches[i],16 );
503		}
504		return rgb;
505	};
506
507	window.briny_hex2hsb = function(hex) {
508		var h   = arguments[1] !== undefined ? arguments[1] : 0;
509		var s   = arguments[2] !== undefined ? arguments[2] : 0;
510		var b   = arguments[3] !== undefined ? arguments[3] : 0;
511		var hsb = briny_rgb2hsb( briny_hex2rgb( hex ) );
512		hsb.h   = Math.min( 359, Math.max( 0, hsb.h + h ) );
513		hsb.s   = Math.min( 100, Math.max( 0, hsb.s + s ) );
514		hsb.b   = Math.min( 100, Math.max( 0, hsb.b + b ) );
515		return hsb;
516	};
517
518	window.briny_hsb2hex = function(hsb) {
519		var rgb = briny_hsb2rgb( hsb );
520		return briny_components2hex( rgb.r, rgb.g, rgb.b );
521	};
522
523	window.briny_rgb2hsb = function(rgb) {
524		var hsb = {};
525		hsb.b   = Math.max( Math.max( rgb.r,rgb.g ),rgb.b );
526		hsb.s   = (hsb.b <= 0) ? 0 : Math.round( 100 * (hsb.b - Math.min( Math.min( rgb.r,rgb.g ),rgb.b )) / hsb.b );
527		hsb.b   = Math.round( (hsb.b / 255) * 100 );
528		if ((rgb.r == rgb.g) && (rgb.g == rgb.b)) {
529			hsb.h = 0;
530		} else if (rgb.r >= rgb.g && rgb.g >= rgb.b) {
531			hsb.h = 60 * (rgb.g - rgb.b) / (rgb.r - rgb.b);
532		} else if (rgb.g >= rgb.r && rgb.r >= rgb.b) {
533			hsb.h = 60 + 60 * (rgb.g - rgb.r) / (rgb.g - rgb.b);
534		} else if (rgb.g >= rgb.b && rgb.b >= rgb.r) {
535			hsb.h = 120 + 60 * (rgb.b - rgb.r) / (rgb.g - rgb.r);
536		} else if (rgb.b >= rgb.g && rgb.g >= rgb.r) {
537			hsb.h = 180 + 60 * (rgb.b - rgb.g) / (rgb.b - rgb.r);
538		} else if (rgb.b >= rgb.r && rgb.r >= rgb.g) {
539			hsb.h = 240 + 60 * (rgb.r - rgb.g) / (rgb.b - rgb.g);
540		} else if (rgb.r >= rgb.b && rgb.b >= rgb.g) {
541			hsb.h = 300 + 60 * (rgb.r - rgb.b) / (rgb.r - rgb.g);
542		} else {
543			hsb.h = 0;
544		}
545		hsb.h = Math.round( hsb.h );
546		return hsb;
547	};
548
549	window.briny_hsb2rgb = function(hsb) {
550		var rgb = {};
551		var h   = Math.round( hsb.h );
552		var s   = Math.round( hsb.s * 255 / 100 );
553		var v   = Math.round( hsb.b * 255 / 100 );
554		if (s == 0) {
555			rgb.r = rgb.g = rgb.b = v;
556		} else {
557			var t1 = v;
558			var t2 = (255 - s) * v / 255;
559			var t3 = (t1 - t2) * (h % 60) / 60;
560			if (h == 360) {
561				h = 0;
562			}
563			if (h < 60) {
564				rgb.r = t1;	rgb.b = t2;   rgb.g = t2 + t3; } else if (h < 120) {
565				rgb.g = t1; rgb.b = t2;	rgb.r = t1 - t3; } else if (h < 180) {
566					rgb.g = t1; rgb.r = t2;	rgb.b = t2 + t3; } else if (h < 240) {
567					rgb.b = t1; rgb.r = t2;	rgb.g = t1 - t3; } else if (h < 300) {
568							rgb.b = t1; rgb.g = t2;	rgb.r = t2 + t3; } else if (h < 360) {
569							rgb.r = t1; rgb.g = t2;	rgb.b = t1 - t3; } else {
570								rgb.r = 0;  rgb.g = 0;	rgb.b = 0;	 }
571		}
572		return { r:Math.round( rgb.r ), g:Math.round( rgb.g ), b:Math.round( rgb.b ) };
573	};
574
575	window.briny_color_picker = function(){
576		var id         = arguments[0] !== undefined ? arguments[0] : "iColorPicker" + Math.round( Math.random() * 1000 );
577		var colors     = arguments[1] !== undefined ? arguments[1] :
578		'#f00,#ff0,#0f0,#0ff,#00f,#f0f,#fff,#ebebeb,#e1e1e1,#d7d7d7,#cccccc,#c2c2c2,#b7b7b7,#acacac,#a0a0a0,#959595,'
579		+ '#ee1d24,#fff100,#00a650,#00aeef,#2f3192,#ed008c,#898989,#7d7d7d,#707070,#626262,#555,#464646,#363636,#262626,#111,#000,'
580		+ '#f7977a,#fbad82,#fdc68c,#fff799,#c6df9c,#a4d49d,#81ca9d,#7bcdc9,#6ccff7,#7ca6d8,#8293ca,#8881be,#a286bd,#bc8cbf,#f49bc1,#f5999d,'
581		+ '#f16c4d,#f68e54,#fbaf5a,#fff467,#acd372,#7dc473,#39b778,#16bcb4,#00bff3,#438ccb,#5573b7,#5e5ca7,#855fa8,#a763a9,#ef6ea8,#f16d7e,'
582		+ '#ee1d24,#f16522,#f7941d,#fff100,#8fc63d,#37b44a,#00a650,#00a99e,#00aeef,#0072bc,#0054a5,#2f3192,#652c91,#91278f,#ed008c,#ee105a,'
583		+ '#9d0a0f,#a1410d,#a36209,#aba000,#588528,#197b30,#007236,#00736a,#0076a4,#004a80,#003370,#1d1363,#450e61,#62055f,#9e005c,#9d0039,'
584		+ '#790000,#7b3000,#7c4900,#827a00,#3e6617,#045f20,#005824,#005951,#005b7e,#003562,#002056,#0c004b,#30004a,#4b0048,#7a0045,#7a0026';
585		var colorsList = colors.split( ',' );
586		var tbl        = '<table class="colorPickerTable"><thead>';
587		for (var i = 0; i < colorsList.length; i++) {
588			if (i % 16 == 0) {
589				tbl += (i > 0 ? '</tr>' : '') + '<tr>';
590			}
591			tbl += '<td style="background-color:' + colorsList[i] + '">&nbsp;</td>';
592		}
593		tbl += '</tr></thead><tbody>'
594			+ '<tr style="height:60px;">'
595			+ '<td colspan="8" id="' + id + '_colorPreview" style="vertical-align:middle;text-align:center;border:1px solid #000;background:#fff;">'
596			+ '<input style="width:55px;color:#000;border:1px solid rgb(0, 0, 0);padding:5px;background-color:#fff;font:11px Arial, Helvetica, sans-serif;" maxlength="7" />'
597			+ '<a href="#" id="' + id + '_moreColors" class="iColorPicker_moreColors"></a>'
598			+ '</td>'
599			+ '<td colspan="8" id="' + id + '_colorOriginal" style="vertical-align:middle;text-align:center;border:1px solid #000;background:#fff;">'
600			+ '<input style="width:55px;color:#000;border:1px solid rgb(0, 0, 0);padding:5px;background-color:#fff;font:11px Arial, Helvetica, sans-serif;" readonly="readonly" />'
601			+ '</td>'
602			+ '</tr></tbody></table>';
603
604		jQuery( document.createElement( "div" ) )
605			.attr( "id", id )
606			.css( 'display','none' )
607			.html( tbl )
608			.appendTo( "body" )
609			.addClass( "iColorPickerTable" )
610			.on(
611				'mouseover', 'thead td', function(){
612					var aaa = briny_rgb2hex( jQuery( this ).css( 'background-color' ) );
613					jQuery( '#' + id + '_colorPreview' ).css( 'background',aaa );
614					jQuery( '#' + id + '_colorPreview input' ).val( aaa );
615				}
616			)
617			.on(
618				'keypress', '#' + id + '_colorPreview input', function(key){
619					var aaa = jQuery( this ).val();
620					if (aaa.length < 7 && ((key.which >= 48 && key.which <= 57) || (key.which >= 97 && key.which <= 102) || (key.which === 35 || aaa.length === 0))) {
621						aaa += String.fromCharCode( key.which );
622					} else if (key.which == 8 && aaa.length > 0) {
623						aaa = aaa.substring( 0, aaa.length - 1 );
624					} else if (key.which === 13 && (aaa.length === 4 || aaa.length === 7)) {
625						var fld  = jQuery( '#' + id ).data( 'field' );
626						var func = jQuery( '#' + id ).data( 'func' );
627						if (func != null && func != 'undefined') {
628							func( fld, aaa );
629						} else {
630							fld.val( aaa ).css( 'backgroundColor', aaa ).trigger( 'change' );
631						}
632						jQuery( '#' + id + '_Bg' ).fadeOut( 500 );
633						jQuery( '#' + id ).fadeOut( 500 );
634
635					} else {
636						key.preventDefault();
637						return false;
638					}
639					if (aaa.substr( 0,1 ) === '#' && (aaa.length === 4 || aaa.length === 7)) {
640						jQuery( '#' + id + '_colorPreview' ).css( 'background',aaa );
641					}
642				}
643			)
644			.on(
645				'click', 'thead td', function(e){
646					var fld  = jQuery( '#' + id ).data( 'field' );
647					var func = jQuery( '#' + id ).data( 'func' );
648					var aaa  = briny_rgb2hex( jQuery( this ).css( 'background-color' ) );
649					if (func != null && func != 'undefined') {
650						func( fld, aaa );
651					} else {
652						fld.val( aaa ).css( 'backgroundColor', aaa ).trigger( 'change' );
653					}
654					jQuery( '#' + id + '_Bg' ).fadeOut( 500 );
655					jQuery( '#' + id ).fadeOut( 500 );
656					e.preventDefault();
657					return false;
658				}
659			)
660			.on(
661				'click', 'tbody .iColorPicker_moreColors', function(e){
662					var thead = jQuery( this ).parents( 'table' ).find( 'thead' );
663					var out   = '';
664					if (thead.hasClass( 'more_colors' )) {
665						for (var i = 0; i < colorsList.length; i++) {
666							if (i % 16 == 0) {
667								out += (i > 0 ? '</tr>' : '') + '<tr>';
668							}
669							out += '<td style="background-color:' + colorsList[i] + '">&nbsp;</td>';
670						}
671						thead.removeClass( 'more_colors' ).empty().html( out + '</tr>' );
672						jQuery( '#' + id + '_colorPreview' ).attr( 'colspan', 8 );
673						jQuery( '#' + id + '_colorOriginal' ).attr( 'colspan', 8 );
674					} else {
675						var rgb = [0,0,0], i = 0, j = -1;	// Set j=-1 or j=0 - show 2 different colors layouts
676						while (rgb[0] < 0xF || rgb[1] < 0xF || rgb[2] < 0xF) {
677							if (i % 18 == 0) {
678								out += (i > 0 ? '</tr>' : '') + '<tr>';
679							}
680							i++;
681							out    += '<td style="background-color:' + briny_components2hex( rgb[0] * 16 + rgb[0],rgb[1] * 16 + rgb[1],rgb[2] * 16 + rgb[2] ) + '">&nbsp;</td>';
682							rgb[2] += 3;
683							if (rgb[2] > 0xF) {
684								rgb[1] += 3;
685								if (rgb[1] > (j === 0 ? 6 : 0xF)) {
686									rgb[0] += 3;
687									if (rgb[0] > 0xF) {
688										if (j === 0) {
689											j      = 1;
690											rgb[0] = 0;
691											rgb[1] = 9;
692											rgb[2] = 0;
693										} else {
694											break;
695										}
696									} else {
697										rgb[1] = (j < 1 ? 0 : 9);
698										rgb[2] = 0;
699									}
700								} else {
701									rgb[2] = 0;
702								}
703							}
704						}
705						thead.addClass( 'more_colors' ).empty().html( out + '<td  style="background-color:#ffffff" colspan="8">&nbsp;</td></tr>' );
706						jQuery( '#' + id + '_colorPreview' ).attr( 'colspan', 9 );
707						jQuery( '#' + id + '_colorOriginal' ).attr( 'colspan', 9 );
708					}
709					jQuery( '#' + id + ' table.colorPickerTable thead td' )
710					.css(
711						{
712							'width':'12px',
713							'height':'14px',
714							'border':'1px solid #000',
715							'cursor':'pointer'
716						}
717					);
718					e.preventDefault();
719					return false;
720				}
721			);
722		jQuery( document.createElement( "div" ) )
723			.attr( "id", id + "_Bg" )
724			.on(
725				'click', function(e) {
726					jQuery( "#" + id + "_Bg" ).fadeOut( 500 );
727					jQuery( "#" + id ).fadeOut( 500 );
728					e.preventDefault();
729					return false;
730				}
731			)
732			.appendTo( "body" );
733		jQuery( '#' + id + ' table.colorPickerTable thead td' )
734			.css(
735				{
736					'width':'12px',
737					'height':'14px',
738					'border':'1px solid #000',
739					'cursor':'pointer'
740				}
741			);
742		jQuery( '#' + id + ' table.colorPickerTable' )
743			.css( {'border-collapse':'collapse'} );
744		jQuery( '#' + id )
745			.css(
746				{
747					'border':'1px solid #ccc',
748					'background':'#333',
749					'padding':'5px',
750					'color':'#fff'
751				}
752			);
753		jQuery( '#' + id + '_colorPreview' )
754			.css( {'height':'50px'} );
755		return id;
756	};
757
758	window.briny_color_picker_show = function(id, fld, func) {
759		if (id === null || id === '') {
760			id = jQuery( '.iColorPickerTable' ).attr( 'id' );
761		}
762		var eICP = fld.offset();
763		var w    = jQuery( '#' + id ).width();
764		var h    = jQuery( '#' + id ).height();
765		var l    = eICP.left + w < jQuery( window ).width() - 10 ? eICP.left : jQuery( window ).width() - 10 - w;
766		var t    = eICP.top + fld.outerHeight() + h < jQuery( document ).scrollTop() + jQuery( window ).height() - 10 ? eICP.top + fld.outerHeight() : eICP.top - h - 13;
767		jQuery( "#" + id )
768			.data( {field: fld, func: func} )
769			.css(
770				{
771					'top':t + "px",
772					'left':l + "px",
773					'position':'absolute',
774					'z-index':999999
775				}
776			)
777			.fadeIn( 500 );
778		jQuery( "#" + id + "_Bg" )
779			.css(
780				{
781					'position':'fixed',
782					'z-index':999998,
783					'top':0,
784					'left':0,
785					'width':'100%',
786					'height':'100%'
787				}
788			)
789			.fadeIn( 500 );
790		var def = fld.val().substr( 0, 1 ) == '#' ? fld.val() : briny_rgb2hex( fld.css( 'backgroundColor' ) );
791		jQuery( '#' + id + '_colorPreview input,#' + id + '_colorOriginal input' ).val( def );
792		jQuery( '#' + id + '_colorPreview,#' + id + '_colorOriginal' ).css( 'background',def );
793	};
794
795	/* Cookies manipulations
796	---------------------------------------------------------------- */
797
798	window.briny_get_cookie = function(name) {
799		var defa  = arguments[1] !== undefined ? arguments[1] : null;
800		var start = document.cookie.indexOf( name + '=' );
801		var len   = start + name.length + 1;
802		if (( ! start) && (name != document.cookie.substring( 0, name.length ))) {
803			return defa;
804		}
805		if (start == -1) {
806			return defa;
807		}
808		var end = document.cookie.indexOf( ';', len );
809		if (end == -1) {
810			end = document.cookie.length;
811		}
812		return unescape( document.cookie.substring( len, end ) );
813	};
814
815	window.briny_set_cookie = function(name, value) {
816		var expires = arguments[2] !== undefined ? arguments[2] : 0;
817		var path    = arguments[3] !== undefined ? arguments[3] : '/';
818		var domain  = arguments[4] !== undefined ? arguments[4] : '';
819		var secure  = arguments[5] !== undefined ? arguments[5] : '';
820		var today   = new Date();
821		today.setTime( today.getTime() );
822		if (expires) {
823			expires = expires * 1000 * 60 * 60 * 24;
824		}
825		var expires_date = new Date( today.getTime() + (expires) );
826		document.cookie  = name + '='
827				+ escape( value )
828				+ ((expires) ? ';expires=' + expires_date.toGMTString() : '')
829				+ ((path) ? ';path=' + path : '')
830				+ ((domain) ? ';domain=' + domain : '')
831				+ ((secure) ? ';secure' : '');
832	};
833
834	window.briny_del_cookie = function(name, path, domain) {
835		var path   = arguments[1] !== undefined ? arguments[1] : '/';
836		var domain = arguments[2] !== undefined ? arguments[2] : '';
837		if (briny_get_cookie( name )) {
838			document.cookie = name + '=' + ((path) ? ';path=' + path : '')
839					+ ((domain) ? ';domain=' + domain : '')
840					+ ';expires=Thu, 01-Jan-1970 00:00:01 GMT';
841		}
842	};
843
844	/* Local storage manipulations
845	---------------------------------------------------------------- */
846
847	window.briny_is_local_storage_exists = function() {
848		try {
849			return 'localStorage' in window && window['localStorage'] !== null;
850		} catch (e) {
851			return false;
852		}		
853	};
854	
855	window.briny_get_storage = function(name) {
856		var defa = arguments[1] !== undefined ? arguments[1] : null;
857		var val = null;
858		if (briny_is_local_storage_exists()) {
859			val = window['localStorage'].getItem(name);
860			if (val === null) val = defa;
861		} else {
862			val = briny_get_cookie(name, defa);
863		}
864		return val;
865	};
866	
867	window.briny_set_storage = function(name, value) {
868		if (briny_is_local_storage_exists())
869			window['localStorage'].setItem(name, value);
870		else 
871			briny_set_cookie(name, value, 365);
872	};
873	
874	window.briny_del_storage = function(name) {
875		if (briny_is_local_storage_exists())
876			window['localStorage'].removeItem(name);
877		else 
878			briny_del_cookie(name);
879	};
880	
881	window.briny_clear_storage = function() {
882		if (briny_is_local_storage_exists())
883			window['localStorage'].clear();
884	};
885
886	/* ListBox and ComboBox manipulations
887	---------------------------------------------------------------- */
888
889	window.briny_clear_listbox = function(box) {
890		for (var i = box.options.length - 1; i >= 0; i--) {
891			box.options[i] = null;
892		}
893	};
894
895	window.briny_add_listbox_item = function(box, val, text) {
896		var item   = new Option();
897		item.value = val;
898		item.text  = text;
899		box.options.add( item );
900	};
901
902	window.briny_del_listbox_item_by_value = function(box, val) {
903		for (var i = 0; i < box.options.length; i++) {
904			if (box.options[i].value == val) {
905				box.options[i] = null;
906				break;
907			}
908		}
909	};
910
911	window.briny_del_listbox_item_by_text = function(box, txt) {
912		for (var i = 0; i < box.options.length; i++) {
913			if (box.options[i].text == txt) {
914				box.options[i] = null;
915				break;
916			}
917		}
918	};
919
920	window.briny_find_listbox_item_by_value = function(box, val) {
921		var idx = -1;
922		for (var i = 0; i < box.options.length; i++) {
923			if (box.options[i].value == val) {
924				idx = i;
925				break;
926			}
927		}
928		return idx;
929	};
930
931	window.briny_find_listbox_item_by_text = function(box, txt) {
932		var idx = -1;
933		for (var i = 0; i < box.options.length; i++) {
934			if (box.options[i].text == txt) {
935				idx = i;
936				break;
937			}
938		}
939		return idx;
940	};
941
942	window.briny_select_listbox_item_by_value = function(box, val) {
943		for (var i = 0; i < box.options.length; i++) {
944			box.options[i].selected = (val == box.options[i].value);
945		}
946	};
947
948	window.briny_select_listbox_item_by_text = function(box, txt) {
949		for (var i = 0; i < box.options.length; i++) {
950			box.options[i].selected = (txt == box.options[i].text);
951		}
952	};
953
954	window.briny_get_listbox_values = function(box) {
955		var delim = arguments[1] !== undefined ? arguments[1] : ',';
956		var str   = '';
957		for (var i = 0; i < box.options.length; i++) {
958			str += (str ? delim : '') + box.options[i].value;
959		}
960		return str;
961	};
962
963	window.briny_get_listbox_texts = function(box) {
964		var delim = arguments[1] !== undefined ? arguments[1] : ',';
965		var str   = '';
966		for (var i = 0; i < box.options.length; i++) {
967			str += (str ? delim : '') + box.options[i].text;
968		}
969		return str;
970	};
971
972	window.briny_sort_listbox = function(box)  {
973		var temp_opts = new Array();
974		var temp      = new Option();
975		for (var i = 0; i < box.options.length; i++) {
976			temp_opts[i] = box.options[i].clone();
977		}
978		for (var x = 0; x < temp_opts.length - 1; x++) {
979			for (var y = (x + 1); y < temp_opts.length; y++) {
980				if (temp_opts[x].text > temp_opts[y].text) {
981					temp         = temp_opts[x];
982					temp_opts[x] = temp_opts[y];
983					temp_opts[y] = temp;
984				}
985			}
986		}
987		for (var i = 0; i < box.options.length; i++) {
988			box.options[i] = temp_opts[i].clone();
989		}
990	};
991
992	window.briny_get_listbox_selected_index = function(box) {
993		for (var i = 0; i < box.options.length; i++) {
994			if (box.options[i].selected) {
995				return i;
996			}
997		}
998		return -1;
999	};
1000
1001	window.briny_get_listbox_selected_value = function(box) {
1002		for (var i = 0; i < box.options.length; i++) {
1003			if (box.options[i].selected) {
1004				return box.options[i].value;
1005			}
1006		}
1007		return null;
1008	};
1009
1010	window.briny_get_listbox_selected_text = function(box) {
1011		for (var i = 0; i < box.options.length; i++) {
1012			if (box.options[i].selected) {
1013				return box.options[i].text;
1014			}
1015		}
1016		return null;
1017	};
1018
1019	window.briny_get_listbox_selected_option = function(box) {
1020		for (var i = 0; i < box.options.length; i++) {
1021			if (box.options[i].selected) {
1022				return box.options[i];
1023			}
1024		}
1025		return null;
1026	};
1027
1028	/* Radio buttons manipulations
1029	---------------------------------------------------------------- */
1030
1031	window.briny_get_radio_value = function(radioGroupObj) {
1032		for (var i = 0; i < radioGroupObj.length; i++) {
1033			if (radioGroupObj[i].checked) {
1034				return radioGroupObj[i].value;
1035			}
1036		}
1037		return null;
1038	};
1039
1040	window.briny_set_radio_checked_by_num = function(radioGroupObj, num) {
1041		for (var i = 0; i < radioGroupObj.length; i++) {
1042			if (radioGroupObj[i].checked && i != num) {
1043				radioGroupObj[i].checked = false;
1044			} else if (i == num) {
1045				radioGroupObj[i].checked = true;
1046			}
1047		}
1048	};
1049
1050	window.briny_set_radio_checked_by_value = function(radioGroupObj, val) {
1051		for (var i = 0; i < radioGroupObj.length; i++) {
1052			if (radioGroupObj[i].checked && radioGroupObj[i].value != val) {
1053				radioGroupObj[i].checked = false;
1054			} else if (radioGroupObj[i].value == val) {
1055				radioGroupObj[i].checked = true;
1056			}
1057		}
1058	};
1059
1060	/* Form manipulations
1061	---------------------------------------------------------------- */
1062
1063	/*
1064	// Usage example:
1065	var error = briny_form_validate(jQuery(form_selector), {		// -------- Options ---------
1066		error_message_show: true,									// Display or not error message
1067		error_message_time: 5000,									// Time to display error message
1068		error_message_class: 'message_box message_box_error',		// Class, appended to error message block
1069		error_message_text: 'Global error text',					// Global error message text (if don't write message in checked field)
1070		error_fields_class: 'error_field',							// Class, appended to error fields
1071		exit_after_first_error: false,								// Cancel validation and exit after first error
1072		rules: [
1073			{
1074				field: 'author',																// Checking field name
1075				min_length: { value: 1,	 message: 'The author name can\'t be empty' },			// Min character count (0 - don't check), message - if error occurs
1076				max_length: { value: 60, message: 'Too long author name'}						// Max character count (0 - don't check), message - if error occurs
1077			},
1078			{
1079				field: 'email',
1080				min_length: { value: 7,	 message: 'Too short (or empty) email address' },
1081				max_length: { value: 60, message: 'Too long email address'},
1082				mask: { value: '^([a-z0-9_\\-]+\\.)*[a-z0-9_\\-]+@[a-z0-9_\\-]+(\\.[a-z0-9_\\-]+)*\\.[a-z]{2,6}$', message: 'Invalid email address'}
1083			},
1084			{
1085				field: 'comment',
1086				min_length: { value: 1,	 message: 'The comment text can\'t be empty' },
1087				max_length: { value: 200, message: 'Too long comment'}
1088			},
1089			{
1090				field: 'pwd1',
1091				min_length: { value: 5,	 message: 'The password can\'t be less then 5 characters' },
1092				max_length: { value: 20, message: 'Too long password'}
1093			},
1094			{
1095				field: 'pwd2',
1096				equal_to: { value: 'pwd1',	 message: 'The passwords in both fields must be equals' }
1097			}
1098		]
1099	});
1100	*/
1101
1102	window.briny_form_validate = function(form, opt) {
1103		var error_msg = '';
1104		form.find( ":input" ).each(
1105			function() {
1106				if (error_msg !== '' && opt.exit_after_first_error) {
1107					return;
1108				}
1109				for (var i = 0; i < opt.rules.length; i++) {
1110					if (jQuery( this ).attr( "name" ) == opt.rules[i].field) {
1111						var val   = jQuery( this ).val();
1112						var error = false;
1113						if (typeof(opt.rules[i].min_length) == 'object') {
1114							if (opt.rules[i].min_length.value > 0 && val.length < opt.rules[i].min_length.value) {
1115								if (error_msg == '') {
1116									jQuery( this ).get( 0 ).focus();
1117								}
1118								error_msg += '<p class="error_item">' + (typeof(opt.rules[i].min_length.message) != 'undefined' ? opt.rules[i].min_length.message : opt.error_message_text ) + '</p>';
1119								error      = true;
1120							}
1121						}
1122						if (( ! error || ! opt.exit_after_first_error) && typeof(opt.rules[i].max_length) == 'object') {
1123							if (opt.rules[i].max_length.value > 0 && val.length > opt.rules[i].max_length.value) {
1124								if (error_msg == '') {
1125									jQuery( this ).get( 0 ).focus();
1126								}
1127								error_msg += '<p class="error_item">' + (typeof(opt.rules[i].max_length.message) != 'undefined' ? opt.rules[i].max_length.message : opt.error_message_text ) + '</p>';
1128								error      = true;
1129							}
1130						}
1131						if (( ! error || ! opt.exit_after_first_error) && typeof(opt.rules[i].mask) == 'object') {
1132							if (opt.rules[i].mask.value !== '') {
1133								var regexp = new RegExp( opt.rules[i].mask.value );
1134								if ( ! regexp.test( val )) {
1135									if (error_msg == '') {
1136										jQuery( this ).get( 0 ).focus();
1137									}
1138									error_msg += '<p class="error_item">' + (typeof(opt.rules[i].mask.message) != 'undefined' ? opt.rules[i].mask.message : opt.error_message_text ) + '</p>';
1139									error      = true;
1140								}
1141							}
1142						}
1143						if (( ! error || ! opt.exit_after_first_error) && typeof(opt.rules[i].state) == 'object') {
1144							if (opt.rules[i].state.value == 'checked' && ! jQuery( this ).get( 0 ).
1144checked) {
1145								if (error_msg == '') {
1146									jQuery( this ).get( 0 ).focus();
1147								}
1148								error_msg += '<p class="error_item">' + (typeof(opt.rules[i].state.message) != 'undefined' ? opt.rules[i].state.message : opt.error_message_text ) + '</p>';
1149								error      = true;
1150							}
1151						}
1152						if (( ! error || ! opt.exit_after_first_error) && typeof(opt.rules[i].equal_to) == 'object') {
1153							if (opt.rules[i].equal_to.value !== '' && val != jQuery( jQuery( this ).get( 0 ).form[opt.rules[i].equal_to.value] ).val()) {
1154								if (error_msg == '') {
1155									jQuery( this ).get( 0 ).focus();
1156								}
1157								error_msg += '<p class="error_item">' + (typeof(opt.rules[i].equal_to.message) != 'undefined' ? opt.rules[i].equal_to.message : opt.error_message_text ) + '</p>';
1158								error      = true;
1159							}
1160						}
1161						if (opt.error_fields_class !== '') {
1162							jQuery( this ).toggleClass( opt.error_fields_class, error );
1163						}
1164					}
1165				}
1166			}
1167		);
1168		if (error_msg !== '' && opt.error_message_show) {
1169			var error_message_box = form.find( ".result" );
1170			if (error_message_box.length == 0) {
1171				error_message_box = form.parent().find( ".result" );
1172			}
1173			if (error_message_box.length == 0) {
1174				form.append( '<div class="result"></div>' );
1175				error_message_box = form.find( ".result" );
1176			}
1177			if (opt.error_message_class) {
1178				error_message_box.toggleClass( opt.error_message_class, true );
1179			}
1180			error_message_box.html( error_msg ).fadeIn();
1181			setTimeout( function() { error_message_box.fadeOut(); }, opt.error_message_time );
1182		}
1183		return error_msg !== '';
1184	};
1185
1186	/* Document manipulations
1187	---------------------------------------------------------------- */
1188
1189	// Animated scroll to selected id
1190	window.briny_document_animate_to = function(id, callback) {
1191		var oft = ! isNaN( id ) ? Number( id ) : 0,
1192			oft2 = -1;
1193		if (isNaN( id )) {
1194			if (id.indexOf( '#' ) == -1) {
1195				id = '#' + id;
1196			}
1197			var obj = jQuery( id ).eq( 0 );
1198			if (obj.length == 0) {
1199				return;
1200			}
1201			oft = obj.offset().top;
1202			oft2  = Math.max( 0, oft - briny_fixed_rows_height() );
1203		}
1204		var speed = Math.min( 1000, Math.max( 300, Math.round( Math.abs( ( oft2 < 0 ? oft : oft2 ) - jQuery( window ).scrollTop() ) / jQuery( window ).height() * 300 ) ) );
1205		if (oft2 >= 0) {
1206			setTimeout(
1207				function() {
1208					if (isNaN( id )) {
1209						oft = obj.offset().top;
1210					}
1211					oft2 = Math.max( 0, oft - briny_fixed_rows_height() );
1212					jQuery( 'body,html' ).stop( true ).animate( {scrollTop: oft2}, Math.floor( speed / 2 ), 'linear', callback );
1213				}, Math.floor( speed / 2 )
1214			);
1215		} else {
1216			oft2 = oft;
1217		}
1218		jQuery( 'body,html' ).stop( true ).animate( {scrollTop: oft2}, speed, 'linear', callback );
1219	};
1220
1221	// Detect fixed rows height
1222	window.briny_fixed_rows_height = function() {
1223		var with_admin_bar  = arguments.length > 0 ? arguments[0] : true;
1224		var with_fixed_rows = arguments.length > 1 ? arguments[1] : true;
1225		var oft             = 0;
1226		// Admin bar height (if visible and fixed)
1227		if (with_admin_bar) {
1228			var admin_bar = jQuery( '#wpadminbar' );
1229			oft          += admin_bar.length > 0 && admin_bar.css( 'display' ) != 'none' && admin_bar.css( 'position' ) == 'fixed'
1230							? admin_bar.height()
1231							: 0;
1232		}
1233		// Fixed rows height
1234		if (with_fixed_rows) {
1235			jQuery( '.sc_layouts_row_fixed_on' ).each(
1236				function() {
1237					if (jQuery( this ).css( 'position' ) == 'fixed') {
1238						oft += jQuery( this ).height();
1239					}
1240				}
1241			);
1242		}
1243		return oft;
1244	};
1245
1246	// Change browser address without reload page
1247	window.briny_document_set_location = function(curLoc){
1248		try {
1249			history.pushState( null, null, curLoc );
1250			return;
1251		} catch (e) {
1252		}
1253		location.href = curLoc;
1254	};
1255
1256	// Add/Change arguments to the url address
1257	window.briny_add_to_url = function(loc, prm) {
1258		var ignore_empty = arguments[2] !== undefined ? arguments[2] : true;
1259		var q            = loc.indexOf( '?' );
1260		var attr         = {};
1261		if (q > 0) {
1262			var qq    = loc.substr( q + 1 ).split( '&' );
1263			var parts = '';
1264			for (var i = 0; i < qq.length; i++) {
1265				var parts      = qq[i].split( '=' );
1266				attr[parts[0]] = parts.length > 1 ? parts[1] : '';
1267			}
1268		}
1269		for (var p in prm) {
1270			attr[p] = prm[p];
1271		}
1272		loc   = (q > 0 ? loc.substr( 0, q ) : loc) + '?';
1273		var i = 0;
1274		for (p in attr) {
1275			if (ignore_empty && attr[p] == '') {
1276				continue;
1277			}
1278			loc += (i++ > 0 ? '&' : '') + p + '=' + attr[p];
1279		}
1280		return loc;
1281	};
1282
1283	// Check if url is page-inner (local) link
1284	window.briny_is_local_link = function(url) {
1285		var rez = url !== undefined;
1286		if (rez) {
1287			var url_pos = url.indexOf( '#' );
1288			if (url_pos == 0 && url.length == 1) {
1289				rez = false;
1290			} else {
1291				if (url_pos < 0) {
1292					url_pos = url.length;
1293				}
1294				var loc     = window.location.href;
1295				var loc_pos = loc.indexOf( '#' );
1296				if (loc_pos > 0) {
1297					loc = loc.substring( 0, loc_pos );
1298				}
1299				rez = url_pos == 0;
1300				if ( ! rez) {
1301					rez = loc == url.substring( 0, url_pos );
1302				}
1303			}
1304		}
1305		return rez;
1306	};
1307
1308	/* Browsers detection
1309	---------------------------------------------------------------- */
1310
1311	window.briny_browser_is_mobile = function() {
1312		var check = false;
1313		(function(a){if (/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od|ad)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows (ce|phone)|xda|xiino/i.test( a ) || /1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i.test( a.substr( 0,4 ) )) {
1314				check = true}
1315		})( navigator.userAgent || navigator.vendor || window.opera );
1316		return check;
1317	};
1318
1319	window.briny_browser_is_ios = function() {
1320		return navigator.userAgent.match( /iPad|iPhone|iPod/i ) != null;
1321	};
1322
1323	window.briny_is_retina = function() {
1324		var mediaQuery = '(-webkit-min-device-pixel-ratio: 1.5), (min--moz-device-pixel-ratio: 1.5), (-o-min-device-pixel-ratio: 3/2), (min-resolution: 1.5dppx)';
1325		return (window.devicePixelRatio > 1) || (window.matchMedia && window.matchMedia( mediaQuery ).matches);
1326	};
1327
1328	/* File functions
1329	---------------------------------------------------------------- */
1330
1331	window.briny_get_file_name = function(path) {
1332		path    = path.replace( /\\/g, '/' );
1333		var pos = path.lastIndexOf( '/' );
1334		if (pos >= 0) {
1335			path = path.substr( pos + 1 );
1336		}
1337		return path;
1338	};
1339
1340	window.briny_get_file_ext = function(path) {
1341		var pos = path.lastIndexOf( '.' );
1342		path    = pos >= 0 ? path.substr( pos + 1 ) : '';
1343		return path;
1344	};
1345
1346	/* Image functions
1347	---------------------------------------------------------------- */
1348
1349	// Return true, if all images in the specified container are loaded
1350	window.briny_is_images_loaded = function(cont) {
1351		var complete = true;
1352		cont.find( 'img' ).each(
1353			function() {
1354				// If any of previous images is not loaded - skip rest
1355				if ( ! complete) {
1356					return;
1357				}
1358				var img = jQuery( this ).get( 0 );
1359				if (typeof img.naturalWidth == 'number' && typeof img.naturalHeight == 'number') {
1360					// See if "naturalWidth" and "naturalHeight" properties are available
1361					complete = ! (this.naturalWidth == 0 && this.naturalHeight == 0);
1362				} else if (typeof img.complete == 'boolean') {
1363					// See if "complete" property is available
1364					complete = img.complete;
1365				}
1366			}
1367		);
1368		return complete;
1369	};
1370
1371	// Call function when all images in the specified container are loaded
1372	window.briny_when_images_loaded = function(cont, callback, max_delay) {
1373		if (max_delay === undefined) {
1374			var max_delay = 3000;
1375		}
1376		if (max_delay <= 0 || briny_is_images_loaded( cont )) {
1377			callback();
1378		} else {
1379			setTimeout(
1380				function(){
1381					briny_when_images_loaded( cont, callback, max_delay - 200 );
1382				}, 200
1383			);
1384		}
1385	};
1386
1387	/* Debug functions
1388	---------------------------------------------------------------- */
1389	window.briny_debug_object = function(obj) {
1390		var recursive   = arguments[1] ? arguments[1] : 0;			// Show inner objects (arrays) in depth
1391		var showMethods = arguments[2] ? arguments[2] : false;		// Show object's methods
1392		var level       = arguments[3] ? arguments[3] : 0;				// Nesting level (for internal usage only)
1393		var dispStr     = "";
1394		var addStr      = "";
1395		var curStr      = "";
1396		if (level > 0) {
1397			dispStr += (obj === null ? "null" : typeof(obj)) + "\n";
1398			addStr   = briny_replicate( ' ', level * 2 );
1399		}
1400		if (obj !== null && (typeof(obj) == 'object' || typeof(obj) == 'array')) {
1401			for (var prop in obj) {
1402				if ( ! showMethods && typeof(obj[prop]) == 'function') {	// || prop=='innerHTML' || prop=='outerHTML' || prop=='innerText' || prop=='outerText')
1403					continue;
1404				}
1405				if (level < recursive && (typeof(obj[prop]) == 'object' || typeof(obj[prop]) == 'array') && obj[prop] != obj) {
1406					dispStr += addStr + prop + '=' + briny_debug_object( obj[prop], recursive, showMethods, level 
1406+ 1 );
1407				} else {
1408					try {
1409						curStr = "" + obj[prop];
1410					} catch (e) {
1411						curStr = "--- Not evaluate ---";
1412					}
1413					dispStr += addStr + prop + '=' + (typeof(obj[prop]) == 'string' ? '"' : '') + curStr + (typeof(obj[prop]) == 'string' ? '"' : '') + "\n";
1414				}
1415			}
1416		} else if (typeof(obj) != 'function') {
1417			dispStr += addStr + (typeof(obj) == 'string' ? '"' : '') + obj + (typeof(obj) == 'string' ? '"' : '') + "\n";
1418		}
1419
1420		return dispStr;	//decodeURI(dispStr);
1421	};
1422
1423	window.briny_debug_log = function(s, clr) {
1424		if (BRINY_STORAGE['user_logged_in']) {
1425			if (jQuery( '#debug_log' ).length == 0) {
1426				jQuery( 'body' ).append( '<div id="debug_log"><span id="debug_log_close">x</span><pre id="debug_log_content"></pre></div>' );
1427				jQuery( "#debug_log_close" ).on(
1428					'click', function(e) {
1429						jQuery( '#debug_log' ).hide();
1430						e.preventDefault();
1431						return false;
1432					}
1433				);
1434			}
1435			if (clr) {
1436				jQuery( '#debug_log_content' ).empty();
1437			}
1438			jQuery( '#debug_log_content' ).prepend( s + ' ' );
1439			jQuery( '#debug_log' ).show();
1440		}
1441	};
1442
1443	window.dcl === undefined && (window.dcl = function(s) { console.log( s ); });
1444	window.dco === undefined && (window.dco = function(s,r) { console.log( briny_debug_object( s,r ) ); });
1445	window.dal === undefined && (window.dal = function(s) { if (BRINY_STORAGE['user_logged_in']) {
1446			alert( s );
1447	} });
1448	window.dao === undefined && (window.dao = function(s,r) { if (BRINY_STORAGE['user_logged_in']) {
1449			alert( briny_debug_object( s,r ) );
1450	} });
1451	window.ddl === undefined && (window.ddl = function(s,c) { briny_debug_log( s,c ); });
1452	window.ddo === undefined && (window.ddo = function(s,r,c) { briny_debug_log( briny_debug_object( s,r ),c ); });
1453
1454})();

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.