var DefaultViewportWidth = 800;
var DefaultViewportHeight = 600;
var DefaultScreenResolution = "1280x960";
var DefaultScreenWidth = 1280;
var DefaultScreenHeight = 960;
var DefaultScreenQuality = "progid:DXImageTransform.Microsoft.Blur(PixelRadius=0, MakeShadow=false)";
var DefaultSiteMarginLeft = 0;
var DefaultSiteMarginTop = 110;
var DefaultSiteMarginRight = 0;
var DefaultSiteMarginBottom = 62;
var DefaultSiteUrl = "http://www.screen-resolution.com/welcome.php";
function CViewport(p) {
        this.Parent = p;
        this.Width = null;
        this.Screen = new CScreen(this);
        this.Init = function() {
                this.Width = DefaultViewportWidth;
                this.Height = DefaultViewportHeight;
                this.Screen.Init();
        }
}
function CScreen(p) {
        this.Parent = p;
        this.Viewport = this.Parent;
        this.Resolution = null;
        this.Width = null;
        this.Height = null;
        this.Zoom = null;
        this.Quality = null;
        this.Site = new CSite(this);
        this.Init = function() {
                this.SetResolution();
                this.SetQuality();
                this.Site.Init();
        }
        this.SetResolution = function(s) {
                if (s == "800x600") {
                        this.Width = 800;
                        this.Height = 600;
                } else if (s == "1024x768") {
                        this.Width = 1024;
                        this.Height = 768;
                } else if (s == "1280x800") {
                        this.Width = 1280;
                        this.Height = 800;
                } else if (s == "1280x960") {
                        this.Width = 1280;
                        this.Height = 960;
                } else if (s == "1440x900") {
                        this.Width = 1440;
                        this.Height = 900;
                } else if (s == "1600x1200") {
                        this.Width = 1600;
                        this.Height = 1200;
                } else if (s == "1680x1050") {
                        this.Width = 1680;
                        this.Height = 1050;
                } else if (s == "1920x1200") {
                        this.Width = 1920;
                        this.Height = 1200;
                } else {
                        this.Resolution = DefaultScreenResolution;
                        this.Width = DefaultScreenWidth;
                        this.Height = DefaultScreenHeight;
                }
                this.Zoom = Math.round(Viewport.Width / this.Width * 100);
                if (this.Zoom <1) {
                        this.Zoom = 1;
                } else {
                        if (this.Zoom> 100) {
                                this.Zoom = 100;
                        }
                }
                this.Site.Init();
        }
        this.SetQuality = function(s) {
                if (s == "low") {
                        this.Quality = "";
                } else {
                        if (s == "high") {
                                this.Quality = "progid:DXImageTransform.Microsoft.Blur(PixelRadius=0, MakeShadow=false)";
                        } else {
                                this.Quality = DefaultScreenQuality;
                        }
                }
        }
}
function CSite(p) {
        this.Parent = p;
        this.Screen = this.Parent;
        this.Width = null;
        this.Height = null;
        this.Url = null;
        this.Init = function() {
                this.Width = this.Screen.Width - DefaultSiteMarginLeft - DefaultSiteMarginRight;
                this.Height = this.Screen.Height - DefaultSiteMarginTop - DefaultSiteMarginBottom;
                this.SetUrl();
        }
        this.SetUrl = function(s) {
                if (s) {
                        if (s.substring(0,7) == "http://") {
                                this.Url = s;
                        } else {
                                this.Url = "http://" + s;
                        }
                } else {
                        if (this.Url == null) {
                                this.Url = DefaultSiteUrl;
                        }
                }
        }
}
function CHtml(p) {
        this.Parent = p;
        this.Screen = null;
        this.Site = null;
        this.Init = function() {
                this.Screen = document.getElementById("Screen");
                this.Site = document.getElementById("Site");
        }
}
function ChangeResolution(s) {
        if (Ready) {
                Viewport.Screen.SetResolution(s);
                Paint();
        }
}
function ChangeQuality(s) {
        if (Ready) {
                Viewport.Screen.SetQuality(s);
                Paint();
        }
}
function ChangeUrl(s) {
        if (Ready) {
                Viewport.Screen.Site.SetUrl(s);
                Paint();
        }
}
function Paint() {
        if (Ready) {
                document.body.style.display = "none";
                document.body.style.filter = Viewport.Screen.Quality;
                document.body.style.zoom = Viewport.Screen.Zoom + "%";
                Html.Site.width = Viewport.Screen.Site.Width;
                Html.Site.height = Viewport.Screen.Site.Height;
                Html.Screen.width = Viewport.Screen.Width;
                Html.Screen.height = Viewport.Screen.Height;
                Html.Site.src = Viewport.Screen.Site.Url;
                document.body.style.display = "block";
        }
}