var Layer=Class.create();Layer.prototype={layerObj:null,selectObj:new Array(),parentObj:null,initialize:function(parent,id,removeEvent){if(parent){this.parentObj=parent;}if(!id){id='layer_canvas';}this.layerObj=new Element('div',{'id':id});if(removeEvent){Event.observe(this.layerObj,'click',(function(){this.removeLayer();}).bind(this));}Event.observe(window,'resize',(function(){this.resizeLayer();}).bind(this));},showLayer:function(color,opacity){if(!color){color='#000000';}if(!opacity){opacity=0.85;}if(Prototype.Browser.IE&&/MSIE 6/.test(navigator.userAgent)){var select=$$('select');for(i=0;i<select.length;i++){if(select[i].style.display!='none'){select[i].style.display='none';this.selectObj.push(select[i]);}}}var size=this.getWindowSize();Element.setStyle(this.layerObj,{'position':'absolute','top':'0px','left':'0px','width':size[0]+'px','height':size[1]+'px','background':color,'opacity':opacity});Element.wrap(this.layerObj,document.body);},resizeLayer:function(){if(this.layerObj){var size=this.getWindowSize();this.layerObj.style.width=size[0]+'px';this.layerObj.style.height=size[1]+'px';if(this.parentObj&&this.parentObj.resizeLayer){this.parentObj.resizeLayer();}}},removeLayer:function(){if(this.layerObj){if(Prototype.Browser.IE&&/MSIE 6/.test(navigator.userAgent)){for(var i=0;i<this.selectObj.length;i++){if(this.selectObj[i].style.display=='none'){this.selectObj[i].style.display='';}}this.selectObj.clear();}Element.remove(this.layerObj);this.layerObj=null;if(this.parentObj&&this.parentObj.removeLayer){this.parentObj.removeLayer();}}},showLoading:function(img,msg,color,opacity){this.showLayer(color,opacity);var loading=new Element('img',{'src':img});Element.setStyle(loading,{'padding':'10px'});var scrollTop=document.documentElement.scrollTop;if(scrollTop==0){scrollTop=document.body.scrollTop}var y=Math.floor(document.documentElement.clientHeight/2)-loading.height+scrollTop;var loadingMsg=new Element('div');Element.setStyle(loadingMsg,{'position':'absolute','top':y+'px','left':'0px','width':'100%','color':'#FFF','fontSize':'12px','textAlign':'center','lineHeight':'120%'});Element.wrap(loading,loadingMsg);if(msg){loadingMsg.insert('<br />'+msg);}this.layerObj.appendChild(loadingMsg);},getDisplay:function(){return this.layerObj;},getWindowSize:function(){var w=document.body.clientWidth;var h=document.body.clientHeight;if(h<document.documentElement.clientHeight){h=document.documentElement.clientHeight;}if(h<document.documentElement.scrollHeight){h=document.documentElement.scrollHeight;}if(h<document.body.scrollHeight){h=document.body.scrollHeight;}return [w,h];}}
