(function (lib, img, cjs, ss, an) {

var p; // shortcut to reference prototypes
lib.webFontTxtInst = {}; 
var loadedTypekitCount = 0;
var loadedGoogleCount = 0;
var gFontsUpdateCacheList = [];
var tFontsUpdateCacheList = [];
lib.ssMetadata = [];



lib.updateListCache = function (cacheList) {		
	for(var i = 0; i < cacheList.length; i++) {		
		if(cacheList[i].cacheCanvas)		
			cacheList[i].updateCache();		
	}		
};		

lib.addElementsToCache = function (textInst, cacheList) {		
	var cur = textInst;		
	while(cur != null && cur != exportRoot) {		
		if(cacheList.indexOf(cur) != -1)		
			break;		
		cur = cur.parent;		
	}		
	if(cur != exportRoot) {		
		var cur2 = textInst;		
		var index = cacheList.indexOf(cur);		
		while(cur2 != null && cur2 != cur) {		
			cacheList.splice(index, 0, cur2);		
			cur2 = cur2.parent;		
			index++;		
		}		
	}		
	else {		
		cur = textInst;		
		while(cur != null && cur != exportRoot) {		
			cacheList.push(cur);		
			cur = cur.parent;		
		}		
	}		
};		

lib.gfontAvailable = function(family, totalGoogleCount) {		
	lib.properties.webfonts[family] = true;		
	var txtInst = lib.webFontTxtInst && lib.webFontTxtInst[family] || [];		
	for(var f = 0; f < txtInst.length; ++f)		
		lib.addElementsToCache(txtInst[f], gFontsUpdateCacheList);		

	loadedGoogleCount++;		
	if(loadedGoogleCount == totalGoogleCount) {		
		lib.updateListCache(gFontsUpdateCacheList);		
	}		
};		

lib.tfontAvailable = function(family, totalTypekitCount) {		
	lib.properties.webfonts[family] = true;		
	var txtInst = lib.webFontTxtInst && lib.webFontTxtInst[family] || [];		
	for(var f = 0; f < txtInst.length; ++f)		
		lib.addElementsToCache(txtInst[f], tFontsUpdateCacheList);		

	loadedTypekitCount++;		
	if(loadedTypekitCount == totalTypekitCount) {		
		lib.updateListCache(tFontsUpdateCacheList);		
	}		
};
// symbols:



(lib.igla = function() {
	this.initialize(img.igla);
}).prototype = p = new cjs.Bitmap();
p.nominalBounds = new cjs.Rectangle(0,0,25,196);


(lib.magnet = function() {
	this.initialize(img.magnet);
}).prototype = p = new cjs.Bitmap();
p.nominalBounds = new cjs.Rectangle(0,0,80,176);


(lib.ozadje = function() {
	this.initialize(img.ozadje);
}).prototype = p = new cjs.Bitmap();
p.nominalBounds = new cjs.Rectangle(0,0,1000,650);


(lib.tuljava_1 = function() {
	this.initialize(img.tuljava_1);
}).prototype = p = new cjs.Bitmap();
p.nominalBounds = new cjs.Rectangle(0,0,295,214);


(lib.tuljava_1_over = function() {
	this.initialize(img.tuljava_1_over);
}).prototype = p = new cjs.Bitmap();
p.nominalBounds = new cjs.Rectangle(0,0,154,143);


(lib.tuljava_2 = function() {
	this.initialize(img.tuljava_2);
}).prototype = p = new cjs.Bitmap();
p.nominalBounds = new cjs.Rectangle(0,0,295,249);


(lib.tuljava_2_over = function() {
	this.initialize(img.tuljava_2_over);
}).prototype = p = new cjs.Bitmap();
p.nominalBounds = new cjs.Rectangle(0,0,154,218);


(lib.tuljavaSwap = function() {
	this.initialize(img.tuljavaSwap);
}).prototype = p = new cjs.Bitmap();
p.nominalBounds = new cjs.Rectangle(0,0,58,68);// helper functions:

function mc_symbol_clone() {
	var clone = this._cloneProps(new this.constructor(this.mode, this.startPosition, this.loop));
	clone.gotoAndStop(this.currentFrame);
	clone.paused = this.paused;
	clone.framerate = this.framerate;
	return clone;
}

function getMCSymbolPrototype(symbol, nominalBounds, frameBounds) {
	var prototype = cjs.extend(symbol, cjs.MovieClip);
	prototype.clone = mc_symbol_clone;
	prototype.nominalBounds = nominalBounds;
	prototype.frameBounds = frameBounds;
	return prototype;
	}


(lib.uizine_toolbar_papiga = function(mode,startPosition,loop) {
	this.initialize(mode,startPosition,loop,{});

	// Layer 1
	this.shape = new cjs.Shape();
	this.shape.graphics.f("#002E6D").s().p("AyjPFIAA+JMAlHAAAIAAeJg");
	this.shape.setTransform(136.3,118.5);

	this.timeline.addTween(cjs.Tween.get(this.shape).wait(1));

}).prototype = getMCSymbolPrototype(lib.uizine_toolbar_papiga, new cjs.Rectangle(17.5,22,237.6,193), null);


(lib.tuljava_over = function(mode,startPosition,loop) {
	this.initialize(mode,startPosition,loop,{});

	// timeline functions:
	this.frame_0 = function() {
		this.stop ();
	}

	// actions tween:
	this.timeline.addTween(cjs.Tween.get(this).call(this.frame_0).wait(2));

	// Layer 1
	this.instance = new lib.tuljava_1_over();
	this.instance.parent = this;

	this.instance_1 = new lib.tuljava_2_over();
	this.instance_1.parent = this;

	this.timeline.addTween(cjs.Tween.get({}).to({state:[{t:this.instance}]}).to({state:[{t:this.instance_1}]},1).wait(1));

}).prototype = p = new cjs.MovieClip();
p.nominalBounds = new cjs.Rectangle(0,0,154,143);


(lib.tuljava = function(mode,startPosition,loop) {
	this.initialize(mode,startPosition,loop,{});

	// timeline functions:
	this.frame_0 = function() {
		this.stop ();
	}

	// actions tween:
	this.timeline.addTween(cjs.Tween.get(this).call(this.frame_0).wait(2));

	// Layer 1
	this.instance = new lib.tuljava_1();
	this.instance.parent = this;

	this.instance_1 = new lib.tuljava_2();
	this.instance_1.parent = this;

	this.timeline.addTween(cjs.Tween.get({}).to({state:[{t:this.instance}]}).to({state:[{t:this.instance_1}]},1).wait(1));

}).prototype = p = new cjs.MovieClip();
p.nominalBounds = new cjs.Rectangle(0,0,295,214);


(lib.magnet_1 = function(mode,startPosition,loop) {
	this.initialize(mode,startPosition,loop,{});

	// Layer 1
	this.instance = new lib.magnet();
	this.instance.parent = this;

	this.timeline.addTween(cjs.Tween.get(this.instance).wait(1));

}).prototype = getMCSymbolPrototype(lib.magnet_1, new cjs.Rectangle(0,0,80,176), null);


(lib.kazalec = function(mode,startPosition,loop) {
	this.initialize(mode,startPosition,loop,{});

	// Layer 1
	this.instance = new lib.igla();
	this.instance.parent = this;

	this.timeline.addTween(cjs.Tween.get(this.instance).wait(1));

}).prototype = getMCSymbolPrototype(lib.kazalec, new cjs.Rectangle(0,0,25,196), null);


(lib.gumb2 = function(mode,startPosition,loop) {
	this.initialize(mode,startPosition,loop,{});

	// Layer 1
	this.instance = new lib.tuljavaSwap();
	this.instance.parent = this;

	this.timeline.addTween(cjs.Tween.get(this.instance).wait(1));

}).prototype = getMCSymbolPrototype(lib.gumb2, new cjs.Rectangle(0,0,58,68), null);


(lib.uizine_toolbar = function(mode,startPosition,loop) {
	this.initialize(mode,startPosition,loop,{});

	// povratna
	this.instance = new lib.uizine_toolbar_papiga();
	this.instance.parent = this;
	this.instance.setTransform(872.5,542.5,1,1,0,0,0,127.5,107.5);
	this.instance.alpha = 0.191;

	this.timeline.addTween(cjs.Tween.get(this.instance).wait(1));

	// static
	this.shape = new cjs.Shape();
	this.shape.graphics.f("#002D6C").s().p("EhOHAFAIAAp/MCSdAAAIJyAAIAAJ/g");
	this.shape.setTransform(500,618);

	this.shape_1 = new cjs.Shape();
	this.shape_1.graphics.f("#002E6D").s().p("EgE4AtyIAArzIJxAAIAALzgEgE4ggVIAAtcIJxAAIAANcg");
	this.shape_1.setTransform(968.7,293);

	this.timeline.addTween(cjs.Tween.get({}).to({state:[{t:this.shape_1},{t:this.shape}]}).wait(1));

}).prototype = getMCSymbolPrototype(lib.uizine_toolbar, new cjs.Rectangle(0,0,1000.1,650), null);


(lib.animacija = function(mode,startPosition,loop) {
if (loop == null) { loop = false; }	this.initialize(mode,startPosition,loop,{});

	// timeline functions:
	this.frame_0 = function() {
		stage.mouseMoveOutside = true; // dovoli zaznavanje premikov miske izven naloge
		
		var podnaloga = this;
		
		var magnet= podnaloga.magnet;
		var tuljava= podnaloga.tuljava;
		var tuljavaOver = podnaloga.tuljavaOver;
		var gumb = podnaloga.gumb;
		var kazalec = podnaloga.kazalec;
		
		var limit = {min:170, max:410};
		
		var faktorji = [0.5,1];
		
		var coilNo = 0;
		
		var interval = 25;
		
		var faktor = 1;
		
		
		podnaloga.pripraviPodnalogo = function () {
			interaktivnost (true);
			magnet.startY = magnet.y;
			magnet.lastY = magnet.y;
		}
		
		function interaktivnost (bool) {
			if (bool) {
				magnet.addEventListener ("mousedown", startDrag);
				magnet.cursor = "pointer";
				
				gumb.addEventListener ("mousedown", changeCoil);
				gumb.cursor = "pointer";
			} else {
				magnet.removeEventListener ("mousedown", startDrag);
				magnet.cursor = "default";
				
				gumb.removeEventListener ("mousedown", changeCoil);
				gumb.cursor = "default";
			}
		}
		
		function changeCoil (event) {
			if (coilNo == 0) {
				coilNo = 1;
			} else {
				coilNo = 0;
			}
			tuljava.gotoAndStop (coilNo);
			tuljavaOver.gotoAndStop (coilNo);
			faktor = faktorji[coilNo];
			podnaloga.parent.playSound("pickUp", 0);
		}
		
		function pricniSimulacijo (bool) {
			if (bool) {
				createjs.Ticker.addEventListener("tick", tick);
				createjs.Ticker.setInterval(interval);
				console.log ("simulacija aktivna!");
			} else {
				createjs.Ticker.removeEventListener("tick", tick);
				console.log ("simulacija ustavljena!");
			}
			
		}
		
		function tick (event) {
			//var tElapsed = event.delta/1000;
			var dy = magnet.y - magnet.lastY;
			
			var rotacija = (dy*(1+coilNo)*faktor);
			
			if (rotacija>40) {rotacija = 40;}
			if (rotacija<-40) {rotacija = -40;}
			
			TweenLite.to(kazalec, 0.1, {rotation:rotacija, ease:Quad.easeInOut});
			
			magnet.lastY = magnet.y;
			
			console.log ("tick!");
		
		}
		
		function startDrag (event) {
			var objekt = event.currentTarget;
			objekt.addEventListener ("pressmove", dragIt);
			objekt.addEventListener ("pressup", dropIt);
			podnaloga.parent.playSound("snap", 0);
			pricniSimulacijo (true);
		}
		
		function dragIt (event) {
			var objekt = event.currentTarget;
			
			var dy = event.stageY;
			
			if (dy>limit.max) {
				dy = limit.max;
			}
			
			if (dy<limit.min) {
				dy = limit.min;
			}
			
			TweenLite.to(objekt, 0.1, {y:dy, ease:Quad.easeInOut});
		
			update = true;
		}
		
		function dropIt (event) {
			var objekt = event.currentTarget;
			objekt.removeEventListener ("pressmove", dragIt);
			objekt.removeEventListener ("pressup", dropIt);
			pricniSimulacijo (false);
			TweenLite.to(kazalec, 0.3, {rotation:0, ease:Quad.easeOut});
		}
	}

	// actions tween:
	this.timeline.addTween(cjs.Tween.get(this).call(this.frame_0).wait(1));

	// Layer 2
	this.gumb = new lib.gumb2();
	this.gumb.parent = this;
	this.gumb.setTransform(176,305,1,1,0,0,0,29,34);

	this.timeline.addTween(cjs.Tween.get(this.gumb).wait(1));

	// tuljavaOver
	this.tuljavaOver = new lib.tuljava_over();
	this.tuljavaOver.parent = this;
	this.tuljavaOver.setTransform(294,315.5,1,1,0,0,0,77,71.5);

	this.timeline.addTween(cjs.Tween.get(this.tuljavaOver).wait(1));

	// magnet
	this.magnet = new lib.magnet_1();
	this.magnet.parent = this;
	this.magnet.setTransform(295,168.1,1,1,0,0,0,40,96);

	this.timeline.addTween(cjs.Tween.get(this.magnet).wait(1));

	// tuljava
	this.tuljava = new lib.tuljava();
	this.tuljava.parent = this;
	this.tuljava.setTransform(295,325,1,1,0,0,0,109,112);

	this.timeline.addTween(cjs.Tween.get(this.tuljava).wait(1));

	// kazalec
	this.kazalec = new lib.kazalec();
	this.kazalec.parent = this;
	this.kazalec.setTransform(636.2,298.5,1,1,0,0,0,12.2,168.6);

	this.timeline.addTween(cjs.Tween.get(this.kazalec).wait(1));

	// ozadje
	this.instance = new lib.ozadje();
	this.instance.parent = this;

	this.timeline.addTween(cjs.Tween.get(this.instance).wait(1));

}).prototype = getMCSymbolPrototype(lib.animacija, new cjs.Rectangle(0,0,1000,650), null);


// stage content:
(lib.magnet_tok = function(mode,startPosition,loop) {
if (loop == null) { loop = false; }	this.initialize(mode,startPosition,loop,{});

	// timeline functions:
	this.frame_0 = function() {
		createjs.Touch.enable(stage);
		stage.enableMouseOver(10);  
		
		this.uizine_toolbar.visible = false;
		
		var naloga = this;
		
		// OSNOVNE NASTAVITVE ZA VEČSTOPENJSKO NALOGO
		
		var barveOzadja = ["#FFFFFF"];  // barva ozadja za vsako nalogo
		
		var can = document.getElementById("canvas");
		can.style.backgroundColor = barveOzadja[0];
		
		// preverjam, ce so podnaloge nalozene
		
		naloga.podnaloga.addEventListener("tick", aliJeZeNalozeno);
		function aliJeZeNalozeno() {
			if (typeof naloga.podnaloga.pripraviPodnalogo !== "undefined") {
				pripraviPodnaloge();
				naloga.podnaloga.removeEventListener("tick", aliJeZeNalozeno);
			}
		}
		
		function pripraviPodnaloge () {
			console.log ("pripravljam podnaloge");
			naloga.podnaloga.pripraviPodnalogo ();
		}
		
		
		// ZVOKI
		
		var assetPath = "sounds/"
		var sounds = [
			 {src:"pickUp.ogg", id:"pickUp"},
			 {src:"snap.ogg", id:"snap"},
			 {src:"zvonec.ogg", id:"zvonec"}
			 ];
		 createjs.Sound.alternateExtensions = ["mp3"];    // if the passed extension is not supported, try this extension
		 createjs.Sound.on("fileload", handleLoad); // call handleLoad when each sound loads
		 createjs.Sound.registerSounds(sounds, assetPath);
			 
		function handleLoad () {
		}
		
		naloga.playSound = function (zvok, zamik) {
			createjs.Sound.play(zvok, {delay:zamik});
		}
		
		this.stop ();
	}

	// actions tween:
	this.timeline.addTween(cjs.Tween.get(this).call(this.frame_0).wait(1));

	// safe area
	this.uizine_toolbar = new lib.uizine_toolbar();
	this.uizine_toolbar.parent = this;
	this.uizine_toolbar.setTransform(500,325,1,1,0,0,0,500,325);

	this.timeline.addTween(cjs.Tween.get(this.uizine_toolbar).wait(1));

	// animacija
	this.podnaloga = new lib.animacija();
	this.podnaloga.parent = this;
	this.podnaloga.setTransform(0,1);

	this.timeline.addTween(cjs.Tween.get(this.podnaloga).wait(1));

}).prototype = p = new cjs.MovieClip();
p.nominalBounds = new cjs.Rectangle(500,325,1000.1,651);
// library properties:
lib.properties = {
	width: 1000,
	height: 650,
	fps: 30,
	color: "#E2E8EF",
	opacity: 1.00,
	webfonts: {},
	manifest: [
		{src:"images/igla.png", id:"igla"},
		{src:"images/magnet.png", id:"magnet"},
		{src:"images/ozadje.png", id:"ozadje"},
		{src:"images/tuljava_1.png", id:"tuljava_1"},
		{src:"images/tuljava_1_over.png", id:"tuljava_1_over"},
		{src:"images/tuljava_2.png", id:"tuljava_2"},
		{src:"images/tuljava_2_over.png", id:"tuljava_2_over"},
		{src:"images/tuljavaSwap.png", id:"tuljavaSwap"}
	],
	preloads: []
};




})(lib = lib||{}, images = images||{}, createjs = createjs||{}, ss = ss||{}, AdobeAn = AdobeAn||{});
var lib, images, createjs, ss, AdobeAn;