window.dv_navigate = function(direction, instance)
{
	dataview_action('navigate', instance, direction, function(){ 
		dv_move_to_top();
	});
}

window.dv_goto = function(goto, instance)
{
	dataview_action('goto', instance, goto, function(){ 
		dv_move_to_top();
	});
}

window.dv_move_to_top = function()
{
	if(dvGoToPageTop){
		window.scrollTo(null,0);
	} else if(dvGoToTop){
		location.href = "#"+instance+"_top"; 
	}
}

window.dv_search = function(searchField, instance)
{
	dataview_action('search', instance, searchField.value);
}

window.dataview_action = function(action, instance, variable, onComplete)
{
	var container = $(instance);
	
	var parameters = {
		instance:	instance,
		action:		action,
		variable:	variable
	}
	
	if(typeof jQuery != 'undefined'){
		var succes_actions = function(html)
		{
			jQuery("#"+instance).html(html);
			if(onComplete != undefined) onComplete();
			try{ dvReset(); } catch(e){}
		}
		
		jQuery.ajax({
			url		: dvAjaxUrl,
			type	: "post",
			data	: parameters,
			success	: succes_actions
		});
	} else {
		var succes_actions = function(transport)
		{
			var responseText = transport.responseText;
			container.innerHTML = responseText;
			
			if(onComplete != undefined) onComplete();
			
			try{ dvReset(); } catch(e){}
		}
		
		new Ajax.Request(dvAjaxUrl,{
			method:			'post',
			parameters:		parameters,
			onSuccess:		succes_actions
		});
	}
}

window.dv_search_focus = function(searchField)
{
	if(searchField.value == searchStr)
	{
		searchField.value = "";
	}
}