Problem Scripting (JavaScript)

Hi, first of all, im following a tutorial and have this error:

Assets/ScriptsInventario/InventoryGrid.js(37,31): BCE0005: Unknown identifier: ‘bag’.

i searched in that line and i watched that bag is declared later :S
i don’t understand the problem (i know is a stupid problem but im trying to understand the code and the error makes nosense for me
thanks
here is the code

var bagName : String = "Pon un nombre a la bolsa";
var bagBtnName : String = "Nombre del boton de la bolsa";
var posBagBtn : Vector2 = Vector2(50,50); //posicion del boton de la bolsa

var slotSize : float = 40; // Este es el tamaño que va a tener la bolsa
var spacingBetweenSlots : float = 15;
var defaultTextureSlot : Texture;
var bagNumber : int; // dice que bolsa está enlazada a esta transformación.

private var numSlot = 16;
private var showBag : boolean = false; //muestra o no muestra esta bolsa.
private var bagPos : Vector2 = Vector2(200,200);

private var tmpTexture : Texture;

private var ctrl : PositionController;



function Start ()
{
	ctrl = transform.parent.GetComponent(PositionController); //el parent es para el inventory, que es el padre de las bolsas
}




function OnGUI ()
{
	if(GUI.Button(Rect(Screen.width - posBagBtn.x, Screen.height - posBagBtn.y, slotSize,slotSize), bagBtnName)) //Pinta un boton, rectángulo.
	{
		ToggleBag();
	}
	
	if(showBag)
	{
		Bag(bagPos.x, bag.Pos.y, 185,200);
	}
}


function ToggleBag ()
{
	if(showBag) 
	{
		HideBag();
	}
	else 
	{
		ShowBag();
	}
}

function HideBag()
{
	showBag = false; 
}

function ShowBag()
{
	showBag = true; 
}



function Bag(posx : float, posY : float, sX : float, sY : float){
GUI.BeginGroup(Rect(Screen.width - posX, Screen.height - posY, sX, sY));
	GUI.Box(Rect(0,0, sX, sY), bagName);
	GUI.EndGroup();
}

Damn, i have founded that problem…
in the line
Bag(bagPos.x, bag.Pos.y, 185,200);

There is a point more…
There are also other error here:
function Bag(posx : float, posY : float, sX : float, sY : float){
The error is, that it is posX , with capital X