 $(document).ready(function() { 
 
 	newDate = new Date(); 
	var getMonth = newDate.getMonth() + 1;
	var getDay = newDate.getDate();
	var getYear = newDate.getFullYear();	
 
    $("a.lightbox").fancybox({
      'zoomSpeedIn': 300,
      'zoomSpeedOut': 300,
    	'overlayShow': true,
    	'overlayOpacity': 0.8,
    	'overlayColor': '#000',	
      'showCloseButton': true,
      'titleShow': true,      
      'titlePosition': 'over',	  
    });
    
    $("a#hra-tvare").fancybox({
		'zoomSpeedIn': 300,
		'zoomSpeedOut': 300,
		'overlayShow': true,
		'overlayOpacity': 0.8,
		'overlayColor': '#000',	
		'showCloseButton': true,
		'titleShow': true,      
		'titlePosition': 'over',	  
		'autoScale': false,
		'width':'700px',
		'height':'900px',
		'href' : this.href,	
		'type': 'swf',
		'swf': {
		  'wmode': 'transparent',
			'allowfullscreen': 'true'
		}
    });	
	
    $("a#hra-kuchar").fancybox({
		'zoomSpeedIn': 300,
		'zoomSpeedOut': 300,
		'overlayShow': true,
		'overlayOpacity': 0.8,
		'overlayColor': '#000',	
		'showCloseButton': true,
		'titleShow': true,      
		'titlePosition': 'over',
		'width':'800px',
		'height':'400px',
		'href' : this.href,	
		'type': 'swf',
		'swf': {
		  'wmode': 'transparent',
			'allowfullscreen': 'true'
		}
    });	

    $("a#hra-gulage").fancybox({
		'zoomSpeedIn': 300,
		'zoomSpeedOut': 300,
		'overlayShow': true,
		'overlayOpacity': 0.8,
		'overlayColor': '#000',	
		'showCloseButton': true,
		'titleShow': true,      
		'titlePosition': 'over',	  
		'autoScale': false,
		'width':'700px',
		'height':'900px',
    });		
	
	
    $("a.lightbox-video").click(function() {
    	$.fancybox({  
        	'zoomSpeedIn': 300,
        	'zoomSpeedOut': 300,
        	'overlayShow': true,
        	'overlayOpacity': 0.8,
        	'overlayColor': '#000',	    			
    			'autoScale'		: false,
    			'transitionIn'	: 'none',
    			'transitionOut'	: 'none',
    			'title'			: this.title,
    			'href' : this.href,			
    			'type'			: 'swf',
    			'swf'			: {
    			  'wmode'		: 'transparent',
    				'allowfullscreen'	: 'true'
    			}
    		});
    	return false;
    });
    
    $("a.lightbox-video-smaller").click(function() {
    	$.fancybox({  
        	'zoomSpeedIn': 300,
        	'zoomSpeedOut': 300,
        	'overlayShow': true,
        	'overlayOpacity': 0.8,
        	'overlayColor': '#000',	    			
    			'autoScale'		: false,
    			'transitionIn'	: 'none',
    			'transitionOut'	: 'none',
    			'title'			: this.title,
    			'titleShow':false,
    			'width':280,
          'height':210,
    			'href' : this.href,			
    			'type'			: 'swf',
    			'swf'			: {
    			  'wmode'		: 'transparent',
    				'allowfullscreen'	: 'true'
    			}
    		});
    	return false;
    });   

	var url = window.location.href;
	var splitted = url.split('/');
	if(splitted[splitted.length-2]){
		if(splitted[splitted.length-2]=='filip-sajler')hoverLogo('a','sp');
		else if(splitted[splitted.length-2]=='ondrej-slanina')hoverLogo('b','sp');
	}
	
	tab = $('#tabs1').tabs();
	tab.tabs('rotate', 6000, true);
	$('#tabs1 ul.miniMenu a').click(function() {
		tab.tabs('rotate', 0);
	});

	$('#tabs2').tabs();

	scroller.init();
	$('.dropdown').each(function(i,v){$(v).animate({height:'toggle'},0)});	
	
  });
 
scroller = {
	distance: 147,
	speed: 900,
	itemCnt: null,
	itemsVisible: 3,
	containerId: 'scroller',
	itemClass: 'scrollItem',
	leftId: 'scrollLeft',
	rightId: 'scrollRight',
	position: 0,
	move:3,
	
	init: function(){
		var items = $('#'+this.containerId+' .'+this.itemClass)
		this.itemCnt=items.length;
//		this.distance=items[0].offsetWidth+items[0].style.marginLeft+items[0].style.marginRight;
		if(!document.getElementById(this.containerId)
			|| !document.getElementById(this.leftId)
			|| !document.getElementById(this.rightId)) return false; 
		this.setButtons();
	},
	setButtons: function(){
		if(this.position+this.itemsVisible>=this.itemCnt){
			$('#'+this.rightId).addClass('disabled');
			document.getElementById(this.rightId).onclick=null;
		} else {
			$('#'+this.rightId).removeClass('disabled');
			document.getElementById(this.rightId).onclick=function(){scroller.right();};
		}
		if(this.position>0){
			$('#'+this.leftId).removeClass('disabled');
			document.getElementById(this.leftId).onclick=function(){scroller.left();};
		} else {
			$('#'+this.leftId).addClass('disabled');
			document.getElementById(this.leftId).onclick=null;
		}
	},
	end: function(){
		this.position=this.itemCnt>this.itemsVisible?this.itemCnt-this.itemsVisible:0;
		document.getElementById(this.containerId).style.left=-this.position*this.distance+'px';
		this.setButtons();
	},
	right: function(){
		var move = ( this.position+2*this.move < this.itemCnt ? this.move : this.itemCnt-this.position-this.move );
		$('#'+this.containerId).animate({left:'-='+move*this.distance},this.speed*move/this.move);
		this.position+=move;
		this.setButtons();
	},
	left: function(){
		var move = ( this.position >= this.move ? this.move : this.position );
		$('#'+this.containerId).animate({left:'+='+move*this.distance},this.speed*move/this.move);
		this.position-=move;
		this.setButtons();
	}
}
droped=false;
function dropdown(e){
	if(droped)$(droped).animate({height:'toggle'},500);
	if(droped==e)droped=false;
	else {
		$(e).animate({height:'toggle'},500);
		droped=e;
	}
}
  
function show_calendar(year, month){
	$.ajax({
		url: "/showCalendar/",
		data: "calendarAction=getCalendar&year="+year+"&month="+month,
		success: function(html){
			document.getElementById('calendar').innerHTML = html;
		}
	})
	return false;
}  
                        
function showVideo(type,videoId){ 
 var videoTA;
 var video = document.getElementById('video-'+videoId); 
 if(type=='next')videoTA = 'video-'+parseInt(videoId-1,10);
 else if(type=='prev')videoTA = 'video-'+parseInt(videoId+1,10);
 var videoAct = document.getElementById(videoTA);
 if(video){
	video.className='shown';
	videoAct.className='hidden';
 }
}

function hoverLogo(which,page){		
	if(page==undefined)page='hp'; 
	var logoWrapper = document.getElementById('hover-logo');	
	if(which==undefined){
		logoWrapper.style.background='';
	}else if(which=='a'){
		if(page=='hp'){
			logoWrapper.style.left='55px';		
			logoWrapper.style.width='246px';
			logoWrapper.style.height='372px';
		}else if(page=='sp'){
			logoWrapper.style.left='149px';		
			logoWrapper.style.width='173px';
			logoWrapper.style.height='178px';		
		}
		logoWrapper.style.background='url(/images/bg/header_'+page+'_a.jpg) no-repeat';
	}else if(which=='b'){
		if(page=='hp'){
			logoWrapper.style.left='255px';		
			logoWrapper.style.width='265px';
			logoWrapper.style.height='355px';
		}else if(page=='sp'){
			logoWrapper.style.left='319px';		
			logoWrapper.style.width='201px';
			logoWrapper.style.height='199px';		
		}
		logoWrapper.style.background='url(/images/bg/header_'+page+'_b.jpg) no-repeat';
	}		
}						
