function inesGetRootPath() {
	currentPath = '.';
	
	var currentUrl = dirname(document.URL);
	currentUrlArray = parse_url(currentUrl);

	if (array_key_exists('path', currentUrlArray)) {
		var currentPath = currentUrlArray['host'];
		currentPath = trim(currentPath, '/');
		currentPathArray = explode('/', currentPath);
		for (var i in currentPathArray) currentPathArray[i] = '..';
		currentPath = implode('/', currentPathArray);
	}

	return currentPath;
}


function inesConfirm() {
	return confirm('sei sicuro di voler continuare?');
}

function inesToDo() {
	return alert("funzionalitą da implementare...")
}

function inesPager(tableId, table, tableArrayJsoned, whereStringOrArray, orderString, optionsArrayJsoned, noResultWarning, page, pagerItems, colspanArrayJsoned) {
	/*
	console.log(tableId);
	console.log(table);
	console.log(tableArrayJsoned);
	console.log(whereStringOrArray);
	console.log(orderString);
	console.log(optionsArrayJsoned);
	console.log(noResultWarning);
	console.log(page);
	console.log(pagerItems);
	*/

	if (!tableId) {
		alert('debug: tableId is not set!');
		return false;
	}

	tableArrayJsoned = rawurlencode(tableArrayJsoned);
	whereStringOrArray = rawurlencode(whereStringOrArray);
	optionsArrayJsoned = rawurlencode(optionsArrayJsoned);

	var newPagerStart = page * pagerItems;

	$.ajax({
		type:'POST',
		url:inesGetRootPath()+'/backoffice/ajax/ajax_table_pager.php',
		data:'table_id='+tableId+'&table='+table+'&table_array_jsoned='+tableArrayJsoned+'&where_string_or_array='+whereStringOrArray+'&order_string='+orderString+'&options_array_jsoned='+optionsArrayJsoned+'&no_result_warning='+noResultWarning+'&pager_start='+newPagerStart+'&pager_items='+pagerItems+'&colspan_array='+colspanArrayJsoned,
		success:function(response){
			$('.pager').remove();
			$('#'+tableId).replaceWith(response);
		}
	});
}


function checkAll(currentClass) {
	$('.'+currentClass).attr('checked', true);
}

function checkNone(currentClass) {
	$('.'+currentClass).attr('checked', false);
}


function validateRadio(obj) {
	if (obj.type == 'hidden' && obj.value == 'F') return true;

	var result = false;
	for (var i=0; i<obj.length; i++) {
		if (obj[i].checked == true) result = true;
	}
	return result;
} 

function getRadioObjectValue(obj) {
	if (obj.type == 'hidden' && obj.value == 'F') return obj.value;

	var result = false;
	for (var i=0; i<obj.length; i++) {
		if (obj[i].checked == true) result = obj[i].value;
	}
	return result;
}