function Page(app,id,fileName){if(app.pages[id]){return app.pages[id]}
this.id= id;this.app= app;this.type= PAGE_TYPE;this.index= app.pages.length;this.appObjectModelPath= APP_NAME + ".pages[" + this.index + "]";this.file= (!fileName?"":fileName);this.loadFunction= LOADING_FRAME_PATH + "." + PAGE_ONLOAD_FUNCTION + "()";this.complete= false;this.layers= new Array();this.preImages= new Array();this.assignPreImage= assignPreImagePage
this.assignLayer= assignLayerPage
this.bring= bringPage
this.open= new Function("window.open('" + this.file +"','"+LOADING_FRAME_NAME+"');");this.app.pages[id]= this.app.pages[this.index]= this;return this}
function assignLayerPage(layer){if(layer && layer.type== LAYER_TYPE){if(!this.layers[layer.id]){this.layers[this.layers.length]= this.layers[layer.id]= layer}
layer.page= this}}
function assignPreImagePage(){for(var i=0;i<arguments.length;i++){prei=arguments[i]
if(prei){if(prei.type != PREIMAGE_TYPE)prei= this.app.preImages[prei]
if(prei)if(!this.preImages[prei.id])this.preImages[this.preImages.length]= this.preImages[prei.id]= prei}}}
function bringPage(){var numOfCachedImgs= 0;if(this.preImages.length>0){var ind=this.preImages.length-1
for(var i=ind;i>=0;i--){if(!this.preImages[i].img){this.preImages[i].cache();numOfCachedImgs++}else{break}}}
return numOfCachedImgs}