﻿/*
    Shows a modal Information screen
    using te ModalObject class as a base class
*/
var ModalPage =  Class.create(ModalObject, 
                              {
                                URL: '',
                                ModalPageCSSClass: 'ModalPageDiv',
                                IFrameCSSClass: 'ModalPageFrame',
                                PageDiv: null,
                                
                              
                                initialize: function($super, id, zIndex, url)
                                            {
                                                $super(id, zIndex);
                                                this.URL = url;
                                            },
                              
                                Show: function($super)
                                {
                                    //Renders the base class
                                    $super();
                                    
                                    //render the information screen.
                                    this.CreatePageDiv();
                                    
                                },
                                
                                Hide: function($super)
                                {
                                    //Hide the information screen
                                    $(this.Id + '_ModalPageFrame').src = '';
                                    $(this.Id + '_ModalPageDiv').remove();
                                    
                                    //Hides the objects of the baseclass
                                    $super();
                                },
                                
                                CreatePageDiv: function()
                                               {
                                                   var ScrollBarOffset_x = document.viewport.getScrollOffsets()[0];
                                                   var ScrollBarOffset_y = document.viewport.getScrollOffsets()[1];
                              
                                                   if(this.PageDiv == null)
                                                   {
                                                        var PageFrame = document.createElement('IFrame');
                                                        PageFrame.setAttribute('id', this.Id + '_ModalPageFrame');
                                                        PageFrame.setAttribute('src', this.URL);
                                                        PageFrame.className = this.IFrameCSSClass;
                                                   
                                                        this.PageDiv = document.createElement('div');
                                                        this.PageDiv.setAttribute('id', this.Id + '_ModalPageDiv');
                                                        this.PageDiv.className = this.ModalPageCSSClass;
                                                        this.PageDiv.appendChild(PageFrame);
                                                                                                            
                                                        document.body.appendChild(this.PageDiv);                   
                                                        $(this.Id + '_ModalPageFrame').setStyle("width: 100%; height:100%; z-index: " + (this.ZIndex + 2));   
                                                        $(this.Id + '_ModalPageFrame').setStyle(this.BorderStyle);   
                                                        $(this.Id + '_ModalPageDiv').setStyle("z-index: " + (this.ZIndex + 1));                                                        
                                                   }
                                                   
                                                   $(this.Id + '_ModalPageDiv').setStyle("left : " + ScrollBarOffset_x + "px");
                                                   $(this.Id + '_ModalPageDiv').setStyle("top : " + ScrollBarOffset_y + "px");
                                                   
                                               }
                                

                              });
                        



