var reset = true;

$(document).ready(function () {
    // gallery plugin added to class adGallery
    $('.adGallery').adGallery();
    // default settings for slider
    $('#slides').slides({
        effect: "fade",
        fadeEasing: "easeInOutQuad",
        crossfade: "true",
        fadeSpeed: 500,
        preload: true,
        preloadImage: '../Assets/Images/loading.gif',
        play: slideShowDelay,
        hoverPause: false,
        animationStart: function (current) {
            $('.caption').animate({
                bottom: -35
            }, 100);
        },
        animationComplete: function (current) {
            $('.caption').animate({
                bottom: 0
            }, 200);
        },
        slidesLoaded: function () {
            $('.caption').animate({
                bottom: 0
            }, 200);
        }
    });
    // cf class added to all the li:s within headlinesListing due to unknown number of items
    $(".pagination").addClass("cf");
    $(".headlinesListing ul li").addClass("cf");
    // Javascript for the functionality of the progressbar
    var text = $(".refill").attr("title");
    $(".refill").append("<div class='progressInfo outfitHelv'><div class='leftside'></div><div class='middle'>" + text + "</div><div class='rightside'></div></div>");
    var inw = $(".progressInfo").width();
    var ce = (inw / 2);
    $(".progressInfo").css("right", -ce + "px");
    $(".progressInfo").append("<img src='/Assets/Images/info-arrow.png' class='pointingArrow' />");
    $(".pointingArrow").css("left", ce - 5 + "px");
    // footer- link menu
    $("#moreMenu").hide();
    $("a.moreMenu").click(function (e) {
        e.preventDefault();
        var isActive = $("#moreMenu").hasClass('extend');
        $('.extend').hide();
        $('.extend').removeClass('extend');
        if (!isActive) {
            $("#moreMenu").addClass('extend');
            $('.extend').fadeIn("fast");
        }
    });
    $("#moreMenu").hover(function () { }, function () { $(this).fadeOut(); })
    // if menu item has submenu, set settings for viewing page 
    var acs = $("li.active div").hasClass("subNavigation");
    if (acs) {
        $("#main").css("padding-top", "40px");
        $("li.active .subNavigation").show();
    }

    if ($(".active.hasMenu").length == 0) {
        $("#main").addClass("noMenuBar");
        $(".contentBottomBg").addClass("noMenuBar");
    }


});
var diligentia = new google.maps.LatLng(59.3369195, 18.0622704);
var parliament = new google.maps.LatLng(59.327383, 18.06747);
var marker;
var map;

function initialize() {

    if ($("#map_canvas").length != 0) {

        var diligentia = new google.maps.LatLng(59.3369195, 18.0622704);

        var mapOptions = {
            zoom: 13,
            mapTypeId: google.maps.MapTypeId.ROADMAP,
            center: diligentia,
            disableDefaultUI: true
        };

        map = new google.maps.Map(document.getElementById("map_canvas"),
      mapOptions);

        //        marker = new google.maps.Marker({
        //            map: map,
        //            draggable: true,
        //            animation: google.maps.Animation.DROP,
        //            position: diligentia
        //        });
        //        
        codeAddress();
    }
}

function codeAddress() {
    geocoder = new google.maps.Geocoder();
    geocoder.geocode({ 'address': mapAddress }, function (results, status) {
        if (status == google.maps.GeocoderStatus.OK) {
            map.setCenter(results[0].geometry.location);
            marker = new google.maps.Marker({
                map: map,
                position: results[0].geometry.location,
                icon: "/Assets/Images/marker.png"
            });
            google.maps.event.addListener(marker, 'click', toggleBounce);
        } else {
            // Do nothing
        }
    });
}

function toggleBounce() {

    if (marker.getAnimation() != null) {
        marker.setAnimation(null);
    } else {
        marker.setAnimation(google.maps.Animation.BOUNCE);
    }
}




