import templateBook.mvc.*
import templateBook.I.*
import templateBook.mvctemplate.*
import templateBook.util.Observable
import templateBook.Configuration


class templateBook.mvctemplate.Book{
  
 var __model:BookModel
 var __target:MovieClip
 var __background:BackgroundView
 var __bookView:BookView
 var __preloader:PreloaderMultipleView
 var __next:NextButtonView
 var __prev:PrevButtonView
  var __areaHorn:AreaHornView
 var __nextChapter:NextChapterView
 var __prevChapter:PrevChapterView
 var __soundPage:SoundPageView
 var __tools:ToolsView
  var __chapterSound:ChapterSoundView
 var __additionalSwfView:AdditionalSwfView
 var __popUpView:PopUpView
 var __containerClip:ContainerClipView
 var __containerBook:ContainerBookView
 var holderPrint:HolderPrintView
 var printChoose:PrintChooseView
 var formular:FormularView
 var list_pages:ListPagesView
 var mask_book:MaskBookView
 var __logo:LogoView
 var __numberPage:NumberPageView
 var __footer:FooterView
 var __descBook:DescBookView
 var __icon:IconView
 var __titlePage:TitlePageView
 var __tableContents:TableContentsView
 var __select_book:SelectBookBtnView
 var __carousel_container:CarouselContainerView
 var containerTool:MovieClip
 
 
//////////////////////////////////////////////////////////////////////////////////////////////
  
  public function Book(target:MovieClip) {
	this.__target=target
	__model = new BookModel(this)
	
	
 //////////////////container Book
 __containerBook = ContainerBookView(__target.attachMovie("_container_book", "__container_book_", 15))
 __containerBook.setModel(__model)
 this.__model.addEventListener("onSetPage",__containerBook)
 this.__model.addEventListener("onResize",__containerBook)
 this.__model.addEventListener("onLoadBackground", __containerBook)
 this.__model.addEventListener("onTweenPageEnd", __containerBook)
 this.__model.addEventListener("onSheetBackEnd", __containerBook)
 this.__model.addEventListener("onLoadingLeft", __containerBook)
 this.__model.addEventListener("onLoadingRight", __containerBook)
 this.__model.addEventListener("onChangedZoom", __containerBook)
 
 //////////////////mask Book
 
 mask_book = MaskBookView(__target.attachMovie("_mask_book", "_mask_book_", 16))
 mask_book.setModel(__model)
 this.__model.addEventListener("onSetPage",mask_book)
 this.__model.addEventListener("onResize",mask_book)
 this.__model.addEventListener("onLoadBackground", mask_book)
 this.__model.addEventListener("onTweenPageEnd", mask_book)
 this.__model.addEventListener("onSheetBackEnd", mask_book)
 this.__model.addEventListener("onLoadingLeft", mask_book)
 this.__model.addEventListener("onLoadingRight", mask_book)
 this.__model.addEventListener("onChangedZoom", mask_book)
  
 	 
  ///////////////////////view book	 
 this.__bookView=BookView(__containerBook.attachMovie("_book","_book_",1))
 //this.__bookView=this.__target._book_
 this.__bookView.setModel(this.__model)
 this.__model.addEventListener("onSetPage",this.__bookView)
 this.__model.addEventListener("onResize",this.__bookView)
 this.__model.addEventListener("onLoadBackground", this.__bookView)
 this.__model.addEventListener("onTweenPageEnd", this.__bookView)
 this.__model.addEventListener("onSheetBackEnd", this.__bookView)
 this.__model.addEventListener("onLoadingLeft", this.__bookView)
 this.__model.addEventListener("onLoadingRight",this.__bookView)
	 
 
 /////tools
 if(Configuration.TOOLS_VISIBLE=="true"){
 __tools = ToolsView(this.__target.attachMovie("_tools", "_tools_", 10))
 __tools.setModel(__model)
 this.__model.addEventListener("onLoadBackground", __tools)
 this.__model.addEventListener("onResize", __tools)
 this.__model.addEventListener("onFaceBook", __tools)
 }
 
  
 if(Configuration.HORN_ENABLED=="true"){
 /////////////////////////area horn
 this.__areaHorn = AreaHornView(__containerBook.attachMovie("_area_horn", "_area_horn_",145))
 this.__areaHorn.setModel(__model)
 this.__model.addEventListener("onResize",__areaHorn)
 this.__model.addEventListener("onSetPage",__areaHorn)
 this.__model.addEventListener("onNextPage",__areaHorn)
 this.__model.addEventListener("onPrevPage",__areaHorn)
 this.__model.addEventListener("onTweenPageEnd", __areaHorn)
 this.__model.addEventListener("onTweenPageStart", __areaHorn)
 this.__model.addEventListener("onSheetBackEnd", __areaHorn)
 this.__model.addEventListener("onStartDragSheet", __areaHorn)
 this.__model.addEventListener("onSheetBackStart", __areaHorn)
 
 }

 ///////////////////////background
 this.__background=BackgroundView(this.__target.attachMovie("_background_book","_background_book_",1))
 this.__background.setModel(this.__model)
 this.__model.addEventListener("onRemoveAll",this.__background)
 this.__model.addEventListener("onTweenPageEnd",this.__background)
 this.__model.addEventListener("onChangeBackground",this.__background)
 this.__model.addEventListener("onResize",this.__background)
 	
 
 ///////////////////////preloader multiple

 if(Configuration.PRELOADER_MULTIPLE=="true"&&Configuration.LOAD_ALL_PAGES=="true"){
 this.__preloader=PreloaderMultipleView(this.__target.attachMovie("_preloaderBook","_preloader_",2))
 this.__preloader.setModel(this.__model)
 this.__model.addEventListener("onRemoveAll",this.__preloader)
 this.__model.addEventListener("onResize", this.__preloader)
 this.__model.addEventListener("onStartLoadPages", this.__preloader)
 this.__model.addEventListener("onLoadImage", this.__preloader)
 this.__model.addEventListener("onEndLoadPages", this.__preloader)
 this.__model.addEventListener("onLoadProgressPage",this.__preloader)
 }
 

 
 ///////////////////////////////////enabled/disabled soundChapter for chapter
 __chapterSound = ChapterSoundView(__target.attachMovie("_chapterSound", "_chapterSound", 44334433))
 __chapterSound.setModel(__model)
 this.__model.addEventListener("onResize",__chapterSound)
 this.__model.addEventListener("onSetPage",__chapterSound)
 this.__model.addEventListener("onNextPage",__chapterSound)
 this.__model.addEventListener("onPrevPage",__chapterSound)
 this.__model.addEventListener("onTweenPageEnd",__chapterSound)
 
 ////////////////  enabled/disabled sound in page
 __soundPage = SoundPageView(this.__target.attachMovie("_soundPage", "_soundPage", __target.getNextHighestDepth()))
 __soundPage.setModel(__model)
 __model.addEventListener("onLoadingRight", __soundPage)
 __model.addEventListener("onLoadingLeft",__soundPage)
  
 
  ///////AdditionalSwfView (lightBox)
 __additionalSwfView = AdditionalSwfView(__target.attachMovie("_additionalSwf", "_addotionalSwf_", __target.getNextHighestDepth()))
 __additionalSwfView.setModel(__model)
 __model.addEventListener("onLoadingRight", __additionalSwfView)
 __model.addEventListener("onLoadingLeft", __additionalSwfView)
 __model.addEventListener("onNextPage", __additionalSwfView)
 __model.addEventListener("onPrevPage", __additionalSwfView)
 __model.addEventListener("onSetPage", __additionalSwfView)
 __model.addEventListener("onShovLightBox", __additionalSwfView)
 __model.addEventListener("onHideLightBox", __additionalSwfView)
  __model.addEventListener("onResize", __additionalSwfView)
 
 
 
 
  ////popUp
 __popUpView = PopUpView(__target.attachMovie("_popUp", "_popUp", __target.getNextHighestDepth()))
 __popUpView.setModel(__model)
 __model.addEventListener("onLoadingRight",__popUpView)
 __model.addEventListener("onLoadingLeft", __popUpView)
 __model.addEventListener("onNextPage",__popUpView)
 __model.addEventListener("onPrevPage", __popUpView)
 
 
 ////ContainerClip
 
 __containerClip = ContainerClipView(__target.attachMovie("_containerClip", "_containerClip_", 3000))
 __containerClip.setModel(__model)
 __model.addEventListener("onResize", __containerClip)
 __model.addEventListener("onNextPage",__containerClip)
 __model.addEventListener("onPrevPage",__containerClip)
 __model.addEventListener("onSetPage", __containerClip)

 
 //////holder print
 holderPrint = HolderPrintView(__target.attachMovie("_holderPrint", "_holderPrint_", 10000))
 holderPrint.setModel(__model)
 __model.addEventListener("onSetPrintPage",holderPrint)

 
 //////print choose
 printChoose = PrintChooseView(__target.attachMovie("_printChoose", "_printChoose", 5003))
 printChoose.setModel(__model)
 __model.addEventListener("onChoosePrint", printChoose)
 __model.addEventListener("onResize", printChoose)
 
 /////formular
 formular = FormularView(__target.attachMovie("_formular", "_formular_", 20000))
 formular.setModel(__model)
 __model.addEventListener("onResize", formular)
 __model.addEventListener("onShovForm", formular)
 


 /////list pages
 list_pages = ListPagesView(__target.attachMovie("_list_pages", "_list_pages_", 21000))
 list_pages.setModel(__model)
 __model.addEventListener("onResize", list_pages)
 __model.addEventListener("onShovForm", list_pages)
 __model.addEventListener("onLoadInitPage", list_pages)
 __model.addEventListener("onShovThumbs", list_pages)
 __model.addEventListener("onHideThumbs", list_pages)
 __model.addEventListener("onSetPage", list_pages)
  __model.addEventListener("onTweenPageEnd", list_pages)
  
  
  
   /////next pages
  /// if(Configuration.ARROW_VISIBLE=="true"){
__next = NextButtonView(__target.attachMovie("_nextbutton_book", "_nextbutton_book_",5,{_alpha:0}))
__next.setModel(__model)
 __model.addEventListener("onResize", __next)
 __model.addEventListener("onShovForm", __next)
 __model.addEventListener("onLoadInitPage", __next)
 __model.addEventListener("onShovThumbs", __next)
 __model.addEventListener("onHideThumbs", __next)
 __model.addEventListener("onSetPage",__next)
 __model.addEventListener("onTweenPageEnd", __next)
 __model.addEventListener("onPrevPage", this.__next)
 __model.addEventListener("onSheetBackEnd", this.__next)
 __model.addEventListener("onStartDragSheet", this.__next)  
 __model.addEventListener("onFaceBook", this.__next)  
  // }

 
  /////prev pages    
 // if(Configuration.ARROW_VISIBLE=="true"){
__prev =  PrevButtonView(__target.attachMovie("_prevbutton_book", "_prevbutton_book_", 6,{_alpha:0}))
__prev.setModel(__model)
 __model.addEventListener("onResize",__prev)
 __model.addEventListener("onShovForm", __prev)
 __model.addEventListener("onLoadInitPage",__prev)
 __model.addEventListener("onShovThumbs",__prev)
 __model.addEventListener("onHideThumbs",__prev)
 __model.addEventListener("onSetPage",__prev)
 __model.addEventListener("onTweenPageEnd",__prev)
 __model.addEventListener("onPrevPage", __prev)
 __model.addEventListener("onNextPage", this.__prev)
 __model.addEventListener("onSheetBackEnd", this.__prev)
 __model.addEventListener("onStartDragSheet", this.__prev)
 __model.addEventListener("onFaceBook", this.__prev)
//  }
 
////logo
__logo =  LogoView(__target.attachMovie("_logo", "_logo_",12))
__logo.setModel(__model)
__model.addEventListener("onResize", __logo)
__model.addEventListener("onFaceBook", __logo)

////footer
__footer =  FooterView(__target.attachMovie("_footer", "_footer_",6043))
__footer.setModel(__model)
__model.addEventListener("onResize",__footer)
__model.addEventListener("onFaceBook", __footer)


////desc Book
if(Configuration.DESC_BOOK_VISIBLE=="true"){
__descBook =  DescBookView(__target.attachMovie("_descBook", "_descBook_",3))
__descBook.setModel(__model)
__model.addEventListener("onResize",__descBook)
__model.addEventListener("onFaceBook", __descBook)
}


////icon 
__icon = IconView(__target.attachMovie("_icon", "_icon_", 3272))
__icon.setModel(this.__model)
__model.addEventListener("onResize",__icon)
__model.addEventListener("onFaceBook",__icon)


/////title page
if(Configuration.TITLE_AND_NUMBER_PAGE_VISIBLE=="true"){
__titlePage = TitlePageView(__target.attachMovie("_title_page", "_title_page_",9998774,{_visible:0}))
__titlePage.setModel(__model)
 __model.addEventListener("onResize",__titlePage)
 __model.addEventListener("onShovForm",__titlePage)
 __model.addEventListener("onLoadInitPage",__titlePage)
 __model.addEventListener("onShovThumbs",__titlePage)
 __model.addEventListener("onHideThumbs",__titlePage)
 __model.addEventListener("onSetPage",__titlePage)
 __model.addEventListener("onTweenPageEnd",__titlePage)
 __model.addEventListener("onPrevPage",__titlePage)
 __model.addEventListener("onSheetBackEnd",__titlePage)
 __model.addEventListener("onStartDragSheet",__titlePage)  
 __model.addEventListener("onFaceBook", __titlePage)  
 __model.addEventListener("change_swfAdress", __titlePage)  
}
 

//table contents
if(Configuration.CHAPTERS_VISIBLE=="true"){
__tableContents = TableContentsView(__target.attachMovie("_table_contents", "_table_contents_",1121,{_visible:false}))
__tableContents.setModel(__model)
 __model.addEventListener("onResize",__tableContents)
 __model.addEventListener("onShovForm",__tableContents)
 __model.addEventListener("onLoadInitPage",__tableContents)
 __model.addEventListener("onShovThumbs",__tableContents)
 __model.addEventListener("onHideThumbs",__tableContents)
 __model.addEventListener("onSetPage",__tableContents)
 __model.addEventListener("onTweenPageEnd",__tableContents)
 __model.addEventListener("onPrevPage",__tableContents)
 __model.addEventListener("onSheetBackEnd",__tableContents)
 __model.addEventListener("onStartDragSheet",__tableContents)  
 __model.addEventListener("onFaceBook",__tableContents)  
 __model.addEventListener("change_swfAdress", __tableContents)  
}


 
 ///_NumberPageView
 if(Configuration.PAGE_MANAGER_VISIBLE=="true"){
  //__numberPage =  NumberPageView(__target.attachMovie("_NumberPageView", "_NumberPageView_",7))
 __numberPage =  NumberPageView(__tools.attachMovie("_NumberPageView", "_NumberPageView_",26020))
 __numberPage.setModel(__model)
__model.addEventListener("onResize", __numberPage)
__model.addEventListener("onSetPage",__numberPage)
__model.addEventListener("onNextPage",__numberPage)
__model.addEventListener("onPrevPage", __numberPage)
__model.removeEventListener("onTweenPageEnd",__numberPage)
__model.addEventListener("onTweenPageEnd", __numberPage)
__model.addEventListener("onFaceBook", __numberPage)

 }
 
 
 /////icon select book
 __select_book =  SelectBookBtnView(__target.attachMovie("_select_book_btn_view", "_select_book_btn_view_",77,{_visible:0}))
// __select_book =  NumberPageView(__tools.attachMovie("_select_book_btn_view", "_select_book_btn_view_",77))
__select_book.setModel(__model)
__model.addEventListener("onResize",__select_book)
__model.addEventListener("onSetPage",__select_book)
__model.addEventListener("onNextPage",__select_book)
__model.addEventListener("onPrevPage",__select_book)
__model.removeEventListener("onTweenPageEnd",__select_book)
__model.addEventListener("onTweenPageEnd",__select_book)
__model.addEventListener("onFaceBook", __select_book)



////carousel container
__carousel_container =  CarouselContainerView(__target.attachMovie("_carousel_container", "_carousel_container_",1800,{_visible:false}))
__carousel_container.setModel(__model)
__model.addEventListener("onResize",__carousel_container)
__model.addEventListener("onSetPage",__carousel_container)
__model.addEventListener("onNextPage",__carousel_container)
__model.addEventListener("onPrevPage",__carousel_container)
__model.removeEventListener("onTweenPageEnd",__carousel_container)
__model.addEventListener("onTweenPageEnd",__carousel_container)
__model.addEventListener("onFaceBook", __carousel_container)
__model.addEventListener("onShowListBook", __carousel_container)
__model.addEventListener("onHideListBook", __carousel_container)

 
 //container for ToolTip
this.containerTool = __target.createEmptyMovieClip("mcTool", 100000)


 
  }
 

}