var Util = new Object();


Util.getHTTP = function(url) {
    if (!url) {
        return "";
    }

    try {
        // ie > 7 ff etc.
        var httpcon;
        try {
            httpcon = new XMLHttpRequest();
        }
        catch (e) {
            // ie <= 6
            try {
                httpcon = new ActiveXObject("Msxml2.XMLHTTP");
            }
            catch(e) {
                try {
                    httpcon = new ActiveXObject("Microsoft.XMLHTTP");
                }
                catch(e) {
                    return null;
                }
            }
        }

        httpcon.open("GET", url, false);
        if (httpcon.overrideMimeType) {
            httpcon.overrideMimeType("text/xml; charset=ISO-8859-1");
        }
        httpcon.send(null);

        return httpcon.responseText;
    }
    catch (e) {
        return null;
    }
};

Util.getBody = function() {
    return document.getElementsByTagName("body")[0];
};

Util.getWindowWidth = function() {
    var width = 0;
    if (window.innerWidth) {
        width = window.innerWidth;
    } else {
        if (document.documentElement && document.documentElement.clientWidth) {
            width = document.documentElement.clientWidth;
        } else {
            var body = Util.getBody();
            if (body && body.clientWidth) {
                width = body.clientWidth;
            }
        }
    }
    return width;
};

Util.getWindowHeight = function() {
    var height = 0;
    if (window.innerHeight) {
        height = window.innerHeight;
    } else {
        if (document.documentElement && document.documentElement.clientHeight) {
            height = document.documentElement.clientHeight;
        } else {
            var body = Util.getBody();
            if (body && body.clientHeight) {
                height = body.clientHeight;
            }
        }
    }
    return height;
};

Util.getPosition = function(element) {
    var left = 0;
    var top = 0;
    if (element && element.tagName) {
        while (element.offsetParent) {
            top += element.offsetTop;
            left += element.offsetLeft;
            element = element.offsetParent;
        }
    }
    return {left: left, top: top};
};


Util.getMousePosition = function(event) {
	if(event.pageX || event.pageY){
		return {left:event.pageX, top:event.pageY};
	}
	return {
		left:event.clientX + document.body.scrollLeft - document.body.clientLeft,
		top:event.clientY + document.body.scrollTop  - document.body.clientTop};
};


Util.getMouseOffset = function(element, event){
	event = event || window.event;
    var docPos = Util.getPosition(element);
    var mousePos = Util.getMousePosition(event);
	return {
        left:mousePos.left - docPos.left,
        top:mousePos.top - docPos.top};
};


Util.cancelEvent = function(e) {
    if (window.event) {
        window.event.cancelBubble = true;
    } else if (e) {
        e.stopPropagation();
    }
};

Util.sendMail = function(name, host) {
    var s1 = "ma";
    var s2 = "ilt";
    var s3 = "o:";
    var s4 = "@";
    window.location = s1 + s2 + s3 + name + s4 + host;
};



