function ocijeni_controller( p_content_id, p_content_type, p_div_ocijeni_id, p_template )
{

    this._ocijeni_url = APP_REWRITE_BASE + 'index.php?cmd=ajax_ocijeni&action=ocijeni';
    this._reload_url = APP_REWRITE_BASE + 'index.php?cmd=ajax_ocijeni&action=show_template';
	
	this.init = function( p_content_id, p_content_type, p_div_ocijeni_id, p_template )
	{
		this._content_id = p_content_id;
		this._content_type = p_content_type;
		
		if( !p_div_ocijeni_id )
		{ p_div_ocijeni_id = 'div_ocijeni';	}
		
		this.$div_ocijeni = $( '#' + p_div_ocijeni_id );
		
		if( p_template )
		{ this._template = p_template; }
		else
		{ this._template = 'default'; }
	}
		
    this.ocijeni = function( p_ocjena )
    {
        var _url = this._ocijeni_url + '&content_id=' + this._content_id + '&content_type=' + this._content_type + '&ocjena=' + p_ocjena + '&_template=' + this._template;

        this.$div_ocijeni.load( _url );
		
    }
	
    //reinit function - called by gallery controller in after_show()
	this.re_init = function( p_content_id, p_content_type, p_div_ocijeni_id, p_template )
	{
		//alert( p_content_id );
		if( p_content_id )
		{
			this._content_id = p_content_id;
			if( p_content_type )
				{ this._content_type = p_content_type; }
			if( p_div_ocijeni_id )
				{ this.$div_ocijeni = $( '#' + p_div_ocijeni_id ); }
			if( p_template )
				{ this._template = p_template; }
			
		}
		this.reload_ocijeni_div();
	}
	
	this.reload_ocijeni_div = function()
	{
		var _url = this._reload_url + '&content_id=' + this._content_id + '&content_type=' + this._content_type + '&_template=' + this._template;
		this.$div_ocijeni.load( _url );
	}
	
	this.empty_ocijeni_div = function()
	{
		this.$div_ocijeni.empty();
	}

	
	//init
	this.init( p_content_id, p_content_type, p_div_ocijeni_id, p_template );

}

//hooks up re-initialization of a ocijeni controller to a gallery controller
function gallery_hook( p_gallery_controller_name, p_ocijeni_controller_name )
{
	var obj_gallery_controller = eval( p_gallery_controller_name );
	
	var eval_text = '';
	//set up the JS code to execute and set the function
	eval_text  = 'obj_gallery_controller.after_show = function( p_arr_entitet )';
	eval_text += '{';
	eval_text += 'if( ( typeof( p_arr_entitet ) != "object" ) || ( p_arr_entitet[0] != 1 ) ) ';
	eval_text += '{ return; }';
	//re-init, entitet_id, entitet_tip( image is 5 ), holder for the template, template name 
	eval_text += p_ocijeni_controller_name + '.re_init( p_arr_entitet[1], 5, "div_ocijeni_sliku" );';
	eval_text += '}';
	
	//execute the hook
	eval( eval_text );
	
	//define before_show
	eval_text = 'obj_gallery_controller.before_show = function(){ ' + p_ocijeni_controller_name + '.empty_ocijeni_div() }';
	eval( eval_text );
	
}
