$(document).ready(function() {
						   
	$('#contact-submenu-extra-info').hide();
	
	$('#contact a').click(function(){
			$('#contact-submenu-extra-info').slideToggle("slow");
			$('#contact-more').toggle();
			return false;
	});
	
	$('#contact-more-button').click(function(){
			$('#contact-submenu-extra-info').slideDown("slow");
			$('#contact-more').css('visibility','hidden');
			return false;
	});
	
	$('#contact-less-button').click(function(){
			$('#contact-submenu-extra-info').slideUp("slow");
			$('#contact-more').css('visibility','visible');
			return false;
	});
	
	$('#menu ul li a').click(function(){						  
			$clicked = $(this);
			$('#menu ul li a').css('text-decoration','none');
			$clicked.css('text-decoration','underline');
	});
	
	if(typeof whichSubmenu!="undefined"){
		if(whichSubmenu == 'about') {
			$('#menu ul li a').css('text-decoration','none');
			$('#menu ul li#about a').css('text-decoration','underline');
		}
	}
		
	$('.main-menu-thumbs').each(function (i) {
		var titles = new RegExp('\\b'+$(this).attr('id')+'\\b', ["gi"]);
		check = subMenuTitles.match(titles);
		if (check != null) { //($(this).attr('class').match(titles)) {
			$(this).css('visibility','visible');
		} else {
			$(this).css('visibility','hidden');
		}
		if(whichSubmenu == "all") {
			$(this).css('visibility','visible');
		}
      });
	
	PEPS.rollover.init();
	
	$('.retractSubmenu').click(function(){
		$('.submenu-list').slideToggle("slow");
		return false;
	});
	
	//keywords:
	if(typeof itemKeywords!="undefined") {
		linkKeywords(itemKeywords);
	}
	
	//blog:
	$('li.blogArchive div.bMonths').hide();

});



PEPS = {};

PEPS.rollover =
{
   init: function()
   {
      this.preload();
     
      $(".ro").hover(
         function () { $(this).attr( 'src', PEPS.rollover.newimage($(this).attr('src')) ); },
         function () { $(this).attr( 'src', PEPS.rollover.oldimage($(this).attr('src')) ); }
      );
   },

   preload: function()
   {
      $(window).bind('load', function() {
         $('.ro').each( function( key, elm ) { $('<img>').attr( 'src', PEPS.rollover.newimage( $(this).attr('src') ) ); });
      });
   },
   
   newimage: function( src )
   {
      return src.substring( 0, src.search(/(\.[a-z]+)$/) ) + '_o' + src.match(/(\.[a-z]+)$/)[0];
   },

   oldimage: function( src )
   {
      return src.replace(/_o\./, '.');
   }
};

function preventBehaviour() {
if (event.preventDefault) { event.preventDefault(); } else { event.returnValue = false; }
}

//keywords:
function linkKeywords(keywords)
	{         
	var el = $("#item-header");
	var el2 = $("#item-body-text");
	var el3 = $("#item-footer");
	$(keywords).each(function()
        {
            var pattern = new RegExp("("+this+"(?!.nl|.com|.net|.tv|.nu|<\/a>))", ["gi"]);
            var rs = "<a href=\"/lib/keywords.php?keyword=$1\" class=\"keyword-link\">$1</a>";
            el.html(el.html().replace(pattern, rs));
			//el2.html(el2.html().replace(/(<a\s.*?>.*?<\/a>)/," "));
			el2.html(el2.html().replace(pattern, rs));
			el3.html(el3.html().replace(pattern, rs));
           
        });
           
	}  
	
	//<([A-Z][A-Z0-9]*)\b[^>]*>.*?</\1>
	
	
//blog:
	function showbMonths(bClass) {
		$('li.blogArchive div.bMonths').hide();
		$(bClass).show("slow");
	}

	function BshowMonth(byear,bmonth) {
		//alert('templates/blogmonth.php?m='+bmonth+'&y='+byear+'');
		$('.popup table tbody tr td.body div.content #blog #blog-content').load('templates/blogmonth.php?y='+byear+'&m='+bmonth+'');
	}
