 /* * update.ch AG *  * jQuery Multipanel for kunsuminfo.ch * version 0.2 * * 2009 by Ph.Urlich (philipp@urlich.ch) * * Requires: * jQuery 1.2.*+ * jquery.timers.js plugin * * example html markup:	<!-- START: Multipanel Teaser -->		<div id="panel1" class="multipanel"><!-- #panel3 the wrapper that will be refered in the init script -->			<div class="frame"><!-- #frame needed for script to find nested items -->										<!-- item uses link and image, title attribute will be used to set text to #teaser_text -->					<div class="item" style="display:block">						<a href="index1.html" title="Das ist der Teasertext1"><img width="100%" src="/bilder/multipanel_bild1.jpg" alt="" /></a>					</div>											<div class="item" style="display:none">						<a href="index2.html" title="Hier noch ein Teasertext2"><img width="100%" src="/bilder/multipanel_bild2.jpg" alt="" /></a>					</div>										<div class="item" style="display:none">						<a href="index3.html" title="Jetzt: Neu!3"><img width="100%" src="/bilder/multipanel_bild3.jpg" alt="" /></a>					</div>									</div>						<!-- transparent background for buttons and text -->			<div class="navibg">&nbsp;</div>					<div class="multiteasernavi">				<!--div class="showCount">1 / 3</div-->								<!-- back button -->				<a class="goback_panel" href="javascript:void(0);" title="zurück">&lt; zur&uuml;ck</a>								<!-- #teaser_text Here text and href will be dynamicly inserted using title attribute of item link -->				<div id="teaser_text"><a>loading...</a></div>								<!-- forward button -->				<a class="goforward_panel" href="javascript:void(0);" title="weiter">vor &gt;</a>			</div>					</div>	<!-- END: Multipanel Teaser -->	 * 	 *  init script example:   timeInterval = miliseconds the items will change default: 5000fadeTime = miliseconds of the fading. default: 1000 $j(function(){	$j('div#panel1').multipanel({ timeInterval: 7000, fadeTime: 400});			});	*/jQuery.fn.multipanel = function(settings) {	settings = jQuery.extend({	     timeInterval: 5000,	     fadeTime: 1000	}, settings);  return this.each(function(){     	/* SET REFERENCE VAR TO OBJECT */	var mt = jQuery(this);   	var panelName = jQuery(this).attr('id');       /* count items in panel */    var count = jQuery('div.frame .item', this).size();		var currentItem = 1;	var currentItemBack;	var currentItemForward;	var itemArray = new Array(count);	/* ref teaserlink and teasertext object */	/*-------------------------------------*/			currentTeaserObject = jQuery('div.frame .item:visible', this);			/* init display */ 	/*-------------------------------------*/			jQuery('div.showCount', this).html(currentItem+' / '+count);	jQuery('div.frame .item', this).each( function(i){		jQuery(this).attr({id:panelName+"_teaser"+(i+1)})	});		/* Functions navigation Link "goback" */	/*-------------------------------------*/		jQuery('a.goback_panel', this).click(function(){		setTeasers('back', settings.fadeTime);		updateCounterDisplay();			jQuery('body').stopTime('itemRotation');		startTimedSlide();		});			/* Functions navigation Link "goforward" */	/*-------------------------------------*/	jQuery('a.goforward_panel', this).click(function(){		setTeasers('next', settings.fadeTime);		updateCounterDisplay();		jQuery('body').stopTime('itemRotation');		startTimedSlide();		});	    jQuery(mt).hover(					 function(){ jQuery('body').stopTime('itemRotation'); },					 					 function(){ startTimedSlide(); }			);					    /* ##############################################*//* GLOBAL STATIC FUNCTIONS ------------- */            /* Start Sequence    */    var startTimedSlide = function(){		jQuery('body').stopTime('itemRotation');    	jQuery('body').everyTime(settings.timeInterval, 'itemRotation', function(){			setTeasers('next', settings.fadeTime);			//updateCounterDisplay();		});    };    	                /* Update the display of the current active and total artikels ex: 1/8    */    var updateCounterDisplay = function(){    	jQuery('div.multiteasernavi div.showCount', mt).html(currentItem+' / '+count);    };				 /* Update teaserlink and text    */    var setTeaserLink = function(teaser){    	teaserText = jQuery(teaser, mt).children('a').attr('title');		teaserHref = jQuery(teaser, mt).children('a').attr('href');		jQuery('#teaser_text a', mt).text(teaserText); 		jQuery('#teaser_text a', mt).attr('href',teaserHref);     };            /* Set the correct menu-entry and artikel active      *  target = Number of the Artikel coming from the Link rel attribute     */    var setTeasers = function(direction,fadeTime){		currentItemTemp = currentItem;  	  if(direction == 'next'){    		currentItem++;			if(currentItem > count){currentItem = 1};		}		else if(direction == 'back'){			currentItem--;						if(currentItem < 1){currentItem = count};		}		jQuery('div.frame div#'+panelName+"_teaser"+currentItemTemp, mt).fadeOut(fadeTime);		jQuery('#teaser_text', mt).fadeOut(fadeTime, function(){					currentTeaser = jQuery('div.frame div#'+panelName+"_teaser"+currentItem, mt).fadeIn(fadeTime);					setTeaserLink(currentTeaser);					jQuery('#teaser_text', mt).fadeIn();			});		    };    		// start teaser slideshow	setTeaserLink(currentTeaserObject);    startTimedSlide();        });};