﻿var s=navigator.userAgent.toLowerCase();var BrowserInfo={isIE:s.indexOf('msie')>-1,isIE7:s.indexOf('msie 7')>-1,isGecko:s.indexOf('gecko/')>-1,isSafari:s.indexOf('safari')>-1,isOpera:s.indexOf('opera')>-1};function rd_openDialog(A,B,C){var B=B||610;var C=C||600;var D=Math.ceil((screen.availWidth-B)/2);var E=Math.ceil((screen.availHeight-C)/2);window.open(A,'_blank','left='+D+',top='+E+', width='+B+', height='+C+', resizable=yes, scrollbars=yes');};function rd_appendStyleSheet(A,B){var C=A.createElement('LINK');C.rel='stylesheet';C.type='text/css';C.href=B;A.getElementsByTagName("HEAD")[0].appendChild(C);return C;};function rd_addEventListener(A,B,C){if (A.attachEvent) A.attachEvent('on'+B,C);else A.addEventListener(B,C,false);};function rd_addEventListenerEx(A,B,C,D){if (A.attachEvent){var B='on'+B;A.attachEvent(B,function(e) { C.apply(A,[e].concat(D||[]));});}else{A.addEventListener(B,function(e) { C.apply(A,[e].concat(D||[]));},false);}};function rd_createEventListener(A,B){var f=function(){var C=[];for (var i=0;i<arguments.length;i++) C.push(arguments[i]);A.apply(this,C.concat(B));};return f;};function rd_cancelEvent(e){if (!e) return false;if (e.preventDefault) e.preventDefault();else e.returnValue=false;};function rd_runFunction(A,B,C){if (!A) return;if (C) A.apply(B,[].concat(C));else A.apply(B);};function rd_getElementDocument(A){return A.ownerDocument||A.document;};function rd_getElementWindow(A){var B=rd_getElementDocument(A);return B.parentWindow||B.defaultView;};function rd_getComputedStyle(A,B){if (A.getComputedStyle) return A.getComputedStyle(B,'');else return B.currentStyle;};
String.prototype.format = function()
{
    var argCnt = arguments.length;

    if (argCnt <= 0)
        return "";

    var params = arguments;

    var str = this.replace(/\%(\d+)/g,
      function($0, $1) {
        var idx = parseInt($1);
        return (!isNaN(idx) && idx <= argCnt ? params[idx - 1] : $0);
      }
    );

    return str;
}

function rd_removeEventListener(el, type, listener)
{
    if (el.removeEventListener)
    {
        el.removeEventListener(type, listener, false);
    }
    else if (el.detachEvent)
    {
        el.detachEvent("on" + type, listener);
    }
}

function rd_getElementRect(el)
{
    var rect = { x: 0, y: 0, width: el.offsetWidth, height: el.offsetHeight };

    while (el)
    {
        rect.x += el.offsetLeft;
        rect.y += el.offsetTop;
        el = el.offsetParent;
    }

    return rect;
}

function rd_getWindowRect()
{
    var rect = new Rect();

    if (window.innerHeight)
    {
        rect.width = window.innerWidth;
        rect.height = window.innerHeight;
        return rect;
    }

    if (document.documentElement && document.documentElement.clientHeight)
    {
        rect.width = document.documentElement.clientWidth;
        rect.height = document.documentElement.clientHeight;
        return rect;
    }

    if (document.body)
    {
        rect.width = document.body.clientWidth;
        rect.height = document.body.clientHeight;
        return rect;
    }

    return rect;
}

function Rect()
{
    this.width = 0;
    this.height = 0;
}