﻿// ---------------------------------------------------------------------------------------- //
// -- JQUERY -- //
// ---------------------------------------------------------------------------------------- //

$(function() { 

    $("#foto_carousel").carouFredSel({       
        
        prev: {
            button: "#foto_carousel_prev",
            key: "left"
        },
        next: {
            button: "#foto_carousel_next",
            key: "right"
        },
        pagination: "#foto_carousel_pag",
        scroll: {
            easing: "easeInOutExpo",
            duration: 1500,
            mousewheel: true
        },
        auto: {
            pauseDuration: 3000,
            pauseOnHover: true
        }
    });

    $("#foto_carousel a").fancybox({
        cyclic: true,
        onStart: function() {
            $("#foto_carousel").trigger("pause");
        },
        onClosed: function() {
            $("#foto_carousel").trigger("play");
        },
        'titlePosition': 'over',
        'titleFormat': function(title, currentArray, currentIndex, currentOpts) {
            return '<span id="fancybox-title-over">Foto ' + (currentIndex + 1) + ' / ' + currentArray.length + (title.length ? ' &nbsp; ' + title : '') + '</span>';
        }

    });

});



$(document).ready(function() {


    if (isiPhone()) {
        $("#header_table").css("display", "none");
    }

    $("a.virtual_tour").colorbox({ iframe: true, innerWidth: 800, innerHeight: 650 });
    $("a.film").colorbox({ width: "80%", height: "80%", iframe: true });
    $("a.iframe").colorbox({ width: "80%", height: "80%", iframe: true });
    //$("a.colorbox_plan").colorbox({inline:true, href:"#plan_container", innerWidth:500, innerHeight: 300});  
    //$("a.colorbox_docs").colorbox({inline:true, href:"#docs_container", innerWidth:500, innerHeight: 300});


    $(function() {

        $('#header').cycle({
            fx: 'zoom',
            sync: false,
            delay: -10000,
            timeout: 500,
            autostop: true
        });
        $('.pand-indekijker-wrapper').cycle({
            fx: 'scrollLeft',
            pause: 5,
            prev: "#indekijker_prev",
            next: "#indekijker_next"

        });

        $(".ic_container_referenties").capslide({
            caption_color: '#868686',
            caption_bgcolor: '#ffffff',
            overlay_bgcolor: '#ffffff',
            border: '',
            showcaption: true,
            width: 202,
            height: 192
        });

        $(".ic_container_aanbod").capslide({
            caption_color: '#868686',
            caption_bgcolor: '#ffffff',
            overlay_bgcolor: '#ffffff',
            border: '',
            showcaption: true,
            width: 227,
            height: 192
        });

    });


});


//Cufon.replace('h1,h2, .ul-navigatie li a, .formulier-label');

// ** FUNCTIONS ** //


// Redirect iPhone/iPod visitors
function isiPhone() {
    return (
        (navigator.userAgent.indexOf("iPhone") != -1) ||
        (navigator.userAgent.indexOf("iPod") != -1) ||
        (navigator.userAgent.indexOf("iPad") != -1)
    );
}

function initEPC(iEPC){
        
    $(function() {  
        
        $("#EPC_slider").slider({
            disabled: true,
            min: 0,
            max: 700,
            value: iEPC
        });
        
    });
            
}

function initBestandenLink(sHypID, sClientID){

    $("#" + sHypID).colorbox({inline:true, href:"#" + sClientID, innerWidth:300, innerHeight: 200});  

}


    

function laadGoogleMap(hypID, toggleID, mapID, iLat, iLong, infoID, arrMarkers, zichtbaar){

    if((hypID != undefined) && (toggleID != undefined) && (mapID != undefined)){
       
        $('#' + hypID).click(function() {       
            $('#' + toggleID).slideToggle('slow', function(){                             
                
              //window.alert(hypID +  " // " + toggleID + " // " + mapID + " // " + iLat + " - "  + iLong );
              $(function(){
        
                    $("#" + mapID).goMap({
                        latitude: iLat,
                        longitude: iLong,
                        zoom: 16,
                        navigationControl: true,
                        navigationControlOptions:{
                            position: 'TOP_LEFT',
                            style: 'SMALL'
                        },
                        mapTypeControl: false,
                        scaleControl: false,
                        scrollwheel: false,
                        maptype: 'HYBRID',
                        autoCenter: true,
                        hideByClick: true,
                        oneInfoWindow: true 
                    });
                            
                });    
                
                setMarkers(mapID, arrMarkers);  
                setHomeMarker(mapID, iLat, iLong, infoID);                                                                          
                          
            });
        });

        if (zichtbaar == true) {
            $('#' + hypID).trigger('click');
        }
    
    }    

}

function laadGoogleMapPrint(mapID, iLat, iLong){
                     
        
      $(function(){

            $("#" + mapID).goMap({
                //latitude: iLat,
                //longitude: iLong,
                zoom: 10,
                navigationControl: true,
                navigationControlOptions:{
                    position: 'TOP_LEFT',
                    style: 'SMALL'
                },
                mapTypeControl: false,
                scaleControl: false,
                scrollwheel: false,
                maptype: 'TERRAIN',
                autoCenter: true,
                hideByClick: true,
                oneInfoWindow: true ,
                markers: [{  
                    latitude: iLat, 
                    longitude: iLong, 
                    icon: '/imgsite/google_maps_huis_actief.png'
                }] 
            });
                    
        });                    
    
        setHomeMarker(mapID, iLat, iLong, '');                                                                          
                          
     

}


function setHomeMarker(mapID, iLat, iLong, infoID){

    if(mapID != undefined){
        
        $(function(){
        
            $.goMap.createMarker({ 
                map: $("#" + mapID),
                latitude: iLat,
                longitude: iLong,
                icon: '/imgsite/google_maps_huis_actief.png',
//                html:{
//                    id: infoID
//                },
                zIndex: 99999
            });
            
        });
        
    }
}

function setMarker(mapID, iLat, iLong, infoID){

    if(mapID != undefined){
        
        $(function(){
        
            $.goMap.createMarker({ 
                map: $("#" + mapID),
                latitude: iLat,
                longitude: iLong,
                icon: '/imgsite/google_maps_huis.png',
//                html: {
//                    id: infoID
//                },
                zIndex: 88888
            });
            
        });
        
    }

}

function setMarkers(mapID, arrMarkers){

    if(mapID != undefined){
        
        $(function(){
        
            var iAantalMarkers  = arrMarkers.length;
            var i = 0;
                       
            for(i = 0 ; i < iAantalMarkers; i++){
                            
                $.goMap.createMarker({ 
                    map: $("#" + mapID),
                    latitude: arrMarkers[i].iLat,
                    longitude: arrMarkers[i].iLong,
                    icon: '/imgsite/google_maps_huis.png',
//                    html: {
//                        id: "#" + arrMarkers[i].infoID 
//                    },
                    zIndex: 8888
                });
                  
            }
                   
        });
        
    }
                    
}




