/*-----------------------------------------

 copyright 2020 by mmc:agentur

 Version: 1.0

 Author: David Rerych

 Author URI: http://www.mmc-agentur.at

 -------------------------------------------*/



$(document).ready(function(){

    $('input[type="text"]').mmcFormDefaults();
    // for browsers that don't support placeholder text
    $('[data-swf]').swfElement();

    $('.csc-sitemap ul').jQuerySitemap('open', 'vertical');

    // lightbox
    (function($){
        $(function(){
            $(".lightbox").lightbox({
                navbarOnTop: 0,
                resizeSpeed: 300,
                overlayOpacity: 0.4,
                strings: {
                    prevLinkTitle: "vorheriges Bild",
                    nextLinkTitle: "nächstes Bild",
                    prevLinkText: "",
                    nextLinkText: "",
                    closeTitle: "schließen",
                    image: "Bild",
                    of: "von"
                }
            });
        });
    })(jQuery);
    
 
    
	// product images
    $('div.related_products a').each(function (key, el) {
    		
    		// preload image
    		var image = new Image();
    		image.src = $(el).attr('href');
    		
    		$(this).click(function () {
		    	var $link = $(this);
				var $image = $('div.product_img img');
				var $fadeElement = $image;
				
				// IE tranparency bug
				if($('body').hasClass('ie7') || $('body').hasClass('ie8')) {
					$fadeElement = $('div.product_img');
				}
				
				// hide image
		    	$fadeElement.fadeOut("fast", function () {
		
		    		// replace image
		    		$image.attr({
			    		src: $link.attr('href'),
			    		alt: $link.attr('title')
			    	});
			    	
			    	// show image
		    		$fadeElement.fadeIn("fast");
		
		    	});
		
		    	return false;
		    });
    });
    

});




function loadFlashHeader(swfUrl, flashvars) {
	$(document).ready(function(){
		
		var width = "100%";
		var height = $('#header').height();
		
		var unique_id = 'header_flash';
	
		var params = {
			allowFullscreen: true,
			allowScriptAccess: 'always',
			wmode: 'opaque',
			bgcolor: '#FFFFFF'
		};
		var attributes = {
			id: unique_id,
			name: unique_id
		};
		
		$('#header').prepend('<div id="'+unique_id+'" />');

		swfobject.embedSWF(swfUrl, unique_id, width, height, "9.0.0",false, flashvars, params, attributes, swfEmbedCallback);
				
		function swfEmbedCallback(e){
			if (e.success) {
				$('#header').css('background', 'none');
			} else {
				//$('#sidebar .wussten_sie_schon').show();
				//$('#header').css('background-image', old_background_image);
			}
		}
	
	});
}
