 /* * * 2008 by Ph.Urlich * jQuery Archivbaum Plugin for Schweizer-Illustrierte.ch * version 0.2 * * Requires: * jQuery 1.2.+ * * +-----------------------------------------+ * | Update SVN: $Revision:: 473           $ | * +-----------------------------------------+ */jQuery.fn.archivBaum = function(speed, settings) {	settings = jQuery.extend({	     //name: "defaultName",	     //size: 5,	     speed: 500	  }, settings);  return this.each(function(){  		jQuery(this).find('li a').click(function(){				var obj = jQuery(this);		var status = obj.next('ul:first').css("display");						obj.next('ul:first').slideDown(speed);			if(obj.parent('li').hasClass('artikel') == false ){				obj.removeClass('close');				obj.addClass('open');			}			//obj.parent('li').siblings().find('ul').hide();				if(status == 'block'){			obj.next('ul:first').slideUp(speed);			if(obj.parent('li').hasClass('artikel') == false ){				obj.removeClass('open');				obj.addClass('close');			}			//obj.parent('li').siblings().find('ul').toggle();		}		else{			obj.next('ul:first').slideDown(speed);			if(obj.parent('li').hasClass('artikel') == false ){				obj.removeClass('close').addClass('open');			}			//obj.parent('li').siblings().find('ul').slideUp(speed);			//obj.parent('li').siblings().each( function(){				// add and removes .close/.open only to links that dont have .artikel				//if( jQuery(this).not('.artikel') ){				//	jQuery(this).children('a').removeClass('open').addClass('close');				//	}			//});		} 	});               });};jQuery.fn.liveUpdate = function(list){  list = jQuery(list);  if ( list.length ) {	      var rows = list.find('ul').find('ul').children('li'),      	cache = rows.map(function(){        return jQuery('a',this)[0].innerHTML.toLowerCase();      });         this      .keyup(filter).keyup()      .parents('form').submit(function(){        return false;      });  }     return this;     function filter(){    var term = jQuery.trim( jQuery(this).val().toLowerCase() ), scores = [];       if ( !term ) {      	rows.show();    } else {      rows.hide();	      cache.each(function(i){        var score = this.score(term);        if (score > 0.1) { scores.push([score, i]); }      });      jQuery.each(scores.sort(function(a, b){return b[0] - a[0];}), function(){       	 jQuery(rows[ this[1] ]).show();		 jQuery(rows[ this[1] ]).parents('ul').show();		 jQuery(rows[ this[1] ]).parents('ul').children("li[class!=artikel]").children('a').removeClass('close').addClass('open');						      });    }  }};