// source --> http://chorklang-diepersdorf.de/wp-content/plugins/simple-download-monitor/js/sdm_wp_scripts.js?ver=6.2.9 
// Simple Download Monitor frontend scripts

function sdm_is_ie() {

    var ua = window.navigator.userAgent;
    var msie = ua.indexOf("MSIE ");

    if (msie > 0 || !!navigator.userAgent.match(/Trident.*rv\:11\./))
    {
	return true;
    }

    return false;
}

jQuery(document).ready(function ($) {

    // Populate all nested titles and links 
    $('li.sdm_cat').each(function () {

	var $this = $(this);
	this_slug = $this.attr('id');
	this_id = $this.children('.sdm_cat_title').attr('id');

	// Run ajax
	$.post(
		sdm_ajax_script.ajaxurl,
		{
		    action: 'sdm_pop_cats',
		    cat_slug: this_slug,
		    parent_id: this_id
		},
		function (response) {

		    // Loop array returned from ajax function
		    $.each(response.final_array, function (key, value) {

			// Populate each matched post title and permalink
			$this.children('.sdm_placeholder').append('<a href="' + value['permalink'] + '"><span class="sdm_post_title" style="cursor:pointer;">' + value['title'] + '</span></a>');
		    });

		    $this.children('span').append('<span style="margin-left:5px;" class="sdm_arrow">&#8616</span>');
		}
	);
    });

    // Hide results on page load
    $('li.sdm_cat').children('.sdm_placeholder').hide();

    // Slide toggle for each list item
    $('body').on('click', '.sdm_cat_title', function (e) {

	// If there is any html.. then we have more elements
	if ($(this).next().html() != '') {

	    $(this).next().slideToggle(); // toggle div titles
	}
    });

    // Download buttons with terms or captcha has this class applied to it
    $('.sdm_download_with_condition').on('click', function (e) {
	e.preventDefault();
	$(this).closest('form').trigger('submit');
    });

    // Check if terms checkbox is enabled.
    if ($('.sdm-termscond-checkbox').length) {

	$.each($('.sdm-termscond-checkbox'), function () {
	    if (!$(this).is(':checked')) {
		var cur = $(this).children(':checkbox');
		var btn = $(cur).closest('form').find('a.sdm_download,a.sdm_download_with_condition');
		$(btn).addClass('sdm_disabled_button');
	    }
	});

	$.each($('.sdm-download-form'), function () {
	    var form = $(this);
	    form.on('submit', function () {
		if ($('.agree_termscond', form).is(':checked')) {
		    $('.sdm-termscond-checkbox', form).removeClass('sdm_general_error_msg');
		    return true;
		} else {
		    $('.sdm-termscond-checkbox', form).addClass('sdm_general_error_msg');
		}
		return false;
	    });
	});

	$.each($('.agree_termscond'), function () {
	    var element = $(this);
	    var form = element.closest('form');
	    element.on('click', function () {
		if (element.is(':checked')) {
		    $('.sdm_download_with_condition', form).removeClass('sdm_disabled_button');
		    $('.sdm-termscond-checkbox', form).removeClass('sdm_general_error_msg');
		} else {
		    $('.sdm_download_with_condition', form).addClass('sdm_disabled_button');
		    $('.sdm-termscond-checkbox', form).addClass('sdm_general_error_msg');
		}
	    });
	});
    }
});
// source --> http://chorklang-diepersdorf.de/wp-content/plugins/vc-extend/assets/shortcodes.js?ver=6.2.9 
(function($) {
"use strict";
var WITHEMES = WITHEMES || {};

/* GOOGLE MAP
--------------------------------------------------------------------------------------------- */
WITHEMES.gmap = function(){
	$('.wi-gmap').each(function(){
		var $this = $(this);
		$this.one('inview', function(event, isInView, visiblePartX, visiblePartY) {
			if (isInView) {
				load_map($this);
			} // inview						  
									  });// bind
								}); // each
	
	function load_map(ele) {
		var $this = ele;
		// check the ID
		var id = $this.attr('id');
		if (!id) {
			id = 'wi-gmap-' + Math.floor((Math.random() * 100) + 1);
			$this.attr('id',id);
		}
		
		// check if google exists
 		if ( typeof(google)!='undefined' ) {
			
			var lat = $this.data('lat') ? $this.data('lat') : '40.7130634';
			var lng = $this.data('lng') ? $this.data('lng') : '-74.0082771';
			var map_zoom = parseInt($this.data('zoom')) ? parseInt($this.data('zoom')) : 16;
			var scrollwheel = $this.data('scrollwheel') ? $this.data('scrollwheel') : false;
			var style = $this.data('style');
			
			var map_styles = new Array();
			//http://snazzymaps.com/style/15/subtle-grayscale
			map_styles['subtle-grayscale'] = [{"featureType":"landscape","stylers":[{"saturation":-100},{"lightness":65},{"visibility":"on"}]},{"featureType":"poi","stylers":[{"saturation":-100},{"lightness":51},{"visibility":"simplified"}]},{"featureType":"road.highway","stylers":[{"saturation":-100},{"visibility":"simplified"}]},{"featureType":"road.arterial","stylers":[{"saturation":-100},{"lightness":30},{"visibility":"on"}]},{"featureType":"road.local","stylers":[{"saturation":-100},{"lightness":40},{"visibility":"on"}]},{"featureType":"transit","stylers":[{"saturation":-100},{"visibility":"simplified"}]},{"featureType":"administrative.province","stylers":[{"visibility":"off"}]},{"featureType":"water","elementType":"labels","stylers":[{"visibility":"on"},{"lightness":-25},{"saturation":-100}]},{"featureType":"water","elementType":"geometry","stylers":[{"hue":"#ffff00"},{"lightness":-25},{"saturation":-97}]}];
			
			//http://snazzymaps.com/style/29/light-monochrome
			map_styles['light-monochrome'] = [{"featureType":"water","elementType":"all","stylers":[{"hue":"#e9ebed"},{"saturation":-78},{"lightness":67},{"visibility":"simplified"}]},{"featureType":"landscape","elementType":"all","stylers":[{"hue":"#ffffff"},{"saturation":-100},{"lightness":100},{"visibility":"simplified"}]},{"featureType":"road","elementType":"geometry","stylers":[{"hue":"#bbc0c4"},{"saturation":-93},{"lightness":31},{"visibility":"simplified"}]},{"featureType":"poi","elementType":"all","stylers":[{"hue":"#ffffff"},{"saturation":-100},{"lightness":100},{"visibility":"off"}]},{"featureType":"road.local","elementType":"geometry","stylers":[{"hue":"#e9ebed"},{"saturation":-90},{"lightness":-8},{"visibility":"simplified"}]},{"featureType":"transit","elementType":"all","stylers":[{"hue":"#e9ebed"},{"saturation":10},{"lightness":69},{"visibility":"on"}]},{"featureType":"administrative.locality","elementType":"all","stylers":[{"hue":"#2c2e33"},{"saturation":7},{"lightness":19},{"visibility":"on"}]},{"featureType":"road","elementType":"labels","stylers":[{"hue":"#bbc0c4"},{"saturation":-93},{"lightness":31},{"visibility":"on"}]},{"featureType":"road.arterial","elementType":"labels","stylers":[{"hue":"#bbc0c4"},{"saturation":-93},{"lightness":-2},{"visibility":"simplified"}]}]
			
			//http://snazzymaps.com/style/80/cool-grey
			map_styles['cool-grey'] = [{"featureType":"landscape","elementType":"labels","stylers":[{"visibility":"off"}]},{"featureType":"transit","elementType":"labels","stylers":[{"visibility":"off"}]},{"featureType":"poi","elementType":"labels","stylers":[{"visibility":"off"}]},{"featureType":"water","elementType":"labels","stylers":[{"visibility":"off"}]},{"featureType":"road","elementType":"labels.icon","stylers":[{"visibility":"off"}]},{"stylers":[{"hue":"#00aaff"},{"saturation":-100},{"gamma":2.15},{"lightness":12}]},{"featureType":"road","elementType":"labels.text.fill","stylers":[{"visibility":"on"},{"lightness":24}]},{"featureType":"road","elementType":"geometry","stylers":[{"lightness":57}]}];
			//http://snazzymaps.com/style/43/bentley
			map_styles['bentley'] = [{"featureType":"landscape","stylers":[{"hue":"#F1FF00"},{"saturation":-27.4},{"lightness":9.4},{"gamma":1}]},{"featureType":"road.highway","stylers":[{"hue":"#0099FF"},{"saturation":-20},{"lightness":36.4},{"gamma":1}]},{"featureType":"road.arterial","stylers":[{"hue":"#00FF4F"},{"saturation":0},{"lightness":0},{"gamma":1}]},{"featureType":"road.local","stylers":[{"hue":"#FFB300"},{"saturation":-38},{"lightness":11.2},{"gamma":1}]},{"featureType":"water","stylers":[{"hue":"#00B6FF"},{"saturation":4.2},{"lightness":-63.4},{"gamma":1}]},{"featureType":"poi","stylers":[{"hue":"#9FFF00"},{"saturation":0},{"lightness":0},{"gamma":1}]}];
			
			//http://snazzymaps.com/style/54/routexl
			map_styles['routexl'] = [{"featureType":"administrative","elementType":"all","stylers":[{"visibility":"on"},{"saturation":-100},{"lightness":20}]},{"featureType":"road","elementType":"all","stylers":[{"visibility":"on"},{"saturation":-100},{"lightness":40}]},{"featureType":"water","elementType":"all","stylers":[{"visibility":"on"},{"saturation":-10},{"lightness":30}]},{"featureType":"landscape.man_made","elementType":"all","stylers":[{"visibility":"simplified"},{"saturation":-60},{"lightness":10}]},{"featureType":"landscape.natural","elementType":"all","stylers":[{"visibility":"simplified"},{"saturation":-60},{"lightness":60}]},{"featureType":"poi","elementType":"all","stylers":[{"visibility":"off"},{"saturation":-100},{"lightness":60}]},{"featureType":"transit","elementType":"all","stylers":[{"visibility":"off"},{"saturation":-100},{"lightness":60}]}];

			var map_pos = new google.maps.LatLng(lat, lng);
			var map_args = {
				mapTypeId	:	google.maps.MapTypeId.ROADMAP,
				center		:	map_pos,
				zoom		:	map_zoom,
				scrollwheel	:	scrollwheel,
			}; // map_args
			
			// map styles
			if ( map_styles[style]!='undefined') {
				map_args['styles'] = map_styles[style];
				}
			
			var gmap = new google.maps.Map(document.getElementById(id), map_args);
			
			// marker
			var show_marker = $this.data('marker');
			if ( show_marker === true ) {
				var marker_args = {
					position	:	map_pos,
					map			:	gmap,
					title		:	$this.data('marker_title'),
				}
				// marker image
				var marker_image = $this.data('marker_image');
				if ( marker_image ) {
					var marker_img = new google.maps.MarkerImage( marker_image, null, null, null,null);
					marker_args['icon'] = marker_img;
				}
				var marker = new google.maps.Marker(marker_args);
			} // show marker
			
			// infowindow
			var info_window = $this.closest('.wi-gmap-container').find('.info_content');
			if (info_window.length > 0) {
				var infowindow = new google.maps.InfoWindow({
					content: info_window.html(),
				});
				google.maps.event.addListener(marker,'click',function(){
					infowindow.open(gmap, marker);
				});
				
				// show infowindow by default
				if ($this.data('open_info') === true) {
					infowindow.open(gmap, marker);
				}
				
			} // info window
			
			// resize
			google.maps.event.addDomListener(window,'resize', function() {
				var center = gmap.getCenter();
				google.maps.event.trigger(gmap,'resize');
				gmap.setCenter(center);
			}); // resize

		} // if google
		else {
			console.log('Google API is not available.');
		} // if google
	} // load_map function
							
}	// gmap

/* INIT FUNCTIONS
--------------------------------------------------------------------------------------------- */
$(document).ready(function() {

	WITHEMES.gmap();
	
						   }); // document ready
})(jQuery);	// EOF;