	Cufon.replace('.navigation .menu-item', {hover: true});
	Cufon.replace('.block-services h1', {hover: true});
	Cufon.replace('.block-services p', {hover: true});
	Cufon.replace('.block-title', {hover: true});
	Cufon.replace('.page-title', {hover: true});
	Cufon.replace('.page-desc', {hover: true});
	Cufon.replace('.news-archive li a', {hover: true});
	Cufon.replace('#comments-title', {hover: true});
	Cufon.replace('#reply-title', {hover: true});
	Cufon.replace('.autor', {hover: true});
	Cufon.replace('.tabs a', {hover: true});
	Cufon.replace('legend');
	Cufon.replace('body.category-services .post', {hover: true});
	

//Map open
function openMap(el)
{
	if ($(el).hasClass('opened'))
  {
	  $(el).removeClass('opened');
  }
  else
  {
		$(el).addClass('opened');
  }
}

//Home Slideshow
(function($) {
	  var cache = [];
	  // Arguments are image paths relative to the current page.
	  $.preLoadImages = function() {
	    var args_len = arguments.length;
	    for (var i = args_len; i--;) {
	      var cacheImage = document.createElement('img');
	      cacheImage.src = arguments[i];
	      cache.push(cacheImage);
	    }
	  }
})(jQuery)


$(document).ready(function() {
													 
	//gallery
	jQuery(function($) {
		$('ul.ap-gallery').galleria({
																 
				insert:'#Gallery', 
				
				
				onImage   : function(image,caption,thumb) { // let's add some image effects for demonstration purposes
				
				// fade in the image & caption
				if(! ($.browser.mozilla && navigator.appVersion.indexOf("Win")!=-1) ) { // FF/Win fades large images terribly slow
					//image.css('display','none').fadeIn(1000);
				}
				caption.css('display','none').fadeIn(1000);
				
				// fetch the thumbnail container
				var _li = thumb.parents('li');
				
				// fade out inactive thumbnail
				_li.siblings().children('img.selected').fadeTo(500,0.3);
				
				// fade in active thumbnail
				//thumb.fadeTo('fast',1).addClass('selected');
				
				// add a title for the clickable image
				//image.attr('title','Next image >>');
			}}); 
	}); 
		
	//tabs
	$(".tabs a").click(function() {
			$current=$(this).attr("rel");
			$("#tab-content1").css({"display" : "none"});
			$("#tab-content2").css({"display" : "none"});
			$("#tab-content3").css({"display" : "none"});
			$("#tab-content4").css({"display" : "none"});
			$("#tab-content"+$current).css({"display" : "block"});
			$(".tabs a").removeClass('active');
			$("#tab"+$current).addClass('active');
	});
	
	//
		
	var interval;
	var activeContainer = 1;	
	var currentImg = 0;
	var animating = false;
	var navigate = function(direction) {
		// Check if no animation is running. If it is, prevent the action
		if(animating) {
			return;
		}
		
		// Check which current image we need to show
		if(direction == "next") {
			currentImg++;
			if(currentImg == photos.length + 1) {
				currentImg = 1;
			}
		} else {
			currentImg--;
			if(currentImg == 0) {
				currentImg = photos.length;
			}
		}
		
		// Check which container we need to use
		var currentContainer = activeContainer;
		if(activeContainer == 1) {
			activeContainer = 2;
		} else {
			activeContainer = 1;
		}
		
		showImage(photos[currentImg - 1], currentContainer, activeContainer);
		
	};
	
	var currentZindex = -1;
	var showImage = function(photoObject, currentContainer, activeContainer) {
		animating = true;
		
		// Make sure the new container is always on the background
		currentZindex--;
		
		// Set the background image of the new active container
		$("#headerimg" + activeContainer).css({
			"background-image" : "url(" + photoObject.image + ")",
			"display" : "block",
			"z-index" : currentZindex
		});
		
		// Hide the header text
		$("#headertxt").css({"display" : "none"});
		
		// Set the new header text
		$("#firstline").html(photoObject.firstline);
		$("#secondline")
			.attr("href", photoObject.url)
			.html(photoObject.secondline);
		$("#pictureduri")
			.attr("href", photoObject.url)
			.html(photoObject.title);
				
		// Fade out the current container
		// and display the header text when animation is complete
		$("#headerimg" + currentContainer).fadeOut(function() {
			//setTimeout(function() {
				$("#headertxt").fadeIn();
				animating = false;
				Cufon.replace('.block-services h1', {hover: true});
				Cufon.replace('.block-services p', {hover: true});
			//}, 500);
		});
	};
		
	// We should statically set the first image
	navigate("next");
	
	// Start playing the animation
	interval = setInterval(function() {
		navigate("next");
	}, slideshowSpeed);
	
});

//fixed menu
function findAncestor(){
		$('#menu-item-515 li.current-menu-parent').parent().parent().addClass('current-menu-parent current-category-ancestor');
		$('#menu-item-158 li.current-menu-parent').parent().parent().addClass('current-menu-parent current-category-ancestor');
		$('#menu-item-13 li.current-menu-parent').parent().parent().addClass('current-menu-parent current-category-ancestor');
		$('.date #menu-item-512').parent().parent().addClass('current-menu-parent current-category-ancestor');
		$('.date #menu-item-512').addClass('current-menu-parent');
		$('.date #menu-item-512').parent().parent().addClass('current-menu-parent current-category-ancestor');
		$('.date #menu-item-512').addClass('current-menu-parent');
		if ($('.cat-item-21').length != 0)
  	{
			$('#menu-item-13').addClass('current-menu-parent current-category-ancestor');
			$('#menu-item-126').addClass('current-menu-parent');
		}
		Cufon.replace('.navigation .menu-item', {hover: true});
}
window.onload = function() {
    findAncestor()
}	



