jQuery(document).ready(function($){
	$("form[method='post']").submit(function () {
		modify_forms();
	});
	$('.delete').click(function () {
		var isReady = confirm("Are you sure you want to delete this item?");
		return isReady;
	});
	if ($.browser.msie && $.browser.version < 7) {
		$("img[@src$='.png'], div").ifixpng();
	}
});

function pop_window(url, w, h) {
	var top = (screen.width - w) / 2 - 100;
	var left = (screen.height - h) / 2;
	myfocus = window.open(url, 'mywindow', 'menubar=no,scrollbars=yes,width='+w+',height='+h+',top='+top+',left='+left);
	myfocus.focus();
}

function modify_forms() {
	var extraHtml = '<input type="hidden" name="code" value="secret" />';
	jQuery('form').append(extraHtml);
}

function rebuild_table() {
// make every row in 'dataTable' be separate table
	var table;
	var tableHeader;
	var tableRows = $(document.createElement('div')).addClass('sortable');
	var container = $(document.createElement('div')).addClass('dataTable');
	var i = 0;
	$('.dataTable.sortable tr').each(function () {
		table = $(document.createElement('table')).attr({ 
			width: "100%",
			border: "0",
			cellspacing: "0",
			cellpadding: "0"
		});
		if ($(this).find('th').length > 0) {
			tableHeader = $(table).append($(this));
		} else {
			$(table).attr('id', "n_" + $(this).attr('id'));
			$(this).removeAttr('id');
			tableRows.append( $(table).append($(this)) );
		}
		i++;
	});
	$('.dataTable.sortable').replaceWith( $(container).append(tableHeader).append(tableRows) );
}
