//Ajax
var in_progress = false;
function refresh_page( o ) {
	var method = o.method ? o.method : 'post';
	
	var pars = '';
	if(o.pars)   pars += o.pars;
	if(o.data)   pars += Object.toQueryString(o.data);

	if(o.url)    o.url = base_url + '/ajax' + o.url;

	var method = pars == '' ? 'post' : 'get';

	if(o.form)   pars = $(o.form);

	show_loader();
	
	o.evalScripts = (o.evalScripts ? o.evalScripts : false);
	
	if(o.div) {
		if( o.onComplete ) {
			var complete = function( data ) { hide_loader(); o.onComplete(data); }
			var ajax_object = new Ajax(o.url, {update: o.div, method: method, postBody: pars, onComplete: complete, evalScripts: o.evalScripts }).request();
		} else {                                                                              
			var ajax_object = new Ajax(o.url, {update: o.div, method: method, postBody: pars, onComplete: hide_loader, evalScripts: o.evalScripts }).request();
		}
	} else {
		if( o.onComplete ) {
			var complete = function( data ) { hide_loader(); o.onComplete(data); }
			var ajax_object = new Ajax(o.url, {method: method, postBody: pars, onComplete: complete}).request();
		} else {
			var ajax_object = new Ajax(o.url, {method: method, postBody: pars, onComplete: hide_loader, evalScripts: o.evalScripts }).request();
		}
	}
	
	return ajax_object;
}

function show_loader() { 
	$(document.body).addClass('inprogress');
}
function hide_loader() { 
	$(document.body).removeClass('inprogress');
}

function reload_page() {
	document.location.reload();
}

function change_tab(tab) {
	$('tab_'+curent_tab).removeClass('on');
	$('tab_'+tab).addClass('on');
	$(curent_tab).hide();
	$(tab).show()
	curent_tab = tab;
}

function hide_objects() {
	//$$('embed, object, select').hide();
	// if ($chk($$('embed'))) { $$('embed').hide(); }
	
	// if ($chk($$('object'))) { $$('object').hide(); }
	
	// if ($chk($$('select'))) { $$('select').hide(); }

	
	if ($('popup') != null)
	{
		$('popup').show();
	}
}

function hide_popup() {
	// $$('embed, object, select').show();
	if ($('popup') != null)
	{
		$('popup').hide();	
	}
}
