/*--------------------------------------------------------------------------*/
/* Common '$' extensions                                                    */
/*--------------------------------------------------------------------------*/
function $F(element) {
	var value = $(element).get('value');
	if (typeof(value) == 'string') {value = value.trim();}
	return value;
}

function $RF(name) {
	var radios = $$('input[name='+name+']');
	for (var i=0; i < radios.length; i++) {
		if (radios[i].checked) {
			return radios[i].getProperty('value');
		}
	}	
}

function $show(element) {
	return $(element).style.display = '';
}

function $hide(element) {
	return $(element).style.display = 'none';
}

function $toggle(element) {
    element = $(element);
	if (element.style.display == 'none') {
		return $show(element);
	} else {
		return $hide(element);
	}		
}

/*--------------------------------------------------------------------------*/
/* Hide/Show indicator functions
/*--------------------------------------------------------------------------*/
function showLoadingIndicator() {
	var top = document.body.scrollTop ;
//	$('loading_bar').style.top = top + 300 + "px";
//	$show('loading_bar');
}

function hideLoadingIndicator() {
//	$hide('loading_bar');
}

/*----------------------------------------------------------------*/
/* Send Ajax Request with the Form data                           */
/*----------------------------------------------------------------*/
function SendRequestByAjax(process, params, callback_func) {
   	showLoadingIndicator();
	var aj = new Request.JSON({
		url: 'process.php?process='+process, 
		method: 'post',
		data: params,
		onSuccess: function(o){
			callback_func(o);
		 	hideLoadingIndicator();
		},
		onFailure: function(o) {
			alert('Request error'); //  o.status + o.statusText  
   			hideLoadingIndicator();
		} 
	}).send();
}


