﻿//compatibility.js


var isIE = (window.navigator.userAgent.indexOf("MSIE") > 0 );
var isIE8 = (window.navigator.userAgent.indexOf("MSIE") >= 8 );
        
if (! isIE ) 
{
    String.prototype.trim = function() { return this.replace(/^\s+|\s+$/, ''); };

    HTMLElement.prototype.__defineGetter__("innerText", function () { return(this.textContent); });
    HTMLElement.prototype.__defineSetter__("innerText", function (txt) { this.textContent = txt; });
    
    Event.prototype.__defineGetter__("srcElement",function(){var node=this.target;while(node.nodeType!=1)node=node.parentNode; return node;});

    var element = HTMLElement.prototype; 
    var capture = ["click", "mousedown", "mouseup", "mousemove", "mouseover", "mouseout" ];

    element.setCapture = function()
    {
        var self = this;
        var flag = false;
        this._capture = function(e)
        {
            if (flag)
            {
                return;
            }
            flag = true;
            var event = document.createEvent("MouseEvents");
            event.initMouseEvent(e.type,
                e.bubbles, e.cancelable, e.view, e.detail,
                e.screenX, e.screenY, e.clientX, e.clientY,
                e.ctrlKey, e.altKey, e.shiftKey, e.metaKey,
                e.button, e.relatedTarget);
            self.dispatchEvent(event);
            flag = false;
        };
        for (var i = 0; i < capture.length; i++)
        {
            window.addEventListener(capture[i], this._capture, true);
        }
    }; 

    element.releaseCapture = function()
    { 
        for (var i=0; i<capture.length; i++) 
        { 
            window.removeEventListener(capture[i], this._capture, true); 
        } 
        
        this._capture = null;
    };
//    HTMLElement.prototype.click = function()
//    {
//        var evt = this.ownerDocument.createEvent('MouseEvents');
//        evt.initMouseEvent('click', true, true, this.ownerDocument.defaultView, 1, 0, 0, 0, 0, false, false, false, false, 0, null);
//        this.dispatchEvent(evt);
//    } 

}
        
function getCoords( element ) 
{
    var coords = { x: 0, y: 0, width: element.offsetWidth, height:element.offsetHeight };
    while (element) 
    {
        coords.x += element.offsetLeft;
        coords.y += element.offsetTop;
        element = element.offsetParent;
    }
    return coords;
}

function ReplaceStringAttribute( objStyle, attribute, newValue )
{
    var replacementString = "";
    if (IsNullOrEmpty(objStyle) || objStyle == ";")
    {
        replacementString = attribute + ":" + newValue + ";";
    }
    else
    {
        var str = "";
        var strTest = "";
        var mySplitResult = objStyle.split(";");

        for (var i = 0; i < mySplitResult.length; i++)
        {
            str = mySplitResult[i].trim();
            strTest = str.substring(0, attribute.length);
            if (strTest == attribute)
            {
                replacementString += " " + attribute + ": " + newValue + ";";
            }
            else
            {
                replacementString += mySplitResult[i] + ";";
            }
        }
    }
    return replacementString;
}
if(typeof(Sys)!=='undefined')Sys.Application.notifyScriptLoaded();