/** Updaten statistieken **/
function pageHit(){

  p = escape(document.location.href);
  rfr = escape(document.referrer);
  if (rfr == "undefined"){ rfr = "";}
  sx = screen.width;
  sy = screen.height;
  sc = (navigator.appName.indexOf("Microsoft") > -1) ? screen.colorDepth : screen.pixelDepth;
  src = 'stats.php?p=' + p + '&rfr=' + rfr + '&sx=' + sx + '&sy=' + sy + '&sc=' + sc;
  src = '<img style="position:absolute;left:-10px;top:-10px;" src="' + src + '" width="1" height="1" border="0" alt="" />';
  document.getElementById('counter').innerHTML = src;  
  
}

$(document).ready(function(){
$("a[rel^='prettyPhoto']").prettyPhoto();

if($("a[rel^='nieuwsPopup']").length != 0){
    $("a[rel^='nieuwsPopup']").prettyPhoto({social_tools:'', animation_speed:'normal', deeplinking:false});
    $("a[rel^='nieuwsPopup']").trigger('click');
}

});


(function($) {
    $.fn.customFadeIn = function(speed, callback) {
        $(this).fadeIn(speed, function() {
            if(jQuery.browser.msie)
                $(this).get(0).style.removeAttribute('filter');
            if(callback != undefined)
                callback();
        });
    };
    $.fn.customFadeOut = function(speed, callback) {
        $(this).fadeOut(speed, function() {
            if(jQuery.browser.msie)
                $(this).get(0).style.removeAttribute('filter');
            if(callback != undefined)
                callback();
        });
    };
})(jQuery);

function loadHighlights(){
    setTimeout('procedeLoadHighlight(1)', 0);
    setTimeout('procedeLoadHighlight(2)', 300);
    setTimeout('procedeLoadHighlight(3)', 600);
    setTimeout('procedeLoadHighlight(4)', 900);

}         
function procedeLoadHighlight(iId){
    if(getEl('highlight_'+iId) != null){
        $('#highlight_'+iId).customFadeIn("slow");
    }
}
function fadeIn(iId){
    if(getEl('fadein_'+iId) != null){
        $('#fadein_'+iId).customFadeIn("slow");
    }
}
function fadeOut(iId){
    if(getEl('fadein_'+iId) != null){
        $('#fadein_'+iId).customFadeOut("slow");
    }
}
function hide(iId){
    if(getEl('fadein_'+iId) != null){
        $('#fadein_'+iId).hide();
    }
}

function getEl(oObj){
    return document.getElementById(oObj);
}
$(document).ready(function(){
     loadHighlights();
     fadeIn(1);
     pageHit();
      
     $('#img_rotate').innerfade({   
         animationtype: 'fade',   
         speed: 'slow',   
         timeout: 6000,   
         type: 'sequence',   
         containerheight: '240px'  
     });   
});


function openRouteInfo(adress, titel) {
    
    sInfoRoute = '<div id="markerWindow" style="font-size:10px;><strong style="font-size:10px;font-weigth:bold;">Routebeschrijving</strong><p><form id="route" class="route" action="javascript:void(0)">Vul uw adres in voor een routebeschrijving <br />naar <i> Herenstraat 36, 2215 KH Voorhout</i>.<br /><table style="margin:5px 0 0 0"><tr><td><span style"font-size:10px">Straatnaam:</span></td><td><input type="text" id="saddr" /></td><td></td></tr><tr><td><span style"font-size:10px">Woonplaats:</span</td><td><input type="text" id="splaa" /></td><td></td></tr><tr><td></td><td><input type="submit" onclick="javascript:route();return false;" class="btn_85" value="Toon route"></td></tr></table><input type="hidden" id="planner_adres" value="' + adress + '" /></form></div>';
    
    oMap.marker.removeMarkers(0);
    
    oMap.marker.addMarker(sLat, sLong, sInfoRoute, true);
}



/**************************
*    Routeplanner
**************************/
function route(){
    // Start address -> moet in het formaat "straat, plaatsnaam" zijn
    saddr = document.getElementById("saddr").value;
    splaa = document.getElementById("splaa").value;

    // Adres van locatie
    daddr = document.getElementById("planner_adres").value;
    
    
    // Url
    url = 'http://maps.google.nl/?ie=UTF8&hl=nl&saddr=' + saddr +',' + splaa + '&daddr=' + daddr + '&f=d&sampleq=1';

    if(saddr != '' && splaa != ''){
        var load = window.open(url,'','scrollbars=yes,menubar=yes,height=600,width=800,resizable=yes,toolbar=yes,location=yes,status=yes');    
    } else {
        alert('Vul a.u.b. een straat en plaatsnaam in.');
    }
}

