var styles = new Array();
styles["home"] = "red";
 styles["album"] = "brown";
 styles["galeria"] = "red3";
 styles["bio"] = "green2";
 styles["video"] = "purple2";
 styles["guestbook"] = "green4";
 styles["shop"] = "blue2";
 styles["kosik"] = "blue2";
 styles["partneri"] = "purple";
 styles["multimedia"] = "purple3";
 styles["booking"] = "green3";
 styles["blog"] = "red2";
 styles["koncerty"] = "blue";
 styles["odohrate"] = "blue";
 styles["novinky"] = "green";
 styles["album"] = "brown";
 styles["press"] = "orange";



document.write('<style>#content {visibility:hidden;} .skryt {display:none} .flashm {display:none} .alt {display:none} .sifr {visibility:hidden} .flash-update .alt {display:block}  </style>');
$(document).ready(function() {
	
	

jQuery.preloadImages = function()
{
  for(var i = 0; i<arguments.length; i++)
  {
//  	alert(arguments[i]);
    jQuery("<img>").attr("src", arguments[i]);
  }
}



if(location.hash == "") $("#content,H1").css({visibility:"visible"});
$('img[@src$=.png],input[@src$=.png],.pngfix').ifixpng();

 
 // vlas. funkcie
    jQuery.fn.extend({
      
     fobject: function(file,w,h) {  
    $(this).flash({
    src: file,
    width: w,
    height: h,
    wmode: "transparent"
}); 
$(this).css({visibility:"hidden"});
   },   
   
    cuttin: function() {    
    var max_l = 700;
    if(!$(this).attr("class")) return;
    var is_length = $(this).attr("class").split(" ");
		if(is_length[1])    {
				length = is_length[1].split("-");				
				if(length[1]) max_l = length[1];
		}
    
    $(this).truncate({max_length: max_l, more: "...viac", less: ""});

	   }
 })


$('table.zoznam tr').hover(
function(){
$(this).addClass("hover");
if($(this).children("td").children("a").attr("href")) {
$(this).css({cursor:"pointer"});
$(this).addClass("haslink");
}
},
function() {
$(this).removeClass("hover");
$(this).removeClass("haslink");
}
);



 $(".haslink").livequery('click', function() { 
 	location.href = $(this).children("td").children("a").attr("href");
 });
 
 
  	
 	$('.truncate').cuttin(); 	
	function pageload(hash) {
	
	
	if(!hash) return;
	
	
	$('#prev,#next,div.menu ul').addClass("remove");
		
    	var div = hash;    	
     	hash=hash.substr(1,hash.length);     	
     	var url = "index.php?page="+hash+"&version=lite";     	
     	
//     	if(hash == "home") $("div.foot-bar div.newsletter").css({visibility:"visible",display:"block"});
     	if(hash == "home") $("div.foot-bar div.newsletter").css({visibility:"visible"}); else $("div.foot-bar div.newsletter").css({visibility:"hidden"}); 
     	
		$("#object").html("");
     	$("body").removeClass().addClass(styles[hash]);     	
     	$("#favicon").attr({href:"/uploads/images/favicon/"+hash+".ico?test"});
     	     	
    	$("div.menu ul li").removeClass("active");	
		$("div.menu ul li a."+hash).parent("li").addClass("active");
		
		var prev_class = $("div.menu ul li.active").prev("li").children("a").attr("class");
		var next_class = $("div.menu ul li.active").next("li").children("a").attr("class");
	
		if(!prev_class) {  prev_class = $("div.menu ul li:last").children("a").attr("class"); }
    	if(!next_class) {  next_class = $("div.menu ul li:first").children("a").attr("class");  }
      
    	$("#prev").attr({rel:prev_class});     	
    	$("#next").attr({rel:next_class});
    	
    	var prev_title = $("div.menu ul li.active").prev("li").children("a").attr("title");
		var next_title = $("div.menu ul li.active").next("li").children("a").attr("title");
	
		if(!prev_title) {  prev_title = $("div.menu ul li:last").children("a").attr("title"); }
    	if(!next_title) {  next_title = $("div.menu ul li:first").children("a").attr("title");  }
      
    	$("#prev").attr({title:prev_title});     	
    	$("#next").attr({title:next_title});
    
    	
	$("#content").load(url+" #content-load","",function(responseText,textStatus, XMLHttpRequest){	
     	     
			$("#loading").fadeOut("normal");			
			$(".remove").removeClass("remove");			


 	 /*	if($(".action").length > 0) {
	     	
			if($(this).css("left") == "100%"){
				$(this).css({left: "-100%"});
			}else{
				$(this).css({left: "100%"});			
			}
			$(".action").removeClass();		
    	 }else{
    	 	$("#content").addClass("action");
    	 }
			*/
			
		if($(this).css("left") == "100%"){
				$(this).css({left: "-100%"});
			}else{
				$(this).css({left: "100%"});			
			}				
			
			
													 
			$(this).animate({left:"0",opacity:1},400);
			
			
			
			$('img[@src$=.png],input[@src$=.png],.pngfix').ifixpng();
			
			
			
			$(document).attr({title:$("h1").text()+' - '+$(".foot-bar h2 a img").attr("alt")});
			$(".foot-bar h2 a").attr({title:$("h1").text()});
				
				
				setAfterLoad();
				getPosition();
				
				
				$('.truncate').cuttin();
						
			$("#content,H1").css({visibility:"visible"})
			$('.myselectbox select').selectbox({debug: true});
				
		});    	
					
    	}    
	
	$.historyInit(pageload);
	
	$('#prev,#next,div.menu ul li:not([@class*=active]) a').livequery('click', function() {
	$("#object").hide();    
	
    $('#prev,#next').addClass("remove");
    if($("#loading").length < 1) $("#content-case2").prepend('<div id="loading"></div>');
    $("#loading").fadeIn("normal");  
    	return false; 
  	});
  	
  		$('#prev,#next,div.menu ul li.active a').livequery('click', function() {

    	return false; 
  	});
	
	//:not([@class*=remove])
$('#prev:not([@class*=remove])').livequery('click', function() {     
		
     var hash = $(this).attr('rel');    
     
     
     $("#content").animate({left:"-100%"},200,'',function(){
	 	echo($(this),hash,100);       
     });
     	
         
    });    
 
  $('#next:not([@class*=remove])').livequery('click', function() { 
           
  
  var hash = $(this).attr('rel');            
     
     
     $("#content").animate({left:"100%"},200,'',function(){
     	echo($(this),hash,-100);  	
     });     
            
     
         
    });
    
    
    $('div.menu ul:not([@class*=remove]) li:not([@class*=active]) a').livequery('click', function() {    		
     	var hash = $(this).attr('class');
     	
     var click = $("div.menu ul li a").index(this);     	     	     	 
     var selected = $("div.menu ul li").index($(".active"));
     
            
     if(selected < click) {
	      
      
     	$("#content").animate({left:"100%"},200,'',function(){
     		echo($(this),hash,-100);
     	});  
     
     }else if (click < selected) {
     
     
     $("#content").animate({left:"-100%"},200,'',function(){
     	echo($(this),hash,100);  
     });
     
     }
     
     
     	
     	
     return false; 	
         
    });    
    
    
    
    
    function echo(e,hash,position){    
    	$.historyLoad("_"+hash);

   }
  
  $('.lyrics .close').livequery('click', function() {
  $(".cover img").fadeIn("fast");  
		$('.lyrics').hide("normal"); 	       
 	return false;
 })
     
  $('td.txt a').livequery('click', function() {
  	if($(".album-cover .lyrics").length < 1) $(".album-cover").append('<div style="display:none" class="lyrics"></div>');
  	var url = $(this).attr("href");
  	
  	$(".album-cover .lyrics").hide("normal",function(){	
  	  	getLyrics(url);	 
 	
  	}); 	       
  	
 	return false;
 })
 
 function getLyrics(url) {
  	  $(".lyrics").load(url+" .case",'',function(){
  	  $(".cover img").fadeOut("fast");
			$(this).show("normal");
	})	
}
 




$('#gopen').livequery('click', function() {
	$(this).hide();
	
	$(".ghide").fadeIn();	      
 	return false; 	
 	
 })
 
if($.browser.safari == false) {
setAfterLoad();
} 

$('.myselectbox select').selectbox({debug: false})

});




 function getPosition() {
    
    var f_h = $("#foot").height();
    var w_width = $(window).width();
    var w_height = $(window).height();
    var wd_height = $(document).height();
    var c_width = $("#content").height();    
    var c_height = w_height-f_h;
    var o_height = $("#object embed").height(); 
    var b_height = $("body").height();    
    
      //if(wd_height >= w_height) {
  			if(w_height > 770) {
 				$("#object").css({top:($("#content").height()-(o_height/2)-16)});
					
				  				
  			}else if (w_height > 580) {
  			
  			
  			
  				var resize_top =  -(200-(w_height-580));
  				
  				if($.browser.msie == true && $.browser.version == 6){                
					//$("#content").css({height:(c_height-(w_height-620))});
				}else{
					$("#content").css({minHeight:(c_height-(w_height-578))});
				}
  				
  				$("#object").css({top:($("#content").height()-(o_height/2)-16)});
  				  				
  				$("body").css({position:"relative",marginTop:resize_top});
  						  				
  			}else{  		
  			
  				
  				var resize_top =  -180;
  				$("#object").css({top:($("#content").height()-(o_height/2)-16)});
				$("body").css({position:"relative",marginTop:resize_top});
  			}    		            		      
       //}
       
       
       if(w_width < 925)  {       
       	$("html").css({overflow : "auto"});
       	$("body").css({width : 990});
       }else{    	   
       	$("html").css({overflow : "hidden"});
       	$("body").css({width : "auto"});
       }
       
       if(w_height < 650){    	   
       //$("html").css({overflow : "auto"});
       }
       $("html").css({overflow : "auto"});
    $("#object").css({visibility:"visible"});
   }

function flirInit(){
	FLIR.init({ path:  'http://katarinaknechtova.com/plugins/facelift/'  } );
	$("H1,.flir").each( function() { 
	FLIR.replace(this);	
	
	} );
}

function setAfterLoad(){
	
if($("div.ghide").length > 1) {
$("div.ghide").hide();
	$("#content div.guestbook").append('<p class="pagination"><a href="#" id="gopen"><img src="uploads/images/texty/zobrazit-viac-prispevkov.png" alt="zobraziť viac príspevkov" style="width:211px; height:22px;" /></a>');
	$('#content div.guestbook p img[@src$=.png]').ifixpng();
}

if($(".menu ul li.active a").attr("rel")) {
 $("#object").show().fobject('/uploads/files/flash/'+$(".menu ul li.active a").attr("rel"),700,562);
 
 }
 $('td.mp3').each(function(){
 if($(this).children("a").attr("href")){
  $(this).flash({
    src: 'uploads/files/flash/musicplayer.swf',
    width: 34,
    height: 13,
    wmode: "transparent",
    flashvars: {  song_url: $(this).children("a").attr("href") }
}); 
 	}
 
 })
 
 
 $('div.demo ul li').each(function(){
 if($(this).children("a").attr("href")){
  $(this).flash({
    src: 'uploads/files/flash/musicplayer.swf',
    width: 34,
    height: 13,
    wmode: "transparent",
    flashvars: {  song_url: $(this).children("a").attr("href") }
}); 

$(this).children(".alt").html($(this).children(".alt").text());
 	}
 })
 
  
 
  $(".playplay").flash({
    src: 'uploads/files/flash/musicplayer_uvod.swf',
    width: 210,
    height: 37,
    wmode: "transparent",
    flashvars: {  song_url: $(".playplay").children("a").attr("href") }
}); 
 


 
  
$('form input[@type=text]').example(function() {return $(this).attr('title');});

$('div.gallery div.image .case').cycle({ 
    fx:     'scrollHorz',
    prev:   '#gprev', 
    next:   '#gnext',
    timeout: 0       
}); 




 
 getPosition();
 flirInit();
 
 $("#videplayer").flash({
    src: 'uploads/files/flash/player.swf',
    width: 599,
    height: 400,
    wmode: "transparent",
    className: "pngfix",    
    flashvars: { videoPath: $("#videourl").attr("href") }
}); 
  
  var prev_image_bg = '/uploads/images/css/bg-'+styles[$("#prev").attr("rel")]+'.png';   
  var prev_image_site = '/uploads/images/css/bg-'+styles[$("#prev").attr("rel")]+'-site.jpg';
  var prev_image_bg = '/uploads/images/css/bg-'+styles[$("#next").attr("rel")]+'.png';   
  var prev_image_site = '/uploads/images/css/bg-'+styles[$("#next").attr("rel")]+'-site.jpg';  
  $.preloadImages(prev_image_bg,prev_image_site,prev_image_bg,prev_image_site);
  
  
  $('#jcycle').parent("div").append('<p class="pagination" style="float:right;"><a href="#" id="cprev"><img src="/uploads/images/texty/predchadzajuca-cast.png" alt="predchádzajúca časť" /></a><span class="separator" style="display:none">&nbsp;<img src="/uploads/images/texty/separator.png" style="width:11px; height:22px;" alt="" />&nbsp;&nbsp;</span><a href="#" id="cnext"><img src="/uploads/images/texty/dalsia-cast.png" alt="ďalšia časť" /></a></p>');  
  $('#jcycle').cycle({
    
    prev:   '#cprev', 
    next:   '#cnext', 
      cleartype:  1,
    after:   onAfter, 
    timeout: 0 
	});
  
  
   
  }


$(window).load(function(){
		
if($.browser.safari == true) {

getPosition();
setAfterLoad();
}

}) 

$(window).resize(function(){		
   		getPosition();	
}) 

function onAfter(curr, next, opts) {
    var index = opts.currSlide;
    $('#cprev').css({visibility:[index == 0 ? 'hidden' : 'visible']});    
    $('#cnext').css({visibility:[index == opts.slideCount - 1 ? 'hidden' : 'visible']});
    if(index == 0  || opts.slideCount - 1 == index) {
    	$(".pagination .separator").hide();
    }else{
    	$(".pagination .separator").show();
    }
    $('p img[@src$=.png]').ifixpng();
}
