$(document).ready(function(){
	$("ul.hausboxnav > li > span:last").attr({style: "background: none"});;

	var hbcntcout = $("div.hausboxcnt").get().length;
	
	var j = 1;
	var current = $("div.hausbox > div.hausboxcnt");
	current.attr({id: "hbcnt0"});
	
	while(current.next().hasClass("hausboxcnt")){
		current = current.next();
		current.attr({id: "hbcnt"+j});
		j++;
	}
	for (i = 1; i <= hbcntcout; ++i) {
		$("div#hbcnt" + i).attr({style: "display: none"});
	}	
	
	var defpic = $("img.showpic").attr('src');
	var defcnt = $("div#hbcnt0");
	
	$("ul.hausboxnav > li").click(function(){
		var navobject = $(this).attr('id');
		if(navobject){
			for (i = 0; i <= hbcntcout; i++) {
				$("div#hbcnt" + i).attr({style: "display: none"});
			}
			$("div#hb"+navobject).attr({style: "display: block"});
		} else {
			for (i = 0; i <= hbcntcout; ++i) {
				$("div#hbcnt" + i).attr({style: "display: none"});
			}		
			defcnt.attr({style: "display: block"});		
		}
		
		if($(this).attr('title')){
			var newpic = $(this).attr('title');
			$("img.showpic").attr({src: newpic});
		} else {
			$("img.showpic").attr({src: defpic});
			$("img.showpic").attr({title: defpic});
		}
	});

    $("ul.hausboxnav > li").hover(function(){
      $(this).attr({style: "color:#C00012"});
    }, function () {
      $(this).attr({style: "color:#000000"});
    });	
});
