// resize content div size on load
$(document).ready(function () {
	$('.scrollContainer div.panel').css('width', $(document).width()+'px');
	$('.bg img').css('width', $(document).width()+'px');
	
	
//	$('.bg').hover(function(){
//		$('#slider .navigation .selected').click();
//		});
	

   		$('#logobox h1').css('font-size', ($(document).width()/11)+'px');
		Cufon.replace('.fontShadow', { fontFamily: 'BIRTH OF A HERO', hover: true/*, textShadow: '#444 -1px -1px, #444 1px 1px' */});  //444


		//.fontWhite img
		//hover poskakuje
			$('.fontWhite, .socialIcon').bind('mouseenter', function() { 
			    var self = $(this);
			    idcko=this.id;  
			     $('#'+idcko+' img').animate({ top: '-12' }, 200, function(){ 
					 				$(this).animate({ top: '6' }, 200); 
					 			});
			    this.iid = setInterval(function() { 
			        $('#'+idcko+' img').animate({ top: '-12' }, 200, function(){ 
					 				$(this).animate({ top: '6' }, 200);			 			
					 });
			    }, 450);
			}).bind('mouseleave', function(){
			    this.iid && clearInterval(this.iid); 
			});
 
		//end hover poskauje
		

	//scrollbar 
	//$('#newsBox').jScrollPane();
	//$('#galleryBox').jScrollPane( { reinitialiseOnImageLoad: true });


 


	//galerka 
		$(".zoom").fancybox({
		openEffect	: 'none',
		closeEffect	: 'none'
	});
	 
	 
	 // video iframe
	 	$(".videoIframe").fancybox({
		maxWidth	: 800,
		maxHeight	: 600,
		fitToView	: false,
		width		: '70%',
		height		: '70%',
		autoSize	: false,
		closeClick	: false,
		openEffect	: 'none',
		closeEffect	: 'none'
	});
	 
	 $(".videoIframe").click(function(){
	 	
	 	$("#jquery_jplayer").jPlayer("pause", 0);	
	 });
	 
	 
	 
	 
	 


	//track name icon change
	$('.track').mouseover(function(){	
		$(this).find("img").attr("src", "img/play.png");
		});
		
	$('.track').mouseout(function(){	
		$(this).find("img").attr("src", "img/toPlayer.png");
		});
		
		
	
	// formular
	
	//mazanie onclick
	$('#formName').click(function(){
		if($(this).val()=="Tvoje meno") $(this).val("");
		});
	$('#formMail').click(function(){
		if($(this).val()=="E-mail") $(this).val("");
		});
	$('#formText').click(function(){
		if($(this).val()=="Text správy") $(this).val("");
		});

	//overenie
	$('#formSend').click(function(){
		var er1=0, er2=0;
		
		
		if( $('#formMail').val()=="E-mail" || $('#formMail').val()=="" ){
			er1=1;
			$('#mailErr').fadeIn(100);	
			}else{
			er1=0;
			$('#mailErr').fadeOut(100);	
			}
		
		if( $('#formText').val()=="Text správy" || $('#formText').val()=="" ){
			er2=1;
			$('#textErr').fadeIn(100);	
			}else{
			er2=0;
			$('#textErr').fadeOut(100);	
			}
		
		if(er1==0 && er2==0){
			$('#form').submit();
			}
		
		});


//klavesnica sipky zmiznu,trosku

$('#keyboard').delay(3000).animate({opacity: 0.25}, 350);
$('#keyboard').hover(function(){ $(this).animate({opacity: 1}, 350); });
$('#keyboard').mouseout(function(){ $(this).animate({opacity: 0.25}, 350); });


});//doc ready end


//scrollbars 2style
$(function(){
	var settings = { autoReinitialise: true };
	var pane = $('#galleryBox')
	pane.jScrollPane(settings); 
});


$(function(){
	var settingsg = { autoReinitialise: true };
	var paneg = $('#newsBox')
	paneg.jScrollPane(settingsg); 
});












	//on change windowsize
$(function(){
    $(window).resize(function(){ 
		$('.scrollContainer div.panel').css('width', $(document).width()+'px'); 
		$('.bg img').css('width', $(document).width()+'px'); 
   		
   		$('#logobox h1').css('font-size', (($(document).width()-80)/11)+'px');
		Cufon.replace('.fontShadow', { fontFamily: 'BIRTH OF A HERO', hover: true/*, textShadow: '#444 -1px -1px, #444 1px 1px' */ }); //444
   		
   		$('#slider .navigation .selected').click(); 
   		
    });
});



//fontik 


Cufon.replace('.font', { fontFamily: 'BIRTH OF A HERO', hover: true }); 
Cufon.replace('.fontShadow', { fontFamily: 'BIRTH OF A HERO', hover: true/*, textShadow: '#444 -1px -1px, #444 1px 1px' */}); //444
Cufon.replace('.fontWhite', { fontFamily: 'BIRTH OF A HERO', hover: true, textShadow: '#fff 0px 1px, #fff 1px 0px' }); 






//jquery audio player

$(document).ready(function(){

	// Local copy of jQuery selectors, for performance.
	var	my_jPlayer = $("#jquery_jplayer"),
		my_trackName = $("#musicContent .track-name"),
		my_playState = $("#musicContent .play-state"),
	//	my_extraPlayInfo = $("#musicContent .extra-play-info"),
		perctBox = $("#musicContent .perctentBox");

	// Some options
	var	opt_play_first = false, // If true, will attempt to auto-play the default track on page loads. No effect on mobile devices, like iOS.
		opt_auto_play = true, // If true, when a track is selected, it will auto-play.
		opt_text_playing = "Now playing", // Text when playing
		opt_text_selected = "Track selected"; // Text when not playing

	// A flag to capture the first track
	var first_track = true;

	// Change the time format
	$.jPlayer.timeFormat.padMin = true;
	$.jPlayer.timeFormat.padSec = true;
	$.jPlayer.timeFormat.sepMin = ":";
	$.jPlayer.timeFormat.sepSec = "";

	// Initialize the play state text
	my_playState.text(opt_text_selected);

	// Instance jPlayer
	my_jPlayer.jPlayer({
		ready: function () {
			$(".track-default").click();
		},
		timeupdate: function(event) {
			//my_extraPlayInfo.text(parseInt(event.jPlayer.status.currentPercentAbsolute, 10) + "%");
			
			perctBox.css( "width" , event.jPlayer.status.currentPercentAbsolute + "%" );
		},
		play: function(event) {
			//my_playState.text(opt_text_playing);
		},
		pause: function(event) {
			//my_playState.text(opt_text_selected);
		},
		ended: function(event) {
			//my_playState.text(opt_text_selected);
		},
		swfPath: "js/jplayer",
		cssSelectorAncestor: "#musicContent",
		supplied: "mp3",
		wmode: "window"
	});

	// Create click handlers for the different tracks
	$(".track").click(function(e) {
		my_trackName.text($(this).text());
		my_jPlayer.jPlayer("setMedia", {
			mp3: $(this).attr("href")
		});
		if((opt_play_first && first_track) || (opt_auto_play && !first_track)) {
			my_jPlayer.jPlayer("play");
		}
		first_track = false;
		$(this).blur();
		return false;
	});

});






// prava lava sipka klavesnica , ocekujeme ci je otvoreny fancybox
$(document).keydown(function(e){
    if (e.keyCode == 39) {         
       if ( $('#fancybox-overlay').length <=0 ){ $('#slider img.right').click(); } 
       return false;
    }
});

$(document).keydown(function(e){
    if (e.keyCode == 37) {  
       if ( $('#fancybox-overlay').length <=0 ){ $('#slider img.left').click(); } 
       return false;
    }
});











