extend(Instructions, createjs.Container);

function Instructions()
{	
	this.initialize();
//--------------------------------//
	var podl = new createjs.Container()
	var game, pause, game_par
	var _active
	var numPages = 2
	var _coor = [
					[24, 141], [23, 143]
				]
	// Заголовок
	var title = new createjs.Sprite(jsons["JSON2"])
	title.gotoAndStop("text_red_instructions")
	// dragAndDrop(title)
	setCoor(title, 220, 11)
	// Содержимое страниц
	var tut = new Array() 
	for (var i = 0; i < numPages; i++) {
		// tut[i] = new createjs.Sprite(jsons["JSON2"])
		// tut[i].gotoAndStop("reward_" + (i+1))
		tut[i] = new createjs.Bitmap(images["instrimgs_" + (i+1)])
		setCoor(tut[i], _coor[i][0], _coor[i][1])
		podl.addChild(tut[i])
		// dragAndDrop(tut[i])
	};

	var next = new Button({pod: "btn_loop", i: "btn_arrow", iconX:85, iconY:21, iconScaleX: -1}) // new Arrow("right")				// Стрелка вперед
	setCoor(next, 521, 603)
	var pre = new Button({pod: "btn_loop", i: "btn_arrow", iconX:19, iconY:21})// new Arrow("left")				// Стрелка назад
	setCoor(pre, 18, 603)

	var frame = new FloatFrame()
	frame.addToTopPlatform(title)
	frame.addToBottomPlatform(next)
	frame.addToBottomPlatform(pre)
	// dragAndDrop(next)
	// dragAndDrop(pre)

	// this.addChild(next)
	// this.addChild(pre)
	this.addChild(podl)
	this.addChild(frame)

	function setActive(v){
		// console.log(v)
		podl.removeAllChildren()

		if(v >=0 && v<numPages)
			active = v

		podl.addChild(tut[active])

		pre.removeAllEventListeners()
		if(active-1 <0){
			if(game)
				pre.addEventListener("click", function(){v_choiseLocation("menu");})
			else if(pause)
				pre.addEventListener("click", function(){v_choiseLocation("pause");})
			else
				pre.addEventListener("click", function(){v_choiseLocation("setting");})
		}else{
			pre.addEventListener("click", function(){setActive(active-1)})
		}

		next.removeAllEventListeners()
		if(active+1 >=numPages){
			if(game){
				next.alpha = 1
				next.addEventListener("click", function(){v_choiseLocation("game", game_par)})
			}else	
				next.alpha = .5
		}else{
			next.alpha = 1
			next.addEventListener("click", function(){setActive(active+1)})
		}

	}

	this.update = function(p){
		if(p && p.game)
			game = p
		else
			game = false

		if(p && p.pause)
			pause = p.pause
		else
			pause = false

		if(p && p.size_field)
			game_par = { size_field: p.size_field }
		setActive(0)
	}
}