function osgInitFancyBox() {
	
	/* Diese Funktion wird im Template out/osg/tpl/page/details/inc/productmain.tpl aufgerufen.
	   Sie muss dort aufgerufen werden und nicht hier global, weil dieses Template ggf. beim Wechsel der Produktvarianten
	   per AJAX neu geladen wird und dann muss diese Funktion aufgeruden werden, um
	   die Initialisierung auf den nachgeladenen HTML-Teil anzuwenden. */
	
	$.osgGlobalVariables = { 
		lastClickedZoomPictureIndex: 1 
	}; 
	
	$("a.cloud-zoom-gallery").click(function(){
		var itemId = $(this).attr('id');
		$.osgGlobalVariables.lastClickedZoomPictureIndex = itemId.split("_")[1];
	});
	
	$("a.fancybox").fancybox({
		'transitionIn'	:	'elastic',
		'transitionOut'	:	'elastic',
		'speedIn'		:	600, 
		'speedOut'		:	200, 
		'overlayShow'	:	true,
		'hideOnOverlayClick':true,
		'overlayOpacity':	0.8,
		'centerOnScroll':	true,
		'overlayColor'  :   '#000000',
		'titleShow'		:	false,
		'orig'			:	'#product_image_container'
	});
	
	$("a#fancyboxTrigger").click(function(event){
		$("a#fancybox_"+$.osgGlobalVariables.lastClickedZoomPictureIndex).trigger('click');
	}); 
}

$("#footer_print_button").click(function(){
	$("#content").printArea(
		{ mode     : 'popup',
          popHt    : 500,
  		  popWd    : 400,
		  popX     : 200,
		  popY     : 200,
		  popTitle : 'Test',
		  popClose : false }
	    );
});

$(document).ready(function() {
  $("#footer_bookmark_button").jBrowserBookmark({
    language : {
      'de' : ['Ihr Browser lässt nicht zu, dass ein Lesezeichen automatisiert erstellt wird. Bitte benutzen Sie die ensprechende Funktion Ihres Browsers, um ein Lesezeichen zu dieser Seite zu erstellen. In den meisten Browsern können Sie [Strg] + ', ' drücken, um ein Lesezeichen zu erstellen.']
    },
    defaultLanguage : 'de'
  }, 'de'
  );
  
	var $_GET = {};
	document.location.search.replace(/\??(?:([^=]+)=([^&]*)&?)/g, function () {
		function decode(s) {
			return decodeURIComponent(s.split("+").join(" "));
		}
		$_GET[decode(arguments[1])] = decode(arguments[2]);
	});
	if($_GET["plain"] == 1) {
		$("html").addClass("plain_page");
	}
	
	$('#to_top').click(function() {
		$('html').scrollTop(0);
	});
});

$(function() {
    $('#home_teaser_image_container').cycle({
        fx:     'fade',
        speed:  '500',
        timeout: 5000,
        pager:  '#home_teaser_nav_ul',
        pagerAnchorBuilder: function(idx, slide) {
            return '#home_teaser_nav_ul li:eq(' + (idx) + ') a';
        },
		allowPagerClickBubble: false,
		next:   '', 
		prev:   '' 
	});
});

$(function() {
	if (!Modernizr.input.placeholder) {
		$(this).find('[placeholder]').each(function() {
			if($(this).val() == '') {
				$(this).val( $(this).attr('placeholder') );
			}
		});
		$('[placeholder]').focus(function() {
			if ($(this).val() == $(this).attr('placeholder')) {
				$(this).val('');
				$(this).removeClass('placeholder');
			}
		}).blur(function() {
			if ($(this).val() == '' || $(this).val() == $(this).attr('placeholder')) {
				$(this).val($(this).attr('placeholder'));
				$(this).addClass('placeholder');
			}
		});
		$('[placeholder]').closest('form').submit(function() {
			$(this).find('[placeholder]').each(function() {
				if ($(this).val() == $(this).attr('placeholder')) {
					$(this).val('');
				}
			})
		});
	}
});
