PageSourceSearch

https://www.fastprint.co.uk/Assets/FastPrint/Scripts/jquery.main.1.0.js?v=1

js fastprint.co.uk collected 2026-10-02 14:39:54 UTC 140,383 bytes, 3,565 lines download raw bytes

1// page init
2bindReady(function(){
3	initItemsZindex();
4});
5
6// page init
7jQuery(function () {
8    //jcf.customForms.replaceAll();
9    initSlideShow();
10    initSameHeight();
11    initTabs();
12    initOpenClose();
13    initCarousel();
14    initPopup();
15    clearInputs();
16    addDefVal();
17});
18function addDefVal(){
19	var _list = jQuery('.add_def_val').find('input:text, input:password, textarea');
20	var p_list = jQuery('.add_def_val').find('input:password');
21
22	if(jQuery(window).width() < 930){
23		for(var i = 0; i < _list.length; i++){
24			if(_list.eq(i).val() == '' && !_list.eq(i).data('changed')){
25			    //_list.eq(i).val(_list.eq(i).siblings('label').text());
26			    _list.eq(i).attr('placeholder', _list.eq(i).siblings('label').text());
27				_list.eq(i).data('val', _list.eq(i).val());
28				_list.eq(i).data('changed', true);
29			}
30		}
31		p_list.focus(function(){
32			if(jQuery(this).val() == '' || jQuery(this).val() == jQuery(this).data('val')) jQuery(this).attr('type', 'password');
33		}).blur(function(){
34			if(jQuery(this).val() == '' || jQuery(this).val() == jQuery(this).data('val')) jQuery(this).attr('type', 'text');
35		}).attr('type', 'text');
36	}
37}
38/*---- clear inputs ---*/
39function clearInputs(){
40	jQuery('input:text, input:password').each(function(){
41		var _el = jQuery(this);
42		_el.data('val', _el.val());
43	    _el.bind('focus', function () {
44
45			if(_el.val() == _el.data('val') && !_el.hasClass('no-clear') ) _el.val('');
46		}).bind('blur', function(){
47			if(_el.val() == '') _el.val(_el.data('val'));
48		});
49	});
50}
51
52
53// content tabs init
54function initTabs() {
55	jQuery('ul.tabset').contentTabs({
56		tabLinks: 'a'
57	});
58	jQuery('ul.q-list').contentTabs({
59		tabLinks: 'a'
60	});
61}
62
63
64// fade gallery init
65function initSlideShow() {
66	jQuery('div.gallery').fadeGallery({
67		slides: '.gmask > ul > li',
68		btnPrev: 'a.btn-prev',
69		btnNext: 'a.btn-next',
70		pagerLinks: '.switcher li',
71		event: 'click',
72		autoRotation: true,
73		autoHeight: true,
74		switchTime: 3000,
75		animSpeed: 500
76	});
77}
78
79
80
81// open-close init
82function initOpenClose() {
83    
84    $(".open-products-tray").on("click", function (e) {
85        e.preventDefault();
86        ga('send', 'event', 'Home Page', 'click', 'Get Started');
87                
88        $(".products-area .btn").trigger("click");        
89    })    
90
91	jQuery('#main .acc-hold .tab-content #tab2.tab').openClose({
92		activeClass: 'active',
93		opener: '.open, .back',
94		slider: '.slider',
95		animSpeed: 400,
96		event:'click',
97		effect: 'fade'
98	});
99	jQuery('.products-area').openClose({
100		activeClass: 'active',
101		opener: '.btn',
102		slider: '.slider',
103		animSpeed: 400,
104		event:'click',
105		effect: 'slide'
106	});
107	jQuery('#wrapper').openClose({
108		activeClass: 'active',
109		opener: '.opener,.close',
110		slider: '#header .hold',
111		animSpeed: 400,
112		event:'click',
113		effect: 'fade'
114	});
115}
116
117// scroll gallery init
118function initCarousel() {
119	jQuery('div.gall-prod').scrollGallery({
120		mask: 'div.gmask',
121		slider: 'ul',
122		slides: 'li',
123		btnPrev: 'a.prev',
124		btnNext: 'a.next',
125		pagerLinks: '.pagination li',
126		autoRotation: false,
127		switchTime: 3000,
128		step: 1,
129		animSpeed: 500
130	});
131	jQuery('div.recent-area').scrollGallery({
132		mask: 'div.gmask',
133		slider: 'ul',
134		slides: 'li',
135		btnPrev: 'a.prev',
136		btnNext: 'a.next',
137		pagerLinks: '.pagination li',
138		autoRotation: false,
139		switchTime: 3000,
140		stretchSlideToMask: true,
141		step: 1,
142		animSpeed: 500
143	});
144	jQuery('div.more-gall').scrollGallery({
145		mask: 'div.gmask',
146		slider: 'ul',
147		slides: 'li',
148		btnPrev: 'a.prev',
149		btnNext: 'a.next',
150		pagerLinks: '.pagination li',
151		autoRotation: false,
152		switchTime: 3000,
153		step: 1,
154		animSpeed: 500
155	});
156	jQuery('div.gall').scrollGallery({
157		mask: 'div.gmask',
158		slider: 'ul',
159		slides: 'li',
160		btnPrev: 'a.prev',
161		btnNext: 'a.next',
162		pagerLinks: '.pagination li',
163		autoRotation: false,
164		switchTime: 3000,
165		step: 1,
166		animSpeed: 500
167	});
168}
169
170
171// align blocks height
172function initSameHeight() {
173	jQuery('#main .panel').sameHeight({
174		elements: 'div.col',
175		flexible: true
176	});
177}
178
179/*--- popup ---*/
180function initPopup(){
181	if(jQuery('#fader').length == 0) jQuery('body').append('<div id="fader"></div>');
182	var _fader = jQuery('#fader');
183	_fader.hide();
184	var _popup = -1;    
185	
186	jQuery('a.popup-btn').each(function(){
187		var _el = this;
188		if(_el.hash && _el.hash.length > 1){
189			_el._popup = jQuery(_el.hash);
190			if(_el._popup.length){
191				_el.onclick = function(){
192					if(_el._popup){
193						_popup = _el._popup;
194						showPopup();
195					}
196					return false;
197				}
198				_el._popup.find('a.close').click(function(){
199					hidePopup();
200					return false;
201				});
202			}
203		}
204	});
205	_fader.click(function(){
206		hidePopup();
207		return false;
208	});
209	
210	jQuery(document).keydown(function(e){
211		if(!e)evt = window.event;
212		if(e.keyCode == 27) hidePopup();
213	});
214	function showPopup(){
215		_fader.css({
216			opacity: 0,
217			height: initH(),
218			display:'block'
219		});
220		_popup.css({top: jQuery(window).scrollTop()});
221		_fader.fadeTo(400, 0.8, function(){
222			if(_popup != -1){
223				_popup.fadeIn(200);
224				var _t = jQuery(window).scrollTop()+ (jQuery(window).height() - _popup.outerHeight())/2;
225				if(_t < 0) _t = 0;
226				_popup.css({top: _t});
227				if(initH() < _popup.outerHeight()+_popup.offset().top) _fader.height(_popup.outerHeight()+_popup.offset().top);
228			}
229		});
230	}
231	function hidePopup(){
232		if(_popup != -1){
233			_popup.fadeOut(400, function(){
234				_fader.fadeOut(200);
235				_popup = -1;
236			});
237		}
238	}
239	function initH(){
240		var _h = jQuery('#wrapper').outerHeight();
241		if(_h < jQuery(window).height()) _h = jQuery(window).height();
242		if(_h < jQuery('body').height()) _h = jQuery('body').height();
243		return _h;
244	}
245}
246
247/*
248 * jQuery Open/Close plugin
249 */
250;(function($) {
251	function OpenClose(options) {
252		this.options = $.extend({
253			addClassBeforeAnimation: true,
254			activeClass:'active',
255			opener:'.opener',
256			slider:'.slide',
257			animSpeed: 400,
258			effect:'fade',
259			event:'click'
260		}, options);
261		this.init();
262	}
263	OpenClose.prototype = {
264		init: function() {
265			if(this.options.holder) {
266				this.findElements();
267				this.attachEvents();
268				this.makeCallback('onInit');
269			}
270		},
271		findElements: function() {
272			this.holder = $(this.options.holder);
273			this.opener = this.holder.find(this.options.opener);
274			this.slider = this.holder.find(this.options.slider);
275			
276			if (!this.holder.hasClass(this.options.activeClass)) {
277				this.slider.addClass(slideHiddenClass);
278			}
279		},
280		attachEvents: function() {
281			// add handler
282			var self = this;
283			this.eventHandler = function(e) {
284				e.preventDefault();
285				if (self.slider.hasClass(slideHiddenClass)) {
286					self.showSlide();
287				} else {
288					self.hideSlide();
289				}
290			};
291			self.opener.bind(self.options.event, this.eventHandler);
292
293			// hove mode handler
294			if(self.options.event === 'over') {
295				self.opener.bind('mouseenter', function() {
296					self.holder.removeClass(self.options.activeClass);
297					self.opener.trigger(self.options.event);
298				});
299				self.holder.bind('mouseleave', function() {
300					self.holder.addClass(self.options.activeClass);
301					self.opener.trigger(self.options.event);
302				});
303			}
304		},
305		showSlide: function() {
306			var self = this;
307			if (self.options.addClassBeforeAnimation) {
308				self.holder.addClass(self.options.activeClass);
309			}
310			self.slider.removeClass(slideHiddenClass);
311
312			self.makeCallback('animStart', true);
313			toggleEffects[self.options.effect].show({
314				box: self.slider,
315				speed: self.options.animSpeed,
316				complete: function() {
317					if (!self.options.addClassBeforeAnimation) {
318						self.holder.addClass(self.options.activeClass);
319					}
320					self.makeCallback('animEnd', true);
321				}
322			});
323		},
324		hideSlide: function() {
325			var self = this;
326			if (self.options.addClassBeforeAnimation) {
327				self.holder.removeClass(self.options.activeClass);
328			}
329			
330			self.makeCallback('animStart', false);
331			toggleEffects[self.options.effect].hide({
332				box: self.slider,
333				speed: self.options.animSpeed,
334				complete: function() {
335					if (!self.options.addClassBeforeAnimation) {
336						self.holder.removeClass(self.options.activeClass);
337					}
338					self.slider.addClass(slideHiddenClass);
339					self.makeCallback('animEnd', false);
340				}
341			});
342		},
343		destroy: function() {
344			this.slider.removeClass(slideHiddenClass);
345			this.opener.unbind(this.options.event, this.eventHandler);
346			this.holder.removeClass(this.options.activeClass).removeData('OpenClose');
347		},
348		makeCallback: function(name) {
349			if(typeof this.options[name] === 'function') {
350				var args = Array.prototype.slice.call(arguments);
351				args.shift();
352				this.options[name].apply(this, args);
353			}
354		}
355	};
356	
357	// add stylesheet for slide on DOMReady
358	var slideHiddenClass = 'js-slide-hidden';
359	$(function() {
360		var tabStyleSheet = $('<style type="text/css">')[0];
361		var tabStyleRule = '.' + slideHiddenClass;
362		tabStyleRule += '{position:absolute !important;left:-9999px !important;top:-9999px !important;display:block !important}';
363		if (tabStyleSheet.styleSheet) {
364			tabStyleSheet.styleSheet.cssText = tabStyleRule;
365		} else {
366			tabStyleSheet.appendChild(document.createTextNode(tabStyleRule));
367		}
368		$('head').append(tabStyleSheet);
369	});
370	
371	// animation effects
372	var toggleEffects = {
373		slide: {
374			show: function(o) {
375				o.box.stop(true).hide().slideDown(o.speed, o.complete);
376			},
377			hide: function(o) {
378				o.box.stop(true).slideUp(o.speed, o.complete);
379			}
380		},
381		fade: {
382			show: function(o) {
383				o.box.stop(true).hide().fadeIn(o.speed, o.complete);
384			},
385			hide: function(o) {
386				o.box.stop(true).fadeOut(o.speed, o.complete);
387			}
388		},
389		none: {
390			show: function(o) {
391				o.box.hide().show(0, o.complete);
392			},
393			hide: function(o) {
394				o.box.hide(0, o.complete);
395			}
396		}
397	};
398	
399	// jQuery plugin interface
400	$.fn.openClose = function(opt) {
401		return this.each(function() {
402			jQuery(this).data('OpenClose', new OpenClose($.extend(opt, {holder: this})));
403		});
404	};
405}(jQuery));
406
407/*
408 * jQuery SameHeight plugin
409 */
410;(function($){
411	$.fn.sameHeight = function(opt) {
412		var options = $.extend({
413			skipClass: 'same-height-ignore',
414			leftEdgeClass: 'same-height-left',
415			rightEdgeClass: 'same-height-right',
416			elements: '>*',
417			flexible: false,
418			multiLine: false,
419			useMinHeight: false,
420			biggestHeight: false
421		},opt);
422		return this.each(function(){
423			var holder = $(this), postResizeTimer, ignoreResize;
424			var elements = holder.find(options.elements).not('.' + options.skipClass);
425			if(!elements.length) return;
426			
427			// resize handler
428			function doResize() {
429				elements.css(options.useMinHeight && supportMinHeight ? 'minHeight' : 'height', '');
430				if(options.multiLine) {
431					// resize elements row by row
432					resizeElementsByRows(elements, options);
433				} else {
434					// resize elements by holder
435					resizeElements(elements, holder, options);
436				}
437			}
438			doResize();
439			
440			// handle flexible layout / font resize
441			var delayedResizeHandler = function() {
442				if(!ignoreResize) {
443					ignoreResize = true;
444					doResize();
445					clearTimeout(postResizeTimer);
446					postResizeTimer = setTimeout(function() {
447						doResize();
448						setTimeout(function(){
449							ignoreResize = false;
450						}, 10);
451					}, 100);
452				}
453			};
454
455			// handle flexible/responsive layout
456			if(options.flexible) {
457				$(window).bind('resize orientationchange fontresize', delayedResizeHandler);
458			}
459
460			// handle complete page load including images and fonts
461			$(window).bind('load', delayedResizeHandler);
462		});
463	};
464	
465	// detect css min-height support
466	var supportMinHeight = typeof document.documentElement.style.maxHeight !== 'undefined';
467	
468	// get elements by rows
469	function resizeElementsByRows(boxes, options) {
470		var currentRow = $(), maxHeight, maxCalcHeight = 0, firstOffset = boxes.eq(0).offset().top;
471		boxes.each(function(ind){
472			var curItem = $(this);
473			if(curItem.offset().top === firstOffset) {
474				currentRow = currentRow.add(this);
475			} else {
476				maxHeight = getMaxHeight(currentRow);
477				maxCalcHeight = Math.max(maxCalcHeight, resizeElements(currentRow, maxHeight, options));
478				currentRow = curItem;
479				firstOffset = curItem.offset().top;
480			}
481		});
482		if(currentRow.length) {
483			maxHeight = getMaxHeight(currentRow);
484			maxCalcHeight = Math.max(maxCalcHeight, resizeElements(currentRow, maxHeight, options));
485		}
486		if(options.biggestHeight) {
487			boxes.css(options.useMinHeight && supportMinHeight ? 'minHeight' : 'height', maxCalcHeight);
488		}
489	}
490	
491	// calculate max element height
492	function getMaxHeight(boxes) {
493		var maxHeight = 0;
494		boxes.each(function(){
495			maxHeight = Math.max(maxHeight, $(this).outerHeight());
496		});
497		return maxHeight;
498	}
499	
500	// resize helper function
501	function resizeElements(boxes, parent, options) {
502		var calcHeight;
503		var parentHeight = typeof parent === 'number' ? parent : parent.height();
504		boxes.removeClass(options.leftEdgeClass).removeClass(options.rightEdgeClass).each(function(i){
505			var element = $(this);
506			var depthDiffHeight = 0;
507			
508			if(typeof parent !== 'number') {
509				element.parents().each(function(){
510					var tmpParent = $(this);
511					if(this === parent[0]) {
512						return false;
513					} else {
514						depthDiffHeight += tmpParent.outerHeight() - tmpParent.height();
515					}
516				});
517			}
518			calcHeight = parentHeight - depthDiffHeight - (element.outerHeight() - element.height());
519			if(calcHeight > 0) {
520				element.css(options.useMinHeight && supportMinHeight ? 'minHeight' : 'height', calcHeight);
521			}
522		});
523		boxes.filter(':first').addClass(options.leftEdgeClass);
524		boxes.filter(':last').addClass(options.rightEdgeClass);
525		return calcHeight;
526	}
527}(jQuery));
528
529/*
530 * jQuery FontResize Event
531 */
532jQuery.onFontResize = (function($) {
533	$(function() {
534		var randomID = 'font-resize-frame-' + Math.floor(Math.random() * 1000);
535		var resizeFrame = $('<iframe>').attr('id', randomID).addClass('font-resize-helper');
536		
537		// required styles
538		resizeFrame.css({
539			width: '100em',
540			height: '10px',
541			position: 'absolute',
542			borderWidth: 0,
543			top: '-9999px',
544			left: '-9999px'
545		}).appendTo('body');
546		
547		// use native IE resize event if possible
548		if(/msie [1-8]./.test(navigator.userAgent.toLowerCase())){
549			resizeFrame.bind('resize', function () {
550				$.onFontResize.trigger(resizeFrame[0].offsetWidth / 100);
551			});
552		}
553		// use script inside the iframe to detect resize for other browsers
554		else {
555			var doc = resizeFrame[0].contentWindow.document;
556			doc.open();
557			doc.write('<scri' + 'pt>window.onload = function(){var em = parent.jQuery("#' + randomID + '")[0];window.onresize = function(){if(parent.jQuery.onFontResize){parent.jQuery.onFontResize.trigger(em.offsetWidth / 100);}}};</scri' + 'pt>');
558			doc.close();
559		}
560		jQuery.onFontResize.initialSize = resizeFrame[0].offsetWidth / 100;
561	});
562	return {
563		// public method, so it can be called from within the iframe
564		trigger: function (em) {
565			$(window).trigger("fontresize", [em]);
566		}
567	};
568}(jQuery));
569
570/*
571* touchSwipe - jQuery Plugin
572* https://github.com/mattbryson/TouchSwipe-Jquery-Plugin
573* http://labs.skinkers.com/touchSwipe/
574* http://plugins.jquery.com/project/touchSwipe
575*
576* Copyright (c) 2010 Matt Bryson (www.skinkers.com)
577* Dual licensed under the MIT or GPL Version 2 licenses.
578*
579* $version: 1.6.0
580*/;(function(d){+"use strict";var n="left",m="right",c="up",u="down",b="in",v="out",k="none",q="auto",j="swipe",r="pinch",e="click",x="horizontal",s="vertical",h="all",f="start",i="move",g="end",o="cancel",a="ontouchstart" in window,w="TouchSwipe";var l={fingers:1,threshold:75,pinchThreshold:20,maxTimeThreshold:null,fingerReleaseThreshold:250,swipe:null,swipeLeft:null,swipeRight:null,swipeUp:null,swipeDown:null,swipeStatus:null,pinchIn:null,pinchOut:null,pinchStatus:null,click:null,triggerOnTouchEnd:true,triggerOnTouchLeave:false,allowPageScroll:"auto",fallbackToMouseEvents:true,excludedElements:"button, input, select, textarea, a, .noSwipe"};d.fn.swipe=function(A){var z=d(this),y=z.data(w);if(y&&typeof A==="string"){if(y[A]){return y[A].apply(this,Array.prototype.slice.call(arguments,1))}else{d.error("Method "+A+" does not exist on jQuery.swipe")}}else{if(!y&&(typeof A==="object"||!A)){return t.apply(this,arguments)}}return z};d.fn.swipe.defaults=l;d.fn.swipe.phases={PHASE_START:f,PHASE_MOVE:i,PHASE_END:g,PHASE_CANCEL:o};d.fn.swipe.directions={LEFT:n,RIGHT:m,UP:c,DOWN:u,IN:b,OUT:v};d.fn.swipe.pageScroll={NONE:k,HORIZONTAL:x,VERTICAL:s,AUTO:q};d.fn.swipe.fingers={ONE:1,TWO:2,THREE:3,ALL:h};function t(y){if(y&&(y.allowPageScroll===undefined&&(y.swipe!==undefined||y.swipeStatus!==undefined))){y.allowPageScroll=k}if(!y){y={}}y=d.extend({},d.fn.swipe.defaults,y);return this.each(function(){var A=d(this);var z=A.data(w);if(!z){z=new p(this,y);A.data(w,z)}})}function p(S,af){var aF=(a||!af.fallbackToMouseEvents),ax=aF?"touchstart":"mousedown",U=aF?"touchmove":"mousemove",au=aF?"touchend":"mouseup",D=aF?null:"mouseleave",R="touchcancel";var ac=0;var N=null;var ag=0;var aB=0;var A=0;var ai=1;var aH=0;var H=d(S);var O="start";var aE=0;var ah=null;var I=0;var Y=0;var aA=0;var aJ=0;try{H.bind(ax,ar);H.bind(R,M)}catch(aC){d.error("events not supported "+ax+","+R+" on jQuery.swipe")}this.enable=function(){H.bind(ax,ar);H.bind(R,M);return H};this.disable=function(){Q();return H};this.destroy=function(){Q();H.data(w,null);return H};function ar(aM){if(X()){return}if(d(aM.target).closest(af.excludedElements,H).length>0){return}var aN=aM.originalEvent;var aL,aK=a?aN.touches[0]:aN;O=f;if(a){aE=aN.touches.length}else{aM.preventDefault()}ac=0;N=null;aH=null;ag=0;aB=0;A=0;ai=1;pinchDistance=0;ah=T();z();if(!a||(aE===af.fingers||af.fingers===h)||ao()){aI(0,aK);I=B();if(aE==2){aI(1,aN.touches[1]);aB=A=Z(ah[0].start,ah[1].start)}if(af.swipeStatus||af.pinchStatus){aL=aD(aN,O)}}else{aL=false}if(aL===false){O=o;aD(aN,O);return aL}else{aj(true)}}function P(aN){var aQ=aN.originalEvent;if(O===g||O===o||ae()){return}var aM,aL=a?aQ.touches[0]:aQ;var aO=V(aL);Y=B();if(a){aE=aQ.touches.length}O=i;if(aE==2){if(aB==0){aI(1,aQ.touches[1]);aB=A=Z(ah[0].start,ah[1].start)}else{V(aQ.touches[1]);A=Z(ah[0].end,ah[1].end);aH=an(ah[0].end,ah[1].end)}ai=y(aB,A);pinchDistance=Math.abs(aB-A)}if((aE===af.fingers||af.fingers===h)||!a||ao()){N=aq(aO.start,aO.end);C(aN,N);ac=G(aO.start,aO.end);ag=L();if(af.swipeStatus||af.pinchStatus){aM=aD(aQ,O)}if(!af.triggerOnTouchEnd||af.triggerOnTouchLeave){var aK=true;if(af.triggerOnTouchLeave){var aP=at(this);aK=az(aO.end,aP)}if(!af.triggerOnTouchEnd&&aK){O=aG(i)}else{if(af.triggerOnTouchLeave&&!aK){O=aG(g)}}if(O==o||O==g){aD(aQ,O)}}}else{O=o;aD(aQ,O)}if(aM===false){O=o;aD(aQ,O)}}function aa(aM){var aO=aM.originalEvent;if(a){if(aO.touches.length>0){av();return true}}if(ae()){aE=aJ}aM.preventDefault();Y=B();if(af.triggerOnTouchEnd||(af.triggerOnTouchEnd==false&&O===i)){O=g;var aL=((aE===af.fingers||af.fingers===h)||!a);var aK=ah[0].end.x!==0;var aN=aL&&aK&&(am()||ay());if(aN){aD(aO,O)}else{O=o;aD(aO,O)}}else{if(O===i){O=o;aD(aO,O)}}aj(false)}function M(){aE=0;Y=0;I=0;aB=0;A=0;ai=1;z();aj(false)}function W(aK){var aL=aK.originalEvent;if(af.triggerOnTouchLeave){O=aG(g);aD(aL,O)}}
580function Q(){H.unbind(ax,ar);H.unbind(R,M);H.unbind(U,P);H.unbind(au,aa);if(D){H.unbind(D,W)}aj(false)}function aG(aN){var aM=aN;var aL=ap();var aK=ad();if(!aL){aM=o}else{if(aK&&aN==i&&(!af.triggerOnTouchEnd||af.triggerOnTouchLeave)){aM=g}else{if(!aK&&aN==g&&af.triggerOnTouchLeave){aM=o}}}return aM}function aD(aM,aK){var aL=undefined;if(ab()){aL=al(aM,aK,j)}if(ao()&&aL!==false){aL=al(aM,aK,r)}if(K()&&aL!==false){aL=al(aM,aK,e)}if(aK===o){M(aM)}if(aK===g){if(a){if(aM.touches.length==0){M(aM)}}else{M(aM)}}return aL}function al(aN,aK,aM){var aL=undefined;if(aM==j){if(af.swipeStatus){aL=af.swipeStatus.call(H,aN,aK,N||null,ac||0,ag||0,aE);if(aL===false){return false}}if(aK==g&&ay()){if(af.swipe){aL=af.swipe.call(H,aN,N,ac,ag,aE);if(aL===false){return false}}switch(N){case n:if(af.swipeLeft){aL=af.swipeLeft.call(H,aN,N,ac,ag,aE)}break;case m:if(af.swipeRight){aL=af.swipeRight.call(H,aN,N,ac,ag,aE)}break;case c:if(af.swipeUp){aL=af.swipeUp.call(H,aN,N,ac,ag,aE)}break;case u:if(af.swipeDown){aL=af.swipeDown.call(H,aN,N,ac,ag,aE)}break}}}if(aM==r){if(af.pinchStatus){aL=af.pinchStatus.call(H,aN,aK,aH||null,pinchDistance||0,ag||0,aE,ai);if(aL===false){return false}}if(aK==g&&am()){switch(aH){case b:if(af.pinchIn){aL=af.pinchIn.call(H,aN,aH||null,pinchDistance||0,ag||0,aE,ai)}break;case v:if(af.pinchOut){aL=af.pinchOut.call(H,aN,aH||null,pinchDistance||0,ag||0,aE,ai)}break}}}if(aM==e){if(aK===o){if(af.click&&(aE===1||!a)&&(isNaN(ac)||ac===0)){aL=af.click.call(H,aN,aN.target)}}}return aL}function ad(){if(af.threshold!==null){return ac>=af.threshold}return true}function ak(){if(af.pinchThreshold!==null){return pinchDistance>=af.pinchThreshold}return true}function ap(){var aK;if(af.maxTimeThreshold){if(ag>=af.maxTimeThreshold){aK=false}else{aK=true}}else{aK=true}return aK}function C(aK,aL){if(af.allowPageScroll===k||ao()){aK.preventDefault()}else{var aM=af.allowPageScroll===q;switch(aL){case n:if((af.swipeLeft&&aM)||(!aM&&af.allowPageScroll!=x)){aK.preventDefault()}break;case m:if((af.swipeRight&&aM)||(!aM&&af.allowPageScroll!=x)){aK.preventDefault()}break;case c:if((af.swipeUp&&aM)||(!aM&&af.allowPageScroll!=s)){aK.preventDefault()}break;case u:if((af.swipeDown&&aM)||(!aM&&af.allowPageScroll!=s)){aK.preventDefault()}break}}}function am(){return ak()}function ao(){return !!(af.pinchStatus||af.pinchIn||af.pinchOut)}function aw(){return !!(am()&&ao())}function ay(){var aK=ap();var aM=ad();var aL=aM&&aK;return aL}function ab(){return !!(af.swipe||af.swipeStatus||af.swipeLeft||af.swipeRight||af.swipeUp||af.swipeDown)}function E(){return !!(ay()&&ab())}function K(){return !!(af.click)}function av(){aA=B();aJ=event.touches.length+1}function z(){aA=0;aJ=0}function ae(){var aK=false;if(aA){var aL=B()-aA;if(aL<=af.fingerReleaseThreshold){aK=true}}return aK}function X(){return !!(H.data(w+"_intouch")===true)}function aj(aK){if(aK===true){H.bind(U,P);H.bind(au,aa);if(D){H.bind(D,W)}}else{H.unbind(U,P,false);H.unbind(au,aa,false);if(D){H.unbind(D,W,false)}}H.data(w+"_intouch",aK===true)}function aI(aL,aK){var aM=aK.identifier!==undefined?aK.identifier:0;ah[aL].identifier=aM;ah[aL].start.x=ah[aL].end.x=aK.pageX;ah[aL].start.y=ah[aL].end.y=aK.pageY;return ah[aL]}function V(aK){var aM=aK.identifier!==undefined?aK.identifier:0;var aL=J(aM);aL.end.x=aK.pageX;aL.end.y=aK.pageY;return aL}function J(aL){for(var aK=0;aK<ah.length;aK++){if(ah[aK].identifier==aL){return ah[aK]}}}function T(){var aK=[];for(var aL=0;aL<=5;aL++){aK.push({start:{x:0,y:0},end:{x:0,y:0},identifier:0})}return aK}function L(){return Y-I}function Z(aN,aM){var aL=Math.abs(aN.x-aM.x);var aK=Math.abs(aN.y-aM.y);return Math.round(Math.sqrt(aL*aL+aK*aK))}function y(aK,aL){var aM=(aL/aK)*1;return aM.toFixed(2)}function an(){if(ai<1){return v}else{return b}}function G(aL,aK){return Math.round(Math.sqrt(Math.pow(aK.x-aL.x,2)+Math.pow(aK.y-aL.y,2)))}function F(aN,aL){var aK=aN.x-aL.x;var aP=aL.y-aN.y;var aM=Math.atan2(aP,aK);var aO=Math.round(aM*180/Math.PI);if(aO<0){aO=360-Math.abs(aO)}return aO}function aq(aL,aK){var aM=F(aL,aK);if((aM<=45)&&(aM>=0)){return n}else{if((aM<=360)&&(aM>=315)){return n}else{if((aM>=135)&&(aM<=225)){return m}else{if((aM>45)&&(aM<135)){return u}else{return c}}}}}function B(){var aK=new Date();return aK.getTime()}function at(aK){aK=d(aK);var aM=aK.offset();var aL={left:aM.left,right:aM.left+aK.outerWidth(),top:aM.top,bottom:aM.top+aK.outerHeight()};return aL}function az(aK,aL){return(aK.x>aL.left&&aK.x<aL.right&&aK.y>aL.top&&aK.y<aL.bottom)}}})(jQuery);
581
582
583/*
584 * jQuery Tabs plugin
585 */
586;(function($){
587	$.fn.contentTabs = function(o){
588		// default options
589		var options = $.extend({
590			activeClass:'active',
591			addToParent:false,
592			autoHeight:false,
593			autoRotate:false,
594			checkHash:false,
595			animSpeed:400,
596			switchTime:3000,
597			effect: 'none', // "fade", "slide"
598			tabLinks:'a',
599			attrib:'href',
600			event:'click'
601		},o);
602
603		return this.each(function(){
604			var tabset = $(this);
605			var tabLinks = tabset.find(options.tabLinks);
606			var tabLinksParents = tabLinks.parent();
607			var prevActiveLink = tabLinks.eq(0), currentTab, animating;
608			var tabHolder;
609
610			// handle location hash
611			if(options.checkHash && tabLinks.filter('[' + options.attrib + '="' + location.hash + '"]').length) {
612				(options.addToParent ? tabLinksParents : tabLinks).removeClass(options.activeClass);
613				setTimeout(function() {
614					window.scrollTo(0,0);
615				},1);
616			}
617			
618			// init tabLinks
619			tabLinks.each(function(){
620				var link = $(this);
621				var href = link.attr(options.attrib);
622				var parent = link.parent();
623				href = href.substr(href.lastIndexOf('#'));
624				
625				// get elements
626				var tab = $(href);
627				link.data('cparent', parent);
628				link.data('ctab', tab);
629				
630				// find tab holder
631				if(!tabHolder && tab.length) {
632					tabHolder = tab.parent();
633				}
634				
635				// show only active tab
636				var classOwner = options.addToParent ? parent : link;
637				if(classOwner.hasClass(options.activeClass) || (options.checkHash && location.hash === href)) {
638					classOwner.addClass(options.activeClass);
639					prevActiveLink = link; currentTab = tab;
640					tab.removeClass(tabHiddenClass).width('');
641					contentTabsEffect[options.effect].show({tab:tab, fast:true});
642				} else {
643					contentTabsEffect[options.effect].hide({tab:tab, fast:true});
644					tab.width(tab.width()).addClass(tabHiddenClass);
645				}
646				
647				// event handler
648				link.bind(options.event, function(e){
649					if(link != prevActiveLink && !animating) {
650						switchTab(prevActiveLink, link);
651						prevActiveLink = link;
652					}
653				});
654				if(options.attrib === 'href') {
655					link.bind('click', function(e){
656						e.preventDefault();
657					});
658				}
659			});
660			
661			// tab switch function
662			function switchTab(oldLink, newLink) {
663				animating = true;
664				var oldTab = oldLink.data('ctab');
665				var newTab = newLink.data('ctab');
666				prevActiveLink = newLink;
667				currentTab = newTab;
668				
669				// refresh pagination links
670				(options.addToParent ? tabLinksParents : tabLinks).removeClass(options.activeClass);
671				(options.addToParent ? newLink.data('cparent') : newLink).addClass(options.activeClass);
672				
673				// hide old tab
674				resizeHolder(oldTab, true);
675				contentTabsEffect[options.effect].hide({
676					speed: options.animSpeed,
677					tab:oldTab,
678					complete: function() {
679						// show current tab
680						resizeHolder(newTab.removeClass(tabHiddenClass).width(''));
681						contentTabsEffect[options.effect].show({
682							speed: options.animSpeed,
683							tab:newTab,
684							complete: function() {
685								if(!oldTab.is(newTab)) {
686									oldTab.width(oldTab.width()).addClass(tabHiddenClass);
687								}
688								animating = false;
689								resizeHolder(newTab, false);
690								autoRotate();
691							}
692						});
693					}
694				});
695			}
696			
697			// holder auto height
698			function resizeHolder(block, state) {
699				var curBlock = block && block.length ? block : currentTab;
700				if(options.autoHeight && curBlock) {
701					tabHolder.stop();
702					if(state === false) {
703						tabHolder.css({height:''});
704					} else {
705						var origStyles = curBlock.attr('style');
706						curBlock.show().css({width:curBlock.width()});
707						var tabHeight = curBlock.outerHeight(true);
708						if(!origStyles) curBlock.removeAttr('style'); else curBlock.attr('style', origStyles);
709						if(state === true) {
710							tabHolder.css({height: tabHeight});
711						} else {
712							tabHolder.animate({height: tabHeight}, {duration: options.animSpeed});
713						}
714					}
715				}
716			}
717			if(options.autoHeight) {
718				$(window).bind('resize orientationchange', function(){
719					resizeHolder(currentTab, false);
720				});
721			}
722			
723			// autorotation handling
724			var rotationTimer;
725			function nextTab() {
726				var activeItem = (options.addToParent ? tabLinksParents : tabLinks).filter('.' + options.activeClass);
727				var activeIndex = (options.addToParent ? tabLinksParents : tabLinks).index(activeItem);
728				var newLink = tabLinks.eq(activeIndex < tabLinks.length - 1 ? activeIndex + 1 : 0);
729				prevActiveLink = tabLinks.eq(activeIndex);
730				switchTab(prevActiveLink, newLink);
731			}
732			function autoRotate() {
733				if(options.autoRotate && tabLinks.length > 1) {
734					clearTimeout(rotationTimer);
735					rotationTimer = setTimeout(function() {
736						if(!animating) {
737							nextTab();
738						} else {
739							autoRotate();
740						}
741					}, options.switchTime);
742				}
743			}
744			autoRotate();
745		});
746	};
747	
748	// add stylesheet for tabs on DOMReady
749	var tabHiddenClass = 'js-tab-hidden';
750	$(function() {
751		var tabStyleSheet = $('<style type="text/css">')[0];
752		var tabStyleRule = '.'+tabHiddenClass;
753		tabStyleRule += '{position:absolute !important;left:-9999px !important;top:-9999px !important;display:block !important}';
754		if (tabStyleSheet.styleSheet) {
755			tabStyleSheet.styleSheet.cssText = tabStyleRule;
756		} else {
757			tabStyleSheet.appendChild(document.createTextNode(tabStyleRule));
758		}
759		$('head').append(tabStyleSheet);
760	});
761	
762	// tab switch effects
763	var contentTabsEffect = {
764		none: {
765			show: function(o) {
766				o.tab.css({display:'block'});
767				if(o.complete) o.complete();
768			},
769			hide: function(o) {
770				o.tab.css({display:'none'});
771				if(o.complete) o.complete();
772			}
773		},
774		fade: {
775			show: function(o) {
776				if(o.fast) o.speed = 1;
777				o.tab.fadeIn(o.speed);
778				if(o.complete) setTimeout(o.complete, o.speed);
779			},
780			hide: function(o) {
781				if(o.fast) o.speed = 1;
782				o.tab.fadeOut(o.speed);
783				if(o.complete) setTimeout(o.complete, o.speed);
784			}
785		},
786		slide: {
787			show: function(o) {
788				var tabHeight = o.tab.show().css({width:o.tab.width()}).outerHeight(true);
789				var tmpWrap = $('<div class="effect-div">').insertBefore(o.tab).append(o.tab);
790				tmpWrap.css({width:'100%', overflow:'hidden', position:'relative'}); o.tab.css({marginTop:-tabHeight,display:'block'});
791				if(o.fast) o.speed = 1;
792				o.tab.animate({marginTop: 0}, {duration: o.speed, complete: function(){
793					o.tab.css({marginTop: '', width: ''}).insertBefore(tmpWrap);
794					tmpWrap.remove();
795					if(o.complete) o.complete();
796				}});
797			},
798			hide: function(o) {
799				var tabHeight = o.tab.show().css({width:o.tab.width()}).outerHeight(true);
800				var tmpWrap = $('<div class="effect-div">').insertBefore(o.tab).append(o.tab);
801				tmpWrap.css({width:'100%', overflow:'hidden', position:'relative'});
802				
803				if(o.fast) o.speed = 1;
804				o.tab.animate({marginTop: -tabHeight}, {duration: o.speed, complete: function(){
805					o.tab.css({display:'none', marginTop:'', width:''}).insertBefore(tmpWrap);
806					tmpWrap.remove();
807					if(o.complete) o.complete();
808				}});
809			}
810		}
811	};
812}(jQuery));
813
814/*
815 * jQuery Carousel plugin
816 */
817;(function($){
818	function ScrollGallery(options) {
819		this.options = $.extend({
820			mask: 'div.mask',
821			slider: '>*',
822			slides: '>*',
823			activeClass:'active',
824			disabledClass:'disabled',
825			btnPrev: 'a.btn-prev',
826			btnNext: 'a.btn-next',
827			generatePagination: false,
828			pagerList: '<ul>',
829			pagerListItem: '<li><a href="#"></a></li>',
830			pagerListItemText: 'a',
831			pagerLinks: '.pagination li',
832			currentNumber: 'span.current-num',
833			totalNumber: 'span.total-num',
834			btnPlay: '.btn-play',
835			btnPause: '.btn-pause',
836			btnPlayPause: '.btn-play-pause',
837			galleryReadyClass: 'gallery-js-ready',
838			autorotationActiveClass: 'autorotation-active',
839			autorotationDisabledClass: 'autorotation-disabled',
840			stretchSlideToMask: false,
841			circularRotation: true,
842			disableWhileAnimating: false,
843			autoRotation: false,
844			pauseOnHover: isTouchDevice ? false : true,
845			maskAutoSize: false,
846			switchTime: 4000,
847			animSpeed: 600,
848			event:'click',
849			swipeGap: false,
850			swipeThreshold: 50,
851			handleTouch: true,
852			vertical: false,
853			useTranslate3D: false,
854			step: false
855		}, options);
856		this.init();
857	}
858	ScrollGallery.prototype = {
859		init: function() {
860			if(this.options.holder) {
861				this.findElements();
862				this.attachEvents();
863				this.refreshPosition();
864				this.refreshState(true);
865				this.resumeRotation();
866				this.makeCallback('onInit', this);
867			}
868		},
869		findElements: function() {
870			// define dimensions proporties
871			this.fullSizeFunction = this.options.vertical ? 'outerHeight' : 'outerWidth';
872			this.innerSizeFunction = this.options.vertical ? 'height' : 'width';
873			this.slideSizeFunction = 'outerHeight';
874			this.maskSizeProperty = 'height';
875			this.animProperty = this.options.vertical ? 'marginTop' : 'marginLeft';
876			this.swipeProperties = this.options.vertical ? ['up', 'down'] : ['left', 'right'];
877			
878			// control elements
879			this.gallery = $(this.options.holder).addClass(this.options.galleryReadyClass);
880			this.mask = this.gallery.find(this.options.mask);
881			this.slider = this.mask.find(this.options.slider);
882			this.slides = this.slider.find(this.options.slides);
883			this.btnPrev = this.gallery.find(this.options.btnPrev);
884			this.btnNext = this.gallery.find(this.options.btnNext);
885			this.currentStep = 0; this.stepsCount = 0;
886			
887			// get start index
888			if(this.options.step === false) {
889				var activeSlide = this.slides.filter('.'+this.options.activeClass);
890				if(activeSlide.length) {
891					this.currentStep = this.slides.index(activeSlide);
892				}
893			}
894			
895			// calculate offsets
896			this.calculateOffsets();
897			$(window).bind('load resize orientationchange', $.proxy(this.onWindowResize, this));
898			
899			// create gallery pagination
900			if(typeof this.options.generatePagination === 'string') {
901				this.pagerLinks = $();
902				this.buildPagination();
903			} else {
904				this.pagerLinks = this.gallery.find(this.options.pagerLinks);
905				this.attachPaginationEvents();
906			}
907			
908			// autorotation control buttons
909			this.btnPlay = this.gallery.find(this.options.btnPlay);
910			this.btnPause = this.gallery.find(this.options.btnPause);
911			this.btnPlayPause = this.gallery.find(this.options.btnPlayPause);
912			
913			// misc elements
914			this.curNum = this.gallery.find(this.options.currentNumber);
915			this.allNum = this.gallery.find(this.options.totalNumber);
916		},
917		attachEvents: function() {
918			this.btnPrev.bind(this.options.event, this.bindScope(function(e){
919				this.prevSlide();
920				e.preventDefault();
921			}));
922			this.btnNext.bind(this.options.event, this.bindScope(function(e){
923				this.nextSlide();
924				e.preventDefault();
925			}));
926			
927			// pause on hover handling
928			if(this.options.pauseOnHover) {
929				this.gallery.hover(this.bindScope(function(){
930					if(this.options.autoRotation) {
931						this.galleryHover = true;
932						this.pauseRotation();
933					}
934				}), this.bindScope(function(){
935					if(this.options.autoRotation) {
936						this.galleryHover = false;
937						this.resumeRotation();
938					}
939				}));
940			}
941			
942			// autorotation buttons handler
943			this.btnPlay.bind(this.options.event, this.bindScope(this.startRotation));
944			this.btnPause.bind(this.options.event, this.bindScope(this.stopRotation));
945			this.btnPlayPause.bind(this.options.event, this.bindScope(function(){
946				if(!this.gallery.hasClass(this.options.autorotationActiveClass)) {
947					this.startRotation();
948				} else {
949					this.stopRotation();
950				}
951			}));
952			
953			// swipe event handling
954			if(isTouchDevice) {
955				// enable hardware acceleration
956				if(this.options.useTranslate3D) {
957					this.slider.css({'-webkit-transform': 'translate3d(0px, 0px, 0px)'});
958				}
959				
960				// swipe gestures
961				if(this.options.handleTouch && $.fn.swipe) {
962					this.mask.swipe({
963						excludedElements: '',
964						fallbackToMouseEvents: false,
965						threshold: this.options.swipeThreshold,
966						allowPageScroll: 'vertical',
967						swipeStatus: $.proxy(function(e, phase, direction, distance) {
968							if(phase === 'start') {
969								this.originalOffset = parseInt(this.slider.stop(true, false).css(this.animProperty));
970							} else if(phase === 'move') {
971								if(direction === this.swipeProperties[0] || direction === this.swipeProperties[1]) {
972									var tmpOffset = this.originalOffset + distance * (direction === this.swipeProperties[0] ? -1 : 1);
973									if(!this.options.swipeGap) {
974										tmpOffset = Math.max(Math.min(0, tmpOffset), this.maxOffset);
975									}
976									this.tmpProps = {};
977									this.tmpProps[this.animProperty] = tmpOffset;
978									this.slider.css(this.tmpProps);
979									e.preventDefault();
980								}
981							} else if(phase === 'cancel') {
982								// return to previous position
983								this.switchSlide();
984							}
985						},this),
986						swipe: $.proxy(function(event, direction) {
987							if(direction === this.swipeProperties[0]) {
988								if(this.currentStep === this.stepsCount - 1) this.switchSlide();
989								else this.nextSlide();
990							} else if(direction === this.swipeProperties[1]) {
991								if(this.currentStep === 0) this.switchSlide();
992								else this.prevSlide();
993							}
994						},this)
995					});
996				}
997			}
998		},
999		onWindowResize: function() {
1000			if(!this.galleryAnimating) {
1001				this.calculateOffsets();
1002				this.refreshPosition();
1003				this.buildPagination();
1004				this.refreshState();
1005				this.resizeQueue = false;
1006			} else {
1007				this.resizeQueue = true;
1008			}
1009		},
1010		refreshPosition: function() {
1011			this.currentStep = Math.min(this.currentStep, this.stepsCount - 1);
1012			this.tmpProps = {};
1013			this.tmpProps[this.animProperty] = this.getStepOffset();
1014			this.slider.stop().css(this.tmpProps);
1015		},
1016		calculateOffsets: function() {
1017			if(this.options.stretchSlideToMask) {
1018				var tmpObj = {};
1019				tmpObj[this.innerSizeFunction] = this.mask[this.innerSizeFunction]();
1020				this.slides.css(tmpObj);
1021			}
1022			
1023			this.maskSize = this.mask[this.innerSizeFunction]();
1024			this.sumSize = this.getSumSize();
1025			this.maxOffset = this.maskSize - this.sumSize;
1026			
1027			// vertical gallery with single size step custom behavior
1028			if(this.options.vertical && this.options.maskAutoSize) {
1029				this.options.step = 1;
1030				this.stepsCount = this.slides.length;
1031				this.stepOffsets = [0];
1032				var tmpOffset = 0;
1033				for(var i = 0; i < this.slides.length; i++) {
1034					tmpOffset -= $(this.slides[i])[this.fullSizeFunction](true);
1035					this.stepOffsets.push(tmpOffset);
1036				}
1037				this.maxOffset = tmpOffset;
1038				return;
1039			}
1040			
1041			// scroll by slide size
1042			if(typeof this.options.step === 'number' && this.options.step > 0) {
1043				this.slideDimensions = [];
1044				this.slides.each($.proxy(function(ind, obj){
1045					this.slideDimensions.push( $(obj)[this.fullSizeFunction](true) );
1046				},this));
1047				
1048				// calculate steps count
1049				this.stepOffsets = [0];
1050				this.stepsCount = 1;
1051				var tmpOffset = 0, tmpStep = 0;
1052				while(tmpOffset > this.maxOffset) {
1053					tmpOffset -= this.getSlideSize(tmpStep, tmpStep + this.options.step);
1054					tmpStep += this.options.step;
1055					this.stepOffsets.push(Math.max(tmpOffset, this.maxOffset));
1056					this.stepsCount++;
1057				}
1058			}
1059			// scroll by mask size
1060			else {
1061				// define step size
1062				this.stepSize = this.maskSize;
1063				
1064				// calculate steps count
1065				this.stepsCount = 1;
1066				var tmpOffset = 0;
1067				while(tmpOffset > this.maxOffset) {
1068					tmpOffset -= this.stepSize;
1069					this.stepsCount++;
1070				}
1071			}
1072		},
1073		getSumSize: function() {
1074			var sum = 0;
1075			this.slides.each($.proxy(function(ind, obj){
1076				sum += $(obj)[this.fullSizeFunction](true);
1077			},this));
1078			this.slider.css(this.innerSizeFunction, sum);
1079			return sum;
1080		},
1081		getStepOffset: function(step) {
1082			step = step || this.currentStep;
1083			if(typeof this.options.step === 'number') {
1084				return this.stepOffsets[this.currentStep];
1085			} else {
1086				return Math.max(-this.currentStep * this.stepSize, this.maxOffset);
1087			}
1088		},
1089		getSlideSize: function(i1, i2) {
1090			var sum = 0;
1091			for(var i = i1; i < Math.min(i2, this.slideDimensions.length); i++) {
1092				sum += this.slideDimensions[i];
1093			}
1094			return sum;
1095		},
1096		buildPagination: function() {
1097			if(typeof this.options.generatePagination === 'string') {
1098				if(!this.pagerHolder) {
1099					this.pagerHolder = this.gallery.find(this.options.generatePagination);
1100				}
1101				if(this.pagerHolder.length && this.oldStepsCount != this.stepsCount) {
1102					this.oldStepsCount = this.stepsCount;
1103					this.pagerHolder.empty();
1104					this.pagerList = $(this.options.pagerList).appendTo(this.pagerHolder);
1105					for(var i = 0; i < this.stepsCount; i++) {
1106						$(this.options.pagerListItem).appendTo(this.pagerList).find(this.options.pagerListItemText).text(i+1);
1107					}
1108					this.pagerLinks = this.pagerList.children();
1109					this.attachPaginationEvents();
1110				}
1111			}
1112		},
1113		attachPaginationEvents: function() {
1114			this.pagerLinks.each(this.bindScope(function(ind, obj){
1115				$(obj).bind(this.options.event, this.bindScope(function(){
1116					this.numSlide(ind);
1117					return false;
1118				}));
1119			}));
1120		},
1121		prevSlide: function() {
1122			if(!(this.options.disableWhileAnimating && this.galleryAnimating)) {
1123				if(this.currentStep > 0) {
1124					this.currentStep--;
1125					this.switchSlide();
1126				} else if(this.options.circularRotation) {
1127					this.currentStep = this.stepsCount - 1;
1128					this.switchSlide();
1129				}
1130			}
1131		},
1132		nextSlide: function(fromAutoRotation) {
1133			if(!(this.options.disableWhileAnimating && this.galleryAnimating)) {
1134				if(this.currentStep < this.stepsCount - 1) {
1135					this.currentStep++;
1136					this.switchSlide();
1137				} else if(this.options.circularRotation || fromAutoRotation === true) {
1138					this.currentStep = 0;
1139					this.switchSlide();
1140				}
1141			}
1142		},
1143		numSlide: function(c) {
1144			if(this.currentStep != c) {
1145				this.currentStep = c;
1146				this.switchSlide();
1147			}
1148		},
1149		switchSlide: function() {
1150			this.galleryAnimating = true;
1151			this.tmpProps = {}
1152			this.tmpProps[this.animProperty] = this.getStepOffset();
1153			this.slider.stop().animate(this.tmpProps,{duration: this.options.animSpeed, complete: this.bindScope(function(){
1154				// animation complete
1155				this.galleryAnimating = false;
1156				if(this.resizeQueue) {
1157					this.onWindowResize();
1158				}
1159				
1160				// onchange callback
1161				this.makeCallback('onChange', this);
1162				this.autoRotate();
1163			})});
1164			this.refreshState();
1165			
1166			// onchange callback
1167			this.makeCallback('onBeforeChange', this);
1168		},
1169		refreshState: function(initial) {
1170			if(this.options.step === 1 || this.stepsCount === this.slides.length) {
1171				this.slides.removeClass(this.options.activeClass).eq(this.currentStep).addClass(this.options.activeClass);
1172			}
1173			this.pagerLinks.removeClass(this.options.activeClass).eq(this.currentStep).addClass(this.options.activeClass);
1174			this.curNum.html(this.currentStep+1);
1175			this.allNum.html(this.stepsCount);
1176			
1177			// initial refresh
1178			if(this.options.maskAutoSize && typeof this.options.step === 'number') {
1179				this.tmpProps = {};
1180				this.tmpProps[this.maskSizeProperty] = this.slides.eq(Math.min(this.currentStep,this.slides.length-1))[this.slideSizeFunction](true);
1181				this.mask.stop()[initial ? 'css' : 'animate'](this.tmpProps);
1182			}
1183			
1184			// disabled state
1185			if(!this.options.circularRotation) {
1186				this.btnPrev.add(this.btnNext).removeClass(this.options.disabledClass);
1187				if(this.currentStep === 0) this.btnPrev.addClass(this.options.disabledClass);
1188				if(this.currentStep === this.stepsCount - 1) this.btnNext.addClass(this.options.disabledClass);
1189			}
1190		},
1191		startRotation: function() {
1192			this.options.autoRotation = true;
1193			this.galleryHover = false;
1194			this.autoRotationStopped = false;
1195			this.resumeRotation();
1196		},
1197		stopRotation: function() {
1198			this.galleryHover = true;
1199			this.autoRotationStopped = true;
1200			this.pauseRotation();
1201		},
1202		pauseRotation: function() {
1203			this.gallery.addClass(this.options.autorotationDisabledClass);
1204			this.gallery.removeClass(this.options.autorotationActiveClass);
1205			clearTimeout(this.timer);
1206		},
1207		resumeRotation: function() {
1208			if(!this.autoRotationStopped) {
1209				this.gallery.addClass(this.options.autorotationActiveClass);
1210				this.gallery.removeClass(this.options.autorotationDisabledClass);
1211				this.autoRotate();
1212			}
1213		},
1214		autoRotate: function() {
1215			clearTimeout(this.timer);
1216			if(this.options.autoRotation && !this.galleryHover && !this.autoRotationStopped) {
1217				this.timer = setTimeout(this.bindScope(function(){
1218					this.nextSlide(true);
1219				}), this.options.switchTime);
1220			} else {
1221				this.pauseRotation();
1222			}
1223		},
1224		bindScope: function(func, scope) {
1225			return $.proxy(func, scope || this);
1226		},
1227		makeCallback: function(name) {
1228			if(typeof this.options[name] === 'function') {
1229				var args = Array.prototype.slice.call(arguments);
1230				args.shift();
1231				this.options[name].apply(this, args);
1232			}
1233		}
1234	};
1235	
1236	// detect device type
1237	var isTouchDevice = (function() {
1238		try {
1239			return ('ontouchstart' in window) || window.DocumentTouch && document instanceof DocumentTouch;
1240		} catch (e) {
1241			return false;
1242		}
1243	}());
1244	
1245	// jquery plugin
1246	$.fn.scrollGallery = function(opt){
1247		return this.each(function(){
1248			$(this).data('ScrollGallery', new ScrollGallery($.extend(opt,{holder:this})));
1249		});
1250	};
1251}(jQuery));
1252
1253/*
1254* touchSwipe - jQuery Plugin
1255* https://github.com/mattbryson/TouchSwipe-Jquery-Plugin
1256* http://labs.skinkers.com/touchSwipe/
1257* http://plugins.jquery.com/project/touchSwipe
1258*
1259* Copyright (c) 2010 Matt Bryson (www.skinkers.com)
1260* Dual licensed under the MIT or GPL Version 2 licenses.
1261*
1262* $version: 1.6.0
1263*/;(function(d){+"use strict";var n="left",m="right",c="up",u="down",b="in",v="out",k="none",q="auto",j="swipe",r="pinch",e="click",x="horizontal",s="vertical",h="all",f="start",i="move",g="end",o="cancel",a="ontouchstart" in window,w="TouchSwipe";var l={fingers:1,threshold:75,pinchThreshold:20,maxTimeThreshold:null,fingerReleaseThreshold:250,swipe:null,swipeLeft:null,swipeRight:null,swipeUp:null,swipeDown:null,swipeStatus:null,pinchIn:null,pinchOut:null,pinchStatus:null,click:null,triggerOnTouchEnd:true,triggerOnTouchLeave:false,allowPageScroll:"auto",fallbackToMouseEvents:true,excludedElements:"button, input, select, textarea, a, .noSwipe"};d.fn.swipe=function(A){var z=d(this),y=z.data(w);if(y&&typeof A==="string"){if(y[A]){return y[A].apply(this,Array.prototype.slice.call(arguments,1))}else{d.error("Method "+A+" does not exist on jQuery.swipe")}}else{if(!y&&(typeof A==="object"||!A)){return t.apply(this,arguments)}}return z};d.fn.swipe.defaults=l;d.fn.swipe.phases={PHASE_START:f,PHASE_MOVE:i,PHASE_END:g,PHASE_CANCEL:o};d.fn.swipe.directions={LEFT:n,RIGHT:m,UP:c,DOWN:u,IN:b,OUT:v};d.fn.swipe.pageScroll={NONE:k,HORIZONTAL:x,VERTICAL:s,AUTO:q};d.fn.swipe.fingers={ONE:1,TWO:2,THREE:3,ALL:h};function t(y){if(y&&(y.allowPageScroll===undefined&&(y.swipe!==undefined||y.swipeStatus!==undefined))){y.allowPageScroll=k}if(!y){y={}}y=d.extend({},d.fn.swipe.defaults,y);return this.each(function(){var A=d(this);var z=A.data(w);if(!z){z=new p(this,y);A.data(w,z)}})}function p(S,af){var aF=(a||!af.fallbackToMouseEvents),ax=aF?"touchstart":"mousedown",U=aF?"touchmove":"mousemove",au=aF?"touchend":"mouseup",D=aF?null:"mouseleave",R="touchcancel";var ac=0;var N=null;var ag=0;var aB=0;var A=0;var ai=1;var aH=0;var H=d(S);var O="start";var aE=0;var ah=null;var I=0;var Y=0;var aA=0;var aJ=0;try{H.bind(ax,ar);H.bind(R,M)}catch(aC){d.error("events not supported "+ax+","+R+" on jQuery.swipe")}this.enable=function(){H.bind(ax,ar);H.bind(R,M);return H};this.disable=function(){Q();return H};this.destroy=function(){Q();H.data(w,null);return H};function ar(aM){if(X()){return}if(d(aM.target).closest(af.excludedElements,H).length>0){return}var aN=aM.originalEvent;var aL,aK=a?aN.touches[0]:aN;O=f;if(a){aE=aN.touches.length}else{aM.preventDefault()}ac=0;N=null;aH=null;ag=0;aB=0;A=0;ai=1;pinchDistance=0;ah=T();z();if(!a||(aE===af.fingers||af.fingers===h)||ao()){aI(0,aK);I=B();if(aE==2){aI(1,aN.touches[1]);aB=A=Z(ah[0].start,ah[1].start)}if(af.swipeStatus||af.pinchStatus){aL=aD(aN,O)}}else{aL=false}if(aL===false){O=o;aD(aN,O);return aL}else{aj(true)}}function P(aN){var aQ=aN.originalEvent;if(O===g||O===o||ae()){return}var aM,aL=a?aQ.touches[0]:aQ;var aO=V(aL);Y=B();if(a){aE=aQ.touches.length}O=i;if(aE==2){if(aB==0){aI(1,aQ.touches[1]);aB=A=Z(ah[0].start,ah[1].start)}else{V(aQ.touches[1]);A=Z(ah[0].end,ah[1].end);aH=an(ah[0].end,ah[1].end)}ai=y(aB,A);pinchDistance=Math.abs(aB-A)}if((aE===af.fingers||af.fingers===h)||!a||ao()){N=aq(aO.start,aO.end);C(aN,N);ac=G(aO.start,aO.end);ag=L();if(af.swipeStatus||af.pinchStatus){aM=aD(aQ,O)}if(!af.triggerOnTouchEnd||af.triggerOnTouchLeave){var aK=true;if(af.triggerOnTouchLeave){var aP=at(this);aK=az(aO.end,aP)}if(!af.triggerOnTouchEnd&&aK){O=aG(i)}else{if(af.triggerOnTouchLeave&&!aK){O=aG(g)}}if(O==o||O==g){aD(aQ,O)}}}else{O=o;aD(aQ,O)}if(aM===false){O=o;aD(aQ,O)}}function aa(aM){var aO=aM.originalEvent;if(a){if(aO.touches.length>0){av();return true}}if(ae()){aE=aJ}aM.preventDefault();Y=B();if(af.triggerOnTouchEnd||(af.triggerOnTouchEnd==false&&O===i)){O=g;var aL=((aE===af.fingers||af.fingers===h)||!a);var aK=ah[0].end.x!==0;var aN=aL&&aK&&(am()||ay());if(aN){aD(aO,O)}else{O=o;aD(aO,O)}}else{if(O===i){O=o;aD(aO,O)}}aj(false)}function M(){aE=0;Y=0;I=0;aB=0;A=0;ai=1;z();aj(false)}function W(aK){var aL=aK.originalEvent;if(af.triggerOnTouchLeave){O=aG(g);aD(aL,O)}}function Q(){H.unbind(ax,ar);H.unbind(R,M);H.unbind(U,P);H.unbind(au,aa);if(D){H.unbind(D,W)}aj(false)}function aG(aN){var aM=aN;var aL=ap();var aK=ad();if(!aL){aM=o}else{if(aK&&aN==i&&(!af.triggerOnTouchEnd||af.triggerOnTouchLeave)){aM=g}else{if(!aK&&aN==g&&af.triggerOnTouchLeave){aM=o}}}return aM}function aD(aM,aK){var aL=undefined;if(ab()){aL=al(aM,aK,j)}if(ao()&&aL!==false){aL=al(aM,aK,r)}if(K()&&aL!==false){aL=al(aM,aK,e)}if(aK===o){M(aM)}if(aK===g){if(a){if(aM.touches.length==0){M(aM)}}else{M(aM)}}return aL}function al(aN,aK,aM){var aL=undefined;if(aM==j){if(af.swipeStatus){aL=af.swipeStatus.call(H,aN,aK,N||null,ac||0,ag||0,aE);if(aL===false){return false}}if(aK==g&&ay()){if(af.swipe){aL=af.swipe.call(H,aN,N,ac,ag,aE);if(aL===false){return false}}switch(N){case n:if(af.swipeLeft){aL=af.swipeLeft.call(H,aN,N,ac,ag,aE)}break;case m:if(af.swipeRight){aL=af.swipeRight.call(H,aN,N,ac,ag,aE)}break;case c:if(af.swipeUp){aL=af.swipeUp.call(H,aN,N,ac,ag,aE)}break;case u:if(af.swipeDown){aL=af.swipeDown.call(H,aN,N,ac,ag,aE)}break}}}if(aM==r){if(af.pinchStatus){aL=af.pinchStatus.call(H,aN,aK,aH||null,pinchDistance||0,ag||0,aE,ai);if(aL===false){return false}}if(aK==g&&am()){switch(aH){case b:if(af.pinchIn){aL=af.pinchIn.call(H,aN,aH||null,pinchDistance||0,ag||0,aE,ai)}break;case v:if(af.pinchOut){aL=af.pinchOut.call(H,aN,aH||null,pinchDistance||0,ag||0,aE,ai)}break}}}if(aM==e){if(aK===o){if(af.click&&(aE===1||!a)&&(isNaN(ac)||ac===0)){aL=af.click.call(H,aN,aN.target)}}}return aL}function ad(){if(af.threshold!==null){return ac>=af.threshold}return true}function ak(){if(af.pinchThreshold!==null){return pinchDistance>=af.pinchThreshold}return true}function ap(){var aK;if(af.maxTimeThreshold){if(ag>=af.maxTimeThreshold){aK=false}else{aK=true}}else{aK=true}return aK}function C(aK,aL){if(af.allowPageScroll===k||ao()){aK.preventDefault()}else{var aM=af.allowPageScroll===q;switch(aL){case n:if((af.swipeLeft&&aM)||(!aM&&af.allowPageScroll!=x)){aK.preventDefault()}break;case m:if((af.swipeRight&&aM)||(!aM&&af.allowPageScroll!=x)){aK.preventDefault()}break;case c:if((af.swipeUp&&aM)||(!aM&&af.allowPageScroll!=s)){aK.preventDefault()}break;case u:if((af.swipeDown&&aM)||(!aM&&af.allowPageScroll!=s)){aK.preventDefault()}break}}}function am(){return ak()}function ao(){return !!(af.pinchStatus||af.pinchIn||af.pinchOut)}function aw(){return !!(am()&&ao())}function ay(){var aK=ap();var aM=ad();var aL=aM&&aK;return aL}function ab(){return !!(af.swipe||af.swipeStatus||af.swipeLeft||af.swipeRight||af.swipeUp||af.swipeDown)}function E(){return !!(ay()&&ab())}function K(){return !!(af.click)}function av(){aA=B();aJ=event.touches.length+1}function z(){aA=0;aJ=0}function ae(){var aK=false;if(aA){var aL=B()-aA;if(aL<=af.fingerReleaseThreshold){aK=true}}return aK}function X(){return !!(H.data(w+"_intouch")===true)}function aj(aK){if(aK===true){H.bind(U,P);H.bind(au,aa);if(D){H.bind(D,W)}}else{H.unbind(U,P,false);H.unbind(au,aa,false);
1263if(D){H.unbind(D,W,false)}}H.data(w+"_intouch",aK===true)}function aI(aL,aK){var aM=aK.identifier!==undefined?aK.identifier:0;ah[aL].identifier=aM;ah[aL].start.x=ah[aL].end.x=aK.pageX;ah[aL].start.y=ah[aL].end.y=aK.pageY;return ah[aL]}function V(aK){var aM=aK.identifier!==undefined?aK.identifier:0;var aL=J(aM);aL.end.x=aK.pageX;aL.end.y=aK.pageY;return aL}function J(aL){for(var aK=0;aK<ah.length;aK++){if(ah[aK].identifier==aL){return ah[aK]}}}function T(){var aK=[];for(var aL=0;aL<=5;aL++){aK.push({start:{x:0,y:0},end:{x:0,y:0},identifier:0})}return aK}function L(){return Y-I}function Z(aN,aM){var aL=Math.abs(aN.x-aM.x);var aK=Math.abs(aN.y-aM.y);return Math.round(Math.sqrt(aL*aL+aK*aK))}function y(aK,aL){var aM=(aL/aK)*1;return aM.toFixed(2)}function an(){if(ai<1){return v}else{return b}}function G(aL,aK){return Math.round(Math.sqrt(Math.pow(aK.x-aL.x,2)+Math.pow(aK.y-aL.y,2)))}function F(aN,aL){var aK=aN.x-aL.x;var aP=aL.y-aN.y;var aM=Math.atan2(aP,aK);var aO=Math.round(aM*180/Math.PI);if(aO<0){aO=360-Math.abs(aO)}return aO}function aq(aL,aK){var aM=F(aL,aK);if((aM<=45)&&(aM>=0)){return n}else{if((aM<=360)&&(aM>=315)){return n}else{if((aM>=135)&&(aM<=225)){return m}else{if((aM>45)&&(aM<135)){return u}else{return c}}}}}function B(){var aK=new Date();return aK.getTime()}function at(aK){aK=d(aK);var aM=aK.offset();var aL={left:aM.left,right:aM.left+aK.outerWidth(),top:aM.top,bottom:aM.top+aK.outerHeight()};return aL}function az(aK,aL){return(aK.x>aL.left&&aK.x<aL.right&&aK.y>aL.top&&aK.y<aL.bottom)}}})(jQuery);
1264
1265/*
1266 * jQuery SlideShow plugin
1267 */
1268;(function($){
1269	function FadeGallery(options) {
1270		this.options = $.extend({
1271			slides: 'ul.slideset > li',
1272			activeClass:'active',
1273			disabledClass:'disabled',
1274			btnPrev: 'a.btn-prev',
1275			btnNext: 'a.btn-next',
1276			generatePagination: false,
1277			pagerList: '<ul>',
1278			pagerListItem: '<li><a href="#"></a></li>',
1279			pagerListItemText: 'a',
1280			pagerLinks: '.pagination li',
1281			currentNumber: 'span.current-num',
1282			totalNumber: 'span.total-num',
1283			btnPlay: '.btn-play',
1284			btnPause: '.btn-pause',
1285			btnPlayPause: '.btn-play-pause',
1286			galleryReadyClass: 'gallery-js-ready',
1287			autorotationActiveClass: 'autorotation-active',
1288			autorotationDisabledClass: 'autorotation-disabled',
1289			autorotationStopAfterClick: false,
1290			circularRotation: true,
1291			switchSimultaneously: true,
1292			disableWhileAnimating: false,
1293			disableFadeIE: false,
1294			autoRotation: false,
1295			pauseOnHover: true,
1296			autoHeight: false,
1297			useSwipe: false,
1298			switchTime: 4000,
1299			animSpeed: 600,
1300			event:'click'
1301		}, options);
1302		this.init();
1303	}
1304	FadeGallery.prototype = {
1305		init: function() {
1306			if(this.options.holder) {
1307				this.findElements();
1308				this.initStructure();
1309				this.attachEvents();
1310				this.refreshState(true);
1311				this.autoRotate();
1312				this.makeCallback('onInit', this);
1313			}
1314		},
1315		findElements: function() {
1316			// control elements
1317			this.gallery = $(this.options.holder).addClass(this.options.galleryReadyClass);
1318			this.slides = this.gallery.find(this.options.slides);
1319			this.slidesHolder = this.slides.eq(0).parent();
1320			this.stepsCount = this.slides.length;
1321			this.btnPrev = this.gallery.find(this.options.btnPrev);
1322			this.btnNext = this.gallery.find(this.options.btnNext);
1323			this.currentIndex = 0;
1324			
1325			// disable fade effect in old IE
1326			if(this.options.disableFadeIE && $.browser.msie && $.browser.version < 9) {
1327				this.options.animSpeed = 0;
1328			}
1329			
1330			// create gallery pagination
1331			if(typeof this.options.generatePagination === 'string') {
1332				this.pagerHolder = this.gallery.find(this.options.generatePagination).empty();
1333				this.pagerList = $(this.options.pagerList).appendTo(this.pagerHolder);
1334				for(var i = 0; i < this.stepsCount; i++) {
1335					$(this.options.pagerListItem).appendTo(this.pagerList).find(this.options.pagerListItemText).text(i+1);
1336				}
1337				this.pagerLinks = this.pagerList.children();
1338			} else {
1339				this.pagerLinks = this.gallery.find(this.options.pagerLinks);
1340			}
1341			
1342			// get start index
1343			var activeSlide = this.slides.filter('.'+this.options.activeClass);
1344			if(activeSlide.length) {
1345				this.currentIndex = this.slides.index(activeSlide);
1346			}
1347			this.prevIndex = this.currentIndex;
1348			
1349			// autorotation control buttons
1350			this.btnPlay = this.gallery.find(this.options.btnPlay);
1351			this.btnPause = this.gallery.find(this.options.btnPause);
1352			this.btnPlayPause = this.gallery.find(this.options.btnPlayPause);
1353			
1354			// misc elements
1355			this.curNum = this.gallery.find(this.options.currentNumber);
1356			this.allNum = this.gallery.find(this.options.totalNumber);
1357			
1358			// handle flexible layout
1359			$(window).bind('load resize orientationchange', $.proxy(this.onWindowResize, this));
1360		},
1361		initStructure: function() {
1362			this.slides.css({display:'block',opacity:0}
1362).eq(this.currentIndex).css({
1363				opacity:''
1364			});
1365		},
1366		attachEvents: function() {
1367			var self = this;
1368			this.btnPrev.bind(this.options.event, function(e){
1369				self.prevSlide();
1370				if(self.options.autorotationStopAfterClick) {
1371					self.stopRotation();
1372				}
1373				e.preventDefault();
1374			});
1375			this.btnNext.bind(this.options.event, function(e){
1376				self.nextSlide();
1377				if(self.options.autorotationStopAfterClick) {
1378					self.stopRotation();
1379				}
1380				e.preventDefault();
1381			});
1382			this.pagerLinks.each(function(ind, obj){
1383				$(obj).bind(self.options.event, function(e){
1384					self.numSlide(ind);
1385					if(self.options.autorotationStopAfterClick) {
1386						self.stopRotation();
1387					}
1388					e.preventDefault();
1389				});
1390			});
1391			
1392			// autorotation buttons handler
1393			this.btnPlay.bind(this.options.event, function(e){
1394				self.startRotation();
1395				e.preventDefault();
1396			});
1397			this.btnPause.bind(this.options.event, function(e){
1398				self.stopRotation();
1399				e.preventDefault();
1400			});
1401			this.btnPlayPause.bind(this.options.event, function(e){
1402				if(!self.gallery.hasClass(self.options.autorotationActiveClass)) {
1403					self.startRotation();
1404				} else {
1405					self.stopRotation();
1406				}
1407				e.preventDefault();
1408			});
1409
1410			// swipe gestures handler
1411			if(this.options.useSwipe && $.fn.swipe) {
1412				this.gallery.swipe({
1413					excludedElements: '',
1414					fallbackToMouseEvents: false,
1415					swipeLeft: function() {
1416						self.nextSlide();
1417					},
1418					swipeRight: function() {
1419						self.prevSlide();
1420					}
1421				});
1422			}
1423			
1424			// pause on hover handling
1425			if(this.options.pauseOnHover) {
1426				this.gallery.hover(function(){
1427					if(self.options.autoRotation) {
1428						self.galleryHover = true;
1429						self.pauseRotation();
1430					}
1431				}, function(){
1432					if(self.options.autoRotation) {
1433						self.galleryHover = false;
1434						self.resumeRotation();
1435					}
1436				});
1437			}
1438		},
1439		onWindowResize: function(){
1440			if(this.options.autoHeight) {
1441				this.slidesHolder.css({height: this.slides.eq(this.currentIndex).outerHeight(true) });
1442			}
1443		},
1444		prevSlide: function() {
1445			if(!(this.options.disableWhileAnimating && this.galleryAnimating)) {
1446				this.prevIndex = this.currentIndex;
1447				if(this.currentIndex > 0) {
1448					this.currentIndex--;
1449					this.switchSlide();
1450				} else if(this.options.circularRotation) {
1451					this.currentIndex = this.stepsCount - 1;
1452					this.switchSlide();
1453				}
1454			}
1455		},
1456		nextSlide: function(fromAutoRotation) {
1457			if(!(this.options.disableWhileAnimating && this.galleryAnimating)) {
1458				this.prevIndex = this.currentIndex;
1459				if(this.currentIndex < this.stepsCount - 1) {
1460					this.currentIndex++;
1461					this.switchSlide();
1462				} else if(this.options.circularRotation || fromAutoRotation === true) {
1463					this.currentIndex = 0;
1464					this.switchSlide();
1465				}
1466			}
1467		},
1468		numSlide: function(c) {
1469			if(this.currentIndex != c) {
1470				this.prevIndex = this.currentIndex;
1471				this.currentIndex = c;
1472				this.switchSlide();
1473			}
1474		},
1475		switchSlide: function() {
1476			var self = this;
1477			if(this.slides.length > 1) {
1478				this.galleryAnimating = true;
1479				if(!this.options.animSpeed) {
1480					this.slides.eq(this.prevIndex).css({opacity:0});
1481				} else {
1482					this.slides.eq(this.prevIndex).stop().animate({opacity:0}
1482,{duration: this.options.animSpeed});
1483				}
1484				
1485				this.switchNext = function() {
1486					if(!self.options.animSpeed) {
1487						self.slides.eq(self.currentIndex).css({opacity:''});
1488					} else {
1489						self.slides.eq(self.currentIndex).stop().animate({opacity:1},{duration: self.options.animSpeed});
1490					}
1491					setTimeout(function() {
1492						self.slides.eq(self.currentIndex).css({opacity:''});
1493						self.galleryAnimating = false;
1494						self.autoRotate();
1495						
1496						// onchange callback
1497						self.makeCallback('onChange', self);
1498					}, self.options.animSpeed);
1499				}
1500				
1501				if(this.options.switchSimultaneously) {
1502					self.switchNext();
1503				} else {
1504					clearTimeout(this.switchTimer);
1505					this.switchTimer = setTimeout(function(){
1506						self.switchNext();
1507					}, this.options.animSpeed);
1508				}
1509				this.refreshState();
1510				
1511				// onchange callback
1512				this.makeCallback('onBeforeChange', this);
1513			}
1514		},
1515		refreshState: function(initial) {
1516			this.slides.removeClass(this.options.activeClass).eq(this.currentIndex).addClass(this.options.activeClass);
1517			this.pagerLinks.removeClass(this.options.activeClass).eq(this.currentIndex).addClass(this.options.activeClass);
1518			this.curNum.html(this.currentIndex+1);
1519			this.allNum.html(this.stepsCount);
1520			
1521			// initial refresh
1522			if(this.options.autoHeight) {
1523				if(initial) {
1524					this.slidesHolder.css({height: this.slides.eq(this.currentIndex).outerHeight(true) });
1525				} else {
1526					this.slidesHolder.stop().animate({height: this.slides.eq(this.currentIndex).outerHeight(true)}, {duration: this.options.animSpeed});
1527				}
1528			}
1529			
1530			// disabled state
1531			if(!this.options.circularRotation) {
1532				this.btnPrev.add(this.btnNext).removeClass(this.options.disabledClass);
1533				if(this.currentIndex === 0) this.btnPrev.addClass(this.options.disabledClass);
1534				if(this.currentIndex === this.stepsCount - 1) this.btnNext.addClass(this.options.disabledClass);
1535			}
1536		},
1537		startRotation: function() {
1538			this.options.autoRotation = true;
1539			this.galleryHover = false;
1540			this.autoRotationStopped = false;
1541			this.resumeRotation();
1542		},
1543		stopRotation: function() {
1544			this.galleryHover = true;
1545			this.autoRotationStopped = true;
1546			this.pauseRotation();
1547		},
1548		pauseRotation: function() {
1549			this.gallery.addClass(this.options.autorotationDisabledClass);
1550			this.gallery.removeClass(this.options.autorotationActiveClass);
1551			clearTimeout(this.timer);
1552		},
1553		resumeRotation: function() {
1554			if(!this.autoRotationStopped) {
1555				this.gallery.addClass(this.options.autorotationActiveClass);
1556				this.gallery.removeClass(this.options.autorotationDisabledClass);
1557				this.autoRotate();
1558			}
1559		},
1560		autoRotate: function() {
1561			var self = this;
1562			clearTimeout(this.timer);
1563			if(this.options.autoRotation && !this.galleryHover && !this.autoRotationStopped) {
1564				this.gallery.addClass(this.options.autorotationActiveClass);
1565				this.timer = setTimeout(function(){
1566					self.nextSlide(true);
1567				}, this.options.switchTime);
1568			} else {
1569				this.pauseRotation();
1570			}
1571		},
1572		makeCallback: function(name) {
1573			if(typeof this.options[name] === 'function') {
1574				var args = Array.prototype.slice.call(arguments);
1575				args.shift();
1576				this.options[name].apply(this, args);
1577			}
1578		}
1579	}
1580
1581	// jquery plugin
1582	$.fn.fadeGallery = function(opt){
1583		return this.each(function(){
1584			$(this).data('FadeGallery', new FadeGallery($.extend(opt,{holder:this})));
1585		});
1586	}
1587}(jQuery));
1588
1589/*
1590* touchSwipe - jQuery Plugin
1591* https://github.com/mattbryson/TouchSwipe-Jquery-Plugin
1592* http://labs.skinkers.com/touchSwipe/
1593* http://plugins.jquery.com/project/touchSwipe
1594*
1595* Copyright (c) 2010 Matt Bryson (www.skinkers.com)
1596* Dual licensed under the MIT or GPL Version 2 licenses.
1597*
1598* $version: 1.6.0
1599*/;(function(d){+"use strict";var n="left",m="right",c="up",u="down",b="in",v="out",k="none",q="auto",j="swipe",r="pinch",e="click",x="horizontal",s="vertical",h="all",f="start",i="move",g="end",o="cancel",a="ontouchstart" in window,w="TouchSwipe";var l={fingers:1,threshold:75,pinchThreshold:20,maxTimeThreshold:null,fingerReleaseThreshold:250,swipe:null,swipeLeft:null,swipeRight:null,swipeUp:null,swipeDown:null,swipeStatus:null,pinchIn:null,pinchOut:null,pinchStatus:null,click:null,triggerOnTouchEnd:true,triggerOnTouchLeave:false,allowPageScroll:"auto",fallbackToMouseEvents:true,excludedElements:"button, input, select, textarea, a, .noSwipe"};d.fn.swipe=function(A){var z=d(this),y=z.data(w);if(y&&typeof A==="string"){if(y[A]){return y[A].apply(this,Array.prototype.slice.call(arguments,1
1599))}else{d.error("Method "+A+" does not exist on jQuery.swipe")}}else{if(!y&&(typeof A==="object"||!A)){return t.apply(this,arguments)}}return z};d.fn.swipe.defaults=l;d.fn.swipe.phases={PHASE_START:f,PHASE_MOVE:i,PHASE_END:g,PHASE_CANCEL:o};d.fn.swipe.directions={LEFT:n,RIGHT:m,UP:c,DOWN:u,IN:b,OUT:v};d.fn.swipe.pageScroll={NONE:k,HORIZONTAL:x,VERTICAL:s,AUTO:q};d.fn.swipe.fingers={ONE:1,TWO:2,THREE:3,ALL:h};function t(y){if(y&&(y.allowPageScroll===undefined&&(y.swipe!==undefined||y.swipeStatus!==undefined))){y.allowPageScroll=k}if(!y){y={}}y=d.extend({},d.fn.swipe.defaults,y);return this.each(function(){var A=d(this);var z=A.data(w);if(!z){z=new p(this,y);A.data(w,z)}})}function p(S,af){var aF=(a||!af.fallbackToMouseEvents),ax=aF?"touchstart":"mousedown",U=aF?"touchmove":"mousemove",au=aF?"touchend":"mouseup",D=aF?null:"mouseleave",R="touchcancel";var ac=0;var N=null;var ag=0;var aB=0;var A=0;var ai=1;var aH=0;var H=d(S);var O="start";var aE=0;var ah=null;var I=0;var Y=0;var aA=0;var aJ=0;try{H.bind(ax,ar);H.bind(R,M)}catch(aC){d.error("events not supported "+ax+","+R+" on jQuery.swipe")}this.enable=function(){H.bind(ax,ar);H.bind(R,M);return H};this.disable=function(){Q();return H};this.destroy=function(){Q();H.data(w,null);return H};function ar(aM){if(X()){return}if(d(aM.target).closest(af.excludedElements,H).length>0){return}var aN=aM.originalEvent;var aL,aK=a?aN.touches[0]:aN;O=f;if(a){aE=aN.touches.length}else{aM.preventDefault()}ac=0;N=null;aH=null;ag=0;aB=0;A=0;ai=1;pinchDistance=0;ah=T();z();if(!a||(aE===af.fingers||af.fingers===h)||ao()){aI(0,aK);I=B();if(aE==2){aI(1,aN.touches[1]);aB=A=Z(ah[0].start,ah[1].start)}if(af.swipeStatus||af.pinchStatus){aL=aD(aN,O)}}else{aL=false}if(aL===false){O=o;aD(aN,O);return aL}else{aj(true)}}function P(aN){var aQ=aN.originalEvent;if(O===g||O===o||ae()){return}var aM,aL=a?aQ.touches[0]:aQ;var aO=V(aL);Y=B();if(a){aE=aQ.touches.length}O=i;if(aE==2){if(aB==0){aI(1,aQ.touches[1]);aB=A=Z(ah[0].start,ah[1].start)}else{V(aQ.touches[1]);A=Z(ah[0].end,ah[1].end);aH=an(ah[0].end,ah[1].end)}ai=y(aB,A);pinchDistance=Math.abs(aB-A)}if((aE===af.fingers||af.fingers===h)||!a||ao()){N=aq(aO.start,aO.end);C(aN,N);ac=G(aO.start,aO.end);ag=L();if(af.swipeStatus||af.pinchStatus){aM=aD(aQ,O)}if(!af.triggerOnTouchEnd||af.triggerOnTouchLeave){var aK=true;if(af.triggerOnTouchLeave){var aP=at(this);aK=az(aO.end,aP)}if(!af.triggerOnTouchEnd&&aK){O=aG(i)}else{if(af.triggerOnTouchLeave&&!aK){O=aG(g)}}if(O==o||O==g){aD(aQ,O)}}}else{O=o;aD(aQ,O)}if(aM===false){O=o;aD(aQ,O)}}function aa(aM){var aO=aM.originalEvent;if(a){if(aO.touches.length>0){av();return true}}if(ae()){aE=aJ}aM.preventDefault();Y=B();if(af.triggerOnTouchEnd||(af.triggerOnTouchEnd==false&&O===i)){O=g;var aL=((aE===af.fingers||af.fingers===h)||!a);var aK=ah[0].end.x!==0;var aN=aL&&aK&&(am()||ay());if(aN){aD(aO,O)}else{O=o;aD(aO,O)}}else{if(O===i){O=o;aD(aO,O)}}aj(false)}function M(){aE=0;Y=0;I=0;aB=0;A=0;ai=1;z();aj(false)}function W(aK){var aL=aK.originalEvent;if(af.triggerOnTouchLeave){O=aG(g);aD(aL,O)}}function Q(){H.unbind(ax,ar);H.unbind(R,M);H.unbind(U,P);H.unbind(au,aa);if(D){H.unbind(D,W)}aj(false)}function aG(aN){var aM=aN;var aL=ap();var aK=ad();if(!aL){aM=o}else{if(aK&&aN==i&&(!af.triggerOnTouchEnd||af.triggerOnTouchLeave)){aM=g}else{if(!aK&&aN==g&&af.triggerOnTouchLeave){aM=o}}}return aM}function aD(aM,aK){var aL=undefined;if(ab()){aL=al(aM,aK,j)}if(ao()&&aL!==false){aL=al(aM,aK,r)}if(K()&&aL!==false){aL=al(aM,aK,e)}if(aK===o){M(aM)}if(aK===g){if(a){if(aM.touches.length==0){M(aM)}}else{M(aM)}}return aL}function al(aN,aK,aM){var aL=undefined;if(aM==j){if(af.swipeStatus){aL=af.swipeStatus.call(H,aN,aK,N||null,ac||0,ag||0,aE);if(aL===false){return false}}if(aK==g&&ay()){if(af.swipe){aL=af.swipe.call(H,aN,N,ac,ag,aE);if(aL===false){return false}}switch(N){case n:if(af.swipeLeft){aL=af.swipeLeft.call(H,aN,N,ac,ag,aE)}break;case m:if(af.swipeRight){aL=af.swipeRight.call(H,aN,N,ac,ag,aE)}break;case c:if(af.swipeUp){aL=af.swipeUp.call(H,aN,N,ac,ag,aE)}break;case u:if(af.swipeDown){aL=af.swipeDown.call(H,aN,N,ac,ag,aE)}break}}}if(aM==r){if(af.pinchStatus){aL=af.pinchStatus.call(H,aN,aK,aH||null,pinchDistance||0,ag||0,aE,ai);if(aL===false){return false}}if(aK==g&&am()){switch(aH){case b:if(af.pinchIn){aL=af.pinchIn.call(H,aN,aH||null,pinchDistance||0,ag||0,aE,ai)}break;case v:if(af.pinchOut){aL=af.pinchOut.call(H,aN,aH||null,pinchDistance||0,ag||0,aE,ai)}break}}}if(aM==e){if(aK===o){if(af.click&&(aE===1||!a)&&(isNaN(ac)||ac===0)){aL=af.click.call(H,aN,aN.target)}}}return aL}function ad(){if(af.threshold!==null){return ac>=af.threshold}return true}function ak(){if(af.pinchThreshold!==null){return pinchDistance>=af.pinchThreshold}return true}function ap(){var aK;if(af.maxTimeThreshold){if(ag>=af.maxTimeThreshold){aK=false}else{aK=true}}else{aK=true}return aK}function C(aK,aL){if(af.allowPageScroll===k||ao()){aK.preventDefault()}else{var aM=af.allowPageScroll===q;switch(aL){case n:if((af.swipeLeft&&aM)||(!aM&&af.allowPageScroll!=x)){aK.preventDefault()}break;case m:if((af.swipeRight&&aM)||(!aM&&af.allowPageScroll!=x)){aK.preventDefault()}break;case c:if((af.swipeUp&&aM)||(!aM&&af.allowPageScroll!=s)){aK.preventDefault()}break;case u:if((af.swipeDown&&aM)||(!aM&&af.allowPageScroll!=s)){aK.preventDefault()}break}}}function am(){return ak()}function ao(){return !!(af.pinchStatus||af.pinchIn||af.pinchOut)}function aw(){return !!(am()&&ao())}function ay(){var aK=ap();var aM=ad();var aL=aM&&aK;return aL}function ab(){return !!(af.swipe||af.swipeStatus||af.swipeLeft||af.swipeRight||af.swipeUp||af.swipeDown)}function E(){return !!(ay()&&ab())}function K(){return !!(af.click)}function av(){aA=B();aJ=event.touches.length+1}function z(){aA=0;aJ=0}function ae(){var aK=false;if(aA){var aL=B()-aA;if(aL<=af.fingerReleaseThreshold){aK=true}}return aK}function X(){return !!(H.data(w+"_intouch")===true)}function aj(aK){if(aK===true){H.bind(U,P);H.bind(au,aa);if(D){H.bind(D,W)}}else{H.unbind(U,P,false);H.unbind(au,aa,false);
1599if(D){H.unbind(D,W,false)}}H.data(w+"_intouch",aK===true)}function aI(aL,aK){var aM=aK.identifier!==undefined?aK.identifier:0;ah[aL].identifier=aM;ah[aL].start.x=ah[aL].end.x=aK.pageX;ah[aL].start.y=ah[aL].end.y=aK.pageY;return ah[aL]}function V(aK){var aM=aK.identifier!==undefined?aK.identifier:0;var aL=J(aM);aL.end.x=aK.pageX;aL.end.y=aK.pageY;return aL}function J(aL){for(var aK=0;aK<ah.length;aK++){if(ah[aK].identifier==aL){return ah[aK]}}}function T(){var aK=[];for(var aL=0;aL<=5;aL++){aK.push({start:{x:0,y:0},end:{x:0,y:0},identifier:0})}return aK}function L(){return Y-I}function Z(aN,aM){var aL=Math.abs(aN.x-aM.x);var aK=Math.abs(aN.y-aM.y);return Math.round(Math.sqrt(aL*aL+aK*aK))}function y(aK,aL){var aM=(aL/aK)*1;return aM.toFixed(2)}function an(){if(ai<1){return v}else{return b}}function G(aL,aK){return Math.round(Math.sqrt(Math.pow(aK.x-aL.x,2)+Math.pow(aK.y-aL.y,2)))}function F(aN,aL){var aK=aN.x-aL.x;var aP=aL.y-aN.y;var aM=Math.atan2(aP,aK);var aO=Math.round(aM*180/Math.PI);if(aO<0){aO=360-Math.abs(aO)}return aO}function aq(aL,aK){var aM=F(aL,aK);if((aM<=45)&&(aM>=0)){return n}else{if((aM<=360)&&(aM>=315)){return n}else{if((aM>=135)&&(aM<=225)){return m}else{if((aM>45)&&(aM<135)){return u}else{return c}}}}}function B(){var aK=new Date();return aK.getTime()}function at(aK){aK=d(aK);var aM=aK.offset();var aL={left:aM.left,right:aM.left+aK.outerWidth(),top:aM.top,bottom:aM.top+aK.outerHeight()};return aL}function az(aK,aL){return(aK.x>aL.left&&aK.x<aL.right&&aK.y>aL.top&&aK.y<aL.bottom)}}})(jQuery);
1600
1601// add z-index to elements
1602function initItemsZindex() {
1603	new zIndexOrder({
1604		selector: '.nav li'
1605	});
1606}
1607
1608// zIndex order module
1609function zIndexOrder(options) {
1610	this.options = {
1611		context: null,
1612		selector: null,
1613		reverse: true,
1614		startIndex: 0
1615	};
1616	for(var p in options) {
1617		if(options.hasOwnProperty(p)) {
1618			this.options[p] = options[p];
1619		}
1620	}
1621	this.init();
1622}
1623zIndexOrder.prototype = {
1624	init: function() {
1625		if(this.options.selector) {
1626			this.elements = lib.queryElementsBySelector(this.options.selector, this.options.context);
1627			if(this.elements.length) {
1628				this.setIndexes();
1629			}
1630		}
1631	},
1632	setIndexes: function() {
1633		for(var i = 0, len = this.elements.length, curIndex; i < len; i++) {
1634			curIndex = i + (this.options.startIndex || 1);
1635			this.elements[this.options.reverse ? len - i - 1 : i].style.zIndex = curIndex;
1636		}
1637	}
1638};
1639
1640/*
1641 * Utility module
1642 */
1643lib = {
1644	hasClass: function(el,cls) {
1645		return el && el.className ? el.className.match(new RegExp('(\\s|^)'+cls+'(\\s|$)')) : false;
1646	},
1647	addClass: function(el,cls) {
1648		if (el && !this.hasClass(el,cls)) el.className += " "+cls;
1649	},
1650	removeClass: function(el,cls) {
1651		if (el && this.hasClass(el,cls)) {el.className=el.className.replace(new RegExp('(\\s|^)'+cls+'(\\s|$)'),' ');}
1652	},
1653	extend: function(obj) {
1654		for(var i = 1; i < arguments.length; i++) {
1655			for(var p in arguments[i]) {
1656				if(arguments[i].hasOwnProperty(p)) {
1657					obj[p] = arguments[i][p];
1658				}
1659			}
1660		}
1661		return obj;
1662	},
1663	each: function(obj, callback) {
1664		var property, len;
1665		if(typeof obj.length === 'number') {
1666			for(property = 0, len = obj.length; property < len; property++) {
1667				if(callback.call(obj[property], property, obj[property]) === false) {
1668					break;
1669				}
1670			}
1671		} else {
1672			for(property in obj) {
1673				if(obj.hasOwnProperty(property)) {
1674					if(callback.call(obj[property], property, obj[property]) === false) {
1675						break;
1676					}
1677				}
1678			}
1679		}
1680	},
1681	event: (function() {
1682		var fixEvent = function(e) {
1683			e = e || window.event;
1684			if(e.isFixed) return e; else e.isFixed = true;
1685			if(!e.target) e.target = e.srcElement;
1686			e.preventDefault = e.preventDefault || function() {this.returnValue = false;};
1687			e.stopPropagation = e.stopPropagaton || function() {this.cancelBubble = true;};
1688			return e;
1689		};
1690		return {
1691			add: function(elem, event, handler) {
1692				if(!elem.events) {
1693					elem.events = {};
1694					elem.handle = function(e) {
1695						var ret, handlers = elem.events[e.type];
1696						e = fixEvent(e);
1697						for(var i = 0, len = handlers.length; i < len; i++) {
1698							if(handlers[i]) {
1699								ret = handlers[i].call(elem, e);
1700								if(ret === false) {
1701									e.preventDefault();
1702									e.stopPropagaton();
1703								}
1704							}
1705						}
1706					};
1707				}
1708				if(!elem.events[event]) {
1709					elem.events[event] = [];
1710					if(elem.addEventListener) elem.addEventListener(event, elem.handle, false);
1711					else if(elem.attachEvent) elem.attachEvent('on'+event, elem.handle);
1712				}
1713				elem.events[event].push(handler);
1714			},
1715			remove: function(elem, event, handler) {
1716				var handlers = elem.events[event];
1717				for(var i = handlers.length - 1; i >= 0; i--) {
1718					if(handlers[i] === handler) {
1719						handlers.splice(i,1);
1720					}
1721				}
1722				if(!handlers.length) {
1723					delete elem.events[event];
1724					if(elem.removeEventListener) elem.removeEventListener(event, elem.handle, false);
1725					else if(elem.detachEvent) elem.detachEvent('on'+event, elem.handle);
1726				}
1727			}
1728		};
1729	}()),
1730	queryElementsBySelector: function(selector, scope) {
1731		scope = scope || document;
1732		if(!selector) return [];
1733		if(selector === '>*') return scope.children;
1734		if(typeof document.querySelectorAll === 'function') {
1735			return scope.querySelectorAll(selector);
1736		}
1737		var selectors = selector.split(',');
1738		var resultList = [];
1739		for(var s = 0; s < selectors.length; s++) {
1740			var currentContext = [scope || document];
1741			var tokens = selectors[s].replace(/^\s+/,'').replace(/\s+$/,'').split(' ');
1742			for (var i = 0; i < tokens.length; i++) {
1743				token = tokens[i].replace(/^\s+/,'').replace(/\s+$/,'');
1744				if (token.indexOf('#') > -1) {
1745					var bits = token.split('#'), tagName = bits[0], id = bits[1];
1746					var element = document.getElementById(id);
1747					if (element && tagName && element.nodeName.toLowerCase() != tagName) {
1748						return [];
1749					}
1750					currentContext = element ? [element] : [];
1751					continue;
1752				}
1753				if (token.indexOf('.') > -1) {
1754					var bits = token.split('.'), tagName = bits[0] || '*', className = bits[1], found = [], foundCount = 0;
1755					for (var h = 0; h < currentContext.length; h++) {
1756						var elements;
1757						if (tagName == '*') {
1758							elements = currentContext[h].getElementsByTagName('*');
1759						} else {
1760							elements = currentContext[h].getElementsByTagName(tagName);
1761						}
1762						for (var j = 0; j < elements.length; j++) {
1763							found[foundCount++] = elements[j];
1764						}
1765					}
1766					currentContext = [];
1767					var currentContextIndex = 0;
1768					for (var k = 0; k < found.length; k++) {
1769						if (found[k].className && found[k].className.match(new RegExp('(\\s|^)'+className+'(\\s|$)'))) {
1770							currentContext[currentContextIndex++] = found[k];
1771						}
1772					}
1773					continue;
1774				}
1775				if (token.match(/^(\w*)\[(\w+)([=~\|\^\$\*]?)=?"?([^\]"]*)"?\]$/)) {
1776					var tagName = RegExp.$1 || '*', attrName = RegExp.$2, attrOperator = RegExp.$3, attrValue = RegExp.$4;
1777					if(attrName.toLowerCase() == 'for' && this.browser.msie && this.browser.version < 8) {
1778						attrName = 'htmlFor';
1779					}
1780					var found = [], foundCount = 0;
1781					for (var h = 0; h < currentContext.length; h++) {
1782						var elements;
1783						if (tagName == '*') {
1784							elements = currentContext[h].getElementsByTagName('*');
1785						} else {
1786							elements = currentContext[h].getElementsByTagName(tagName);
1787						}
1788						for (var j = 0; elements[j]; j++) {
1789							found[foundCount++] = elements[j];
1790						}
1791					}
1792					currentContext = [];
1793					var currentContextIndex = 0, checkFunction;
1794					switch (attrOperator) {
1795						case '=': checkFunction = function(e) { return (e.getAttribute(attrName) == attrValue) }; break;
1796						case '~': checkFunction = function(e) { return (e.getAttribute(attrName).match(new RegExp('(\\s|^)'+attrValue+'(\\s|$)'))) }; break;
1797						case '|': checkFunction = function(e) { return (e.getAttribute(attrName).match(new RegExp('^'+attrValue+'-?'))) }; break;
1798						case '^': checkFunction = function(e) { return (e.getAttribute(attrName).indexOf(attrValue) == 0) }; break;
1799						case '$': checkFunction = function(e) { return (e.getAttribute(attrName).lastIndexOf(attrValue) == e.getAttribute(attrName).length - attrValue.length) }; break;
1800						case '*': checkFunction = function(e) { return (e.getAttribute(attrName).indexOf(attrValue) > -1) }; break;
1801						default : checkFunction = function(e) { return e.getAttribute(attrName) };
1802					}
1803					currentContext = [];
1804					var currentContextIndex = 0;
1805					for (var k = 0; k < found.length; k++) {
1806						if (checkFunction(found[k])) {
1807							currentContext[currentContextIndex++] = found[k];
1808						}
1809					}
1810					continue;
1811				}
1812				tagName = token;
1813				var found = [], foundCount = 0;
1814				for (var h = 0; h < currentContext.length; h++) {
1815					var elements = currentContext[h].getElementsByTagName(tagName);
1816					for (var j = 0; j < elements.length; j++) {
1817						found[foundCount++] = elements[j];
1818					}
1819				}
1820				currentContext = found;
1821			}
1822			resultList = [].concat(resultList,currentContext);
1823		}
1824		return resultList;
1825	},
1826	trim: function (str) {
1827		return str.replace(/^\s+/, '').replace(/\s+$/, '');
1828	},
1829	bind: function(f, scope, forceArgs){
1830		return function() {return f.apply(scope, typeof forceArgs !== 'undefined' ? [forceArgs] : arguments);};
1831	}
1832};
1833
1834// DOM ready handler
1835function bindReady(handler){
1836	var called = false;
1837	var ready = function() {
1838		if (called) return;
1839		called = true;
1840		handler();
1841	};
1842	if (document.addEventListener) {
1843		document.addEventListener('DOMContentLoaded', ready, false);
1844	} else if (document.attachEvent) {
1845		if (document.documentElement.doScroll && window == window.top) {
1846			var tryScroll = function(){
1847				if (called) return;
1848				if (!document.body) return;
1849				try {
1850					document.documentElement.doScroll('left');
1851					ready();
1852				} catch(e) {
1853					setTimeout(tryScroll, 0);
1854				}
1855			};
1856			tryScroll();
1857		}
1858		document.attachEvent('onreadystatechange', function(){
1859			if (document.readyState === 'complete') {
1860				ready();
1861			}
1862		});
1863	}
1864	if (window.addEventListener) window.addEventListener('load', ready, false);
1865	else if (window.attachEvent) window.attachEvent('onload', ready);
1866}
1867
1868
1869/*
1870 * JavaScript Custom Forms Module
1871 */
1872jcf = {
1873	// global options
1874	modules: {},
1875	plugins: {},
1876	baseOptions: {
1877		useNativeDropOnMobileDevices: true,
1878		unselectableClass:'jcf-unselectable',
1879		labelActiveClass:'jcf-label-active',
1880		labelDisabledClass:'jcf-label-disabled',
1881		classPrefix: 'jcf-class-',
1882		hiddenClass:'jcf-hidden',
1883		focusClass:'jcf-focus',
1884		wrapperTag: 'div'
1885	},
1886	// replacer function
1887	customForms: {
1888		setOptions: function(obj) {
1889			for(var p in obj) {
1890				if(obj.hasOwnProperty(p) && typeof obj[p] === 'object') {
1891					jcf.lib.extend(jcf.modules[p].prototype.defaultOptions, obj[p]);
1892				}
1893			}
1894		},
1895		replaceAll: function() {
1896			for(var k in jcf.modules) {
1897				var els = jcf.lib.queryBySelector(jcf.modules[k].prototype.selector);
1898				for(var i = 0; i<els.length; i++) {
1899					if(els[i].jcf) {
1900						// refresh form element state
1901						els[i].jcf.refreshState();
1902					} else {
1903						// replace form element
1904						if(!jcf.lib.hasClass(els[i], 'default') && jcf.modules[k].prototype.checkElement(els[i])) {
1905							new jcf.modules[k]({
1906								replaces:els[i]
1907							});
1908						}
1909					}
1910				}
1911			}
1912		},
1913		refreshAll: function() {
1914			for(var k in jcf.modules) {
1915				var els = jcf.lib.queryBySelector(jcf.modules[k].prototype.selector);
1916				for(var i = 0; i<els.length; i++) {
1917					if(els[i].jcf) {
1918						// refresh form element state
1919						els[i].jcf.refreshState();
1920					}
1921				}
1922			}
1923		},
1924		refreshElement: function(obj) {
1925			if(obj && obj.jcf) {
1926				obj.jcf.refreshState();
1927			}
1928		},
1929		destroyAll: function() {
1930			for(var k in jcf.modules) {
1931				var els = jcf.lib.queryBySelector(jcf.modules[k].prototype.selector);
1932				for(var i = 0; i<els.length; i++) {
1933					if(els[i].jcf) {
1934						els[i].jcf.destroy();
1935					}
1936				}
1937			}
1938		}
1939	},
1940	// detect device type
1941	isTouchDevice: (function() {
1942		try {
1943			return ('ontouchstart' in window) || window.DocumentTouch && document instanceof DocumentTouch;
1944		} catch (e) {
1945			return false;
1946		}
1947	}()),
1948	// define base module
1949	setBaseModule: function(obj) {
1950		jcf.customControl = function(opt){
1951			this.options = jcf.lib.extend({}, jcf.baseOptions, this.defaultOptions, opt);
1952			this.init();
1953		};
1954		for(var p in obj) {
1955			jcf.customControl.prototype[p] = obj[p];
1956		}
1957	},
1958	// add module to jcf.modules
1959	addModule: function(obj) {
1960		if(obj.name){
1961			// create new module proto class
1962			jcf.modules[obj.name] = function(){
1963				jcf.modules[obj.name].superclass.constructor.apply(this, arguments);
1964			};
1965			jcf.lib.inherit(jcf.modules[obj.name], jcf.customControl);
1966			for(var p in obj) {
1967				jcf.modules[obj.name].prototype[p] = obj[p];
1968			}
1969			// on create module
1970			jcf.modules[obj.name].prototype.onCreateModule();
1971			// make callback for exciting modules
1972			for(var mod in jcf.modules) {
1973				if(jcf.modules[mod] != jcf.modules[obj.name]) {
1974					jcf.modules[mod].prototype.onModuleAdded(jcf.modules[obj.name]);
1975				}
1976			}
1977		}
1978	},
1979	// add plugin to jcf.plugins
1980	addPlugin: function(obj) {
1981		if(obj && obj.name) {
1982			jcf.plugins[obj.name] = function() {
1983				this.init.apply(this, arguments);
1984			};
1985			for(var p in obj) {
1986				jcf.plugins[obj.name].prototype[p] = obj[p];
1987			}
1988		}
1989	},
1990	// miscellaneous init
1991	init: function(){
1992		if(navigator.msPointerEnabled) {
1993			this.eventPress = 'MSPointerDown';
1994			this.eventMove = 'MSPointerMove';
1995			this.eventRelease = 'MSPointerUp';
1996		} else {
1997			this.eventPress = this.isTouchDevice ? 'touchstart' : 'mousedown';
1998			this.eventMove = this.isTouchDevice ? 'touchmove' : 'mousemove';
1999			this.eventRelease = this.isTouchDevice ? 'touchend' : 'mouseup';
2000		}
2001
2002		// init jcf styles
2003		setTimeout(function(){
2004			jcf.lib.domReady(function(){
2005				jcf.initStyles();
2006			});
2007		},1);
2008		return this;
2009	},
2010	initStyles: function() {
2011		// create <style> element and rules
2012		var head = document.getElementsByTagName('head')[0],
2013			style = document.createElement('style'),
2014			rules = document.createTextNode('.'+jcf.baseOptions.unselectableClass+'{'+
2015				'-moz-user-select:none;'+
2016				'-webkit-tap-highlight-color:rgba(255,255,255,0);'+
2017				'-webkit-user-select:none;'+
2018				'user-select:none;'+
2019			'}');
2020		
2021		// append style element
2022		style.type = 'text/css';
2023		if(style.styleSheet) {
2024			style.styleSheet.cssText = rules.nodeValue;
2025		} else {
2026			style.appendChild(rules);
2027		}
2028		head.appendChild(style);
2029	}
2030}.init();
2031
2032/*
2033 * Custom Form Control prototype
2034 */
2035jcf.setBaseModule({
2036	init: function(){
2037		if(this.options.replaces) {
2038			this.realElement = this.options.replaces;
2039			this.realElement.jcf = this;
2040			this.replaceObject();
2041		}
2042	},
2043	defaultOptions: {
2044		// default module options (will be merged with base options)
2045	},
2046	checkElement: function(el){
2047		return true; // additional check for correct form element
2048	},
2049	replaceObject: function(){
2050		this.createWrapper();
2051		this.attachEvents();
2052		this.fixStyles();
2053		this.setupWrapper();
2054	},
2055	createWrapper: function(){
2056		this.fakeElement = jcf.lib.createElement(this.options.wrapperTag);
2057		this.labelFor = jcf.lib.getLabelFor(this.realElement);
2058		jcf.lib.disableTextSelection(this.fakeElement);
2059		jcf.lib.addClass(this.fakeElement, jcf.lib.getAllClasses(this.realElement.className, this.options.classPrefix));
2060		jcf.lib.addClass(this.realElement, jcf.baseOptions.hiddenClass);
2061	},
2062	attachEvents: function(){
2063		jcf.lib.event.add(this.realElement, 'focus', this.onFocusHandler, this);
2064		jcf.lib.event.add(this.realElement, 'blur', this.onBlurHandler, this);
2065		jcf.lib.event.add(this.fakeElement, 'click', this.onFakeClick, this);
2066		jcf.lib.event.add(this.fakeElement, jcf.eventPress, this.onFakePressed, this);
2067		jcf.lib.event.add(this.fakeElement, jcf.eventRelease, this.onFakeReleased, this);
2068
2069		if(this.labelFor) {
2070			this.labelFor.jcf = this;
2071			jcf.lib.event.add(this.labelFor, 'click', this.onFakeClick, this);
2072			jcf.lib.event.add(this.labelFor, jcf.eventPress, this.onFakePressed, this);
2073			jcf.lib.event.add(this.labelFor, jcf.eventRelease, this.onFakeReleased, this);
2074		}
2075	},
2076	fixStyles: function() {
2077		// hide mobile webkit tap effect
2078		if(jcf.isTouchDevice) {
2079			var tapStyle = 'rgba(255,255,255,0)';
2080			this.realElement.style.webkitTapHighlightColor = tapStyle;
2081			this.fakeElement.style.webkitTapHighlightColor = tapStyle;
2082			if(this.labelFor) {
2083				this.labelFor.style.webkitTapHighlightColor = tapStyle;
2084			}
2085		}
2086	},
2087	setupWrapper: function(){
2088		// implement in subclass
2089	},
2090	refreshState: function(){
2091		// implement in subclass
2092	},
2093	destroy: function() {
2094		if(this.fakeElement && this.fakeElement.parentNode) {
2095			this.fakeElement.parentNode.removeChild(this.fakeElement);
2096		}
2097		jcf.lib.removeClass(this.realElement, jcf.baseOptions.hiddenClass);
2098		this.realElement.jcf = null;
2099	},
2100	onFocus: function(){
2101		// emulated focus event
2102		jcf.lib.addClass(this.fakeElement,this.options.focusClass);
2103	},
2104	onBlur: function(cb){
2105		// emulated blur event
2106		jcf.lib.removeClass(this.fakeElement,this.options.focusClass);
2107	},
2108	onFocusHandler: function() {
2109		// handle focus loses
2110		if(this.focused) return;
2111		this.focused = true;
2112		
2113		// handle touch devices also
2114		if(jcf.isTouchDevice) {
2115			if(jcf.focusedInstance && jcf.focusedInstance.realElement != this.realElement) {
2116				jcf.focusedInstance.onBlur();
2117				jcf.focusedInstance.realElement.blur();
2118			}
2119			jcf.focusedInstance = this;
2120		}
2121		this.onFocus.apply(this, arguments);
2122	},
2123	onBlurHandler: function() {
2124		// handle focus loses
2125		if(!this.pressedFlag) {
2126			this.focused = false;
2127			this.onBlur.apply(this, arguments);
2128		}
2129	},
2130	onFakeClick: function(){
2131		if(jcf.isTouchDevice) {
2132			this.onFocus();
2133		} else if(!this.realElement.disabled) {
2134			this.realElement.focus();
2135		}
2136	},
2137	onFakePressed: function(e){
2138		this.pressedFlag = true;
2139	},
2140	onFakeReleased: function(){
2141		this.pressedFlag = false;
2142	},
2143	onCreateModule: function(){
2144		// implement in subclass
2145	},
2146	onModuleAdded: function(module) {
2147		// implement in subclass
2148	},
2149	onControlReady: function() {
2150		// implement in subclass
2151	}
2152});
2153
2154/*
2155 * JCF Utility Library
2156 */
2157jcf.lib = {
2158	bind: function(func, scope){
2159		return function() {
2160			return func.apply(scope, arguments);
2161		}
2162	},
2163	browser: (function() {
2164		var ua = navigator.userAgent.toLowerCase(), res = {},
2165		match = /(webkit)[ \/]([\w.]+)/.exec(ua) || /(opera)(?:.*version)?[ \/]([\w.]+)/.exec(ua) ||
2166				/(msie) ([\w.]+)/.exec(ua) || ua.indexOf("compatible") < 0 && /(mozilla)(?:.*? rv:([\w.]+))?/.exec(ua) || [];
2167		res[match[1]] = true;
2168		res.version = match[2] || "0";
2169		res.safariMac = ua.indexOf('mac') != -1 && ua.indexOf('safari') != -1;
2170		return res;
2171	})(),
2172	getOffset: function (obj) {
2173		if (obj.getBoundingClientRect && !navigator.msPointerEnabled) {
2174			var scrollLeft = window.pageXOffset || document.documentElement.scrollLeft || document.body.scrollLeft;
2175			var scrollTop = window.pageYOffset || document.documentElement.scrollTop || document.body.scrollTop;
2176			var clientLeft = document.documentElement.clientLeft || document.body.clientLeft || 0;
2177			var clientTop = document.documentElement.clientTop || document.body.clientTop || 0;
2178			return {
2179				top:Math.round(obj.getBoundingClientRect().top + scrollTop - clientTop),
2180				left:Math.round(obj.getBoundingClientRect().left + scrollLeft - clientLeft)
2181			}
2182		} else {
2183			var posLeft = 0, posTop = 0;
2184			while (obj.offsetParent) {posLeft += obj.offsetLeft; posTop += obj.offsetTop; obj = obj.offsetParent;}
2185			return {top:posTop,left:posLeft};
2186		}
2187	},
2188	getScrollTop: function() {
2189		return window.pageYOffset || document.documentElement.scrollTop;
2190	},
2191	getScrollLeft: function() {
2192		return window.pageXOffset || document.documentElement.scrollLeft;
2193	},
2194	getWindowWidth: function(){
2195		return document.compatMode=='CSS1Compat' ? document.documentElement.clientWidth : document.body.clientWidth;
2196	},
2197	getWindowHeight: function(){
2198		return document.compatMode=='CSS1Compat' ? document.documentElement.clientHeight : document.body.clientHeight;
2199	},
2200	getStyle: function(el, prop) {
2201		if (document.defaultView && document.defaultView.getComputedStyle) {
2202			return document.defaultView.getComputedStyle(el, null)[prop];
2203		} else if (el.currentStyle) {
2204			return el.currentStyle[prop];
2205		} else {
2206			return el.style[prop];
2207		}
2208	},
2209	getParent: function(obj, selector) {
2210		while(obj.parentNode && obj.parentNode != document.body) {
2211			if(obj.parentNode.tagName.toLowerCase() == selector.toLowerCase()) {
2212				return obj.parentNode;
2213			}
2214			obj = obj.parentNode;
2215		}
2216		return false;
2217	},
2218	isParent: function(child, parent) {
2219		while(child.parentNode) {
2220			if(child.parentNode === parent) {
2221				return true;
2222			}
2223			child = child.parentNode;
2224		}
2225		return false;
2226	},
2227	getLabelFor: function(object) {
2228		if(jcf.lib.getParent(object,'label')) {
2229			return object.parentNode;
2230		} else if(object.id) {
2231			return jcf.lib.queryBySelector('label[for="' + object.id + '"]')[0];
2232		}
2233	},
2234	disableTextSelection: function(el){
2235		if (typeof el.onselectstart !== 'undefined') {
2236			el.onselectstart = function() {return false};
2237		} else if(window.opera) {
2238			el.setAttribute('unselectable', 'on');
2239		} else {
2240			jcf.lib.addClass(el, jcf.baseOptions.unselectableClass);
2241		}
2242	},
2243	enableTextSelection: function(el) {
2244		if (typeof el.onselectstart !== 'undefined') {
2245			el.onselectstart = null;
2246		} else if(window.opera) {
2247			el.removeAttribute('unselectable');
2248		} else {
2249			jcf.lib.removeClass(el, jcf.baseOptions.unselectableClass);
2250		}
2251	},
2252	queryBySelector: function(selector, scope){
2253		return this.getElementsBySelector(selector, scope);
2254	},
2255	prevSibling: function(node) {
2256		while(node = node.previousSibling) if(node.nodeType == 1) break;
2257		return node;
2258	},
2259	nextSibling: function(node) {
2260		while(node = node.nextSibling) if(node.nodeType == 1) break;
2261		return node;
2262	},
2263	fireEvent: function(element,event) {
2264		if(element.dispatchEvent){
2265			var evt = document.createEvent('HTMLEvents');
2266			evt.initEvent(event, true, true );
2267			return !element.dispatchEvent(evt);
2268		}else if(document.createEventObject){
2269			var evt = document.createEventObject();
2270			return element.fireEvent('on'+event,evt);
2271		}
2272	},
2273	isParent: function(p, c) {
2274		while(c.parentNode) {
2275			if(p == c) {
2276				return true;
2277			}
2278			c = c.parentNode;
2279		}
2280		return false;
2281	},
2282	inherit: function(Child, Parent) {
2283		var F = function() { }
2284		F.prototype = Parent.prototype
2285		Child.prototype = new F()
2286		Child.prototype.constructor = Child
2287		Child.superclass = Parent.prototype
2288	},
2289	extend: function(obj) {
2290		for(var i = 1; i < arguments.length; i++) {
2291			for(var p in arguments[i]) {
2292				if(arguments[i].hasOwnProperty(p)) {
2293					obj[p] = arguments[i][p];
2294				}
2295			}
2296		}
2297		return obj;
2298	},
2299	hasClass: function (obj,cname) {
2300		return (obj.className ? obj.className.match(new RegExp('(\\s|^)'+cname+'(\\s|$)')) : false);
2301	},
2302	addClass: function (obj,cname) {
2303		if (!this.hasClass(obj,cname)) obj.className += (!obj.className.length || obj.className.charAt(obj.className.length - 1) === ' ' ? '' : ' ') + cname;
2304	},
2305	removeClass: function (obj,cname) {
2306		if (this.hasClass(obj,cname)) obj.className=obj.className.replace(new RegExp('(\\s|^)'+cname+'(\\s|$)'),' ').replace(/\s+$/, '');
2307	},
2308	toggleClass: function(obj, cname, condition) {
2309		if(condition) this.addClass(obj, cname); else this.removeClass(obj, cname);
2310	},
2311	createElement: function(tagName, options) {
2312		var el = document.createElement(tagName);
2313		for(var p in options) {
2314			if(options.hasOwnProperty(p)) {
2315				switch (p) {
2316					case 'class': el.className = options[p]; break;
2317					case 'html': el.innerHTML = options[p]; break;
2318					case 'style': this.setStyles(el, options[p]); break;
2319					default: el.setAttribute(p, options[p]);
2320				}
2321			}
2322		}
2323		return el;
2324	},
2325	setStyles: function(el, styles) {
2326		for(var p in styles) {
2327			if(styles.hasOwnProperty(p)) {
2328				switch (p) {
2329					case 'float': el.style.cssFloat = styles[p]; break;
2330					case 'opacity': el.style.filter = 'progid:DXImageTransform.Microsoft.Alpha(opacity='+styles[p]*100+')'; el.style.opacity = styles[p]; break;
2331					default: el.style[p] = (typeof styles[p] === 'undefined' ? 0 : styles[p]) + (typeof styles[p] === 'number' ? 'px' : '');
2332				}
2333			}
2334		}
2335		return el;
2336	},
2337	getInnerWidth: function(el) {
2338		return el.offsetWidth - (parseInt(this.getStyle(el,'paddingLeft')) || 0) - (parseInt(this.getStyle(el,'paddingRight')) || 0);
2339	},
2340	getInnerHeight: function(el) {
2341		return el.offsetHeight - (parseInt(this.getStyle(el,'paddingTop')) || 0) - (parseInt(this.getStyle(el,'paddingBottom')) || 0);
2342	},
2343	getAllClasses: function(cname, prefix, skip) {
2344		if(!skip) skip = '';
2345		if(!prefix) prefix = '';
2346		return cname ? cname.replace(new RegExp('(\\s|^)'+skip+'(\\s|$)'),' ').replace(/[\s]*([\S]+)+[\s]*/gi,prefix+"$1 ") : '';
2347	},
2348	getElementsBySelector: function(selector, scope) {
2349		if(typeof document.querySelectorAll === 'function') {
2350			return (scope || document).querySelectorAll(selector);
2351		}
2352		var selectors = selector.split(',');
2353		var resultList = [];
2354		for(var s = 0; s < selectors.length; s++) {
2355			var currentContext = [scope || document];
2356			var tokens = selectors[s].replace(/^\s+/,'').replace(/\s+$/,'').split(' ');
2357			for (var i = 0; i < tokens.length; i++) {
2358				token = tokens[i].replace(/^\s+/,'').replace(/\s+$/,'');
2359				if (token.indexOf('#') > -1) {
2360					var bits = token.split('#'), tagName = bits[0], id = bits[1];
2361					var element = document.getElementById(id);
2362					if (tagName && element.nodeName.toLowerCase() != tagName) {
2363						return [];
2364					}
2365					currentContext = [element];
2366					continue;
2367				}
2368				if (token.indexOf('.') > -1) {
2369					var bits = token.split('.'), tagName = bits[0] || '*', className = bits[1], found = [], foundCount = 0;
2370					for (var h = 0; h < currentContext.length; h++) {
2371						var elements;
2372						if (tagName == '*') {
2373							elements = currentContext[h].getElementsByTagName('*');
2374						} else {
2375							elements = currentContext[h].getElementsByTagName(tagName);
2376						}
2377						for (var j = 0; j < elements.length; j++) {
2378							found[foundCount++] = elements[j];
2379						}
2380					}
2381					currentContext = [];
2382					var currentContextIndex = 0;
2383					for (var k = 0; k < found.length; k++) {
2384						if (found[k].className && found[k].className.match(new RegExp('(\\s|^)'+className+'(\\s|$)'))) {
2385							currentContext[currentContextIndex++] = found[k];
2386						}
2387					}
2388					continue;
2389				}
2390				if (token.match(/^(\w*)\[(\w+)([=~\|\^\$\*]?)=?"?([^\]"]*)"?\]$/)) {
2391					var tagName = RegExp.$1 || '*', attrName = RegExp.$2, attrOperator = RegExp.$3, attrValue = RegExp.$4;
2392					if(attrName.toLowerCase() == 'for' && this.browser.msie && this.browser.version < 8) {
2393						attrName = 'htmlFor';
2394					}
2395					var found = [], foundCount = 0;
2396					for (var h = 0; h < currentContext.length; h++) {
2397						var elements;
2398						if (tagName == '*') {
2399							elements = currentContext[h].getElementsByTagName('*');
2400						} else {
2401							elements = currentContext[h].getElementsByTagName(tagName);
2402						}
2403						for (var j = 0; elements[j]; j++) {
2404							found[foundCount++] = elements[j];
2405						}
2406					}
2407					currentContext = [];
2408					var currentContextIndex = 0, checkFunction;
2409					switch (attrOperator) {
2410						case '=': checkFunction = function(e) { return (e.getAttribute(attrName) == attrValue) }; break;
2411						case '~': checkFunction = function(e) { return (e.getAttribute(attrName).match(new RegExp('(\\s|^)'+attrValue+'(\\s|$)'))) }; break;
2412						case '|': checkFunction = function(e) { return (e.getAttribute(attrName).match(new RegExp('^'+attrValue+'-?'))) }; break;
2413						case '^': checkFunction = function(e) { return (e.getAttribute(attrName).indexOf(attrValue) == 0) }; break;
2414						case '$': checkFunction = function(e) { return (e.getAttribute(attrName).lastIndexOf(attrValue) == e.getAttribute(attrName).length - attrValue.length) }; break;
2415						case '*': checkFunction = function(e) { return (e.getAttribute(attrName).indexOf(attrValue) > -1) }; break;
2416						default : checkFunction = function(e) { return e.getAttribute(attrName) };
2417					}
2418					currentContext = [];
2419					var currentContextIndex = 0;
2420					for (var k = 0; k < found.length; k++) {
2421						if (checkFunction(found[k])) {
2422							currentContext[currentContextIndex++] = found[k];
2423						}
2424					}
2425					continue;
2426				}
2427				tagName = token;
2428				var found = [], foundCount = 0;
2429				for (var h = 0; h < currentContext.length; h++) {
2430					var elements = currentContext[h].getElementsByTagName(tagName);
2431					for (var j = 0; j < elements.length; j++) {
2432						found[foundCount++] = elements[j];
2433					}
2434				}
2435				currentContext = found;
2436			}
2437			resultList = [].concat(resultList,currentContext);
2438		}
2439		return resultList;
2440	},
2441	scrollSize: (function(){
2442		var content, hold, sizeBefore, sizeAfter;
2443		function buildSizer(){
2444			if(hold) removeSizer();
2445			content = document.createElement('div');
2446			hold = document.createElement('div');
2447			hold.style.cssText = 'position:absolute;overflow:hidden;width:100px;height:100px';
2448			hold.appendChild(content);
2449			document.body.appendChild(hold);
2450		}
2451		function removeSizer(){
2452			document.body.removeChild(hold);
2453			hold = null;
2454		}
2455		function calcSize(vertical) {
2456			buildSizer();
2457			content.style.cssText = 'height:'+(vertical ? '100%' : '200px');
2458			sizeBefore = (vertical ? content.offsetHeight : content.offsetWidth);
2459			hold.style.overflow = 'scroll'; content.innerHTML = 1;
2460			sizeAfter = (vertical ? content.offsetHeight : content.offsetWidth);
2461			if(vertical && hold.clientHeight) sizeAfter = hold.clientHeight;
2462			removeSizer();
2463			return sizeBefore - sizeAfter;
2464		}
2465		return {
2466			getWidth:function(){
2467				return calcSize(false);
2468			},
2469			getHeight:function(){
2470				return calcSize(true)
2471			}
2472		}
2473	}()),
2474	domReady: function (handler){
2475		var called = false
2476		function ready() {
2477			if (called) return;
2478			called = true;
2479			handler();
2480		}
2481		if (document.addEventListener) {
2482			document.addEventListener("DOMContentLoaded", ready, false);
2483		} else if (document.attachEvent) {
2484			if (document.documentElement.doScroll && window == window.top) {
2485				function tryScroll(){
2486					if (called) return
2487					if (!document.body) return
2488					try {
2489						document.documentElement.doScroll("left")
2490						ready()
2491					} catch(e) {
2492						setTimeout(tryScroll, 0)
2493					}
2494				}
2495				tryScroll()
2496			}
2497			document.attachEvent("onreadystatechange", function(){
2498				if (document.readyState === "complete") {
2499					ready()
2500				}
2501			})
2502		}
2503		if (window.addEventListener) window.addEventListener('load', ready, false)
2504		else if (window.attachEvent) window.attachEvent('onload', ready)
2505	},
2506	event: (function(){
2507		var guid = 0;
2508		function fixEvent(e) {
2509			e = e || window.event;
2510			if (e.isFixed) {
2511				return e;
2512			}
2513			e.isFixed = true; 
2514			e.preventDefault = e.preventDefault || function(){this.returnValue = false}
2515			e.stopPropagation = e.stopPropagaton || function(){this.cancelBubble = true}
2516			if (!e.target) {
2517				e.target = e.srcElement
2518			}
2519			if (!e.relatedTarget && e.fromElement) {
2520				e.relatedTarget = e.fromElement == e.target ? e.toElement : e.fromElement;
2521			}
2522			if (e.pageX == null && e.clientX != null) {
2523				var html = document.documentElement, body = document.body;
2524				e.pageX = e.clientX + (html && html.scrollLeft || body && body.scrollLeft || 0) - (html.clientLeft || 0);
2525				e.pageY = e.clientY + (html && html.scrollTop || body && body.scrollTop || 0) - (html.clientTop || 0);
2526			}
2527			if (!e.which && e.button) {
2528				e.which = e.button & 1 ? 1 : (e.button & 2 ? 3 : (e.button & 4 ? 2 : 0));
2529			}
2530			if(e.type === "DOMMouseScroll" || e.type === 'mousewheel') {
2531				e.mWheelDelta = 0;
2532				if (e.wheelDelta) {
2533					e.mWheelDelta = e.wheelDelta/120;
2534				} else if (e.detail) {
2535					e.mWheelDelta = -e.detail/3;
2536				}
2537			}
2538			return e;
2539		}
2540		function commonHandle(event, customScope) {
2541			event = fixEvent(event);
2542			var handlers = this.events[event.type];
2543			for (var g in handlers) {
2544				var handler = handlers[g];
2545				var ret = handler.call(customScope || this, event);
2546				if (ret === false) {
2547					event.preventDefault()
2548					event.stopPropagation()
2549				}
2550			}
2551		}
2552		var publicAPI = {
2553			add: function(elem, type, handler, forcedScope) {
2554				if (elem.setInterval && (elem != window && !elem.frameElement)) {
2555					elem = window;
2556				}
2557				if (!handler.guid) {
2558					handler.guid = ++guid;
2559				}
2560				if (!elem.events) {
2561					elem.events = {};
2562					elem.handle = function(event) {
2563						return commonHandle.call(elem, event);
2564					}
2565				}
2566				if (!elem.events[type]) {
2567					elem.events[type] = {};
2568					if (elem.addEventListener) elem.addEventListener(type, elem.handle, false);
2569					else if (elem.attachEvent) elem.attachEvent("on" + type, elem.handle);
2570					if(type === 'mousewheel') {
2571						publicAPI.add(elem, 'DOMMouseScroll', handler, forcedScope);
2572					}
2573				}
2574				var fakeHandler = jcf.lib.bind(handler, forcedScope);
2575				fakeHandler.guid = handler.guid;
2576				elem.events[type][handler.guid] = forcedScope ? fakeHandler : handler;
2577			},
2578			remove: function(elem, type, handler) {
2579				var handlers = elem.events && elem.events[type];
2580				if (!handlers) return;
2581				delete handlers[handler.guid];
2582				for(var any in handlers) return;
2583				if (elem.removeEventListener) elem.removeEventListener(type, elem.handle, false);
2584				else if (elem.detachEvent) elem.detachEvent("on" + type, elem.handle);
2585				delete elem.events[type];
2586				for (var any in elem.events) return;
2587				try {
2588					delete elem.handle;
2589					delete elem.events;
2590				} catch(e) {
2591					if(elem.removeAttribute) {
2592						elem.removeAttribute("handle");
2593						elem.removeAttribute("events");
2594					}
2595				}
2596				if(type === 'mousewheel') {
2597					publicAPI.remove(elem, 'DOMMouseScroll', handler);
2598				}
2599			}
2600		}
2601		return publicAPI;
2602	}())
2603}
2604
2605// custom select module
2606jcf.addModule({
2607	name:'select',
2608	selector:'select.jcf',
2609	defaultOptions: {
2610		hideDropOnScroll: true,
2611		showNativeDrop: false,
2612		handleDropPosition: false,
2613		selectDropPosition: 'bottom', // or 'top'
2614		wrapperClass:'select-area',
2615		focusClass:'select-focus',
2616		dropActiveClass:'select-active',
2617		selectedClass:'item-selected',
2618		currentSelectedClass:'current-selected',
2619		disabledClass:'select-disabled',
2620		valueSelector:'span.center', 
2621		optGroupClass:'optgroup',
2622		openerSelector:'a.select-opener',		
2623		selectStructure:'<span class="left"></span><span class="center"></span><a class="select-opener"></a>',
2624		wrapperTag: 'span',
2625		classPrefix:'select-',		
2626		dropFlippedClass: 'select-options-flipped',
2627		dropHiddenClass:'options-hidden',
2628		dropScrollableClass:'options-overflow',
2629		dropClass:'select-options',
2630		dropClassPrefix:'drop-',
2631		dropStructure:'<div class="drop-holder"><div class="drop-list"></div></div>',
2632		dropSelector:'div.drop-list'
2633	},
2634	checkElement: function(el){
2635		return (!el.size && !el.multiple);
2636	},
2637	setupWrapper: function(){
2638		jcf.lib.addClass(this.fakeElement, this.options.wrapperClass);
2639		this.realElement.parentNode.insertBefore(this.fakeElement, this.realElement);
2640		this.fakeElement.innerHTML = this.options.selectStructure;
2641		this.fakeElement.style.width = (this.realElement.offsetWidth > 0 ? this.realElement.offsetWidth + 'px' : 'auto');
2642
2643		// show native drop if specified in options
2644		if(jcf.isTouchDevice && jcf.baseOptions.useNativeDropOnMobileDevices) {
2645			this.options.showNativeDrop = true;
2646		}
2647		if(this.options.showNativeDrop) {
2648			this.fakeElement.appendChild(this.realElement);
2649			jcf.lib.removeClass(this.realElement, this.options.hiddenClass);
2650			jcf.lib.setStyles(this.realElement, {
2651				top:0,
2652				left:0,
2653				margin:0,
2654				padding:0,
2655				opacity:0,
2656				border:'none',
2657				position:'absolute',
2658				width: jcf.lib.getInnerWidth(this.fakeElement) - 1,
2659				height: jcf.lib.getInnerHeight(this.fakeElement) - 1
2660			});
2661			jcf.lib.event.add(this.realElement, 'touchstart', function(){
2662				this.realElement.title = '';
2663			}, this)
2664		}
2665		
2666		// create select body
2667		this.opener = jcf.lib.queryBySelector(this.options.openerSelector, this.fakeElement)[0];
2668		this.valueText = jcf.lib.queryBySelector(this.options.valueSelector, this.fakeElement)[0];
2669		jcf.lib.disableTextSelection(this.valueText);
2670		this.opener.jcf = this;
2671
2672		if(!this.options.showNativeDrop) {
2673			this.createDropdown();
2674			this.refreshState();
2675			this.onControlReady(this);
2676			this.hideDropdown(true);
2677		} else {
2678			this.refreshState();
2679		}
2680		this.addEvents();
2681	},
2682	addEvents: function(){
2683		if(this.options.showNativeDrop) {
2684			jcf.lib.event.add(this.realElement, 'click', this.onChange, this);
2685		} else {
2686			jcf.lib.event.add(this.fakeElement, 'click', this.toggleDropdown, this);
2687		}
2688		jcf.lib.event.add(this.realElement, 'change', this.onChange, this);
2689	},
2690	onFakeClick: function() {
2691		// do nothing (drop toggles by toggleDropdown method)
2692	},
2693	onFocus: function(){
2694		jcf.modules[this.name].superclass.onFocus.apply(this, arguments);
2695		if(!this.options.showNativeDrop) {
2696			// Mac Safari Fix
2697			if(jcf.lib.browser.safariMac) {
2698				this.realElement.setAttribute('size','2');
2699			}
2700			jcf.lib.event.add(this.realElement, 'keydown', this.onKeyDown, this);
2701			if(jcf.activeControl && jcf.activeControl != this) {
2702				jcf.activeControl.hideDropdown();
2703				jcf.activeControl = this;
2704			}
2705		}
2706	},
2707	onBlur: function(){
2708		if(!this.options.showNativeDrop) {
2709			// Mac Safari Fix
2710			if(jcf.lib.browser.safariMac) {
2711				this.realElement.removeAttribute('size');
2712			}
2713			if(!this.isActiveDrop() || !this.isOverDrop()) {
2714				jcf.modules[this.name].superclass.onBlur.apply(this);
2715				if(jcf.activeControl === this) jcf.activeControl = null;
2716				if(!jcf.isTouchDevice) {
2717					this.hideDropdown();
2718				}
2719			}
2720			jcf.lib.event.remove(this.realElement, 'keydown', this.onKeyDown);
2721		} else {
2722			jcf.modules[this.name].superclass.onBlur.apply(this);
2723		}
2724	},
2725	onChange: function() {
2726		this.refreshState();
2727	},
2728	onKeyDown: function(e){
2729		this.dropOpened = true;
2730		jcf.tmpFlag = true;
2731		setTimeout(function(){jcf.tmpFlag = false},100);
2732		var context = this;
2733		context.keyboardFix = true;
2734		setTimeout(function(){
2735			context.refreshState();
2736		},10);
2737		if(e.keyCode == 13) {
2738			context.toggleDropdown.apply(context);
2739			return false;
2740		}
2741	},
2742	onResizeWindow: function(e){
2743		if(this.isActiveDrop()) {
2744			this.hideDropdown();
2745		}
2746	},
2747	onScrollWindow: function(e){
2748		if(this.options.hideDropOnScroll) {
2749			this.hideDropdown();
2750		} else if(this.isActiveDrop()) {
2751			this.positionDropdown();
2752		}
2753	},
2754	onOptionClick: function(e){
2755		var opener = e.target && e.target.tagName && e.target.tagName.toLowerCase() == 'li' ? e.target : jcf.lib.getParent(e.target, 'li');
2756		if(opener) {
2757			this.dropOpened = true;
2758			this.realElement.selectedIndex = parseInt(opener.getAttribute('rel'));
2759			if(jcf.isTouchDevice) {
2760				this.onFocus();
2761			} else {
2762				this.realElement.focus();
2763			}
2764			this.refreshState();
2765			this.hideDropdown();
2766			jcf.lib.fireEvent(this.realElement, 'change');
2767		}
2768		return false;
2769	},
2770	onClickOutside: function(e){
2771		if(jcf.tmpFlag) {
2772			jcf.tmpFlag = false;
2773			return;
2774		}
2775		if(!jcf.lib.isParent(this.fakeElement, e.target) && !jcf.lib.isParent(this.selectDrop, e.target)) {
2776			this.hideDropdown();
2777		}
2778	},
2779	onDropHover: function(e){
2780		if(!this.keyboardFix) {
2781			this.hoverFlag = true;
2782			var opener = e.target && e.target.tagName && e.target.tagName.toLowerCase() == 'li' ? e.target : jcf.lib.getParent(e.target, 'li');
2783			if(opener) {
2784				this.realElement.selectedIndex = parseInt(opener.getAttribute('rel'));
2785				this.refreshSelectedClass(parseInt(opener.getAttribute('rel')));
2786			}
2787		} else {
2788			this.keyboardFix = false;
2789		}
2790	},
2791	onDropLeave: function(){
2792		this.hoverFlag = false;
2793	},
2794	isActiveDrop: function(){
2795		return !jcf.lib.hasClass(this.selectDrop, this.options.dropHiddenClass);
2796	},
2797	isOverDrop: function(){
2798		return this.hoverFlag;
2799	},
2800	createDropdown: function(){
2801		// remove old dropdown if exists
2802		if(this.selectDrop) {
2803			this.selectDrop.parentNode.removeChild(this.selectDrop);
2804		}
2805
2806		// create dropdown holder
2807		this.selectDrop = document.createElement('div');
2808		this.selectDrop.className = this.options.dropClass;
2809		this.selectDrop.innerHTML = this.options.dropStructure;
2810		jcf.lib.setStyles(this.selectDrop, {position:'absolute'});
2811		this.selectList = jcf.lib.queryBySelector(this.options.dropSelector,this.selectDrop)[0];
2812		jcf.lib.addClass(this.selectDrop, this.options.dropHiddenClass);
2813		document.body.appendChild(this.selectDrop);
2814		this.selectDrop.jcf = this;
2815		jcf.lib.event.add(this.selectDrop, 'click', this.onOptionClick, this);
2816		jcf.lib.event.add(this.selectDrop, 'mouseover', this.onDropHover, this);
2817		jcf.lib.event.add(this.selectDrop, 'mouseout', this.onDropLeave, this);
2818		this.buildDropdown();
2819	},
2820	buildDropdown: function() {
2821		// build select options / optgroups
2822		this.buildDropdownOptions();
2823
2824		// position and resize dropdown
2825		this.positionDropdown();
2826
2827		// cut dropdown if height exceedes
2828		this.buildDropdownScroll();
2829	},
2830	buildDropdownOptions: function() {
2831		this.resStructure = '';
2832		this.optNum = 0;
2833		for(var i = 0; i < this.realElement.children.length; i++) {
2834			this.resStructure += this.buildElement(this.realElement.children[i], i) +'\n';
2835		}
2836		this.selectList.innerHTML = this.resStructure;
2837	},
2838	buildDropdownScroll: function() {
2839		if(this.options.dropMaxHeight) {
2840			if(this.selectDrop.offsetHeight > this.options.dropMaxHeight) {
2841				this.selectList.style.height = this.options.dropMaxHeight+'px';
2842				this.selectList.style.overflow = 'auto';
2843				this.selectList.style.overflowX = 'hidden';
2844				jcf.lib.addClass(this.selectDrop, this.options.dropScrollableClass);
2845			}
2846		}
2847		jcf.lib.addClass(this.selectDrop, jcf.lib.getAllClasses(this.realElement.className, this.options.dropClassPrefix, jcf.baseOptions.hiddenClass));
2848	},
2849	parseOptionTitle: function(optTitle) {
2850		return (typeof optTitle === 'string' && /\.(jpg|gif|png|bmp|jpeg)(.*)?$/i.test(optTitle)) ? optTitle : '';
2851	},
2852	buildElement: function(obj, index){
2853		// build option
2854		var res = '', optImage;
2855		if(obj.tagName.toLowerCase() == 'option') {
2856			if(!jcf.lib.prevSibling(obj) || jcf.lib.prevSibling(obj).tagName.toLowerCase() != 'option') {
2857				res += '<ul>';
2858			}
2859			
2860			optImage = this.parseOptionTitle(obj.title);
2861			res += '<li rel="'+(this.optNum++)+'" class="'+(obj.className? obj.className + ' ' : '')+(index % 2 ? 'option-even ' : '')+'jcfcalc"><a href="#">'+(optImage ? '<img src="'+optImage+'" alt="" />
2861' : '')+'<span>' + obj.innerHTML + '</span></a></li>';
2862			if(!jcf.lib.nextSibling(obj) || jcf.lib.nextSibling(obj).tagName.toLowerCase() != 'option') {
2863				res += '</ul>';
2864			}
2865			return res;
2866		}
2867		// build option group with options
2868		else if(obj.tagName.toLowerCase() == 'optgroup' && obj.label) {
2869			res += '<div class="'+this.options.optGroupClass+'">';
2870			res += '<strong class="jcfcalc"><em>'+(obj.label)+'</em></strong>';
2871			for(var i = 0; i < obj.children.length; i++) {
2872				res += this.buildElement(obj.children[i], i);
2873			}
2874			res += '</div>';
2875			return res;
2876		}
2877	},
2878	positionDropdown: function(){
2879		var ofs = jcf.lib.getOffset(this.fakeElement), selectAreaHeight = this.fakeElement.offsetHeight, selectDropHeight = this.selectDrop.offsetHeight;
2880		var fitInTop = ofs.top - selectDropHeight >= jcf.lib.getScrollTop() && jcf.lib.getScrollTop() + jcf.lib.getWindowHeight() < ofs.top + selectAreaHeight + selectDropHeight;
2881		
2882		
2883		if((this.options.handleDropPosition && fitInTop) || this.options.selectDropPosition === 'top') {
2884			this.selectDrop.style.top = (ofs.top - selectDropHeight)+'px';
2885			jcf.lib.addClass(this.selectDrop, this.options.dropFlippedClass);
2886		} else {
2887			this.selectDrop.style.top = (ofs.top + selectAreaHeight)+'px';
2888			jcf.lib.removeClass(this.selectDrop, this.options.dropFlippedClass);
2889		}
2890		this.selectDrop.style.left = ofs.left+'px';
2891		this.selectDrop.style.width = this.fakeElement.offsetWidth+'px';
2892	},
2893	showDropdown: function(){
2894		document.body.appendChild(this.selectDrop);
2895		jcf.lib.removeClass(this.selectDrop, this.options.dropHiddenClass);
2896		jcf.lib.addClass(this.fakeElement,this.options.dropActiveClass);
2897		this.positionDropdown();
2898
2899		// highlight current active item
2900		var activeItem = this.getFakeActiveOption();
2901		this.removeClassFromItems(this.options.currentSelectedClass);
2902		jcf.lib.addClass(activeItem, this.options.currentSelectedClass);
2903		
2904		// show current dropdown
2905		jcf.lib.event.add(window, 'resize', this.onResizeWindow, this);
2906		jcf.lib.event.add(window, 'scroll', this.onScrollWindow, this);
2907		jcf.lib.event.add(document, jcf.eventPress, this.onClickOutside, this);
2908		this.positionDropdown();
2909	},
2910	hideDropdown: function(partial){
2911		if(this.selectDrop.parentNode) {
2912			if(this.selectDrop.offsetWidth) {
2913				this.selectDrop.parentNode.removeChild(this.selectDrop);
2914			}
2915			if(partial) {
2916				return;
2917			}
2918		}
2919		if(typeof this.origSelectedIndex === 'number') {
2920			this.realElement.selectedIndex = this.origSelectedIndex;
2921		}
2922		jcf.lib.removeClass(this.fakeElement,this.options.dropActiveClass);
2923		jcf.lib.addClass(this.selectDrop, this.options.dropHiddenClass);
2924		jcf.lib.event.remove(window, 'resize', this.onResizeWindow);
2925		jcf.lib.event.remove(window, 'scroll', this.onScrollWindow);
2926		jcf.lib.event.remove(document.documentElement, jcf.eventPress, this.onClickOutside);
2927		if(jcf.isTouchDevice) {
2928			this.onBlur();
2929		}
2930	},
2931	toggleDropdown: function(){
2932		if(!this.realElement.disabled) {
2933			if(jcf.isTouchDevice) {
2934				this.onFocus();
2935			} else {
2936				this.realElement.focus();
2937			}
2938			if(this.isActiveDrop()) {
2939				this.hideDropdown();
2940			} else {
2941				this.showDropdown();
2942			}
2943			this.refreshState();
2944		}
2945	},
2946	scrollToItem: function(){
2947		if(this.isActiveDrop()) {
2948			var dropHeight = this.selectList.offsetHeight;
2949			var offsetTop = this.calcOptionOffset(this.getFakeActiveOption());
2950			var sTop = this.selectList.scrollTop;
2951			var oHeight = this.getFakeActiveOption().offsetHeight;
2952			//offsetTop+=sTop;
2953
2954			if(offsetTop >= sTop + dropHeight) {
2955				this.selectList.scrollTop = offsetTop - dropHeight + oHeight;
2956			} else if(offsetTop < sTop) {
2957				this.selectList.scrollTop = offsetTop;
2958			}
2959		}
2960	},
2961	getFakeActiveOption: function(c) {
2962		return jcf.lib.queryBySelector('li[rel="'+(typeof c === 'number' ? c : this.realElement.selectedIndex) +'"]',this.selectList)[0];
2963	},
2964	calcOptionOffset: function(fake) {
2965		var h = 0;
2966		var els = jcf.lib.queryBySelector('.jcfcalc',this.selectList);
2967		for(var i = 0; i < els.length; i++) {
2968			if(els[i] == fake) break;
2969			h+=els[i].offsetHeight;
2970		}
2971		return h;
2972	},
2973	childrenHasItem: function(hold,item) {
2974		var items = hold.getElementsByTagName('*');
2975		for(i = 0; i < items.length; i++) {
2976			if(items[i] == item) return true;
2977		}
2978		return false;
2979	},
2980	removeClassFromItems: function(className){
2981		var children = jcf.lib.queryBySelector('li',this.selectList);
2982		for(var i = children.length - 1; i >= 0; i--) {
2983			jcf.lib.removeClass(children[i], className);
2984		}
2985	},
2986	setSelectedClass: function(c){
2987		jcf.lib.addClass(this.getFakeActiveOption(c), this.options.selectedClass);
2988	},
2989	refreshSelectedClass: function(c){
2990		if(!this.options.showNativeDrop) {
2991			this.removeClassFromItems(this.options.selectedClass);
2992			this.setSelectedClass(c);
2993		}
2994		if(this.realElement.disabled) {
2995			jcf.lib.addClass(this.fakeElement, this.options.disabledClass);
2996			if(this.labelFor) {
2997				jcf.lib.addClass(this.labelFor, this.options.labelDisabledClass);
2998			}
2999		} else {
3000			jcf.lib.removeClass(this.fakeElement, this.options.disabledClass);
3001			if(this.labelFor) {
3002				jcf.lib.removeClass(this.labelFor, this.options.labelDisabledClass);
3003			}
3004		}
3005	},
3006	refreshSelectedText: function() {
3007		if(!this.dropOpened && this.realElement.title) {
3008			this.valueText.innerHTML = this.realElement.title;
3009		} else {
3010			if(this.realElement.options[this.realElement.selectedIndex].title) {
3011				var optImage = this.parseOptionTitle(this.realElement.options[this.realElement.selectedIndex].title);
3012				this.valueText.innerHTML = (optImage ? '<img src="'+optImage+'" alt="" />' : '') + this.realElement.options[this.realElement.selectedIndex].innerHTML;
3013			} else {
3014				this.valueText.innerHTML = this.realElement.options[this.realElement.selectedIndex].innerHTML;
3015			}
3016		}
3017	},
3018	refreshState: function(){
3019		this.origSelectedIndex = this.realElement.selectedIndex;
3020		this.refreshSelectedClass();
3021		this.refreshSelectedText();
3022		if(!this.options.showNativeDrop) {
3023			this.positionDropdown();
3024			if(this.selectDrop.offsetWidth) {
3025				this.scrollToItem();
3026			}
3027		}
3028	}
3029});
3030
3031
3032// custom radio module
3033jcf.addModule({
3034	name:'radio',
3035	selector: 'input[type="radio"]',
3036	defaultOptions: {
3037		wrapperClass:'rad-area',
3038		focusClass:'rad-focus',
3039		checkedClass:'rad-checked',
3040		uncheckedClass:'rad-unchecked',
3041		disabledClass:'rad-disabled',
3042		radStructure:'<span></span>'
3043	},
3044	getRadioGroup: function(item){
3045		var name = item.getAttribute('name');
3046		if(name) {
3047			return jcf.lib.queryBySelector('input[name="'+name+'"]', jcf.lib.getParent('form'));
3048		} else {
3049			return [item];
3050		}
3051	},
3052	setupWrapper: function(){
3053		jcf.lib.addClass(this.fakeElement, this.options.wrapperClass);
3054		this.fakeElement.innerHTML = this.options.radStructure;
3055		this.realElement.parentNode.insertBefore(this.fakeElement, this.realElement);
3056		this.refreshState();
3057		this.addEvents();
3058	},
3059	addEvents: function(){
3060		jcf.lib.event.add(this.fakeElement, 'click', this.toggleRadio, this);
3061		if(this.labelFor) {
3062			jcf.lib.event.add(this.labelFor, 'click', this.toggleRadio, this);
3063		}
3064	},
3065	onFocus: function(e) {
3066		jcf.modules[this.name].superclass.onFocus.apply(this, arguments);
3067		setTimeout(jcf.lib.bind(function(){
3068			this.refreshState();
3069		},this),10);
3070	},
3071	toggleRadio: function(){
3072		if(!this.realElement.disabled) {
3073			this.realElement.checked = true;
3074		}
3075		this.refreshState();
3076	},
3077	refreshState: function(){
3078		var els = this.getRadioGroup(this.realElement);
3079		for(var i = 0; i < els.length; i++) {
3080			var curEl = els[i].jcf;
3081			if(curEl) {
3082				if(curEl.realElement.checked) {
3083					jcf.lib.addClass(curEl.fakeElement, curEl.options.checkedClass);
3084					jcf.lib.removeClass(curEl.fakeElement, curEl.options.uncheckedClass);
3085					if(curEl.labelFor) {
3086						jcf.lib.addClass(curEl.labelFor, curEl.options.labelActiveClass);
3087					}
3088				} else {
3089					jcf.lib.removeClass(curEl.fakeElement, curEl.options.checkedClass);
3090					jcf.lib.addClass(curEl.fakeElement, curEl.options.uncheckedClass);
3091					if(curEl.labelFor) {
3092						jcf.lib.removeClass(curEl.labelFor, curEl.options.labelActiveClass);
3093					}
3094				}
3095				if(curEl.realElement.disabled) {
3096					jcf.lib.addClass(curEl.fakeElement, curEl.options.disabledClass);
3097					if(curEl.labelFor) {
3098						jcf.lib.addClass(curEl.labelFor, curEl.options.labelDisabledClass);
3099					}
3100				} else {
3101					jcf.lib.removeClass(curEl.fakeElement, curEl.options.disabledClass);
3102					if(curEl.labelFor) {
3103						jcf.lib.removeClass(curEl.labelFor, curEl.options.labelDisabledClass);
3104					}
3105				}
3106			}
3107		}
3108	}
3109});
3110
3111
3112/**
3113 * Lightbox v2.7.1
3114 * by Lokesh Dhakar - http://lokeshdhakar.com/projects/lightbox2/
3115 *
3116 * @license http://creativecommons.org/licenses/by/2.5/
3117 * - Free for use in both personal and commercial projects
3118 * - Attribution requires leaving author name, author link, and the license info intact
3119 */
3120
3121(function() {
3122  // Use local alias
3123  var $ = jQuery;
3124
3125  var LightboxOptions = (function() {
3126    function LightboxOptions() {
3127      this.fadeDuration                = 500;
3128      this.fitImagesInViewport         = true;
3129      this.resizeDuration              = 700;
3130      this.positionFromTop             = 50;
3131      this.showImageNumberLabel        = true;
3132      this.alwaysShowNavOnTouchDevices = false;
3133      this.wrapAround                  = false;
3134    }
3135    
3136    // Change to localize to non-english language
3137    LightboxOptions.prototype.albumLabel = function(curImageNum, albumSize) {
3138      return "Image " + curImageNum + " of " + albumSize;
3139    };
3140
3141    return LightboxOptions;
3142  })();
3143
3144
3145  var Lightbox = (function() {
3146    function Lightbox(options) {
3147      this.options           = options;
3148      this.album             = [];
3149      this.currentImageIndex = void 0;
3150      this.init();
3151    }
3152
3153    Lightbox.prototype.init = function() {
3154      this.enable();
3155      this.build();
3156    };
3157
3158    // Loop through anchors and areamaps looking for either data-lightbox attributes or rel attributes
3159    // that contain 'lightbox'. When these are clicked, start lightbox.
3160    Lightbox.prototype.enable = function() {
3161      var self = this;
3162      $('body').on('click', 'a[rel^=lightbox], area[rel^=lightbox], a[data-lightbox], area[data-lightbox]', function(event) {
3163        self.start($(event.currentTarget));
3164        return false;
3165      });
3166    };
3167
3168    // Build html for the lightbox and the overlay.
3169    // Attach event handlers to the new DOM elements. click click click
3170    Lightbox.prototype.build = function() {
3171      var self = this;
3172      $("<div id='lightboxOverlay' class='lightboxOverlay'></div><div id='lightbox2' class='lightbox'><div class='lb-outerContainer'><div class='lb-container'><img class='lb-image' src='' /><div class='lb-nav'><a class='lb-prev' href='' ></a><a class='lb-next' href='' ></a></div><div class='lb-loader'><a class='lb-cancel'></a></div></div></div><div class='lb-dataContainer'><div class='lb-data'><div class='lb-details'><span class='lb-caption'></span><span class='lb-number'></span></div><div class='lb-closeContainer'><a class='lb-close'></a></div></div></div></div>").appendTo($('body'));
3173      
3174      // Cache jQuery objects
3175      this.$lightbox       = $('#lightbox2');
3176      this.$overlay        = $('#lightboxOverlay');
3177      this.$outerContainer = this.$lightbox.find('.lb-outerContainer');
3178      this.$container      = this.$lightbox.find('.lb-container');
3179
3180      // Store css values for future lookup
3181      this.containerTopPadding = parseInt(this.$container.css('padding-top'), 10);
3182      this.containerRightPadding = parseInt(this.$container.css('padding-right'), 10);
3183      this.containerBottomPadding = parseInt(this.$container.css('padding-bottom'), 10);
3184      this.containerLeftPadding = parseInt(this.$container.css('padding-left'), 10);
3185      
3186      // Attach event handlers to the newly minted DOM elements
3187      this.$overlay.hide().on('click', function() {
3188        self.end();
3189        return false;
3190      });
3191
3192      this.$lightbox.hide().on('click', function(event) {
3193        if ($(event.target).attr('id') === 'lightbox') {
3194          self.end();
3195        }
3196        return false;
3197      });
3198
3199      this.$outerContainer.on('click', function(event) {
3200        if ($(event.target).attr('id') === 'lightbox') {
3201          self.end();
3202        }
3203        return false;
3204      });
3205
3206      this.$lightbox.find('.lb-prev').on('click', function() {
3207        if (self.currentImageIndex === 0) {
3208          self.changeImage(self.album.length - 1);
3209        } else {
3210          self.changeImage(self.currentImageIndex - 1);
3211        }
3212        return false;
3213      });
3214
3215      this.$lightbox.find('.lb-next').on('click', function() {
3216        if (self.currentImageIndex === self.album.length - 1) {
3217          self.changeImage(0);
3218        } else {
3219          self.changeImage(self.currentImageIndex + 1);
3220        }
3221        return false;
3222      });
3223
3224      this.$lightbox.find('.lb-loader, .lb-close').on('click', function() {
3225        self.end();
3226        return false;
3227      });
3228    };
3229
3230    // Show overlay and lightbox. If the image is part of a set, add siblings to album array.
3231    Lightbox.prototype.start = function($link) {
3232      var self    = this;
3233      var $window = $(window);
3234
3235      $window.on('resize', $.proxy(this.sizeOverlay, this));
3236
3237      $('select, object, embed').css({
3238        visibility: "hidden"
3239      });
3240
3241      this.sizeOverlay();
3242
3243      this.album = [];
3244      var imageNumber = 0;
3245
3246      function addToAlbum($link) {
3247        self.album.push({
3248          link: $link.attr('href'),
3249          title: $link.attr('data-title') || $link.attr('title')
3250        });
3251      }
3252
3253      // Support both data-lightbox attribute and rel attribute implementations
3254      var dataLightboxValue = $link.attr('data-lightbox');
3255      var $links;
3256
3257      if (dataLightboxValue) {
3258        $links = $($link.prop("tagName") + '[data-lightbox="' + dataLightboxValue + '"]');
3259        for (var i = 0; i < $links.length; i = ++i) {
3260          addToAlbum($($links[i]));
3261          if ($links[i] === $link[0]) {
3262            imageNumber = i;
3263          }
3264        }
3265      } else {
3266        if ($link.attr('rel') === 'lightbox') {
3267          // If image is not part of a set
3268          addToAlbum($link);
3269        } else {
3270          // If image is part of a set
3271          $links = $($link.prop("tagName") + '[rel="' + $link.attr('rel') + '"]');
3272          for (var j = 0; j < $links.length; j = ++j) {
3273            addToAlbum($($links[j]));
3274            if ($links[j] === $link[0]) {
3275              imageNumber = j;
3276            }
3277          }
3278        }
3279      }
3280      
3281      // Position Lightbox
3282      var top  = $window.scrollTop() + this.options.positionFromTop;
3283      var left = $window.scrollLeft();
3284      this.$lightbox.css({
3285        top: top + 'px',
3286        left: left + 'px'
3287      }).fadeIn(this.options.fadeDuration);
3288
3289      this.changeImage(imageNumber);
3290    };
3291
3292    // Hide most UI elements in preparation for the animated resizing of the lightbox.
3293    Lightbox.prototype.changeImage = function(imageNumber) {
3294      var self = this;
3295
3296      this.disableKeyboardNav();
3297      var $image = this.$lightbox.find('.lb-image');
3298
3299      this.$overlay.fadeIn(this.options.fadeDuration);
3300
3301      $('.lb-loader').fadeIn('slow');
3302      this.$lightbox.find('.lb-image, .lb-nav, .lb-prev, .lb-next, .lb-dataContainer, .lb-numbers, .lb-caption').hide();
3303
3304      this.$outerContainer.addClass('animating');
3305
3306      // When image to show is preloaded, we send the width and height to sizeContainer()
3307      var preloader = new Image();
3308      preloader.onload = function() {
3309        var $preloader, imageHeight, imageWidth, maxImageHeight, maxImageWidth, windowHeight, windowWidth;
3310        $image.attr('src', self.album[imageNumber].link);
3311
3312        $preloader = $(preloader);
3313
3314        $image.width(preloader.width);
3315        $image.height(preloader.height);
3316        
3317        if (self.options.fitImagesInViewport) {
3318          // Fit image inside the viewport.
3319          // Take into account the border around the image and an additional 10px gutter on each side.
3320
3321          windowWidth    = $(window).width();
3322          windowHeight   = $(window).height();
3323          maxImageWidth  = windowWidth - self.containerLeftPadding - self.containerRightPadding - 20;
3324          maxImageHeight = windowHeight - self.containerTopPadding - self.containerBottomPadding - 120;
3325
3326          // Is there a fitting issue?
3327          if ((preloader.width > maxImageWidth) || (preloader.height > maxImageHeight)) {
3328            if ((preloader.width / maxImageWidth) > (preloader.height / maxImageHeight)) {
3329              imageWidth  = maxImageWidth;
3330              imageHeight = parseInt(preloader.height / (preloader.width / imageWidth), 10);
3331              $image.width(imageWidth);
3332              $image.height(imageHeight);
3333            } else {
3334              imageHeight = maxImageHeight;
3335              imageWidth = parseInt(preloader.width / (preloader.height / imageHeight), 10);
3336              $image.width(imageWidth);
3337              $image.height(imageHeight);
3338            }
3339          }
3340        }
3341        self.sizeContainer($image.width(), $image.height());
3342      };
3343
3344      preloader.src          = this.album[imageNumber].link;
3345      this.currentImageIndex = imageNumber;
3346    };
3347
3348    // Stretch overlay to fit the viewport
3349    Lightbox.prototype.sizeOverlay = function() {
3350      this.$overlay
3351        .width($(window).width())
3352        .height($(document).height());
3353    };
3354
3355    // Animate the size of the lightbox to fit the image we are showing
3356    Lightbox.prototype.sizeContainer = function(imageWidth, imageHeight) {
3357      var self = this;
3358      
3359      var oldWidth  = this.$outerContainer.outerWidth();
3360      var oldHeight = this.$outerContainer.outerHeight();
3361      var newWidth  = imageWidth + this.containerLeftPadding + this.containerRightPadding;
3362      var newHeight = imageHeight + this.containerTopPadding + this.containerBottomPadding;
3363      
3364      function postResize() {
3365        self.$lightbox.find('.lb-dataContainer').width(newWidth);
3366        self.$lightbox.find('.lb-prevLink').height(newHeight);
3367        self.$lightbox.find('.lb-nextLink').height(newHeight);
3368        self.showImage();
3369      }
3370
3371      if (oldWidth !== newWidth || oldHeight !== newHeight) {
3372        this.$outerContainer.animate({
3373          width: newWidth,
3374          height: newHeight
3375        }, this.options.resizeDuration, 'swing', function() {
3376          postResize();
3377        });
3378      } else {
3379        postResize();
3380      }
3381    };
3382
3383    // Display the image and it's details and begin preload neighboring images.
3384    Lightbox.prototype.showImage = function() {
3385      this.$lightbox.find('.lb-loader').hide();
3386      this.$lightbox.find('.lb-image').fadeIn('slow');
3387    
3388      this.updateNav();
3389      this.updateDetails();
3390      this.preloadNeighboringImages();
3391      this.enableKeyboardNav();
3392    };
3393
3394    // Display previous and next navigation if appropriate.
3395    Lightbox.prototype.updateNav = function() {
3396      // Check to see if the browser supports touch events. If so, we take the conservative approach
3397      // and assume that mouse hover events are not supported and always show prev/next navigation
3398      // arrows in image sets.
3399      var alwaysShowNav = false;
3400      try {
3401        document.createEvent("TouchEvent");
3402        alwaysShowNav = (this.options.alwaysShowNavOnTouchDevices)? true: false;
3403      } catch (e) {}
3404
3405      this.$lightbox.find('.lb-nav').show();
3406
3407      if (this.album.length > 1) {
3408        if (this.options.wrapAround) {
3409          if (alwaysShowNav) {
3410            this.$lightbox.find('.lb-prev, .lb-next').css('opacity', '1');
3411          }
3412          this.$lightbox.find('.lb-prev, .lb-next').show();
3413        } else {
3414          if (this.currentImageIndex > 0) {
3415            this.$lightbox.find('.lb-prev').show();
3416            if (alwaysShowNav) {
3417              this.$lightbox.find('.lb-prev').css('opacity', '1');
3418            }
3419          }
3420          if (this.currentImageIndex < this.album.length - 1) {
3421            this.$lightbox.find('.lb-next').show();
3422            if (alwaysShowNav) {
3423              this.$lightbox.find('.lb-next').css('opacity', '1');
3424            }
3425          }
3426        }
3427      }
3428    };
3429
3430    // Display caption, image number, and closing button.
3431    Lightbox.prototype.updateDetails = function() {
3432      var self = this;
3433
3434      // Enable anchor clicks in the injected caption html.
3435      // Thanks Nate Wright for the fix. @https://github.com/NateWr
3436      if (typeof this.album[this.currentImageIndex].title !== 'undefined' && this.album[this.currentImageIndex].title !== "") {
3437        this.$lightbox.find('.lb-caption')
3438          .html(this.album[this.currentImageIndex].title)
3439          .fadeIn('fast')
3440          .find('a').on('click', function(event){
3441            location.href = $(this).attr('href');
3442          });
3443      }
3444    
3445      if (this.album.length > 1 && this.options.showImageNumberLabel) {
3446        this.$lightbox.find('.lb-number').text(this.options.albumLabel(this.currentImageIndex + 1, this.album.length)).fadeIn('fast');
3447      } else {
3448        this.$lightbox.find('.lb-number').hide();
3449      }
3450    
3451      this.$outerContainer.removeClass('animating');
3452    
3453      this.$lightbox.find('.lb-dataContainer').fadeIn(this.options.resizeDuration, function() {
3454        return self.sizeOverlay();
3455      });
3456    };
3457
3458    // Preload previous and next images in set.
3459    Lightbox.prototype.preloadNeighboringImages = function() {
3460      if (this.album.length > this.currentImageIndex + 1) {
3461        var preloadNext = new Image();
3462        preloadNext.src = this.album[this.currentImageIndex + 1].link;
3463      }
3464      if (this.currentImageIndex > 0) {
3465        var preloadPrev = new Image();
3466        preloadPrev.src = this.album[this.currentImageIndex - 1].link;
3467      }
3468    };
3469
3470    Lightbox.prototype.enableKeyboardNav = function() {
3471      $(document).on('keyup.keyboard', $.proxy(this.keyboardAction, this));
3472    };
3473
3474    Lightbox.prototype.disableKeyboardNav = function() {
3475      $(document).off('.keyboard');
3476    };
3477
3478    Lightbox.prototype.keyboardAction = function(event) {
3479      var KEYCODE_ESC        = 27;
3480      var KEYCODE_LEFTARROW  = 37;
3481      var KEYCODE_RIGHTARROW = 39;
3482
3483      var keycode = event.keyCode;
3484      var key     = String.fromCharCode(keycode).toLowerCase();
3485      if (keycode === KEYCODE_ESC || key.match(/x|o|c/)) {
3486        this.end();
3487      } else if (key === 'p' || keycode === KEYCODE_LEFTARROW) {
3488        if (this.currentImageIndex !== 0) {
3489          this.changeImage(this.currentImageIndex - 1);
3490        } else if (this.options.wrapAround && this.album.length > 1) {
3491          this.changeImage(this.album.length - 1);
3492        }
3493      } else if (key === 'n' || keycode === KEYCODE_RIGHTARROW) {
3494        if (this.currentImageIndex !== this.album.length - 1) {
3495          this.changeImage(this.currentImageIndex + 1);
3496        } else if (this.options.wrapAround && this.album.length > 1) {
3497          this.changeImage(0);
3498        }
3499      }
3500    };
3501
3502    // Closing time. :-(
3503    Lightbox.prototype.end = function() {
3504      this.disableKeyboardNav();
3505      $(window).off("resize", this.sizeOverlay);
3506      this.$lightbox.fadeOut(this.options.fadeDuration);
3507      this.$overlay.fadeOut(this.options.fadeDuration);
3508      $('select, object, embed').css({
3509        visibility: "visible"
3510      });
3511    };
3512
3513    return Lightbox;
3514
3515  })();
3516
3517  $(function() {
3518    var options  = new LightboxOptions();
3519    var lightbox = new Lightbox(options);
3520  });
3521
3522}).call(this);
3523
3524$(document).ready(function () {
3525	//cookie banner
3526
3527	function hideCookies() {
3528		var hideCookie = getCookie('hideCookie');
3529		if (hideCookie == null || hideCookie == "") {
3530			$('#cookie-banner').css('display', 'block');
3531		} else {
3532			$('#cookie-banner').css('display', 'none');
3533		}
3534	}
3535
3536	$(window).load(function () {
3537		$('.cookie-banner-button').bind('click', function () {
3538			setCookie('hideCookie', '0', 365);
3539			$('#cookie-banner').fadeOut();
3540		});
3541
3542	});
3543
3544	$(window).load(function () {
3545		hideCookies();
3546	});
3547
3548	function getCookie(cookieName) {
3549		var theCookie = " " + document.cookie;
3550		var ind = theCookie.indexOf(" " + cookieName + "=");
3551		if (ind == -1) ind = theCookie.indexOf(";" + cookieName + "=");
3552		if (ind == -1 || cookieName == "") return "";
3553		var ind1 = theCookie.indexOf(";", ind + 1);
3554		if (ind1 == -1) ind1 = theCookie.length;
3555		return unescape(theCookie.substring(ind + cookieName.length + 2, ind1));
3556	}
3557
3558	function setCookie(cookieName, cookieValue, nDays) {
3559		var today = new Date();
3560		var expire = new Date();
3561		if (nDays == null || nDays == 0) nDays = 1;
3562		expire.setTime(today.getTime() + 3600000 * 24 * nDays);
3563		document.cookie = cookieName + "=" + escape(cookieValue) + ";expires=" + expire.toGMTString() + ";path=/;";
3564	}
3565});

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.