/*
 * Main functionalities
 * @author: valerie@wephic.net
 * 
 * ************************************************************/

 $(document).ready(function(){
 
 /*
 * unobtrusive switchers
 ******************************/
	if ($("dl#navigation").length) {

		$("dl#navigation").children("dt").each(function(i){
			if ($(this).is(".active")){
				$(this).prepend('<span class="switcher">-</span>');
				$(this).css("border-bottom-width","1px");
			} else {
				$(this).prepend('<span class="switcher">+</span>');
				$(this).css("border-bottom-width","5px");
				$(this).nextAll().each(function(j){
					if($(this).is("dt")){return false;}
					$(this).hide();
				});
			}
		});
		
		$("dl#navigation dt span.switcher").click(function(){
			var nextAll = $(this).parent("dt").nextAll();
			if ($(this).text() == "+") {
				$(this).text("-");
				$(this).parent("dt").css("border-bottom-width","1px");
			} else {
				$(this).text("+");
				$(this).parent("dt").css("border-bottom-width","5px");
			}
			nextAll.each(function(i){
				if ($(this).is("dt")) {
					return false;
				}
				$(this).toggle();
			});
		});
		
	}
 /*
 * unobtrusive print
 * => only on internal page
 ******************************/
	//if( $("#page.homepage").length == 0 ){
	//	if( $("#wide-site-tools").length == 0 ){
	//		$("#content").append('<div id="wide-site-tools" class="block"><ul class="inline"></ul></div>');
	//	}
	//	$('#wide-site-tools ul.inline').prepend('<li class="print"><a href="javascript:window.print();">Print this page</a></li>');
	//}
 });