var z_index = 5;
var windows = Array();


JQ(document).ready(function(){
	init();
});

function init(){
	JQ('.icon_info').unbind();
	JQ('.window_close').unbind();
	
	JQ('.icon_info').bind('click', 
		function(event){
			block_ui('block');
			var win_id = "";
			var window = "";
			var open_window = true;
			/* GO trough all opened windows and close them */
			while(1){
				win_id = windows.pop();
				if(win_id == undefined){
					break;
				}
				/* If we closed the window to which the buttom belongs, we are not going top open it again */
				if(win_id == this.id + '_window'){
					open_window = false;
				}
				window = JQ('#' + win_id);
				block_ui('block');
				close_window(window);
			}

			if(open_window){
				var offset = JQ(this).offset();
				var win_id = new_window(this.id + '_window', offset.top + 3, offset.left + 13);
				var window = JQ('#' + win_id);
				var content = JQ('#' + win_id +' .content');
				JQ.ajax({
	  				type: "POST",
  					url: "ajaxItemList",
  					data: "id=" + this.id + "&action=get_text",
  					success: 
  					function(data){
    					content.html(data);
    					init();
  					}
				});
			}
			else{
				block_ui('unblock');
			}	
			init();
			return false;
		}
	);
	JQ('.window_close').bind('click',
		function(event) {
			block_ui('block');
			var window = JQ(this).parents().filter('.window');
			close_window(window);
			windows.pop();
			init();
			return false;	
		}
	);
}



					
