﻿function popup(url) {
    var newWin = window.open(url, 'mywin', 'width=800,height=600,scrollbars=yes,resizable=yes');
}
function popupPreview(url) {
    var newWin = window.open(url, 'mywin', 'width=900,height=600,scrollbars=yes,resizable=yes,adddressbar=yes');
}
function backToTop() {
    var x1 = x2 = x3 = 0;
    var y1 = y2 = y3 = 0;

    if (document.documentElement) {
        x1 = document.documentElement.scrollLeft || 0;
        y1 = document.documentElement.scrollTop || 0;
    }

    if (document.body) {
        x2 = document.body.scrollLeft || 0;
        y2 = document.body.scrollTop || 0;
    }

    x3 = window.scrollX || 0;
    y3 = window.scrollY || 0;

    var x = Math.max(x1, Math.max(x2, x3));
    var y = Math.max(y1, Math.max(y2, y3));

    window.scrollTo(Math.floor(x / 2), Math.floor(y / 2));

    if (x > 0 || y > 0) {
        window.setTimeout("backToTop()", 25);
    }
}
function DoRollOver(name, over) {
    if (window.document.images) {
        if (over)
            window.document.images[name].src = "/images/buttons/" + name + "-hover.jpg";
        else
            window.document.images[name].src = "/images/buttons/" + name + ".jpg";
    }
}
function hoverOver(oElement, bHover) {
    if (bHover == 1) {
        //oElement.className='area-hover';
    } else {
        //oElement.className='area';
    }
}
function rowHover(oElement, bHover) {
    if (bHover == 1) {
        oElement.className = 'trNoticeOver';
    } else {
        oElement.className = 'trNoticeOut';
    }
}
function trHover(oElement, bAlt, bHover) {
    if (bAlt == 1) {
        if (bHover == 1) {
            oElement.className = 'trOverAlt';
        } else {
            oElement.className = 'trOutAlt';
        }
    } else {
        if (bHover == 1) {
            oElement.className = 'trOver';
        } else {
            oElement.className = 'trOut';
        }
    }
}
function doPopup(url, w, h) {
    newwindow = window.open(url, 'name', 'height=' + h + ',width=' + w + ',resizable=no,scrollbars=no,toolbar=no,status=no');
    if (window.focus) { newwindow.focus() }
    return false;
}



function getStyle(oElm, strCssRule) {
    var strValue = "";
    if (document.defaultView && document.defaultView.getComputedStyle) {
        var css = document.defaultView.getComputedStyle(oElm, null);
        strValue = css ? css.getPropertyValue(strCssRule) : null;
    }
    else if (oElm.currentStyle) {
        strCssRule = strCssRule.replace(/\-(\w)/g, function(strMatch, p1) {
            return p1.toUpperCase();
        });
        strValue = oElm.currentStyle[strCssRule];
    }
    return strValue;
}

function InitPicker(el, elcolor) {
    var colorPicker = new mooSphere({
        cpBoxes: [el],
        startXY: [false],
        resizable: [true],
        onShow: function(el) { },
        onHide: function(event, el, color) {
            //--uncomment these examples to see some of the objects you have access to here
            //console.debug('hooked it!'+this.name+' '+event.target.className+' '+el.id);
            //console.debug('hex:'+color);
            document.getElementById(elcolor).value = color;
            __doPostBack('ctl00$Body$btnProjectUsersAddedUpdate', '');
        }
    });
}

function getAbsoluteTop(objectId) {
    // Get an object top position from the upper left viewport corner
    // Tested with relative and nested objects
    o = document.getElementById(objectId)
    oTop = o.offsetTop            // Get top position from the parent object
    while (o.offsetParent != null) { // Parse the parent hierarchy up to the document element
        oParent = o.offsetParent  // Get parent object reference
        oTop += oParent.offsetTop // Add parent top position
        o = oParent
    }
    // Return top position
    return oTop
}
