if (typeof(AC) == 'undefined') { AC = {}; }



AC.OverlayScreen = Class.create();
Object.extend(AC.OverlayScreen.prototype, Event.Listener);
Object.extend(AC.OverlayScreen.prototype, {

    initialize: function(overlay) {
        this.listenForEvent(AC.ViewMaster, 'ViewMasterWillShowNotification', false, this.willShow);
        this.listenForEvent(overlay, 'beforeClose', false, this.willClose);
    },

    screen: function(overlayPanel) {
        var body = $(document.documentElement);
        var dimensions = body.getDimensions();

        var width = dimensions.width;
        if (document.body.clientWidth>width) width = document.body.clientWidth;

        var height = dimensions.height;
        if (document.body.clientHeight>height) height = document.body.clientHeight;

        this._screen = new Element('div', { id:'OverlayPanelScreen', className:'overlaypanelscreen',
            style: 'position:absolute; display:none; top:0; left:0; width:'+width+'px; height:'+height+'px;'
        });
        document.body.appendChild(this._screen);

        this._screen.observe('click', overlayPanel.close.bindAsEventListener(overlayPanel));
    },

    escape: function(overlayPanel) {
        this._escape = Event.observe(window, 'keyup', function(evt) {
            if (evt.keyCode == Event.KEY_ESC) {
                if (overlayPanel.currentSection) {
                    overlayPanel.close();
                }
            }
        }.bind(overlayPanel));
    },

    willShow: function(evt) {
        var overlayPanel = evt.event_data.data.sender;
        var incoming = evt.event_data.data.incomingView;
//console.log(overlayPanel)
        if (overlayPanel.overlay) {
            if (!this._escape) this.escape(overlayPanel);

            if (incoming) {
                if (!this._screen) this.screen(overlayPanel);
                new Effect.Appear(this._screen, { duration:1, from:0, to:.85 });
            }
        }
    },

    willClose: function(evt, outgoing, incoming) {
        var overlayPanel = evt.event_data.data;

        if (overlayPanel.overlay) {
            new Effect.Fade(this._screen, { duration:.3,
                afterFinish: function(effect) {
                    effect.element.setOpacity(0);
                }
            });
        }
    }
});




Event.onDOMReady(function() {
    AC.OverlayPanel.overlayScreen = new AC.OverlayScreen(AC.OverlayPanel.overlay);
	loadImgs();
});


function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function loadImgs(){
//	MM_preloadImages("/images/overlays/bento/overlay_gradient20090106.png","/images/overlays/close_button.png","/images/overlays/bento/overlay_thumbbg_image_active20090106.png","/images/overlays/bento/overlay_thumbbg_image20090106.png","/images/overlays/bento/overlay_arrowright20090106.gif","/images/overlays/bento/overlay_arrowleft20090106.gif","/images/overlays/overlay_panel_default.png","/images/slider/dot20070414.png","/products/bento/whatsnew/imgs/screen11_small.png","/products/bento/whatsnew/imgs/screen10_small.png","/products/bento/whatsnew/imgs/screen13_small.png","/products/bento/whatsnew/imgs/screen12_small.png","/products/bento/whatsnew/imgs/screen3_small.png","/products/bento/whatsnew/imgs/screen2_small.png","/products/bento/whatsnew/imgs/screen5_small.png","/products/bento/whatsnew/imgs/screen4_small.png","/products/bento/whatsnew/imgs/screen7_small.png","/products/bento/whatsnew/imgs/screen6_small.png","/products/bento/whatsnew/imgs/screen9_small.png","/products/bento/whatsnew/imgs/screen8_small.png","/products/bento/whatsnew/imgs/screen15_small.png","/products/bento/whatsnew/imgs/screen14_small.png","/products/bento/whatsnew/imgs/screen0_small.png","/products/bento/whatsnew/imgs/screen1_small.png","/products/bento/templates/classes_sm.png","/products/bento/templates/customers_sm.png","/products/bento/templates/contacts_sm.png","/products/bento/templates/digital_media_sm.png","/products/bento/templates/diet_log_sm.png","/products/bento/templates/donations_sm.png","/products/bento/templates/event_planning_sm.png","/products/bento/templates/equipment_sm.png","/products/bento/templates/exercise_log_sm.png","/products/bento/templates/events_sm.png","/products/bento/templates/files_sm.png","/products/bento/templates/expenses_sm.png","/products/bento/templates/home_maintenance_sm.png","/products/bento/templates/health_record_sm.png","/products/bento/templates/inventory_sm.png","/products/bento/templates/home_inventory_sm.png","/products/bento/templates/items_sold_sm.png","/products/bento/templates/issue_tracking_sm.png","/products/bento/templates/meeting_notes_sm.png","/products/bento/templates/job_search_sm.png","/products/bento/templates/my_house_search_sm.png","/products/bento/templates/membership_list_sm.png","/products/bento/templates/notes_sm.png","/products/bento/templates/my_vacation_sm.png","/products/bento/templates/products_for_sale_sm.png","/products/bento/templates/party_planner_sm.png","/products/bento/templates/student_list_sm.png","/products/bento/templates/recipes_sm.png","/products/bento/templates/projects_sm.png","/products/bento/templates/to-do-items_sm.png","/products/bento/templates/time_billing_sm.png","/products/bento/templates/user_names_passwords_sm.png","/products/bento/templates/tv_movies_sm.png","/products/bento/templates/vehicle_maintenance_sm.png","/products/bento/templates/wine_collection_sm.png","/products/bento/themes/theme1_sm.png","/products/bento/themes/theme10_sm.png","/products/bento/themes/theme11_sm.png","/products/bento/themes/theme12_sm.png","/products/bento/themes/theme13_sm.png","/products/bento/themes/theme14_sm.png","/products/bento/themes/theme15_sm.png","/products/bento/themes/theme17_sm.png","/products/bento/themes/theme16_sm.png","/products/bento/themes/theme18_sm.png","/products/bento/themes/theme19_sm.png","/products/bento/themes/theme2_sm.png","/products/bento/themes/theme20_sm.png","/products/bento/themes/theme21_sm.png","/products/bento/themes/theme22_sm.png","/products/bento/themes/theme23_sm.png","/products/bento/themes/theme24_sm.png","/products/bento/themes/theme25_sm.png","/products/bento/themes/theme26_sm.png","/products/bento/themes/theme28_sm.png","/products/bento/themes/theme27_sm.png","/products/bento/themes/theme29_sm.png","/products/bento/themes/theme3_sm.png","/products/bento/themes/theme30_sm.png","/products/bento/themes/theme31_sm.png","/products/bento/themes/theme4_sm.png","/products/bento/themes/theme5_sm.png","/products/bento/themes/theme6_sm.png","/products/bento/themes/theme7_sm.png","/products/bento/themes/theme9_sm.png","/products/bento/themes/theme8_sm.png")
}
											 



