
import mx.transitions.Tween;
import mx.transitions.easing.*

import templateBook.mvctemplate.*
import templateBook.mvc.*
import templateBook.I.*
import flash.display.BitmapData
import templateBook.util.Observable
import templateBook.Configuration
import flash.filters.GlowFilter;

import templateBook.ToolTip

     
class templateBook.mvctemplate.AbstractTools extends AbstractView {
	  

var symbol:MovieClip	
var containerReflect:MovieClip
var tweenOver:Tween
var tweenOver2:Tween
var tweenOut:Tween
var tweenOut2:Tween

var mc_over:MovieClip
var bcg:MovieClip


var __y:Number

////toools
var desc_tool:String 
var orient:String
var tool:ToolTip
    
////////////////////////////////////////////////////////////////////////////////////////////////////////////

	function AbstractTools() {
		__y = this.symbol._y
		
		var colorIcon = Configuration.TOOLS_COLOR_ICON
		if(colorIcon!=undefined){
		NewColor.setColor(this.symbol,colorIcon);
		}
		
		var color_bcg_icon = Configuration.TOOLS_COLOR_BCG_ICON
		if (color_bcg_icon != undefined) {
			NewColor.setColor(bcg, color_bcg_icon);
		}
		
	}
		
//////////////////////////////////////////////////////////////////////////////////////////////////

    function onLoad() {
	
			
	}

//////////////////////////////////////////////////////////////////////////////////////////////////

   function onRollOver() {
	var m:BookModel=BookModel(BookModel.getInstance())   
	   	
	////shov tool Tip
	if(Configuration.TOOL_TIP_VISIBLE=="true"){
	if(desc_tool!=undefined&&desc_tool!=""&&desc_tool.length>0){	
	setOrient()
		
	ToolTip.path= m.__container.containerTool
	tool = ToolTip.create();
	tool.orient = orient
	tool.show = desc_tool
	}
	}
	   
	
	////mc over ( bcg png )
	/*
	symbol.swapDepths(101)
	var dep:Number = symbol.getDepth() -1
	mc_over = this.attachMovie("bcg_icon_over", "bcg_icon_over", dep, { _alpha:0 } );
	var color_bcg_icon_over = Configuration.TOOLS_COLOR_BCG_ICON_OVER
	if (color_bcg_icon_over != undefined) {
		NewColor.setColor(mc_over, color_bcg_icon_over);
	}
	tweenOver = new Tween(mc_over, '_alpha', Strong.easeOut, 0, 100, .3, true)
	
	////color icon
	if(Configuration.TOOLS_COLOR_ICON_OVER!=undefined){
	NewColor.setColor(symbol, Configuration.TOOLS_COLOR_ICON_OVER);
	}
	/*/

	
		
	tweenOver = new Tween(symbol, '_y', Strong.easeOut, symbol._y,symbol._y-5, .3, true)
	 tweenOver2 = new Tween(containerReflect,'_y',Strong.easeOut,containerReflect._y,5,.3,true)
	   
   }

//////////////////////////////////////////////////////////////////////////////////////////////////

    function setOrient() {
		if (Configuration.TOOLS_POSITION == "down") {
		orient = "TR"	
		}else{
		orient = "BR"
	    }		
		
		orient = "TR";
	}

//////////////////////////////////////////////////////////////////////////////////////////////////


   function onRollOut() {
	   tool.hide()
	   
	   ////icon png
	   tweenOver.stop()
	   tweenOver = new Tween(mc_over, '_alpha', Strong.easeOut, mc_over._alpha, 0, .3, true)
	   
	   ///color symbol
	   if (Configuration.TOOLS_COLOR_ICON != undefined) {
		  NewColor.setColor(symbol, Configuration.TOOLS_COLOR_ICON);		   
	   }else{
	   var k:Color = new Color(symbol);
	   k.setTransform( {
           ra: '100', rb: '0',
           ga: '100', gb: '0',
           ba: '100', bb: '0', 
           aa: '100', ab: '0'
        } );
	   }
	     
	   
	 tweenOut = new Tween(symbol, '_y', Strong.easeOut, symbol._y, __y, .3, true)  
	 tweenOut2 = new Tween(containerReflect,'_y',Strong.easeOut,containerReflect._y,0,.3,true)
	   
   }

//////////////////////////////////////////////////////////////////////////////////////////////////

function release() {
	tool.hide()
	onRollOut()
}

//////////////////////////////////////////////////////////////////////////////////////////////////

function onReleaseOutside() {
	release()
}
   
//////////////////////////////////////////////////////////////////////////////////////////////////
  
function createMaskReflection() {
		   
	    var thumbWidth:Number = symbol._width
		var thumbHeight:Number = symbol._height
		var spaceBcg:Number = 0
	    var spaceReflection:Number = 1
		
	   
	   	var reflect:MovieClip = this.createEmptyMovieClip("containerReflect", 10).createEmptyMovieClip("image", 1)
			
		var bmpRef:BitmapData = new BitmapData(thumbWidth,thumbHeight, true,0xFF0000)
		bmpRef.draw(this)
		reflect.attachBitmap(bmpRef, 1, "auto", true)
		reflect._yscale = -100
		reflect._y = thumbHeight * 2 +spaceBcg * 4 + spaceReflection
	   
		
	    var fillType:String = "linear";
		var colors:Array = [0xFFFFFF, 0xFFFFFF];
		var alphas:Array = [70, 0];
		var ratios:Array = [0, 225];
		var matrix = {matrixType:"box", x:0, y:0, w:thumbWidth, h:(thumbHeight-thumbHeight/4), r:(90/180)*Math.PI};
		
		var _maskReflect:MovieClip = this.containerReflect.createEmptyMovieClip("maskReflection",2)
		_maskReflect.beginGradientFill(fillType, colors, alphas, ratios, matrix, "pad");
		_maskReflect.moveTo(0, 0);
		_maskReflect.lineTo(0, thumbHeight);
		_maskReflect.lineTo(thumbWidth+spaceBcg*2, thumbHeight);
		_maskReflect.lineTo(thumbWidth+spaceBcg*2, 0);
		_maskReflect.lineTo(0, 0);
		_maskReflect.endFill();
		_maskReflect._y = thumbHeight + spaceBcg*2
		
		
		_maskReflect.cacheAsBitmap = true
		reflect.cacheAsBitmap = true
		reflect.setMask(_maskReflect)
		
		
}

//////////////////////////////////////////////////////////////////////////////////////////////////

}
