RWS.Holds =
{
	Request : function(rsn)
	{
		if (!RWS.Patron.current.loggedIn)
		{
			COMP.LoadLibrariesSerial(['rws_login'], function(){COMP.Login.HandleShowLogin("RWS.Holds.Request(" + rsn + ")")});
			return;
		}
	
		COMP.SendAjaxCommand('rws_request_hold',{rsn:rsn},this.HandleResult, this);
	}

	,HandleResult : function(o)
	{
	if (o.error)
            {
                var dialog = new RWS.Dialog({title: 'Error', message:o.error});
				dialog.show();
                return;
            }
			
    //kokoni play sound on success
    if (o.success && COMP.Config.GetDefault('enableSounds')){//success always true
	var soundName = COMP.Config.GetDefault('holdPlacedByPatronSound');
    COMP.PlaySound(soundName);//this plays no matter what
	}
    
		alert(o.message)
	}
};

// Only show one reservation window at a time, if curRSN is 0. When the reservation window closes is will set this to 0.
RWS.Circ =
{
	curRSN : 0
	,Show : function(rsn)
	{
		if (!RWS.Patron.current.loggedIn)
		{
			COMP.Login.HandleShowLogin("RWS.Circ.Show(" + rsn + ")");
			return;
		} 

		if (RWS.Circ.curRSN)
			return;

		RWS.Circ.curRSN = rsn;
		var dialog = new COMP.ResWindow({rsn:rsn,patBC:RWS.Patron.current.data.barcode,admin:false});
		dialog.show();
	}
	,clearRSN:function()
	{
		RWS.Circ.curRSN = 0;
	}
};
if (window.COMP) COMP.Broadcast('scriptLoaded_rws_circ');