﻿$(function() {
	var toggleable = $('.toggleable');

	$(toggleable).each(function() {
		var toggleable_item = this;
		var content = $('.tgcontent', toggleable_item);

		if(content.children().length > 1){
			var handle = $('.tghandle', toggleable_item);
			var handleHTML = handle.html();
			handle.html('<span class="tgactive">' + handleHTML + '</span>');

			if(!$(this).hasClass('tgopened')){
				content.addClass('tghidden').hide();
			}

			$(handle).click(function(event) {
				$(content).slideToggle('normal', function() {
					if($(this).hasClass('tghidden')){
						$(this).removeClass('tgvisible');
						if($.browser.msie){$(this).get(0).style.removeAttribute('filter')};
					}else{
						$(this).addClass('tghidden');
					}
				});
			});
		}
	});


	$('a.blank').click(function(){
		window.open(this.href);

		return false;
	});
});
