﻿/*
Custom Javascripts functions and presets
*/

$(document).ready(function() {
    $("#quickmenu li:last").css("border-bottom", "1px solid #DDDDDD");
    $("#ProjectOverview li:last").css("border-bottom", "1px solid #000");

    voteChangeUri = document.getElementById("votechange");
    _url = document.location.href;

    // If logged on, no login page needed!
    var test = readCookie("rabomemeber");    
    if ((test != null) && (_url.search(/stemmen.html/i) != -1)) {
        document.location.href = '/nl/stemmen/overzicht.html';
    } else {
        if (voteChangeUri) {
           voteChangeUri.style.display = 'none';
        }
    }

    /*
    Find through visited URL the right selected path in menu ;P
    Jquery powered
    */
    _searchUrls = ["home", "verkiezingen", "genomineerde", "stem", "contact","winnaars"];

    for (i = 0; i < _searchUrls.length; i++) {
        _result = _url.search(eval("/\\/" + _searchUrls[i] + "/i"));
        if (_result != -1) {

            var menu = $("div.navigatie li");

            menu.each(function() {
                var _searchText = $(this).text();

                if (_searchText.search(eval("/" + _searchUrls[i] + "/i")) != -1) {
                    $(this).addClass("current");
                }
            });

        }
    }
});
