/*!
 * Functions: controling startpage
 *
 * Copyright 2011, zwobundstahmann GbR
 * http://www.zwobundstahmann.de
 *
 * Date: 2011-06-06
 */
$(document).ready(function() {

// Scrollbar
 	var oScroll1 = $('#scrollbar1');
	if(oScroll1.length > 0){
		oScroll1.tinyscrollbar();
	}

	// Kontakt-Box
	$("#togglebox-kontakt").hide();
	$(".toggle-kontakt").click(function () {
		$("#togglebox-kontakt").slideToggle().toggleClass("active");
		$(".toggle-kontakt").toggleClass("active");
	});

var isiPad = navigator.userAgent.match(/iPad/i) != null;
if(isiPad){ var fancytype = 'inline' } else { var fancytype = 'iframe' }
// iFrame mit Fancybox
	$("a.fancyframe").each(function(){ 

		  var ref_value = $(this).attr('rev');
		  var dWidth = 900;  // Default-Breite
		  var dHeight = 450; // Default-Hoehe
		  try {var dWidth = parseInt(ref_value.match(/width:\s*[0-9]+/i)[0].replace(/[^0-9]/g,''))} catch (e) {};
		  try {var dHeight = parseInt(ref_value.match(/height:\s*[0-9]+/i)[0].replace(/[^0-9]/g,''))} catch (e) {};
		  $(this).fancybox(
		  {   'showNavArrows': false,'transitionIn': 'none','transitionOut': 'none','type': fancytype,'scrolling': 'auto','titlePosition': 'outside', 'width': dWidth,'height': dHeight
 	});
	
	
		$("a.fancygoogle").each(function(){ 
		  $(this).fancybox(
		  {   'showNavArrows': false,'transitionIn': 'none','transitionOut': 'none','type': 'iframe','scrolling': 'auto','titlePosition': 'outside', 'width': 900,'height': 590
 	});	});	
	

// rel-Tags 
/*	$("a").each(function(){
		$(this).attr("rel", ($(this).attr("rel")).replace(/\[(.+?)\]/g, '$1'));
	});*/
// Fancybox Bilder
	$("a[rel^=lightbox]").fancybox({
		'overlayShow'			:	true,
		'overlayOpacity'		:   	0.8,
		'overlayColor'  		:   	'#000',
		'titleShow'			:	true,
		'titlePosition' 		:   	'inside',
		'transitionIn'			:	'elastic',
		'transitionOut'			:	'elastic',
		'speedIn'			:	600, 
		'speedOut'			:	200,
		'changeSpeed'			: 	300,
		'changeFade'			:	'fast',
		'showCloseButton'		:	true,
		'showNavArrows'			: 	true,
		'enableEscapeButton'		:	true
		
	});
	
});

$("#tip_volker,#tip_susanne,#tip_michael").tooltip({ 
		// tweak the position
   		offset: [15, 150],
		effect: 'slide'
	}).dynamic({ bottom: { direction: 'down', bounce: true } });	
	

// SlideshowInitialisieren
newsSlider.init();

// Optional: Das Rotationsintervall setzen (default ist 20000 ms)
newsSlider.setInterval(10000);

// Rotation starten
newsSlider.doRotate();	
	
	// validate the contact form when it is submitted
	$("#kontaktfomular").validate();	


}); // EndofDR


