/**
AKR: jquery.REK.js
Globale jQuery-Funktionen:
- Fancybox
- Scroll-to-top
**/

// Fancybox
jQuery(document).ready(function() { 
	//autoclose-Funktion für toBasket und toNotepad
	function autoCloseFancy(){
  	setTimeout ('jQuery.fancybox.close()', 4000);
  }
  // Diverse Klassen-getriebene Fancybox-Aufrufe
	jQuery('.showToBasketNotepadInfoFancy').fancybox( //toBasket toNotepad
		{'transitionIn':'elastic','transitionOut':'elastic','speedIn':300,'speedOut':300,'hideOnContentClick':true,'type':'inline','overlayColor':'#999',
		 'showCloseButton':false,'onComplete':autoCloseFancy,'scrolling':'no'}
	);
	jQuery('.showPictureFancy').fancybox( //big cover
		{'transitionIn':'elastic','transitionOut':'elastic','speedIn':600,'speedOut':400,'hideOnContentClick':true,'type':'image','overlayColor':'#111'}
	);
	jQuery('.showWidgetDMR').fancybox( //DMR
		{'transitionIn':'elastic','transitionOut':'elastic','speedIn':600,'speedOut':400,'type':'iframe','width':650,'height':830,'overlayColor':'#111' }
	);
	jQuery('.showWidgetBook2Look').fancybox( //book2look
		{'transitionIn':'elastic','transitionOut':'elastic','speedIn':600,'speedOut':400,'type':'iframe','width':1050,'height':800,'overlayColor':'#111' }
	);
	jQuery('.showWidgetLitvideo').fancybox( //LitVideo
		{'transitionIn':'elastic','transitionOut':'elastic','speedIn':600,'speedOut':400,'type':'iframe','width':780,'height':500,'overlayColor':'#111' }
	);
	jQuery('.showWidgetAudio').fancybox( //Hörprobe
		{'transitionIn':'elastic','transitionOut':'elastic','speedIn':600,'speedOut':400,'type':'iframe','width':400,'height':200,'overlayColor':'#111' }
	);
	jQuery('.showWidgetPDF').fancybox(
		{'transitionIn':'elastic','transitionOut':'elastic','speedIn':600,'speedOut':400,'type':'iframe','width':'100%','height':'100%','overlayColor':'#111' }
	);
	jQuery('.showBuchkatalog').fancybox( //suchmaschinen
		{'padding':3,'transitionIn':'elastic','transitionOut':'elastic','speedIn':600,'speedOut':400,'type':'iframe','width':920,'height':'100%','overlayColor':'#111','centerOnScroll':true }
	);
	jQuery('.showDetailMini').fancybox( //schulbuchClass
		{'transitionIn':'elastic','transitionOut':'elastic','speedIn':600,'speedOut':400,'type':'iframe','width':830,'height':650,'overlayColor':'#111','centerOnScroll':true }
	);
	jQuery('.showJAlbum').fancybox( //JAlbum Fotogalerie
		{'padding':5,'transitionIn':'elastic','transitionOut':'elastic','speedIn':600,'speedOut':400,'type':'iframe','width':980,'height':'98%','overlayColor':'#000','centerOnScroll':true }
	);
	jQuery('.showFLV').fancybox( //FLV-Videos abspielen
		{'padding':10,'transitionIn':'elastic','transitionOut':'elastic','speedIn':600,'speedOut':400,'type':'iframe','width':640,'height':500,'overlayColor':'#000','centerOnScroll':true }
	);
	jQuery('.showVideo').fancybox( //Videos
		{'padding':0,'autoScale':false,'transitionIn':'elastic','transitionOut':'elastic','title':jQuery('.showVideo').title,'width':640,'height':385,'type':'swf','overlayColor':'#111',
		'swf':{'wmode':'transparent','allowfullscreen':'true'}
	});
	
	
	//Funktion "back-to-top", lange Seiten bequem per Klick nach oben scrollen lassen
	jQuery("#back-top").hide();									// hide #back-top first
	jQuery(function () {												// fade in #back-top
		jQuery(window).scroll(function () {
			if (jQuery(this).scrollTop() > 100) {
				jQuery('#back-top').fadeIn();
			} else {
				jQuery('#back-top').fadeOut();
			}
		});
		jQuery('#back-top a').click(function () {	// scroll body to 0px on click
			jQuery('body,html').animate({
				scrollTop: 0
			}, 800);
			jQuery('#back-top').fadeOut();
			return false;
		});
	});
	
	

	/** AKR: 	Mobile-Detection.
						Per alert fragen, ob mobile-Version erwünscht. 
						Wenn nicht, Cookie setzten, das diese Frage zukünftig unterbindet.
						Wenn ja, redirect auf reuffel.de/mobile 
						
	if(screen.width < 500 ||
		navigator.userAgent.match(/Android/i) ||
		navigator.userAgent.match(/webOS/i) ||
		navigator.userAgent.match(/iPhone/i) ||
		navigator.userAgent.match(/iPod/i))
		{
			if(!jQuery.cookie("classic")) {
				//Cookie ist gesetzt, nichts tun
			}
			else {
				// kein Cookie gesetzt, fragen ob Wechsel auf mobile gewnünscht
				if(confirm("Möchten Sie zur Smartphone-Variante 'iReuffel' wechseln?")) 
					{ //JA! Wechseln ...
	        	document.location.href="http://www.reuffel.de/mobile"; 
						//window.location = "http:/www.reuffel.de/mobile";
	    		}
	    	else
	    		{	//NEIN! Nicht wechseln, Cookie setzen. Wenn gesetzt, diese Frage nicht mehr stellen!
	        	var COOKIE_NAME = 'classic';
						var options = { path: '/' }; //Cookie-Pfad = root
						var COOKIE_CONTENT = 'stayclassic'
						jQuery.cookie(COOKIE_NAME, COOKIE_CONTENT, options); //Cookie setzen
	    		}
			}
		};
	**/




//ende (document).ready
});



