$(document).ready(function(){	
});


/**
 * Load pop up for page profil
 * 
 * @param module
 * @param action
 * @param params
 * @param link
 * @param holder_id
 * @param width
 * @param height
 * @param title
 * @return
 */



function showPopupPageProfil(module, action, params, holder_id, width, height) {	
	width = (width == null) ? 370 : width;
	height = (height == null) ? 320 : height;

	holder_id = (holder_id == null) ? 'popup-holder' : holder_id;
	
	$('#' + holder_id).remove();
	var a = $("<div></div>").attr('id', holder_id).css('text-align', 'left');
	$('body').append(a);
	
	if(params != null){
		params = '&'+params;
	}
	else
		params = '';
	//$('#' + holder_id).load('index.php?module='+module+'&action='+action+params);
	
	$.ajax({
		  url: 'index.php?module='+module+'&action='+action+params,
		  success: function(data) {
			$('#' + holder_id).html(data);
			$('div.ui-dialog').css('top','50px');
		  }
	});
	
	
	
	$('#' + holder_id).dialog( {
		modal : true,
		zIndex : 10,
		position : [ 'center', 'top' ],
		width : width,
		draggable: false,
		resizable: false,
		resize: "auto",
		autoResize:true
	});
	
	$('.ui-widget-overlay').live("click", function() {
        $('#' + holder_id).dialog("close");
    });   
	
	$(".ui-dialog-titlebar-close").hide();
	$(".ui-dialog-titlebar").hide();
	//$('#' + holder_id).siblings('div.ui-dialog-titlebar').removeClass(
			//'ui-widget-header');
	//$('#' + holder_id).siblings('div.ui-dialog-titlebar').addClass(
		//	'ui-widget-dialog-header');
	return true;
}







//Define the overlay, derived from google.maps.OverlayView
function Label(opt_options) {
 // Initialization
 this.setValues(opt_options);

 // Label specific
 var span = this.span_ = document.createElement('span');
 span.style.cssText = 'color: #000; position: relative; left: 180%; top: -60px; ' +
                      'white-space: nowrap; border: 0px; z-index:999;' +
                      'padding: 2px; color:#ffffff';

 var div = this.div_ = document.createElement('div');
 div.appendChild(span);
 div.style.cssText = 'position: absolute; display: none; z-index: 9999; test';

};
Label.prototype = new google.maps.OverlayView;

// Implement onAdd
Label.prototype.onAdd = function() {
 var pane = this.getPanes().overlayLayer;
 pane.appendChild(this.div_);
 pane.style.zIndex = 800;

 // Ensures the label is redrawn if the text or position is changed.
 var me = this;
 this.listeners_ = [
   google.maps.event.addListener(this, 'position_changed',
       function() { me.draw(); }),
   google.maps.event.addListener(this, 'text_changed',
       function() { me.draw(); }),
   google.maps.event.addListener(this, 'zindex_changed',
	   function() { me.draw(); })
 ];
};

// Implement onRemove
Label.prototype.onRemove = function() {
 this.div_.parentNode.removeChild(this.div_);

 // Label is removed from the map, stop updating its position/text.
 for (var i = 0, I = this.listeners_.length; i < I; ++i) {
   google.maps.event.removeListener(this.listeners_[i]);
 }
};

// Implement draw
Label.prototype.draw = function() {
 var projection = this.getProjection();
 var position = projection.fromLatLngToDivPixel(this.get('position'));

 var div = this.div_;
 div.style.left = position.x + 'px';
 div.style.top = position.y + 'px';
 div.style.display = 'block';
 div.style.zIndex = 700;

 this.span_.innerHTML = this.get('text').toString();
};
