$( document ).ready(function() {

    if($(".producerfinder-list").length){
        initAllPruducer ();
    }
    if($(".oneProducerMap").length){
        oneProducerMap ();
    }

    if($(".producer-to-map").length){
        ProducerProductMap();
    }
    else{
        $('.maprow').hide();
    }


    $('.produkte-produzente').find('.element-top:not(.normallink)').on('click', function(){
        $(this).find(".loader").show();
        $( ".produkte-produzente-content-inner").css('opacity' , '.2');
        $(".produkte-produzente-content").removeClass('active');
        $('.element-top').removeClass('element-top-active');
        $('.element-sub').removeClass('element-sub-active');

        var _this = $(this);

        if($('html').attr('lang') == 'fr') var lang= 1;
        else var lang = 0;

        $( ".produkte-produzente-content-inner" ).load( "index.php?id="+$(this).attr('data-uid')+"&type=564507&L="+lang , function(){

            _this.addClass('element-top-active');

            position_top_content($('.element-top-active'));

            $(".produkte-produzente-content").addClass('active');
            $(".produkte-produzente-content").prepend('<div class="produkte-produzente-content-close"><span class="fairtrade-icon_x"></span></div>');
            $(".produkte-produzente-content-close").on('click',function(){
                //$(".produkte-produzente-content").slideUp('fast');
                $('.hiddencontent').append($(".produkte-produzente-content") );
            });

            $('html, body').animate({
                scrollTop: $(".produkte-produzente-content").offset().top - 200
            }, 'slow');


            if($(".producerfinder-list").length){
                initAllPruducer ();
            }
            $('.element-top').find(".loader").hide();

                $( ".produkte-produzente-content-inner").css('opacity' , '1');


        });
    });

    $('.produkte-produzente').find('.element-sub:not(.normallink)').on('click', function(){
        $( ".produkte-produzente-content-inner").css('opacity' , '.2');
        $(this).find(".loader").show();

        $(".produkte-produzente-content").removeClass('active');
        $('.element-sub').removeClass('element-sub-active');
        $('.element-top').removeClass('element-top-active');

        var _this = $(this);

        if($('html').attr('lang') == 'fr') var lang= 1;
        else var lang = 0;

        $( ".produkte-produzente-content-inner" ).load( "index.php?id="+$(this).attr('data-uid')+"&type=564507&L="+lang , function(){

            _this.addClass('element-sub-active');

            position_sub_content($('.element-sub-active'));

            $(".produkte-produzente-content").addClass('active');
            $(".produkte-produzente-content").prepend('<div class="produkte-produzente-content-close"><span class="fairtrade-icon_x"></span></div>');
            $(".produkte-produzente-content-close").on('click',function(){
                //$(".produkte-produzente-content").slideUp('fast');
                $('.hiddencontent').append($(".produkte-produzente-content") );
            });
            $('html, body').animate({
                scrollTop: $(".produkte-produzente-content").offset().top - 200
            }, 'slow');
            //$(".produkte-produzente-content").slideDown('fast');

            if($(".producerfinder-list").length){
                initAllPruducer ();
            }
            $('.element-sub').find(".loader").hide();
            $( ".produkte-produzente-content-inner").css('opacity' , '1');

        });
    });



    if(window.location.hash) {

        setTimeout(function(){
            var hash = window.location.hash.substring(1);
            $('#element-'+hash).trigger('click');
            //$('.producerfinder-list-item.first').removeClass('accordion-header-active');
            //$('.producerfinder-list-item.first').removeClass('ui-accordion-header-active');
        }, 500);

    }
});

function position_top_content(_this){

    if(__device >= 3){

        var myIndex = (_this.attr('data-pos')) % 3;
        var maxint = parseInt(($('.element-top').length)/3, 10)*3;
        var myRest  = _this.nextAll('.element-top').length;

        if(myIndex ==0 || myRest == 0 ){
            $( ".produkte-produzente-content" ).insertAfter( _this );
        }
        else if(myRest < 3 && _this.attr('data-pos') > maxint ){
            $('.elemente-top').append($(".produkte-produzente-content") );
        }
        else if(myIndex == 1 ){
            $( ".produkte-produzente-content" ).insertAfter( _this.next().next() );
        }
        else if(myIndex == 2 ){
            $( ".produkte-produzente-content" ).insertAfter( _this.next() );
        }
    }
    if(__device < 3){
        $( ".produkte-produzente-content" ).insertAfter( _this );
    }
}

function position_sub_content(_this){

    if(__device >= 3){

        var myIndex = (_this.attr('data-pos')) % 6;
        var maxint = parseInt(($('.element-sub').length)/6, 10)*6;
        var myRest  = _this.nextAll('.element-sub').length;




        if(myIndex ==0 || myRest == 0 ){
            $( ".produkte-produzente-content" ).insertAfter( _this );
        }
        else if(myRest < 6 && _this.attr('data-pos') > maxint  ){
            $('.elemente-sub').append($(".produkte-produzente-content") );

        }
        else if(myIndex == 1 ){
            $( ".produkte-produzente-content" ).insertAfter( _this.next().next().next().next().next() );

        }
        else if(myIndex == 2 ){
            $( ".produkte-produzente-content" ).insertAfter( _this.next().next().next().next() );

        }
        else if(myIndex == 3 ){
            $( ".produkte-produzente-content" ).insertAfter( _this.next().next().next() );

        }
        else if(myIndex == 4 ){
            $( ".produkte-produzente-content" ).insertAfter( _this.next().next() );

        }
        else if(myIndex == 5 ){
            $( ".produkte-produzente-content" ).insertAfter( _this.next() );

        }


    }
    if(__device < 3){

        var myIndex = (_this.attr('data-pos')) % 2;
        var maxint = parseInt(($('.element-sub').length)/2, 10)*2;
        var myRest  = _this.nextAll('.element-sub').length;

        if(myIndex ==0 || myRest == 0 ){
            $( ".produkte-produzente-content" ).insertAfter( _this );
        }
        else if(myRest < 2 && _this.attr('data-pos') > maxint  ){
            $('.elemente-sub').append($(".produkte-produzente-content") );

        }
        else if(myIndex == 1 ){
            $( ".produkte-produzente-content" ).insertAfter( _this.next() );

        }



    }
}

$(window).load(function() {
    $('.produkte-produzente').css("display","block");

    eql_div();

    $(window).resize(function(){
        if($('.produkte-produzente').length){

            $('.hiddencontent').append($(".produkte-produzente-content") );

            if($('.element-top-active')) position_top_content($('.element-top-active'));
            if($('.element-sub-active')) position_sub_content($('.element-sub-active'));

            eql_div();

        }
    });
});

function eql_div(){
    if(__device >= 3){
        $( '.element-top > .kachel' ).height($( '.element-top > .kachel' ).width());
        $( '.element-sub > .kachel' ).height($( '.element-sub > .kachel' ).width()/2);
    }

    if(__device < 3){
        $( '.element-top > .kachel' ).height($( '.element-top > .kachel' ).width()/2);
        $( '.element-sub > .kachel' ).height($( '.element-sub > .kachel' ).width());
    }
}





var myProducerMarkers = [];
var mapProducer;
var markerProducer = [];
var boundsProducer = [];

function ProducerProductMap(){

    boundsProducer = new google.maps.LatLngBounds();
    var infowindow = null;
    infowindow = new google.maps.InfoWindow({
        content: "."
    });
    myProducerMarkers = [];
    $('.producer-to-map').each(function(){
        if($(this).attr('data-geolat') != '' && $(this).attr('data-geolan') != ''){
            myProducerMarkers.push([$(this).attr('data-uid'), parseFloat($(this).attr('data-geolat')), parseFloat($(this).attr('data-geolan'))]);
        }
    });

    var image = {
        url: '/typo3conf/ext/igx_products/Resources/Public/Icons/pin_ft.png',
        // This marker is 20 pixels wide by 32 pixels high.
        size: new google.maps.Size(37, 59),
        // The origin for this image is (0, 0).
        origin: new google.maps.Point(0, 0),
        // The anchor for this image is the base of the flagpole at (0, 32).
        anchor: new google.maps.Point(18, 59)
    };

    mapProducer = new google.maps.Map(document.getElementById('mapProducer'), {
        scrollwheel: false
    });

    for (i = 0; i < myProducerMarkers.length; i++) {


        var markerHtml = '';

        markerHtml = markerHtml+"<div class='map-marker'><h4>"+$('#prod-'+myProducerMarkers[i][0]).html()+"</h4><p>";

        if($("#mitarbeiter-" + myProducerMarkers[i][0]).length ){
            markerHtml = markerHtml+""+$("#mitarbeiter-" + myProducerMarkers[i][0]).html()+"<br />";
        }
        if($("#ort-" + myProducerMarkers[i][0]).length ){
            markerHtml = markerHtml+""+$("#ort-" + myProducerMarkers[i][0]).html()+"<br /></p><p>";
        }
        if($("#floid-" + myProducerMarkers[i][0]).length ){
            markerHtml = markerHtml+"<b>Floid:</b> "+$("#floid-" + myProducerMarkers[i][0]).html()+"<br />";
        }
        if($("#produktion-" + myProducerMarkers[i][0]).length ){
            markerHtml = markerHtml+"<b>Réseau de producteurs:</b> "+$("#produktion-" + myProducerMarkers[i][0]).html()+"<br />";
        }
        if($("#zertifizierung-" + myProducerMarkers[i][0]).length ){
            markerHtml = markerHtml+"<b>Type Certification:</b> "+$("#zertifizierung-" + myProducerMarkers[i][0]).html()+"<br />";
        }
        if($("#catnames-" + myProducerMarkers[i][0]).length ){
            markerHtml = markerHtml+"<b>Produit Certifié:</b> "+$("#catnames-" + myProducerMarkers[i][0]).html()+"<br />";
        }
        if($("#link-" + myProducerMarkers[i][0]).length ){
            markerHtml = markerHtml+"<div><a href='"+$("#link-" + myProducerMarkers[i][0]).attr('href')+"' >"+$("#link-" + myProducerMarkers[i][0]).html()+"</a></div>";
        }
        markerHtml = markerHtml+"</p></div>";



        markerProducer[myProducerMarkers[i][0]] = new google.maps.Marker({
            position: new google.maps.LatLng(myProducerMarkers[i][1], myProducerMarkers[i][2]),
            map: mapProducer,
            icon: image,
            html:markerHtml
        });

        var marker = markerProducer[myProducerMarkers[i][0]];
        google.maps.event.addListener(marker, 'click', function () {
            infowindow.setContent(this.html);
            infowindow.open(mapProducer, this);
        });

        boundsProducer.extend(markerProducer[myProducerMarkers[i][0]].getPosition());
    }

    mapProducer.fitBounds(boundsProducer);

    google.maps.event.addListenerOnce(mapProducer, 'bounds_changed', function(event) {
        if (this.getZoom() > 7) {
            this.setZoom(7);
        }
    });

}

function oneProducerMap (){
    if($('#mapProducer2').length){

        var image = {
            url: '/typo3conf/ext/igx_products/Resources/Public/Icons/pin_ft.png',
            // This marker is 20 pixels wide by 32 pixels high.
            size: new google.maps.Size(37, 59),
            // The origin for this image is (0, 0).
            origin: new google.maps.Point(0, 0),
            // The anchor for this image is the base of the flagpole at (0, 32).
            anchor: new google.maps.Point(18, 59)
        };

        mapProducer = new google.maps.Map(document.getElementById('mapProducer2'), {
            scrollwheel: false,
            center: {lat: parseFloat($('#mapP').attr('data-geolat')), lng: parseFloat($('#mapP').attr('data-geolan'))},
            zoom: 7
        });


        marker = new google.maps.Marker({
            position: new google.maps.LatLng(parseFloat($('#mapP').attr('data-geolat')), parseFloat($('#mapP').attr('data-geolan'))),
            map: mapProducer,
            icon: image
        });

    }
}

function initPruducerMap() {
    if($('#mapProducer').length){


        mapProducer = new google.maps.Map(document.getElementById('mapProducer'), {
            scrollwheel: false
        });

        getPruducerMapData();

        createPruducerMarkers();
    }

}

function getPruducerMapData(){
    myProducerMarkers = [];
    $('.producerfinder-list .producerfinder-list-item').each(function(){
        if($(this).attr('data-geolat') != '' && $(this).attr('data-geolan') != '' && $(this).attr('data-showmap') == '1'){
            myProducerMarkers.push([$(this).attr('data-uid'), parseFloat($(this).attr('data-geolat')), parseFloat($(this).attr('data-geolan'))]);
        }
    });


}

function createPruducerMarkers(){

    boundsProducer = new google.maps.LatLngBounds();

    var infowindow = null;

    infowindow = new google.maps.InfoWindow({
        content: "."
    });



    var image = {
        url: '/typo3conf/ext/igx_products/Resources/Public/Icons/pin_ft.png',
        // This marker is 20 pixels wide by 32 pixels high.
        size: new google.maps.Size(37, 59),
        // The origin for this image is (0, 0).
        origin: new google.maps.Point(0, 0),
        // The anchor for this image is the base of the flagpole at (0, 32).
        anchor: new google.maps.Point(18, 59)
    };

    for (i = 0; i < myProducerMarkers.length; i++) {


        var markerHtml = '';

        markerHtml = markerHtml+"<div class='map-marker'><h4>"+$('#prod-'+myProducerMarkers[i][0]).html()+"</h4><p>";

        if($("#mitarbeiter-" + myProducerMarkers[i][0]).length ){
            markerHtml = markerHtml+""+$("#mitarbeiter-" + myProducerMarkers[i][0]).html()+"<br />";
        }
        if($("#ort-" + myProducerMarkers[i][0]).length ){
            markerHtml = markerHtml+""+$("#ort-" + myProducerMarkers[i][0]).html()+"<br /></p><p>";
        }
        if($("#floid-" + myProducerMarkers[i][0]).length ){
            markerHtml = markerHtml+"<b>Floid:</b> "+$("#floid-" + myProducerMarkers[i][0]).html()+"<br />";
        }
        if($("#produktion-" + myProducerMarkers[i][0]).length ){
            markerHtml = markerHtml+"<b>Réseau de producteurs:</b> "+$("#produktion-" + myProducerMarkers[i][0]).html()+"<br />";
        }
        if($("#zertifizierung-" + myProducerMarkers[i][0]).length ){
            markerHtml = markerHtml+"<b>Type Certification:</b> "+$("#zertifizierung-" + myProducerMarkers[i][0]).html()+"<br />";
        }
        if($("#catnames-" + myProducerMarkers[i][0]).length ){
            markerHtml = markerHtml+"<b>Produit Certifié:</b> "+$("#catnames-" + myProducerMarkers[i][0]).html()+"<br />";
        }
        if($("#link-" + myProducerMarkers[i][0]).length ){
            markerHtml = markerHtml+"<div><a href='"+$("#link-" + myProducerMarkers[i][0]).attr('href')+"' >"+$("#link-" + myProducerMarkers[i][0]).html()+"</a></div>";
        }
        markerHtml = markerHtml+"</p></div>";

        markerProducer[myProducerMarkers[i][0]] = new google.maps.Marker({
            position: new google.maps.LatLng(myProducerMarkers[i][1], myProducerMarkers[i][2]),
            map: mapProducer,
            icon: image,
            html:markerHtml
        });

        var marker = markerProducer[myProducerMarkers[i][0]];
        google.maps.event.addListener(marker, 'click', function () {
            infowindow.setContent(this.html);
            infowindow.open(mapProducer, this);
        });

        boundsProducer.extend(markerProducer[myProducerMarkers[i][0]].getPosition());
    }

    mapProducer.fitBounds(boundsProducer);

    google.maps.event.addListenerOnce(mapProducer, 'bounds_changed', function(event) {
        boundsTimeout = setTimeout(function(){ if(mapProducer.getZoom() > 10) mapProducer.setZoom(10); clearTimeout(boundsTimeout); }, 3000);
    });

}

function initProducerFilter() {

    $(".FilterProd").on( "click", function( event ) {


        var cont = new Array();

        if($("#mapProducerFilterCategory").chosen().val() == 0 && $("#mapProducerFilterContinent").chosen().val() == 0 && $("#mapProducerFilterLand").chosen().val() == 0){
            $( ".producerfinder-list-item").each(function(){
                    cont.push($(this));
            });
        }
        else if($("#mapProducerFilterCategory").chosen().val() != 0 && $("#mapProducerFilterContinent").chosen().val() == 0 && $("#mapProducerFilterLand").chosen().val() == 0 ) {
            $( ".producerfinder-list-item[data-categories*='"+$("#mapProducerFilterCategory").chosen().val()+"']").each(function(){
                    cont.push($(this));
            });
        }
        else if($("#mapProducerFilterCategory").chosen().val() != 0 && $("#mapProducerFilterContinent").chosen().val() != 0 && $("#mapProducerFilterLand").chosen().val() == 0 ) {
            $( ".producerfinder-list-item[data-categories*='"+$("#mapProducerFilterCategory").chosen().val()+"'][data-continent*='"+$("#mapProducerFilterContinent").chosen().val()+"']").each(function(){
                    cont.push($(this));
            });
        }
        else if($("#mapProducerFilterCategory").chosen().val() != 0 && $("#mapProducerFilterContinent").chosen().val() != 0 && $("#mapProducerFilterLand").chosen().val() != 0 ) {
            $( ".producerfinder-list-item[data-categories*='"+$("#mapProducerFilterCategory").chosen().val()+"'][data-continent*='"+$("#mapProducerFilterContinent").chosen().val()+"'][data-land*='"+$("#mapProducerFilterLand").chosen().val()+"']").each(function(){
                cont.push($(this));
            });
        }
        else if($("#mapProducerFilterCategory").chosen().val() == 0 && $("#mapProducerFilterContinent").chosen().val() != 0 && $("#mapProducerFilterLand").chosen().val() != 0 ) {
            $( ".producerfinder-list-item[data-continent*='"+$("#mapProducerFilterContinent").chosen().val()+"'][data-land*='"+$("#mapProducerFilterLand").chosen().val()+"']").each(function(){
                cont.push($(this));
            });
        }
        else if($("#mapProducerFilterCategory").chosen().val() == 0 && $("#mapProducerFilterContinent").chosen().val() == 0 && $("#mapProducerFilterLand").chosen().val() != 0 ) {
            $( ".producerfinder-list-item[data-land*='"+$("#mapProducerFilterLand").chosen().val()+"']").each(function(){
                cont.push($(this));
            });
        }
        else if($("#mapProducerFilterCategory").chosen().val() != 0 && $("#mapProducerFilterContinent").chosen().val() == 0 && $("#mapProducerFilterLand").chosen().val() != 0 ) {
            $( ".producerfinder-list-item[data-categories*='"+$("#mapProducerFilterCategory").chosen().val()+"'][data-land*='"+$("#mapProducerFilterLand").chosen().val()+"']").each(function(){
                cont.push($(this));
            });
        }
        else if($("#mapProducerFilterCategory").chosen().val() == 0 && $("#mapProducerFilterContinent").chosen().val() != 0 && $("#mapProducerFilterLand").chosen().val() == 0 ) {
            $( ".producerfinder-list-item[data-continent*='"+$("#mapProducerFilterContinent").chosen().val()+"']").each(function(){
                cont.push($(this));
            });
        }
        $( $(".producerfinder-list").contents() ).appendTo('#hidenDivProd');
        $.each(cont, function(key, value) {
            var el1 = $( this );
            var el2 = $( this ).next();
            el1.appendTo('.producerfinder-list');
            el2.appendTo('.producerfinder-list');
        });


        for (key in markerProducer) {
            if (arrayHasOwnIndex(markerProducer, key)) {
                markerProducer[key].setMap(null);
            }
        }


        myProducerMarkers = [];
        markerProducer = [];
        boundsProducer = [];




        getPruducerMapData();
        createPruducerMarkers();
        $('.t3ddy-accordion').each(function(){
            var $accordionContainer = $(this);
            $(this).find('h5.t3ddy-accordion-header').first().addClass('first');
            $(this).find('h5.t3ddy-accordion-header').last().addClass('last');
            $accordionContainer.accordion({
                heightStyle: 'content',
                navigation: true,
                collapsible: true,
                active: false
            });
            $(this).find('h5.t3ddy-accordion-header .ui-accordion-header-icon').addClass('fairtrade-icon_plus');
        });
});}


function initProdFilter(){

    $("#mapProducerFilterCategory option").each(function()
    {

        if($(this).val() != '0' && $( ".producerfinder-list-item[data-categories*='"+$(this).val()+"']").length == 0){
            $(this).remove();
        }

        $(".chosen-ProducerFilter").trigger("chosen:updated");

    });
    initProdContFilter();

}

function initProdContFilter(){

    $( "#mapProducerFilterContinent" ).empty();
    $("#mapProducerFilterContinent").append( new Option($("#mapProducerFilterContinent").attr('data-lable'),'0') );


    $( "#mapProducerFilterLand" ).empty();
    $("#mapProducerFilterLand").append( new Option($("#mapProducerFilterLand").attr('data-lable'),'0') );

    var cont = new Array();

    if($("#mapProducerFilterCategory").chosen().val() == 0){
        $( ".producerfinder-list-item").each(function(){

            if (cont.indexOf($(this).attr('data-continent')) == -1) {
                cont.push($(this).attr('data-continent'));
            }
        });
    }
    else{

        $( ".producerfinder-list-item[data-categories*='"+$("#mapProducerFilterCategory").chosen().val()+"']").each(function(){
            if (cont.indexOf($(this).attr('data-continent')) == -1) {
                cont.push($(this).attr('data-continent'));
            }
        });
    }
    cont.sort();
    $.each(cont, function(key, value) {

        $("#mapProducerFilterContinent").append( new Option(value,value) );
    });


    $(".chosen-ProducerFilter").trigger("chosen:updated");
    initProdLandFilter();

}

function initProdLandFilter(){


    $( "#mapProducerFilterLand" ).empty();
    $("#mapProducerFilterLand").append( new Option($("#mapProducerFilterLand").attr('data-lable'),'0') );

    var cont = new Array();

    if($("#mapProducerFilterCategory").chosen().val() == 0 && $("#mapProducerFilterContinent").chosen().val() == 0){
        $( ".producerfinder-list-item").each(function(){

            if (cont.indexOf($(this).attr('data-land')) == -1) {
                cont.push($(this).attr('data-land'));
            }

        });
    }
    else if($("#mapProducerFilterCategory").chosen().val() != 0 && $("#mapProducerFilterContinent").chosen().val() == 0 ) {

        $( ".producerfinder-list-item[data-categories*='"+$("#mapProducerFilterCategory").chosen().val()+"']").each(function(){

            if (cont.indexOf($(this).attr('data-land')) == -1) {
                cont.push($(this).attr('data-land'));
            }
        });
    }

    else if($("#mapProducerFilterCategory").chosen().val() == 0 && $("#mapProducerFilterContinent").chosen().val() != 0 ) {

        $( ".producerfinder-list-item[data-continent*='"+$("#mapProducerFilterContinent").chosen().val()+"']").each(function(){

            if (cont.indexOf($(this).attr('data-land')) == -1) {
                cont.push($(this).attr('data-land'));
            }
        });
    }

    else{
        $( ".producerfinder-list-item[data-categories*='"+$("#mapProducerFilterCategory").chosen().val()+"'][data-continent*='"+$("#mapProducerFilterContinent").chosen().val()+"']").each(function(){

            if (cont.indexOf($(this).attr('data-land')) == -1) {
                cont.push($(this).attr('data-land'));
            }
        });
    }
    cont.sort();
    $.each(cont, function(key, value) {

        $("#mapProducerFilterLand").append( new Option(value,value) );
    });
    $(".chosen-ProducerFilter").trigger("chosen:updated");

}

function initAllPruducer (){
    initPruducerMap();
    checkInitAccordeonTabs();
    //initProducerFilter();
    $('.chosen-ProducerFilter').chosen({ width: '100%', disable_search_threshold: 10, no_results_text: "Kein Ergebnis" });

    $('.t3ddy-accordion').each(function(){
        var $accordionContainer = $(this);
        $(this).find('h5.t3ddy-accordion-header').first().addClass('first');
        $(this).find('h5.t3ddy-accordion-header').last().addClass('last');
        $accordionContainer.accordion({
            heightStyle: 'content',
            navigation: true,
            collapsible: true,
            active: false
        });

        $(this).find('h5.t3ddy-accordion-header .ui-accordion-header-icon').addClass('fairtrade-icon_plus');
    });

    initProdFilter();
    $("#mapProducerFilterCategory").chosen().change(function(){
        initProdContFilter();
    });
    $("#mapProducerFilterContinent").chosen().change(function(){
        initProdLandFilter();
    });
    initProducerFilter();


    if ( $( ".producerfinder-list" ).hasClass( "notshowlistfirst" ) ) {

        $( $(".producerfinder-list").contents() ).appendTo('#hidenDivProd');

    }

    if ($("button.FilterProd").attr("data-dofilter")){



        var res = $("button.FilterProd").attr("data-dofilter").split("|");


        $("#mapProducerFilterCategory").val($("#mapProducerFilterCategory").find('option:contains('+res[0]+')').val());
        $("#mapProducerFilterContinent").val(res[1]);
        $("#mapProducerFilterLand").val(res[2]);
        $(".chosen-ProducerFilter").trigger("chosen:updated");

        $( "button.FilterProd" ).trigger( "click");

    }

    $('.show-on-map').on('click' , function(){
        google.maps.event.trigger(markerProducer[$(this).attr('data-uid')], 'click');
        $('html, body').animate({
            scrollTop: ($(".producerfinder").offset().top)-130
        }, 500);

        mapProducer.setZoom(7);
    });






}

function arrayHasOwnIndex(array, prop) {
    return array.hasOwnProperty(prop) && /^0$|^[1-9]\d*$/.test(prop) && prop <= 4294967294; // 2^32 - 2
}


  // DCE Produzenten



