$(document).ready(function(){

$('a[rel*=facebox]').facebox();
$("a[rel*=videogallery]").facebox();

var siteTitle = $("title").text();
var curloc = window.location.hash;
var curloc2='';
curloc1 = curloc.split("/");
curloc = curloc1[0];
if(curloc1[1]){curloc2 = '/'+curloc1[1];}else{curloc2 = '';}
if(curloc!='')
{
 $("a[href*='"+curloc+"']").each(function() {
  $('.navigation a.current').removeClass('current');
  $(this).addClass('current');
	var siteTitle = $(this).text();
	//document.title = $(this).text();
	$(this).click();
  location.hash = curloc+curloc2;
 });
}



function fixNavigation()
{
  var windowscrollTop = $(window).scrollTop();
	if(windowscrollTop>402){ $('.navigation ul').addClass('navigation-fixed');}
	else{ $('.navigation ul').removeClass('navigation-fixed');  }
}

fixNavigation()
$(window).scroll(function() {
 fixNavigation();
 
 $("h1 a[name!='']").each(function() {
	var thisname = $(this).attr('name');
	var windowscrollTop = $(window).scrollTop();
	var position = $(this).position();
	var tmp2 = position.top - windowscrollTop;
  if(tmp2>-80 && tmp2<=100){
	    $(".navigation a[href*="+thisname+"]").each(function() { 
			      $('.navigation a.current').removeClass('current');
            $(this).addClass('current');
						var sitetitle = $(this).text()+' - Àíäð³é Çàë³ñêî';
			      document.title = sitetitle;
			   });
	}
 });
 
});


$('a').click(function() {
			var sitetitle = $(this).text()+' - Àíäð³é Çàë³ñêî';
			//$('title').text(sitetitle);
			document.title = sitetitle;
});

$('.navigation a').click(function(ev) {
			$('.navigation a.current').removeClass('current');
			$(this).addClass('current');
});



$.fn.newsTitleLoad = function(startnews){
     $('#load-news').fadeIn();
			var startnews = $("#news-more").attr("rel");
			var  nextnews = parseInt(startnews)+4;
			$("#news-more").attr("rel",nextnews);
			var dataString = 'startnews='+ startnews+'&menuid=3' ;
		  $.ajax({
		     type: "POST",
   			 url: '/lib/1/php/news-list.php',
   			 data: dataString,
				 cache: false,
				 success: function(html){
						 $('.news-list').append(html);
						 $('#load-news').fadeOut();
			   }
		    });
  		return false;
}

$('#news-more').click(function(){
    var startnews = $(this).attr("rel");
		$.fn.newsTitleLoad(startnews);
}); 
	
	/*$('.news-list dd a').click(function(){
	    $('.shownews').fadeOut();
			var newsid = $(this).attr("href");
			var parent = $(this).parent();
			parent.append('<div id="load-news-all" style="display:none;"><img src="/images/loading.gif" alt="" /></div>');
			$('#load-news-all').fadeIn();
			$('.shownews').remove();
			$('.news-list dd a').removeClass("news-title-sell");
			$(this).addClass("news-title-sell");
			var dataString = 'newsid='+ newsid+'&menuid=3' ;
		  $.ajax({
		     type: "POST",
   			 url: '/lib/1/php/news-all.php',
   			 data: dataString,
				 cache: false,
				 success: function(html){
				     parent.append(html);
						 $('.shownews').css('display','none');
						 $('#load-news-all').fadeOut();
						 //$('.shownews').fadeIn();
						 $('.shownews').show("slow");
						 $('#load-news-all').remove();
			   }
		    });
  		//return false;
	});*/



	
	$.fn.discographyLoad = function(discographyID,CurrentMenuID){
	  $("#"+discographyID).append('<div id="load-album" style="display:none;"><img src="/images/loading.gif" alt="" /></div>');
	    $('#load-album').fadeIn();
			var parent = $("#"+discographyID).parent().parent().parent();
			var dataString = 'albumid='+ discographyID+'&menuid='+CurrentMenuID ;
		  $.ajax({
		     type: "POST",
   			 url: '/lib/1/php/discography.php',
   			 data: dataString,
				 cache: false,
				 success: function(html){
						 parent.html(html);
						 $('#load-album').fadeOut();
			   }
		    });
  		return false;
	 
	};
	
	$('.discography').click(function(){
	   var albumid = $(this).attr("id");
	   $.fn.discographyLoad(albumid,22);
	});   
	
	
	$.fn.guestbookLoad = function(CurrentMenuID, page){
	  $("#guestbookLoad").append('<div><img src="/images/loading.gif" alt="" /></div>');
	    //$('#load-album').fadeIn();
			//var parent = $("#guestbookLoad").parent().parent().parent();
			var dataString = 'page='+page+'&menuid='+CurrentMenuID ;
		  $.ajax({
		     type: "POST",
   			 url: '/lib/1/php/guestbook_list.php',
   			 data: dataString,
				 cache: false,
				 success: function(html){
						 //parent.html(html);
						 $("#guestbookLoad").html(html);
						 //$('#load-album').fadeOut();
			   }
		    });
  		return false;
	 
	};
	
	
});

