
//Stop IE flicker
if ($.browser.msie == true) {
document.execCommand('BackgroundImageCache', false, true);
}
/*
 * Jonathan Howard
 *
 * jQuery Pause
 * version 0.2
 *
 * Requires: jQuery 1.0 (tested with svn as of 7/20/2006)
 *
 * Feel free to do whatever you'd like with this, just please give credit where
 * credit is do.
 *
 *
 *
 * pause() will hold everything in the queue for a given number of milliseconds,
 * or 1000 milliseconds if none is given.
 *
 *
 *
 * unpause() will clear the queue of everything of a given type, or 'fx' if no
 * type is given.
 */

$.fn.pause = function(milli,type) {
	milli = milli || 1000;
	type = type || "fx";
	return this.queue(type,function(){
		var self = this;
		setTimeout(function(){
			$.dequeue(self);
		},milli);
	});
};

$.fn.clearQueue = $.fn.unpause = function(type) {
	return this.each(function(){
		type = type || "fx";
		if(this.queue && this.queue[type]) {
			this.queue[type].length = 0;
		}
	});
};
<!--
/*
 * Accordion - jQuery widget
 *
 * Copyright (c) 2006 Jörn Zaefferer, Frank Marcia
 *
 * Dual licensed under the MIT and GPL licenses:
 *   http://www.opensource.org/licenses/mit-license.php
 *   http://www.gnu.org/licenses/gpl.html
 *
 */

// nextUntil is necessary, would be nice to have this in jQuery core
jQuery.fn.nextUntil = function(expr) {
    var match = [];

    // We need to figure out which elements to push onto the array
    this.each(function(){
        // Traverse through the sibling nodes
        for( var i = this.nextSibling; i; i = i.nextSibling ) {
            // Make sure that we're only dealing with elements
            if ( i.nodeType != 1 ) continue;

            // If we find a match then we need to stop
            if ( jQuery.filter( expr, [i] ).r.length ) break;

            // Otherwise, add it on to the stack
            match.push( i );
        }
    });

    return this.pushStack( match, arguments );
}; 


 
// create private scope with $ alias for jQuery
(function($) {
	// save reference to plugin method
	var plugin = $.fn.Accordion = function(settings) {
		
		//ben add
		var defaultObj;
		var defaultClass;
		
		// setup configuration
		// TODO: allow multiple arguments to extend, see bug #344
		settings = $.extend($.extend({}, arguments.callee.defaults), $.extend({
			// define context defaults
			header: $(':first-child', this)[0].tagName // take first childs tagName as header
		}, settings || {}));
		
		// calculate active if not specified, using the first header
		var container = this,
			active = settings.active ? $(settings.active, this) : settings.active === false ? $("<div>") : $(settings.header, this).eq(0),
			running = 0;
		
		if(settings.toFade){
			$(settings.fadeClass).hide();
		}
			$(settings.fadeClass,container).toggle();
		
		//ben add
		defaultObj = active;
		defaultObj.removeClass("selected");
		defaultClass = defaultObj.attr('class');
		
		$(settings.header, container)
			.not(active && active[0] || "")
			.nextUntil(settings.header)
			.hide();
		active.addClass(settings.selectedClass);
		
		var clickHandler = function(event) {
//--------------------------------------------------------------------------------------------------------------
			// get the click target
			var clicked = $(event.target);
			// if animations are still active, or the active header is the target, ignore click
			//ben change
			if(running || clicked[0] == active[0] ||  !clicked.is(settings.header)){
				if(defaultObj[0] == active[0]) return;
				if(!clicked.is(settings.header) || running) return;
				
				
				
				
				// switch classes
				clicked.removeClass(settings.selectedClass);
				clicked.removeClass(clicked.attr('id')+'_active');
				clicked.addClass(clicked.attr('id'));
				
				defaultObj.addClass(settings.selectedClass);
				defaultObj.removeClass(defaultObj.attr('id')+'_off')
				defaultObj.addClass(defaultClass);
				
				// find elements to show and hide
				var toShow = $(defaultObj).nextUntil(settings.header),
					toHide = $(clicked).nextUntil(settings.header),
					data = [defaultObj, clicked, toShow, toHide];
					
				active = defaultObj;
				// count elements to animate
				running = toHide.size() + toShow.size();
				var finished = function() {
					if(--running)
						return;
					// maintain flexible height
					toHide.css({height: ''});
					toShow.css({height: ''});
					
					// trigger custom change event
					//container.trigger("change", data);
					$(settings.fadeClass,toShow).show();
				};
				// TODO if hideSpeed is set to zero, animations are crappy
				// workaround: use hide instead
				// solution: animate should check for speed of 0 and do something about it
				
				$(settings.fadeClass,toHide).hide();
				toHide.slideUp(settings.hideSpeed, finished);
				toShow.slideDown(settings.showSpeed, finished);
				/*
				//ben add
				if(settings.toFade){
					try{
						eval("$."+$(toHide).attr("title")+"Hide();");
					}
					catch(e){}
					$(toHide).find(settings.fadeClass).fadeOut(settings.fadeSpeed);
					$(toShow).find(settings.fadeClass).pause(200).fadeIn(settings.fadeSpeed);
				}*/
				
				if(event.preventDefault)
					event.preventDefault();
				
			}
			else{
			if(!clicked.is(settings.header)) return;
				//return;
			
				if(defaultObj[0] == active[0]){
					// switch classes
					active.removeClass(settings.selectedClass);
					active.removeClass(active.attr('id'));
					active.addClass(active.attr('id')+"_off");	
					
					clicked.addClass(settings.selectedClass);
					clicked.addClass(clicked.attr('id')+"_active");			
				}
				else if(defaultObj[0] == clicked[0]){
					// switch classes
					active.removeClass(settings.selectedClass);
					active.removeClass(active.attr('id')+"_active");
					active.addClass(active.attr('id'));
					defaultObj.removeClass(settings.selectedClass);
					defaultObj.removeClass(defaultObj.attr('id')+"_off");
					defaultObj.addClass(defaultObj.attr('id'));	
				
				}
				else{			
					// switch classes
					active.removeClass(settings.selectedClass);
					active.removeClass(active.attr('id')+"_active");
					active.addClass(active.attr('id'));
					clicked.addClass(settings.selectedClass);
					clicked.addClass(clicked.attr('id')+"_active");
				}
				
				
				// find elements to show and hide
				var toShow = $(clicked).nextUntil(settings.header),
					toHide = $(active).nextUntil(settings.header),
					data = [clicked, active, toShow, toHide];
				active = clicked;
				// count elements to animate
				running = toHide.size() + toShow.size();
				var finished = function() {
					if(--running)
						return;
					// maintain flexible height
					toHide.css({height: ''});
					toShow.css({height: ''});
					
					// trigger custom change event
					//container.trigger("change", data);
					$(settings.fadeClass,toShow).show();
				};
				// TODO if hideSpeed is set to zero, animations are crappy
				// workaround: use hide instead
				// solution: animate should check for speed of 0 and do something about it
				$(settings.fadeClass,toHide).hide();
				toHide.slideUp(settings.hideSpeed, finished);
				toShow.slideDown(settings.showSpeed, finished);
				/*
				//ben add
				if(settings.toFade){
					try{
						eval("$."+$(toHide).attr("title")+"Hide();");
					}
					catch(e){}
					$(toHide).find(settings.fadeClass).fadeOut(settings.fadeSpeed);
					$(toShow).find(settings.fadeClass).pause(200).fadeIn(settings.fadeSpeed);
				}*/
				
				if(event.preventDefault)
					event.preventDefault();
			}//ben add
//--------------------------------------------------------------------------------------------------------------
		};
		var activateHandlder = function(event, index) {
			// call clickHandler with custom event
			clickHandler({
				target: $(settings.header, this)[index]
			});
		};
	
		return container
			.bind("click", clickHandler)
			.bind("activate", activateHandlder);
	};
	// define static defaults
	plugin.defaults = {
		selectedClass: "selected",
		showSpeed: 'slow',
		hideSpeed: 'fast'
	};
	
	// shortcut for trigger, nicer API and easily to document
	$.fn.activate = function(index) {
		return this.trigger('activate', [index || 0]);
	};
	
})(jQuery);
//-->



	$(function(){
		
		// highly customized Accordion
		$('#list2').Accordion({
			active: 'dt.selected',
			selectedClass: "active",
			showSpeed: 1000,
			hideSpeed: 1000,
			toFade: true,
			fadeSpeed: 850,
			fadeClass: ".tofade"
		}).change(function(event, newHeader, oldHeader, newContent, oldContent) {
		});
		
		// set global defaults for all following Accordions, will be valid for #list1, #list2 and #list4, #list3 sets them for itself
		$.extend($.fn.Accordion.defaults, {
			showSpeed: 1000,
			hideSpeed: 1000
		});
		

		
		// bind to change event of select to control first and seconds accordion
		// similar to tab's plugin triggerTab(), without an extra method
		$('#switch select').change(function() {
			$('#list1, #list2').activate( this.selectedIndex-1 );
		});
		
		
	});