﻿jQuery(document).ready(function() {
    jQuery('.office-list-horis .office').each(function(i) {

        var earth = $(this).find('a.map-tt');

        var address = $(this).find('div.map-address').html();
        var latlon = $(earth).attr('rel');

        jQuery(earth).qtip({
            content: '<div id="map_' + i + '"/>'
            ,
            show: {
                delay: 100,
                when: 'mouseover',
                solo: true
            },
            hide: {
                when: {
                    event: 'unfocus'
                }
            },
            position: {
                corner: {
                    target: 'bottomMiddle',
                    tooltip: 'topMiddle'
                }
            },
            style: {
                width: 435,
                height: 240,

                border: {
                    width: 9,
                    radius: 5,
                    color: '#D3D3D3'
                },
                tip: {
                    corner: 'topMiddle', // We declare our corner within the object using the corner sub-option
                    color: '#D3D3D3',
                    size: {
                        x: 12, y: 18
                    }
                }
            },
            api: {
                onShow: function() {

                    var e = $('#map_' + i);

                    $.GoogleMaps(e,
                    {
                        latlong: latlon,
                        address: '<div style="font-size: 1.2em;"><strong>Precio Systemutveckling AB</strong><br/>' + address +'</div>',
                        infoWindow: true,
                        iconImage: {
                            url: ep_settings.getInstance().siteUrl + 'Templates/Public/Styles/images/precio-gicon.png',
                            height: 25,
                            width: 32
                        },
                        iconShadow: {
                            url: ep_settings.getInstance().siteUrl + 'Templates/Public/Styles/images/precio-gicon-shadow.png',
                            height: 34,
                            width: 47
                        },
                        height: 240,
                        width: 400
                    });
                }
                //,onHide : function() {this.destroy();}  // this is optional to clear memory
            }
        });
    });
});
