function pretplata_controller( p_kategorija_id, p_podkategorija_id, p_is_logged_in )
{
	
    this._get_status_url = APP_REWRITE_BASE + 'index.php?cmd=ajax_kategorija_pretplata';
    this._pretplata_quick_url = APP_REWRITE_BASE + 'index.php?cmd=ajax_kategorija_pretplata&action=pretplati_quick';
    this._pretplata_url = APP_REWRITE_BASE + 'index.php?cmd=ajax_kategorija_pretplata&action=pretplati';
    this._otkazi_url = APP_REWRITE_BASE + 'index.php?cmd=ajax_kategorija_pretplata&action=otkazi';
    
    this._quick_login_url = APP_REWRITE_BASE + 'index.php?cmd=do_login&action=ajax_login';
    this._quick_registration_url = APP_REWRITE_BASE + 'index.php?cmd=do_register&action=ajax_save';
    
    this._quck_login_sucess = false;
    
    this._float_jq_id = '#float_pretplata_kategorija';
    this._content_jq_id = '#float_pretplata_kategorija_inner';
    this._login_float_jq_id = '#float_login_registracija';
	
    this._is_logged_in = ( p_is_logged_in ) ? true : false;
    
    
    if(! p_podkategorija_id )
    {
    	var p_podkategorija_id = 0;
    }

    this._kategorija_id = p_kategorija_id;
	this._podkategorija_id = parseInt(p_podkategorija_id);
   
        
    this.get_status = function()
    {
		if ( this._is_logged_in )
		{
			var _url = this._get_status_url + '&kategorija_id=' + this._kategorija_id + '&podkategorija_id=' + this._podkategorija_id;
			$( this._content_jq_id ).load( _url );
			$( this._float_jq_id ).show();
		}
		else
		{
			this.show_quick_login();
		}
        
    }
    
    /* open logreg float or subscribe */
    this.pretplati_quick = function()
    {
		if ( this._is_logged_in )
		{
			var _url = this._pretplata_quick_url + '&kategorija_id=' + this._kategorija_id + '&podkategorija_id=' + this._podkategorija_id;
			
			$( this._content_jq_id ).load( _url );
			
			//$( this.float_pretplata_kategorija ).show();
			$( this._float_jq_id ).show();
		}
		else
		{
			var cid = this._kategorija_id;
			if( this._podkategorija_id > 0 ) { cid = this._podkategorija_id; }
			
 			this.show_quick_login( cid );
		}
        
    }

    this.pretplati = function()
    {
		if ( this._is_logged_in )
		{
			var _url = this._pretplata_url + '&kategorija_id=' + this._kategorija_id + '&podkategorija_id=' + this._podkategorija_id;
			
			$( this._content_jq_id ).load( _url );
			//$( this.float_pretplata_kategorija ).show();
			$( this._float_jq_id ).show();
		}
		else
		{
			var cid = this._kategorija_id;
			if( this._podkategorija_id > 0 ) { cid = this._podkategorija_id; }
			
 			this.show_quick_login( cid );

		}
	}
	
	this.otkazi = function()
    {
        
        var _url = this._otkazi_url + '&kategorija_id=' + this._kategorija_id + '&podkategorija_id=' + this._podkategorija_id;
        
        $( this._content_jq_id ).load( _url );
        $( this._float_jq_id ).show;
            
	},
	this.close_float = function()
	{
		$( this._float_jq_id ).hide();
	},
	
	/* quick login & registration */
	this.show_quick_login = function( p_cid )
	{
		logreg_open( 3, p_cid );
	}
	
	/*
	,
	this.hide_quick_login = function()
	{
		$( this._login_float_jq_id ).hide();
		//reload page if just logged in
		if( this._quck_login_sucess )
		{
			//location.href = location.href;
			location.reload(true);
		}
	},
	*/
	
	/*
	this.clean_float = function()
	{
		this.hide_all_responses();
		$( '#float_login_registracija_inner .float_pretplata_novi input' ).val('');
		$( '#input_quick_password' ).val('');
	}
	*/
	
	/*
	this.hide_all_responses = function()
	{
		$("#login_fail").hide();
		$("#login_success").hide();
		$("#register_reply_0").hide();
		$("#register_reply_1").hide();
		$("#register_reply_2").hide();
		
	}
	*/
	/*
	this.quick_login = function()
	{
		//gather data
		var user =  $('#input_quick_username').val() ;
		var pass =  $('#input_quick_password').val() ;
		var kat_id = this._kategorija_id;
		if ( this._podkategorija_id )
		{
			kat_id = this._podkategorija_id;
		}
		
		//send data, process reply
		$.post( this._quick_login_url, { email: user , lozinka: pass, pretplati_kategoriju: kat_id }, 
			function ( response_data )
			{
				obj_pretplata_kategorija.quick_login_reply ( response_data );
			}
		);
	},
	*/
	/*
	this.quick_login_reply = function( p_response_code )
	{
		if( p_response_code == "1" )
		{
			this.hide_all_responses();
			$( '#login_success').show();
			
			this._quck_login_sucess = true;
		}
		else
		{
			this.hide_all_responses();
			$( '#login_fail').show();
		}
	},
	*/
	/*
	this.quick_register = function()
	{
		//gather data
		var user =  $('#input_quick_registration_username').val() ;
		var pass =  $('#input_quick_registration_password').val() ;
		var pass_con =  $('#input_quick_registration_password_2').val() ;
		var kat_id = this._kategorija_id;
		if ( this._podkategorija_id )
		{
			kat_id = this._podkategorija_id;
		}
		
		//send data, process reply
		$.post( this._quick_registration_url, { ed_email: user , ed_lozinka: pass, ed_lozinka_confirm: pass_con, pretplati_kategoriju: kat_id }, 
			function ( response_data )
			{
				obj_pretplata_kategorija.quick_register_reply ( eval(response_data) );
			}
		);
	},
	*/
	/*
	this.quick_register_reply = function( p_response_array )
	{
		if( p_response_array.length != 2 )
		{
			this.quick_register_show_hide(0);
			return false;
		}
		
		if( p_response_array[0] == 1 )
		{
			this.quick_register_show_hide(2);
			return true;
		}
		else
		{
			$( '#register_reply_1' ).html('');
			for( i=0; i<p_response_array[1].length; i++ )
			{
				$( '#register_reply_1' ).append( p_response_array[1][i] + ".<br />" );
				
			}
			
			this.quick_register_show_hide(1);
			$('#login_fail').hide();
			$('#login_success').hide();
			return true;
			
		}
		
	},
	*/
	/*
	this.quick_register_show_hide = function( p_num )
	{
		for (i=0; i<3; i++)
		{
			if( p_num == i )
			{
				$( '#register_reply_' + i).show();
			}
			else
			{
				$( '#register_reply_' + i).hide();
			}
		}
	};
	*/
}

function uspjesna_pretplata()
{
	$("#infomat_float").show();
	setTimeout("$('#infomat_float').fadeOut(1000);", 1000);
}
