﻿function simple_tooltip(target_items, name)
{
    $(target_items).each(findtooltip );
    function findtooltip(i)
    {
        $("body").append("<div class='" + name + "' id='" + name + i + "'><p>" + $(this).attr('title') + "</p></div>");
        var my_tooltip = $("#" + name + i);

        $(this).removeAttr("title").mouseover(function()
        {
            my_tooltip.css({ opacity: 0.8, display: "none" }).fadeIn(100);
        }).mousemove(function(kmouse)
        {
            my_tooltip.css({ left: kmouse.pageX + 15, top: kmouse.pageY + 15 });
        }).mouseout(function()
        {
            my_tooltip.fadeOut(100);
        });
    }
}

function Infowin(latlng, html)
{
    this.latlng_ = latlng;
    this.html_ = html;
    this.prototype = new GOverlay();
    this.initialize = function(map)
    {
        var div = $('<div />');
        div.css({
        position: 'absolute',
            width: 200
        }).appendTo(map.getContainer())
        this.map_ = map;
        this.div_ = div;
        this.update(html);
    }
    this.update = function(html)
    {
        this.html_ = html;
        this.div_.empty();
        $('<div />').addClass('infowin-top').appendTo(this.div_);
        var content = $('<div />').addClass('infowin-content').css({
            'position': 'relative',
            'overflow': 'hidden',
            'max-height': 120
        }).html(html);
        $('<div />').addClass('infowin-bottom').append(content).appendTo(this.div_);
        this.redraw(true);
    }
    // Remove the main DIV from the map pane
    this.remove = function()
    {
        this.div_.remove();
    }
    this.copy = function()
    {
        return new Infowin(this.latlng_, this.html_);
    }
    this.redraw = function(force)
    {
        if (!force) return;
        var point = this.map_.fromLatLngToDivPixel(this.latlng_);
        this.div_.css({
            left: point.x + 100,
            top: point.y - this.div_.height() + 10
        });
    }
}

function OpenWindow(url)
{
    window.open(url, '', config = 'toolbar=no, menubar=no, scrollbars=yes, resizable=yes, location=no, directories=no, status=yes, width=950, height=700, left=' + (screen.width - 950) / 2 + ', top=' + (screen.height - 700) / 2);
}



