﻿/*	-----------------------------------------	//
//	Projekt: wpSEO.de													//
//	Autor:	 Sergej Müller										//
//	Datum:	 Juni 2008												//
//																						//
//	Dateiname: js/slides.js										//
//	----------------------------------------- */


/*
* initialize
*
* Initialisiert die Ausführung der Slideshow
*
* @package	slideshow.js
* @author		Sergej Müller
* @since		26.12.2008
* @change		26.12.2008
* @access		public
* @param		object	args	Objekt mit Argumenten
*/

(function($) {
	$(function() {

	$('#slider #control').css({'visibility' : 'visible'}); 
	$('#slides img').css({'margin-left' : '0'});
	$('#slider').css({'height' : '460px'});

	$('#slider #control li').mouseover(function() {
     $(this).css({'background-image' : 'url(bilder/cycle/nav/buttonsover.png)', 'background-repeat' : 'no-repeat', 'background-attachment' : 'scroll', 'background-position' : '0 0'});
	 });
  	$('#slider #control li').mouseout(function() {
     $(this).css({'background-image' : 'url(bilder/cycle/nav/buttons.png)', 'background-repeat' : 'no-repeat', 'background-attachment' : 'scroll', 'background-position' : '0 0'});
	 });
  	$('#pause').mouseover(function() {
     $(this).css({'background-position' : '-23px 0'});
	 });
  	$('#pause').mouseout(function() {
     $(this).css({'background-position' : '-23px 0'});
	 });
  	$('#play').mouseover(function() {
     $(this).css({'background-position' : '-36px 0'});
	 });
  	$('#play').mouseout(function() {
     $(this).css({'background-position' : '-36px 0'});
	 });
	 $('#next').mouseover(function() {
     $(this).css({'background-position' : '-52px 0'});
	 });
  	$('#next').mouseout(function() {
     $(this).css({'background-position' : '-52px 0'});
	 });
		
		/* Funktion für die Pausetaste */
		function pause() {
			$('#play').show();
			$('#pause').hide();
			$('#slides').cycle('pause');
			
			return false;
		}
		
		
		/* Nach der Transaktion */
		function before(curr, next, opts) {
			$('#play').click(
				function() {
					$('#play').hide();
					$('#pause').show();
					
					if (opts.currSlide == 0) {
						$('#slides').cycle(1);
					}
					
					$('#slides').cycle('resume');
					return false;
				}
			);
			
		};
		
		
		/* Vor der Transaktion */
		function after(curr, next, opts) {
			
		
			if (opts.currSlide == 0) {
				pause();
				$('#control').fadeIn('slow');
			}
		};
		
		
		/* Klick auf Pause */
		$('#pause').click(pause);
		
		
		/* Slider starten */
		$('#slides').cycle(
			{
				fx:    'fade',
				delay: 9000,
				'prev':	 					'#prev',
			 	'next':	 					'#next',
			 	'after':		 			after,
			 	'before':					before,
			 	'timeout':	 			1000,
			 	'speedin':				1000,
	 	 		'speedout':				4000,
	 	 		'speednext':			1000,
	 	 		'prevNextClick':	pause
			}
		);
		
		
		/* Control ein- und ausblenden */
		
	});
	
})(jQuery);
