﻿function hideDialog(hideElement) {
    $(hideElement).dialog('close');
  
}

function remove() {
    this.remove();
}
function rebindDialog(rebindElement)
{
    $(rebindElement).dialog({
            bgiframe: true,
            height: 420,
            width: 360,
            modal: true,
            autoOpen: false,
            resizable: true
        })
        
}

function createDialog(contentID, dWidth, dHeight) {
    return $(contentID).dialog({
        bgiframe: true,
        height: dHeight,
        width: dWidth,
        modal: true,
        autoOpen: false,
        resizable: true
//  to wydaje się byś zbędne, więc usunąć po jakimś czasie :)
//        ,close: $(function() {
//            $(this).remove();
//        })
    })
}

function showMessage(className, messageText) {
    //alert(className + ' ' + messageText);
    if (messageText.length == 0) return false;
    //$("<span class='" + className + "'>").html(messageText).hide('pulsate', {}, 500, function() { $(this).remove(); })
    $('#mes').css(className);
    $('#mes').html("<span id='tempMes' class='" + className + "'>" + messageText + "</span>").hide('pulsate', {}, 500, function() { $('#tempMes').remove(); })
}

$.fn.googleMap = function(address, options) {
    var defaults = {
        lat: 44.081996,
        long: -123.0286928,
        zoom: 14,
        mapTypeId: google.maps.MapTypeId.ROADMAP
    };

    options = $.extend(defaults, options || {});

    var center = new google.maps.LatLng(options.lat, options.long);
    var map = new google.maps.Map(this.get(0), $.extend(options, { center: center }));

    var geocoder = new google.maps.Geocoder();
    geocoder.geocode({ address: address }, function(results, status) {
        if (status == google.maps.GeocoderStatus.OK && results.length) {
            if (status != google.maps.GeocoderStatus.ZERO_RESULTS) {
                map.setCenter(results[0].geometry.location);
                var marker = new google.maps.Marker({
                    position: results[0].geometry.location,
                    map: map
                });
            }
        }
    });
};
