﻿function OpenNewWindow(url, fullWindow) {
    var windowOptions = "";
    if (fullWindow == false) {
        windowOptions = "toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=yes, resizable=yes, copyhistory=yes, width=750, height=600";
    }
    window.open(url,"_blank",windowOptions);
}

function CurrentClientDimensions() {
    this.width = 0;
    this.height = 0;
    var browserName = whichBrs();
    switch (browserName) {
        case 'Safari':
            this.height = window.innerHeight;
            this.width = window.innerWidth;
            break;
        case 'Opera':
            this.height = window.innerHeight;
            this.width = window.innerWidth;
            break;
        case 'Internet Explorer':
            this.height = document.documentElement.clientHeight;
            this.width = document.documentElement.clientWidth;
            break;
        case 'Firefox':
            this.height = window.innerHeight;
            this.width = window.innerWidth;
            break;
    }
}
CurrentClientDimensions.prototype.toString = function() {
    return this.width.toString() + "/" + this.height.toString();
}

function TargetDimensions(width, height) {
    this.width = width;
    this.height = height;
}
function TargetDimensions() {
    var frame = document.getElementById('Main');
    var pixX = GetStyleValue(frame, 'width');
    var pixY = GetStyleValue(frame, 'height');
    pixX = pixX.replace(/px/, '');
    pixY = pixY.replace(/px/, '');
    var x = parseInt(pixX, 10);
    var y = parseInt(pixY, 10);
    if (isNaN(x)) x = 787;
    if (isNaN(y)) y = 564;
    this.width = x;
    this.height = y;
}
TargetDimensions.prototype.toString = function() {
    return this.width.toString() + "/" + this.height.toString();
}

function WindowFormatOps() {
    var clientDims = new CurrentClientDimensions();
    var desiredDims = new TargetDimensions();
    var DeltaX = desiredDims.width - clientDims.width;
    var DeltaY = desiredDims.height - clientDims.height;
    if (DeltaX != 0 || DeltaY != 0) {
        self.resizeBy(DeltaX, DeltaY);
    }
}

function GetStyleValue(ele, dimName) {
    var styleVal = ele.style[dimName];
    if (!styleVal) {
        if (document.defaultView) {
            styleVal = document.defaultView.getComputedStyle(ele, '').getPropertyValue(dimName);
        }
        else if (ele.currentStyle) {
            styleVal = ele.currentStyle[dimName];
        }
    }
    
    return styleVal;
}


