// JavaScript Document


window.addEvent('domready', function(){

  ReMooz.assign('.remooz, .pix a', {
					'origin': 'img',
					'shadow': 'onOpen', // fx is faster because shadow appears after resize animation
					'resizeFactor': 0.9, // resize to maximum 80% of screen size
					'cutOut': false, // don't hide the original
					'opacityResize': 0, // opaque resize
					'dragging': true, // disable dragging
					'centered': true // resize to center of the screen, not relative to the source element
				});

});

// http://davidwalsh.name/dwclickable-entire-block-clickable-mootools-12
// dwClickable: Entire Block Clickable Using MooTools 1.2

var dwClickables = new Class({
	
	//implements
	Implements: [Options],

	//options
	options: {
		elements: $$('div'),
		selectClass: '',
		anchorToSpan: false
	},
	
	//initialization
	initialize: function(options) {
		//set options
		this.setOptions(options);
		//set clickable
		this.doClickables();
	},
	
	//a method that does whatever you want
	doClickables: function() {
		
		//for all of the elements
		this.options.elements.each(function(el) {
			
			//get the href
			var anchor = el.getElements('a' + (this.options.selectClass ? '.' + this.options.selectClass : ''))[0];
			
			//if we found one
			if($defined(anchor)) {
				
				//add a click event to the item so it goes there when clicked. 
				this.setClick(el,anchor.get('href'));
				
				//modify anchor to span if necesssary
				if(this.options.anchorToSpan) {
					var span = new Element('span',{
						text: anchor.get('text')
					}).replaces(anchor);
				}
			}
			
		},this);
	},
	
	//ads the click event
	setClick: function(element,href) {
		
		element.addEvent('click', function() {
			window.location = href;
		});
	}
	
});



var Video = {
	  init: function(){
			  
				var collection = $$('.image a.play');
				var divs = $$('.video-item');
				collection.each(function(element, index){
						var divId = divs[index].getProperty('id');
				    element.addEvent('click', function(event){
								event.preventDefault();
								var obj = new Swiff(divId+'.swf', {
									id: divId,
									width: 388,
									height: 290,
									container: divId,
									params: {
											wmode: 'opaque',
											bgcolor: '#000000'
									}
								});
						});
				});
		}
};


window.addEvent('domready', function() {
	
	var clix = new dwClickables({
		elements: $$('.clickable'),
		anchorToSpan: false
	});
	
	
    //store titles and text
			$$('a.tipz').each(function(element,index) {
				var content = element.get('title').split('::');
				element.store('tip:title', content[0]);
				element.store('tip:text', content[1]);
			});
			
			//create the tooltips
			var tipz = new Tips('.tipz',{
				className: 'tipz',
				fixed: true,
				hideDelay: 50,
				showDelay: 50
			});
			
			//customize
			
			tipz.addEvents({
				'show': function(tip) {
					tip.fade('in');
				},
				'hide': function(tip) {
					tip.fade('out');
				}
			});
			

	if ($('page-ukazky')) {
		Video.init();
	}
	
	if ($('video-slideshow')) {
	
	Video.init(); 
	
		//SAMPLE 8 - slideshow
			
			
			var thumbs = $$('#slide_thumbs a');
			var nS8 = new noobSlide({
				box: $('video-slideshow'),
				items: $$('#video-slideshow img'),
				size: 650,
				handles: $$('#slide_thumbs a'),
				addButtons: {previous: $('prev'), next: $('next') },
				onWalk: function(currentItem,currentHandle){
					//style for handles
					$$(this.handles,thumbs).removeClass('active');
					$$(currentHandle,thumbs[this.currentIndex]).addClass('active');
					//text for "previous" and "next" default buttons
					//$('prev8').set('html','prev '+this.items[this.previousIndex].innerHTML);
					//$('next8').set('html',this.items[this.nextIndex].innerHTML+' next');
				}
			});
			//more "previous" and "next" buttons
			nS8.addActionButtons('previous',$$('#video-slideshow .prev'));
			nS8.addActionButtons('next',$$('#video-slideshow .next'));
			//more handle buttons
			nS8.addHandleButtons(thumbs);
			//walk to item 3 witouth fx
			nS8.walk(0,false,true);
		}
});