$(document).ready(function() { 

	prepPDF();

	if ($('#teaser_img').length > 0) {
		$('#teaser_img').css({backgroundPosition: "100px 0px"});
		$('#teaser_img').animate({backgroundPosition: "0px 0px"},7500);
	}

	if ($('.ngg-galleryoverview').length > 0) {

		$('div.ngg-gallery-thumbnail a').live("click",function(){
			return false;
		});
		
		$('div.ngg-galleryoverview a.prev,div.ngg-galleryoverview a.next').fadeTo(0,"0.6");

		$('<p>'+$('div.ngg-gallery-thumbnail img').attr("title")+'</p>').appendTo('.ngg-galleryoverview');

		$('div.ngg-galleryoverview a.prev,div.ngg-galleryoverview a.next').hover(function(){
			$(this).fadeTo(500,"1");
		}, function () {
  			$(this).fadeTo(200,"0.6");
		});
	}
	
	
	
	
	if ($('.wpcf7-mail-sent-ok').length > 0) {
		$('.wpcf7-form').html(
			$('.wpcf7-mail-sent-ok').html()
		);
		
		$('.wpcf7-form').addClass('wpcf7-mail-sent-ok');
		$('#content p').hide();
	}

});

function prepPDF() {
	var pageHasPDFs = false;
	var i;
	var alinks = document.getElementById("content").getElementsByTagName("a");
	for (i=0; i<alinks.length; i++) {
	var currentLink = alinks[i];
	var images = currentLink.getElementsByTagName("img");
	/*Check if the link is an image (we don't want icons next to images) and that ".pdf" appears in the link href.*/
	if (images.length == 0 && currentLink.href.indexOf('.pdf') != -1) {
	  var curClass = currentLink.getAttribute("class");
	  if (curClass != null) { currentLink.className = curClass + " pdf"; }
	  else { currentLink.className = "pdf"; }
	  pageHasPDFs = true;
	}
	}
}
