function __postBack(sender, action, params) {
	p = '';
	s = '';
	for(var i = 0; i < params.length; i++) {
		p += s + params[i];
		s = "','";
	}

	var __state = $('#document_form').find('input[name="__state"]').val();
	__state += '|'+sender+'|'+action+"|'"+p+"'";
	$('#document_form').find('input[name="__state"]').val(__state);
	
	$('#document_form').submit();
}

(function($) {
	$.fn.screenCenter = function() {
		var left = (($(window).width() / 2) + $(document).scrollLeft()) - ($(this).width() / 2);
		var top = (($(window).height() / 2) + $(document).scrollTop()) - ($(this).height() / 2);
		$(this).css({ position: 'absolute', left: left, top: top });
		return this;
	};
})(jQuery);

function getCursorPosition(e) {
	e = e || window.event;
	var cursor = {x:0, y:0};
	if (e.pageX || e.pageY) {
		cursor.x = e.pageX;
	    cursor.y = e.pageY;
    } else {
		cursor.x = e.clientX +
			(document.documentElement.scrollLeft ||
			document.body.scrollLeft) -
			document.documentElement.clientLeft;
		cursor.y = e.clientY +
			(document.documentElement.scrollTop ||
			document.body.scrollTop) -
			document.documentElement.clientTop;
	};
	return cursor;
};

/**
 * Przekierowuje przeglądarkę na podany adres.
 * 
 * @param url Adres url
 */
function redirect(url) {
	document.location.href = url;
};

/**
 * Klasa generatora tabelek htmlowych.
 */
function TableGenerator() {
	// utworzenie obiektu tabelki
	this.table = document.createElement('table');
	this.table_body = document.createElement('tbody');
	this.table.appendChild(this.table_body);
	
	this.current_row = null;
	
	/**
	 * Dodaje nowy wiersz do tabeli.
	 */
	this.addRow = function() {
		var row = document.createElement('tr');
		this.table_body.appendChild(row);
		this.current_row = row;
	};
	
	/**
	 * Dodaje komórkę tabeli do aktualnego wiersza.
	 * 
	 * @param content Zawartość komórki (obiekt lub tekst)
	 */
	this.addCell = function(content) {
		var cell = document.createElement('td');
		$(cell).append(content);
		this.current_row.appendChild(cell);
	};
	
	/**
	 * Zwraca wygenerowany obiekt tabeli.
	 */
	this.getTable = function() {
		return this.table;
	};
};

var dialog = $(document.createElement('div'));

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

