import mx.data.encoders.Num;
import templateBook.mvctemplate.*
import templateBook.mvc.*
import templateBook.I.*
import flash.display.BitmapData
import templateBook.util.Observable
import templateBook.Configuration
import mx.transitions.Tween
import mx.transitions.easing.*

class templateBook.mvctemplate.TitlePageView extends AbstractView {

var mc_right:MovieClip            //right movie clip
var mc_left:MovieClip             //left movieclip
var container:MovieClip           //container for title page
var tween1:Tween                  //tween
var inter                         //handler for setInterval
	
///////////////////////////////////////////////////////////

function TitlePageView() {
	setVariable()
}

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

public function defaultController (model:Observable):Controller {
  return null;////new LogoController(model)
 }
 
////////////////////////////////////////////////////////////

function setVariable() {
	mc_right = container.mc_right
	mc_left = container.mc_left
}
 
////////////////////////////////////////////////////////////

function onLoad() {
     onResize()
	 ///color left
	 NewColor.setColor(mc_left.bcg, Configuration.COLOR_BCG_NUMBER_PAGE_LEFT);
	 ///color right
	 NewColor.setColor(mc_right.bcg, Configuration.COLOR_BCG_NUMBER_PAGE_RIGHT);
}

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

function onFaceBook() {
	_visible = true
	clearInterval(inter);
	inter = setInterval(this,'first_show',500);
}

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

function first_show() {
	clearInterval(inter);
	tween1.stop();
}

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

function left_visible(boolean_:Boolean) {
	if (boolean_) {
		mc_left._visible=true
	}else {
		mc_left._visible=false
	}
}

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

function right_visible(boolean_:Boolean) {
	if (boolean_) {
		mc_right._visible=true
	}else {
		mc_right._visible=false
	}
}

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

function create() {
	
}

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

function onLoadLogo() {
		
}

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

function onResize() {
	var m:BookModel = BookModel(this.getModel())
	this._x = m.__container.__containerBook._x + m.getWidthCurrent()/2
	//position TitlePageView
	var obj:Object = Converter.convert( { x:( -Configuration.PAGE_WIDTH + 7.5), y:(Configuration.PAGE_HEIGHT - 25) }, m.__container.__containerBook, this._parent);
	this._y = obj.y;
	///position left container
	var obj:Object = Converter.convert( { x:(15), y:(Configuration.PAGE_HEIGHT - 25) }, m.__container.__containerBook,container);
	mc_left._x = obj.x//-m.getWidthCurrent() / 2 - 20
	////postion right
	mc_right._x = m.getWidthCurrent() / 2
}

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

function change_swfAdress(obj:Object) {
	var m:BookModel = BookModel(this.getModel())
	////right
	var nr_right:Number = obj.nr_right
	var title_right:Number = m.__pages[nr_right].titlePage
	var visibleNumberLocal:String = m.__pages[nr_right].visibleNumber	
	var visibleNumberGlobal:String = Configuration.VISIBLE_NUMBER_PAGE
	var visibleNumber:String = (visibleNumberLocal.length) ? visibleNumberLocal : visibleNumberGlobal
	mc_right.nr.text = (visibleNumber=="true") ? nr_right : ""
	mc_right.nr.textColor=Configuration.COLOR_NUMBER_PAGE
	mc_right.nr.autoSize="right"
	mc_right.mc_line._x = mc_right.nr._x - 10
	mc_right.title.autoSize = "right";
	mc_right.title.text = title_right
	mc_right.title.textColor=Configuration.COLOR_TITLE_PAGE
	mc_right.title._x = mc_right.mc_line._x - mc_right.title._width - 10
	if (mc_right.title.length == 0 || mc_right.nr.length == 0) {
		mc_right.mc_line._visible=false
	}else {
		mc_right.mc_line._visible=true
	}
	//left
	var nr_left:Number = obj.nr_left
	var title_left:Number = m.__pages[nr_left].titlePage
	mc_left.nr.text = nr_left
	mc_left.nr.textColor=Configuration.COLOR_NUMBER_PAGE
	mc_left.nr.autoSize="left"
	mc_left.mc_line._x = mc_left.nr._x + mc_left.nr._width+10
	mc_left.title.autoSize = "left";
	mc_left.title.text = title_left
	mc_left.title.textColor=Configuration.COLOR_TITLE_PAGE
	mc_left.title._x=mc_left.mc_line._x+10
}

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

}

