// Ask for user confirmation and redirect
function confirmAndRedirect(msg, url, ref){
	if((ref != null) && (ref != ''))
		ref = '&ref=' + encodeURIComponent(ref);
	else ref = '';
	if(confirm(msg)) window.location = url + ref;
}

// Select all checkboxes in specified column in given table
function selectAll(table_id, col_id, checked, customFunc, forced){
	var table = document.getElementById(table_id);
	if(!table) return;

	var count = table.rows.length;

	for(var i=1; i<count; ++i){
		var selectBox = table.rows[i].cells[col_id].childNodes[0];
		if(selectBox && (selectBox.type == 'checkbox') && (!selectBox.disabled || forced)){
			selectBox.checked = checked;
			if(customFunc != '') eval(customFunc);
		}
	}
}

/********** Page Number input field script **********/
function pageNumberInputFocus(obj){
	var id = obj.id;
	if(id.indexOf('page_') != 0) return;

	obj.value = Number(id.substr(5));
	obj.select();
}

function pageNumberInputBlur(obj){
	obj.value = obj.defaultValue;
}
