/*	About:	  Author: Michal Schejbal	  Version: 1.0		- Based on mootools 1.3	Changelog (only vital changes):		1.1:		  -	Usage:		Type these to element class attribute		1. Selectors:		  ui-make-[ui control class name]		  Otherwise you can alter _uiConstrols.set function select mechanism		example:		  ui-make-scroller  // Will find all elements with this class and make them scrollers		2. Special parameters:		  - ui-omit         // This element will be omitted		  - ui-wrapped      // This element was already wraped		Styling via css		1. Available class names:		  Use these class names to style ui elements		  - ui-htmlButton		  - ui-scroller		  - ui-select		  - ui-checkbox		  - ui-radio		  - ui-treeView		  - ui-slideShow	    - ui-make-overinput   // mootools implementation*/var _uiControls = new Class({  //  ['button', 'submit', 'scroller', 'select', 'checkbox', 'radio', 'treeView', 'slideShow', 'overinput']	set: function(types)	{		types.each(function(item)		{			switch(item)			{			  case 'submit':			    $$('input[type="submit"]').each(function(e)					{					  if(!e.hasClass('ui-wrapped') && !e.hasClass('ui-omit'))							new _uiHtmlButton(e);					});					break;			  case 'button':			    $$('input[type="button"], .ui-make-htmlButton').each(function(e)					{					  if(!e.hasClass('ui-wrapped') && !e.hasClass('ui-omit'))							new _uiHtmlButton(e);					});					break;			  case 'scroller':			    $$('input.ui-make-scroller').each(function(e)					{					  if(!e.hasClass('ui-wrapped') && !e.hasClass('ui-omit'))							new _uiScroller(e);					});					break;			  case 'select':			    $$('select').each(function(e)					{					  if(!e.hasClass('ui-wrapped') && !e.hasClass('ui-omit'))							new _uiSelect(e);					});					break;			  case 'checkbox':			    $$('input[type="checkbox"]').each(function(e)					{					  if(!e.hasClass('ui-wrapped') && !e.hasClass('ui-omit'))							new _uiCheckbox(e);					});					break;			  case 'radio':			    $$('input[type="radio"]').each(function(e)					{					  if(!e.hasClass('ui-wrapped') && !e.hasClass('ui-omit'))							new _uiRadio(e);					});					break;			  case 'treeView':			    $$('.ui-make-treeView').each(function(e)					{					  if(!e.hasClass('ui-wrapped') && !e.hasClass('ui-omit'))							new _uiTreeView(e);					});					break;			  case 'slideShow':			    $$('.ui-make-slideShow').each(function(e)					{					  if(!e.hasClass('ui-wrapped') && !e.hasClass('ui-omit'))					  {					    var tmp  = e.getElements('img');					    var imgs = new Array();					    					    for(var i=0; i<tmp.length; i++)					      imgs.push({src: tmp[i].src, title: tmp[i].title ? tmp[i].title : tmp[i].alt});							e.empty();							new _uiSlideShow(e, imgs, JSON.decode(e.title));							e.removeProperty('title');						}					});					break;			  case 'overinput':			    $$('input[alt], ui-make-overinput').each(function(e)					{						if(e.alt!=null && !e.hasClass('ui-wrapped') && !e.hasClass('ui-omit'))						{							new OverText(e, {wrap: false, poll: true});							e.addClass('ui-wrapped');						}					});			    break;			}		});	},	setBrowserInfo: function()	{	  $('body').addClass(Browser.name+' '+Browser.name+Browser.version+' flash'+Browser.Plugins.Flash.version+' '+Browser.Platform.name);	},		makeTogglable: function(toggler, element, timeout, linkedTogglers)   {      if(!timeout)    timeout = 1000;      if(timeout<500) timeout = 500;		toggler.store('fxm', new Fx.Morph(element, {duration: timeout-300}).set({opacity: 0}));		toggler.store('fxs', new Fx.Slide(element, {duration: timeout, mode: 'vertical', transition: 'quad:out', resetHeight: true}).hide());		if(linkedTogglers) toggler.store('linked', linkedTogglers.length ? linkedTogglers : [linkedTogglers]);		toggler.addEvent('click', function()		{		   this.retrieve('fxm').start({opacity: this.retrieve('fxs').open ? [1,0] : [0,1]});		   this.retrieve('fxs').toggle();		   var linked = this.retrieve('linked');		   if(linked)		   {			   var length = linked.length;			   for(var i=0; i<length; i++)			   {				   if(linked[i].retrieve('fxs').open && this!=linked[i])					{						linked[i].retrieve('fxm').start({opacity: [1,0]});				   	linked[i].retrieve('fxs').slideOut();				   }			   }		   }		   		   if(this.get('type')!='checkbox')		   	return false;		});   }});var controls = new _uiControls();// ---------------------------------------------------------------------------------------------------// Button// ---------------------------------------------------------------------------------------------------var _uiHtmlButton = new Class({	e: null,	capsule: null,  initialize: function(e)  {    this.e     = e;    var parent = e.getParent();    var size   = e.getSize();    e.setStyle('display', 'none');    e.addClass('ui-wrapped');    this.capsule = new Element('div',		{			'class': 'ui-htmlButton',			styles:			{				width: size.x			}		});    var link = new Element('a',		{			text: e.get('value') ? e.get('value') : e.get('text'),			title: e.get('title'),			'class': 'link',			styles:			{			},			events:			{			  click: function()			  {			    if(e.get('tag')!='a')			    {				    var form = this.e.getParent('form');				    if(form) this.e.getParent('form').submit();				    else this.e.fireEvent('click');			    }					return true;			  }.bind(this)			}		});		if(e.get('tag')=='a') link.set('href', e.get('href'));		this.capsule.adopt(link);    // Borders    link.adopt(new Element('span', {'class': 'border _top'}));    link.adopt(new Element('span', {'class': 'border _left'}));    link.adopt(new Element('span', {'class': 'border _bottom'}));    link.adopt(new Element('span', {'class': 'border _right'}));    parent.adopt(this.capsule);    this.capsule.adopt(e);  }});// ---------------------------------------------------------------------------------------------------// Scroller// ---------------------------------------------------------------------------------------------------var _uiScroller = new Class({  Implements: [Options],	e: null,	capsule: null,	label: null,	count: null,	options:	{	  max: 0,               		// If non-zero checks for maximum value	  min: 0,	  negativeValues: false,	  showMax: false,          	// Create max element for displaying max value	  autoWidth: false	},		events: null,  initialize: function(e, opts)  {   	this.e     = e;   	this.count = parseInt(this.e.get('value'));    var parent = this.e.getParent();    var size   = this.e.getSize();    this.setOptions(opts);    this.e.addClass('ui-wrapped');        this.capsule = new Element('div',		{			'class': 'ui-scroller',			styles:			{			  position: 'relative',				width: size.x,				height: size.y			}		});				if(this.options.showMax)		{	    this.label = new Element('input',			{				styles:				{				  position: 'absolute',				  top: 0,				  left: 0,					width: size.x,					height: this.e.getStyle('height'),					'text-align': this.e.getStyle('text-align')				},				events:				{				  keydown: function(ev)					{						this.e.fireEvent('keydown', ev);					}.bind(this)				}			});			this.label.set('value', this.count+'/'+this.options.max);			this.capsule.adopt(this.label);		}		    var plus = new Element('a',		{			text: '+',			href: '',			'class': 'plus',			styles:			{			  position: 'absolute'			},			events:			{			  click: function()			  {			    this.plus();			    this._runEvents('plus');					return false;			  }.bind(this)			}		});		this.capsule.adopt(plus);		    var separator = new Element('div',		{			'class': 'separator',			styles:			{			  position: 'absolute'			}		});		this.capsule.adopt(separator);    var minus = new Element('a',		{			text: '-',			href: '#',			'class': 'minus',			styles:			{			  position: 'absolute'			},			events:			{			  click: function()			  {			    this.minus();			    this._runEvents('minus');					return false;			  }.bind(this)			}		});		this.capsule.adopt(minus);		e.addEvent('keydown', function(ev)		{			switch(ev.code)			{			  case 38:  // up          this.plus();          this._runEvents('plus');          break;			  case 40:  // down					this.minus();					this._runEvents('minus');			    break;			}						return true;		}.bind(this));		e.addEvent('keyup', function(ev)		{			switch(ev.code)			{			  case 38:			  case 40:			    break;				default:				  this.count = parseInt(this.e.get('value'));				  this._runEvents('change');				  break;			}			return true;		}.bind(this));		    e.inject(this.capsule, 'top');    parent.adopt(this.capsule);    this.autoWidth();  },    plus: function()  {    if((this.count+1)<=this.options.max || !this.options.max)			this.e.set('value', ++this.count);		if(this.label)		  this.label.set('value', this.count+'/'+this.options.max);		  		this.e.fireEvent('change');    this.autoWidth();  },    minus: function()  {    if((this.count-1)>=this.options.min || this.options.negativeValues)			this.e.set('value', --this.count);					if(this.label)		  this.label.set('value', this.count+'/'+this.options.max);		this.e.fireEvent('change');    this.autoWidth();  },  autoWidth: function()  {    if(this.options.autoWidth)    {      var width = parseInt(this.e.getStyle('font-size'))-3;          if(this.label)      {        width = this.label.get('value').length*width;        this.capsule.setStyle('width', width);        this.label.setStyle('width', width-2);        this.e.setStyle('width', width-2);      }      else      {        width = this.e.get('value').length*width;        this.capsule.setStyle('width', width);        this.e.setStyle('width', width);      }    }  },    addEvent: function(name, fn)  {    if(!this.events) this.events = new Array();    this.events.push({name: name, fn: fn});  },    _runEvents: function(name)  {    if(this.events)    {	    var length = this.events.length;	    for(var i=0; i<length; i++)	    {	      var e = this.events[i];	      if(name==e.name) e.fn();	    }    }  }});// ---------------------------------------------------------------------------------------------------// Select// ---------------------------------------------------------------------------------------------------var _uiSelect = new Class({  Implements: [Options],	e: null,	options:	{	  dropdownTime: 200,		useWrapped: true,		arrowText: '»'	},	capsule: null,	select: null,	arrowOver: null,	arrow: null,	wrapper: null,	list: null,	fxList: null,	inst: null,      // Static  initialize: function(e, opts)  {   	this.e  = e;    var parent = e.getParent();    var size   = e.getSize();    this.setOptions(opts);    if(!_uiSelect.inst) _uiSelect.inst = new Array();    _uiSelect.inst.push(this);    e.addClass('ui-wrapped');    e.setStyles({position: 'absolute', 'z-index': 4, opacity: 0});    this.capsule = new Element('div',		{			'class': 'ui-select',			styles:			{			  position: 'relative',				width: size.x,				height: size.y			}		});    this.select = new Element('div',		{			text: e.options[e.selectedIndex].text,			'class': 'select',			styles:			{			  position: 'absolute',			  top: 0,			  left: 0,			  width: size.x,			  height: size.y,			  'line-height': size.y,			  overflow: 'hidden',			  'white-space': 'nowrap',			  cursor: 'pointer',			  'z-index': 2			},			events:			{			  click: function()			  {			    if(this.fxList) this.fxList.toggle();			  }.bind(this)			}		});		this.capsule.adopt(this.select);    this.arrowOver = new Element('div',		{			'class': 'arrowOver',			styles:			{			  position: 'absolute',			  cursor: 'pointer',			  'z-index': 3			},			events:			{			  click: function()			  {			    if(this.fxList) this.fxList.toggle();			  }.bind(this)			}		});    this.arrow = new Element('div',		{			text: this.options.arrowText,			'class': 'arrow',			styles:			{			  cursor: 'pointer'			},			events:			{			  click: function()			  {			    if(this.fxList) this.fxList.toggle();			  }.bind(this)			}		});		this.arrowOver.adopt(this.arrow);		this.capsule.adopt(this.arrowOver);    this.capsule.adopt(e);    parent.adopt(this.capsule);		this.options.useWrapped ? this.useWrapped() : this.useDefailt();  },  useDefault: function()  {		this.e.addEvent('change', function()		{		  this.select.set('text', this.e.options[this.e.selectedIndex].text);		}.bind(this));		this.e.setStyle('visibility', 'visible');  },  useWrapped: function(size)  {		var size = this.capsule.getSize();		this.wrapper = new Element('div',  	{			'class': 'listWrapper',  	  styles:  	  {			  position: 'absolute',			  top: size.y+1,			  left: 0,			  width: size.x,			  'z-index': 1			}		});    this.list = new Element('ol',    {      'class': 'list',			styles:			{			  position: 'absolute',			  top: 0,			  width: (size.x-2)+'px',			  'max-height': '300px',			  margin: 0,				'overflow-y': 'auto',				'overflow-x': 'hidden',				'z-index': 1			}    });    for(var i=0; i<this.e.options.length; i++)    {	    this.list.adopt(new Element('li',	    {	      'class': (!(i%2) ? 'odd ' : 'even ') + (!i ? 'first' : '') + (i==this.e.options.length-1 ? 'last' : ''),	      text: this.e.options[i].text,	      title: this.e.options[i].text,	      styles:				{				  cursor: 'pointer',				  'white-space': 'nowrap'				},	      events:	      {					click: function(arg)					{					  this.select.set('text', this.e.options[arg].text);					  this.e.selectedIndex = arg;					  this.fxList.toggle();					}.bind(this,i)	      }	    }));    }    this.wrapper.adopt(this.list);    this.capsule.adopt(this.wrapper);    this.fxList = new Fx.Slide(this.list,		{			duration: this.options.dropdownTime,			transition: 'quad:out',			wrapper: this.wrapper		}).hide();		this.fxList.addEvent('start', function()	  {	    for(var i=0; i<_uiSelect.inst.length; i++)	    {	      if(_uiSelect.inst[i]!=this)	        _uiSelect.inst[i].fxList.hide();	    }	    if(!this.fxList.open)				this.wrapper.setStyle('z-index',parseInt(this.wrapper.getStyle('z-index'))+5);	  }.bind(this));		this.fxList.addEvent('complete', function()	  {			if(!this.fxList.open)				this.wrapper.setStyle('z-index',parseInt(this.wrapper.getStyle('z-index'))-5);	  }.bind(this));    this.e.setStyle('visibility', 'hidden');  }});// ---------------------------------------------------------------------------------------------------// Checkbox// ---------------------------------------------------------------------------------------------------var _uiCheckbox = new Class({	orig: null,	capsule: null,	box: null,	check: null,	inst: null,  initialize: function(e)  {   	this.e     = e;    var parent = e.getParent();    var size   = e.getSize();		e.setStyle('display', 'none');    e.addClass('ui-wrapped');    if(!_uiCheckbox.inst) _uiCheckbox.inst = new Array();    _uiCheckbox.inst.push(this);    this.capsule = new Element('div',		{			'class': 'ui-checkox',			styles:			{			  position: 'relative',				width: size.x,				height: size.y			}		});		this.box = new Element('div',		{		  'class': 'cbBox',		  styles:		  {		    position: 'absolute',		    cursor: 'pointer'		  },		  events:		  {		    click: function()		    {		      this.toggle();		    }.bind(this)		  }		});		this.capsule.adopt(this.box);		this.check = new Element('div',		{		  //text: '●',		  'class': 'cbCheck',		  styles:		  {		    position: 'absolute',		    cursor: 'pointer'		  },		  events:		  {		    click: function()		    {		      this.toggle();		    }.bind(this)		  }		});		this.capsule.adopt(this.check);		label = parent.getElement('label[for="'+this.e.get('id')+'"]');		label.removeProperty('for');		label.addClass('cbLabel');		label.setStyle('position', 'absolute');		label.addEvent('click', function()		{		  this.toggle();		}.bind(this));		parent.adopt(this.capsule);		this.capsule.adopt(this.e);		this.capsule.adopt(label);		if(this.e.checked) this.check.toggleClass('checked');  },  toggle: function()  {    this.e.fireEvent('click');    this.e.checked = !this.e.checked;    this.check.toggleClass('checked');    if(this.e.get('onclick'))    {      var sid = this.e.get('id');      var id  = '_uiCheckbox'+_uiCheckbox.inst.length;			this.e.set('id', id);			eval(this.e.get('onclick').replace(new RegExp('this+', 'g'), '$(\''+id+'\')'));			this.e.set('id', sid);		}  }});// ---------------------------------------------------------------------------------------------------// Radio// ---------------------------------------------------------------------------------------------------var _uiRadio = new Class({	orig: null,	inst: null,  initialize: function(e)  {   	this.e     = e;    var parent = e.getParent();    var size   = e.getSize();    this.setOptions(opts);    if(!_uiRadio.inst) _uiRadio.inst = new Array();    _uiRadio.inst.push(this);    e.addClass('ui-wrapped');    e.setStyles({position: 'absolute', 'z-index': 4, opacity: 0});    this.capsule = new Element('div',		{			'class': 'ui-select',			styles:			{			  position: 'relative',				width: size.x,				height: size.y			}		});	}});// ---------------------------------------------------------------------------------------------------// List// ---------------------------------------------------------------------------------------------------var _uiList = new Class({  Implements: [Options],	options:	{	  checks: false,		columns: 1,		width: 250,		height: 200	},		win: null,        				// Main window handle	parent: null,	list: null,       				// UL  initialize: function(parent, opts)  {    this.setOptions(opts);    this.parent = parent;  		this.win = new Element('div',		{		  'class': 'ui-list',		  styles:		  {		    width: this.options.width,		    height: this.options.height,		    overflow: 'hidden'		  }		});				this.list = new Element('ul',		{		  'class': 'level-0',		  styles:		  {				margin: 0,				padding: 0		  }		});				this.win.adopt(this.list);		parent.adopt(this.win);	},		// Array of structure [{title: , value: , nodes: [...]}]	add: function(items)	{	  var level  = 0;	  var length = items.length;	  	  if(length)	  {	    for(var i=0; i<length; i++)	    {	      var row = this._insert(this.list, items[i]);	      if(items[i].nodes.length) this._add(row, items[i].nodes, level+1);	    }	  }	},		_add: function(parent, items, level)	{	  var length = items.length;		var list = new Element('ul',		{		  'class': 'level-'+level,		  styles:		  {				margin: 0,				'padding-left': 2*level		  }		});		parent.adopt(list);	  parent.store('fxMorph', new Fx.Morph(list, {duration: 250}));	  parent.store('fxToggle', new Fx.Slide(list, {duration: 250, transition: 'quad:out', resetHeight: true}).hide());      for(var i=0; i<length; i++)    {      var row = this._insert(list, items[i]);      if(items[i].nodes.length) this._add(row, items[i].nodes, level+1);    }	}.protect(),		_insert: function(parent, item)	{		var row = new Element('li',		{		  styles:		  {		    position: 'relative',		    padding: 0		  },		  events:		  {		    click: function()		    {		    }		  }		});				if(this.options.checks)		{			row.adopt(new Element('input',			{				type: 'checkbox',				value: item.value,				events:				{				  click: function()				  {				    this.getParent().getElements('input[type="checkbox"]').each(function(e)				    {				      if(e!=this) e.checked = this.checked;				    }.bind(this));				  }				}			}));						row.adopt(new Element('a',			{			  text: '',			  styles:			  {			    position: 'absolute',			    top: 0,			    right: 0,			    'font-size': 9			  },				events:				{				  click: function()				  {				    this.getParent().getElements('input[type="checkbox"]').each(function(e)				    {				      e.checked = !e.checked;				    });				  }				}			}));		}				row.adopt(new Element('label',		{			text: item.title,			styles:			{			  position: 'absolute',			  top: 0,			  left: 18,			  right: 10			  			},			events:			{			  click: function()			  {	        this.getParent().retrieve('fxMorph').start({opacity: this.getParent().retrieve('fxToggle').open ? [1,0] : [0,1]});	        this.getParent().retrieve('fxToggle').toggle();			  }			}		}));				parent.adopt(row);		return row;	}.protect()});// ---------------------------------------------------------------------------------------------------// Tree// ---------------------------------------------------------------------------------------------------var _uiTreeView = new Class({  initialize: function(e)  {    e.addClass('ui-treeView ui-wrapped');    this.browse(e);  /*  	list = e.getChildren('ul');   	for(var i=0; i<list.length; i++)			this.browse(list[i]);	*/  },	browse: function(list)	{	  if(list)	  {		  list.getChildren('li').each(function(item)			{			  item.setStyle('position', 'relative');				var active  = item.hasClass('active');				var childen = item.getChildren('ul');				for(var i=0; i<childen.length; i++)   			{					var child = childen[i];				  if(child)				  {				    item.setStyle('background', '0');				    					  wrapper = new Element('div',					  {							styles:							{							}					  });					  toggler = new Element('a',					  {					    text: active ? '-' : '+',							'class': 'toggler',							href: '',					    events:					    {					      click: function()					      {		              this.set('text', this.retrieve('fxToggle').open ? '+' : '-');		              this.retrieve('fxMorph').start({opacity: this.retrieve('fxToggle').open ? [1,0] : [0,1]});		              this.retrieve('fxToggle').toggle();		              return false;					      }					    }					  });					  toggler.store('fxMorph', new Fx.Morph(child, {duration: 500}));					  toggler.store('fxToggle', new Fx.Slide(child, {duration: 500, transition: 'quad:out', resetHeight: true, wrapper: wrapper}));					  if(!active) toggler.retrieve('fxToggle').hide();					  					  // Dont know really why, but with this style IE7 dont gets crazy					  if(Browser.ie7)					  	wrapper.setStyle('position', 'relative');					  wrapper.adopt(child);					  item.adopt(wrapper);					  item.adopt(toggler);					  this.browse(child);					}				}			}.bind(this));		}	}});// ---------------------------------------------------------------------------------------------------// SlideShow// ---------------------------------------------------------------------------------------------------var _uiSlideShow = new Class({  Implements: [Options],	h: null,	size: null,		options:	{	   images: true,		  delay: 6000,	  random: false,	  adjustSize: false,   				// Adjust size to boxing element		clickToFullSize: false,     // This setting uses mediabox advanced		description: false,         // Show title of the image	  menu: false,	  	  effects:	  {	    transition: true,	    slide: false,	    move: false	  },		controls:		{		  proggress: false,		  timing: false		},		loading:		{		  visible: true,		  delay: 500,		  progress: true,		  bgColor: '#fff'		}	},	eDisplay: null,	eMenu: null,	eDescPos: null,	eDesc: null,	// Controls	controls:	{		h: null,    // Controls window		progress:		{		  enabled: false,		  h: null,		  hDone: null,		  hCount: null		},		timing:		{		  enabled: false,		  h: null,		  hText: null,		  hGraph: null		}	},	// Images	images: new Array(),  loaded: 0,    						// Preload status  count: 0,     						// Img count	current: 0,	timeout: 0,     					//  Time	timein: 0,	dImgCheckLoad: null, 			// Delay before check	// Loading	eLoading: null,	dLoadingStart: null,	dLoadingStop: null,	// Slides	hPeriod: null,		// Effects	efFns: new Array(),  initialize: function(e, imgs, opts)  {		this.h = e;		this.h.setStyle('position', 'relative');		this.h.setStyle('z-index', 0);		e.addClass('ui-slideShow');		this.size = this.h.getSize();		this.setOptions(opts);				this.options.delay = Math.round(this.options.delay/1000)*1000;	// Makes sure that only whole second were inputed		this.iniDisplay();		this.iniControls();		this.iniEffects();		this.iniDescription();		if(this.options.random) imgs.sort(this.aRnd);		this.count = imgs.length;		for(var i=0; i<this.count; i++)			this.options.images ? this.imgLoad(imgs[i]) : this.divLoad(imgs[i]);		if(this.options.menu) this.iniMenu();		this.loadingStart();		this.current = 0;		this.display();		this.timein	 = 0;		this.timeout	= this.options.delay/1000;		if(this.images.length>1)			this.hPeriod = this.autoplay.periodical(1000, this);	},	// ------------------------------------------------------------------------------------------------------------------------	// Slideshow	display: function()	{		if(this.options.menu)		{			for(var i=0; i<this.images.length; i++)			{				if(this.current==i) this.images[i].hMenu.addClass('active');				else this.images[i].hMenu.removeClass('active');			}		}		if(this.dImgCheckLoad)		{			clearInterval(this.dImgCheckLoad);			this.dImgCheckLoad = null;		}		clearInterval(this.dLoadingStart);		if(this.images.length>1)			this.dLoadingStart = this.loadingStart.delay(this.options.delay-this.options.loading.delay, this);		if(!this.images[this.current].completed)		{			this.eLoading.setStyles(			{				'background-image': 'url("/img/common/loading.gif")',				'background-position': (this.size.x/2-16)+'px '+(this.size.y/2-16)+'px',				'background-repeat': 'no-repeat'			});			this.dImgCheckLoadProgress = true;			this.dImgCheckLoad				 = this.display.delay(75, this);			return;		}				if(this.options.description && this.images[this.current].title)		{			(function()			{				this.eDesc.set('text', this.images[this.current].title);				this.eDesc.retrieve('fxMorph').start({opacity: [0,0.7]});				this.eDesc.retrieve('fxSlide').slideIn();			}.delay(this.options.loading.delay, this));						if(this.images.length>1)			{				(function()				{					this.eDesc.retrieve('fxMorph').start({opacity: [0.7,0]});					this.eDesc.retrieve('fxSlide').slideOut();				}.delay(this.options.delay-this.options.loading.delay, this));			}		}		this.dLoadingStop = this.loadingStop.delay(this.options.loading.delay*2, this);				if(!this.options.loading.visible) this.runEffects();		else this.eDisplay.empty();		this.eDisplay.adopt(this.images[this.current].h);	},	autoplay: function()	{			if(this.timein==this.options.delay/1000)			{				this.timein	= 0;				this.timeout = this.options.delay/1000;				this.next();			}			else			{				this.timein++;				this.timeout--;			}			this.controlsSetTiming();	},	next: function()	{		this.current++;		if(this.current==this.count)			this.current = 0;		this.display();	},	prev: function()	{		this.current--;		if(this.current<0)			this.current = this.count-1;		this.display();	},	// ------------------------------------------------------------------------------------------------------------------------	// Elements	iniDisplay: function()	{		this.eDisplay = new Element('div',		{			'class': 'display',			styles:			{				position: 'absolute',				top: 0,				left: 0,				width: this.size.x+'px',				height: this.size.y+'px',				'text-align': 'center',				overflow: 'hidden'			},			events:			{				click: function()				{				}.bind(this)			}		});		this.h.adopt(this.eDisplay);	},	iniMenu: function()	{		this.eMenu = new Element('ul',		{			'class': 'menu',			styles:			{				position: 'absolute'			}		});		for(var i=0; i<this.count; i++)		{			var li = new Element('li');			var a = new Element('a',			{				//text: i,				href: '',				rel: i			});			a.addEvent('click', function(el)			{				for(var i=0; i<this.images.length; i++)				{					if(this.images[i].hMenu==el)					{						// Stop all						clearInterval(this.hPeriod);						clearTimeout(this.dLoadingStart);						clearTimeout(this.dLoadingStop);						this.loadingStart();						this.dLoadingStop = this.loadingStop.delay(this.options.loading.delay, this);						this.current = i;						this.display.delay(this.options.loading.delay, this);						this.timein	= 0;						this.timeout = this.options.delay/1000;						this.controlsSetTiming();						this.hPeriod = this.autoplay.periodical(1000, this);						break;					}				}				return false;			}.bind(this, li));			li.adopt(a);			this.images[i].hMenu = li;			this.eMenu.adopt(li);		}		this.h.adopt(this.eMenu);	},	iniControls: function()	{		this.controls.progress.enabled = this.options.controlsProgress;		this.controls.timing.enabled	 = this.options.controlsTiming;		this.controls.h = new Element('div',		{			'class': 'controls',			styles:			{				position: 'absolute',				'z-index': '1000'			}		});		// Progress		if(this.controls.progress.enabled)		{			this.controls.progress.h = new Element('span',			{				'class': 'progress'			});			this.controls.h.adopt(this.controls.progress.h);		}		// Timing		if(this.controls.timing.enabled)		{			this.controls.timing.h = new Element('span', {'class': 'timing'});			this.controls.timing.hText = new Element('label');			this.controls.timing.h.adopt(this.controls.timing.hText);			this.controls.timing.hGraph = new Element('span');			this.controls.timing.h.adopt(this.controls.timing.hGraph);			this.controls.h.adopt(this.controls.timing.h);		}		this.h.adopt(this.controls.h);	},		iniDescription: function()	{		if(this.options.description)		{			this.eDescPos = new Element('div',			{				'class': 'descPos',				styles:				{					position: 'absolute',					top: 0,					width: '100%',					'z-index': 1000				}			});			this.eDesc = new Element('div',			{				'class': 'desc'			});						this.eDescPos.adopt(this.eDesc);			this.h.adopt(this.eDescPos);						this.eDesc.store('fxMorph', new Fx.Morph(this.eDesc, {duration: 500}));			this.eDesc.store('fxSlide', new Fx.Slide(this.eDesc, {duration: 500, transition: 'quad:out', resetHeight: true}));			this.eDesc.retrieve('fxMorph').set({opacity: 0});			this.eDesc.retrieve('fxSlide').hide();		}	},	// ------------------------------------------------------------------------------------------------------------------------	// Loading	loadingStart: function()	{		if(!this.eLoading)		{			this.eLoading = new Element('div',			{				styles:				{					position: 'absolute',					top: 0,					left: 0,					width: this.size.x,					height: this.size.y				}			});			if(this.options.loading.progress)				this.eLoading.setStyle('background', 'url("/img/common/loading.gif") no-repeat '+(this.size.x/2-16)+'px '+(this.size.y/2-16)+'px');			if(this.options.loading.visible)				this.eLoading.setStyle('background-color', this.options.loading.bgColor);			this.fxLoading = new Fx.Morph(this.eLoading, {duration: this.options.loading.delay}).set({opacity: 0});			this.fxLoading.start({opacity: [0,1]});			this.h.adopt(this.eLoading);		}	},	loadingStop: function()	{		if(this.eLoading)		{			this.fxLoading.start({opacity: [1,0]});			(function()			{				if(this.eLoading)				{					this.eLoading.dispose();					this.fxLoading = null;					this.eLoading	= null;				}			}.delay(this.options.loading.delay, this));		}	},	// ------------------------------------------------------------------------------------------------------------------------	// Effects	iniEffects: function()	{		// Transition		if(this.options.effects.transition)		{			this.efFns.push(function()			{				if(this.images.length>1)				{					(function(current)					{						new Fx.Morph(this.images[current].h, {duration: this.options.loading.delay*5}).start({opacity: [1,0]});						this.images[current].h.setStyle('z-index', parseInt(this.images[current].h.getStyle('z-index'))+1);							(function()							{								this.dispose();								this.setStyle('z-index', 0);							}.delay(this.options.loading.delay*5, this.images[current].h));					}.delay(this.options.delay, this, this.current));				}				this.images[this.current].h.setStyle('opacity', 0);				new Fx.Morph(this.images[this.current].h, {duration: this.options.loading.delay*5}).start({opacity: [0,1]});			}.bind(this));		}		// Slide		if(this.options.effects.slide)		{			this.efFns.push(function()			{				// Should prevents from blinking when position changing				this.images[this.current].h.setStyle('left', this.images[this.current].h.getStyle('width'));				new Fx.Morph(this.images[this.current].h, {duration: this.options.loading.delay*4}).start(				{					left: [this.images[this.current].h.width, this.images[this.current].left]				});			}.bind(this));		}		// Move		if(this.options.effects.move)		{			this.efFns.push(function()			{				if(this.images.length>1)				{	 				this.images[this.current].h.setStyles(					{						width: this.images[this.current].h.width*2,						height: this.images[this.current].h.height*2					});					new Fx.Morph(this.images[this.current].h, {duration: this.options.delay+(this.options.loading.delay*5)}).start(					{						top: [-this.rnd(0,this.images[this.current].h.height), -this.rnd(0,this.images[this.current].h.height)],						left: [-this.rnd(0,this.images[this.current].h.width), -this.rnd(0,this.images[this.current].h.width)]					});				}			}.bind(this));		}	},	runEffects: function()	{		for(var i=0; i<this.efFns.length; i++)			this.efFns[i]();	},	// ------------------------------------------------------------------------------------------------------------------------	// IMG loading	imgLoad: function(img)	{		if(!img) return false;		if(img.src==null) return false;		var data =		{			h: null,			width: 0,			height: 0,			top: 0,			left: 0,			ratio: 0,			title: img.title,			hMenu: null,			completed: false		};		data.h = new Element('img',		{			src: img.src,			alt: img.title,			//morph: {duration: this.options.loading.delay*5},			styles:			{				position: 'absolute',				top: 0,				left: 0,				'z-index': 0			}		});		data.h.addEvent('load', function(el)		{				this.loaded++;				this.controlsSetProgress();				for(var i=0; i<this.images.length; i++)				{					if(this.images[i].h==el)					{						this.images[i].width	= this.images[i].h.width;						this.images[i].height = this.images[i].h.height;						// Adjust size to boxing element						if(this.options.adjustSize)						{							this.images[i].ratio = this.images[i].h.width>this.images[i].h.height ? this.images[i].h.width/this.size.x : this.images[i].h.height/this.size.y;							this.images[i].h.width	/= this.images[i].ratio;							this.images[i].h.height /= this.images[i].ratio;						}						// Center both vertical and horizontal						this.images[i].left = this.size.x/2-this.images[i].h.width/2;						this.images[i].top	= this.size.y/2-this.images[i].h.height/2;						this.images[i].h.setStyles(						{							top: this.images[i].top,							left: this.images[i].left						});						if(this.options.clickToFullSize)						{							this.images[i].h.setStyle('cursor', 'pointer');							this.images[i].h.addEvent('click', function()							{								Mediabox.open(this.h.src, this.h.alt, 'mediabox['+this.width+' '+this.height+']');							}.bind(this.images[i]));						}						//$('debug').innerHTML += '<p>'+JSON.encode(this.images[i])+'</p>';						this.images[i].completed = true;						break;					}				}		}.bind(this, data.h));		/*		data.h.addEvent('mousewheel', function()		{			new Request({url: this.src}).send();		});		*/		this.images.push(data);	},			// ------------------------------------------------------------------------------------------------------------------------	// IMG loading	divLoad: function(div)	{		var data =		{			h: null,			width: 0,			height: 0,			top: 0,			left: 0,			ratio: 0,			title: '',			hMenu: null,			completed: true		};		data.h = div;				var size = div.getSize();				data.width  = size.x;		data.height = size.y;				div.setStyles(		{			position: 'absolute',			top: 0,			left: 0,			'z-index': 0		});				this.images.push(data);	},	// Controls functions	controlsSetProgress: function()	{		if(this.controls.progress.enabled)		{			this.controls.progress.h.set('text', 'Nahráno '+this.loaded+' z '+this.count+' obrázků');		}	},	controlsSetTiming: function()	{		if(this.controls.timing.enabled)		{//			this.controls.timing.hText.set('text', 'Další obrázek za '+this.timeout+'s.');			var fx = new Fx.Morph(this.controls.timing.hGraph, {duration: 700, unit: '%'});			fx.start({width: (this.timeout/(this.options.delay/1000)*100)+'%'});		}	},	aRnd: function()	{		return (Math.floor(Math.random()*5));	},	rnd: function(min, max)	{		return Math.random()*(max - min);	}});// ---------------------------------------------------------------------------------------------------// Form Valid// ---------------------------------------------------------------------------------------------------var _uiFormValidator = new Class({	orig: null,	initialize: function(e)	{		var formValidator = new Form.Validator(e,		{			evaluateFieldsOnBlur: false,			evaluateFieldsOnChange: true		});		formValidator.addEvent('formValidate', function(passed, form, ev)		{			if(!passed)			{				alert('Formulář není správně vyplňen');			}		});		formValidator.add('cc_atleast1',		{				errorMsg: 'Vyplňte toto pole',				test: function(el)				{						if(!el.value.length) return false;						else return true;				}		});		formValidator.add('cc_atleast4',		{				errorMsg: 'Vyplňte aspoň 4 znaky',				test: function(el)				{						if(el.value.length<4) return false;						else return true;				}		});		formValidator.add('cc_pass',		{				errorMsg: 'Hesla nesouhlasí',				test: function(el)				{						if(el.value.length<4) return false;						else return true;				}		});		formValidator.add('cc_email',		{				errorMsg: 'Špatně zadaný formát emailu',				test: function(el)				{						if(el.value.match(new RegExp('^\\w(\\w|-|\\.)*@(\\w|-|\\.)+\\.\\w+$'))==null) return false;						else return true;				}		});		formValidator.add('cc_phone',		{				errorMsg: 'Špatně zadaný formát telefonního čísla',				test: function(el)				{						if(el.value.match(new RegExp('^((\\+|00){0,1}\\d{3} {0,1}){0,1}\\d{3} {0,1}\\d{6}$'))==null) return false;						else return true;				}		});		formValidator.add('cc_phone_short', //bez predcisli		{				errorMsg: 'Špatně zadaný formát telefonního čísla',				test: function(el)				{						if(el.value.match(new RegExp('^\\d{9}$'))==null) return false;						else return true;				}		});		formValidator.add('cc_postal',		{				errorMsg: 'Špatně zadaný formát poštovního čísla',				test: function(el)				{						if(el.value.match(new RegExp('^\\d{3} {0,1}\\d{2,3}$'))==null) return false;						else return true;				}		});		formValidator.add('cc_login',		{				errorMsg: 'Špatně zadaný login',				test: function(el)				{						if(el.value.match(new RegExp('^\\w*$'))==null) return false;						else return true;				}		});	}});
