﻿$(document).ready(function () {
    Galleria.loadTheme('/Scripts/galleria/themes/classic/galleria.classic.min.js');
    galleria();
    Galleria.ready(function () {
        this.bind('idle_enter', function (e) {
            this.play();
        });
    });

    $("a.recipe-modal").click(function () {
        
        var url = "/recipe/details";
        var jsonString = "{\"recipeID\":'" + $(this).attr("rel") + "'}";

        $.ajax({
            type: "POST",
            url: url,
            dataType: "html",
            data: jsonString,
            contentType: "application/json; charset=utf-8",

            success: function (result) {
                $('.modal-bg').html('');
                $('.modal-bg').html(result);

                $(this).each(function () {
                    $("#modal .close").show();
                    $(".modal-bg , #modal").fadeIn("1000");

                    $(".close").click(function () {
                        $(".modal-bg , #modal").fadeOut("1000");
                    });
                });
            },
            error: function (request, error) {
            }
        });

    });



    if ($("#map").length > 0)
        initializeMap();
});

function galleria() {
    $(".gallery-container").galleria({
        width: 940,
        autoplay:true,
        height: 310,
        showImagenav: false,
        showCounter: false,
        showInfo: false,
        thumbnails: "empty"
    });
};

function initializeMap() {
    var latlng = new google.maps.LatLng(53.644472, -1.768541);
    var image = '/Content/images/shaws-marker.png';
    var myOptions = {
        zoom: 16,
        center: latlng,
        scrollwheel: false,
        mapTypeId: google.maps.MapTypeId.ROADMAP
    };
    var map = new google.maps.Map(document.getElementById("map"),
        myOptions);


    var marker = new google.maps.Marker({
        position: latlng,
        map: map,
        icon: image,
        animation: google.maps.Animation.DROP
    });

}


