﻿doc =
{
	tag : function (input) { return document.getElementsByTagName(input) },
	id : function (input) { return document.getElementById(input) },
	css : 
		function(input) 
		{ 
			elements = [];
			wholeDoc = doc.tag("*");
			for (var i = 0; i < wholeDoc.length; i++)
			{
				if(wholeDoc[i].className.match("(^| )" + input + "( |$)"))
					elements.push(wholeDoc[i]);
			}
			return elements;
		},
	body: function() { return document.getElementsByTagName("body")[0] },
	target:
          function(e)
          {
            if(e.srcElement)
                return e.srcElement;
            if(e.target)
                return e.target;
            return null;
          },
	add : 
		function(tag, innerHtml, className, id)
		{
			element = document.createElement(tag);
			element.innerHTML = innerHtml;
			element.className = className;
			element.id = id;
			doc.body().appendChild(element);
		},
	create : function(input) { return document.createElement(input) },
	setFunction : 
		function(element, handler, action)
		{
			if(!element.attachEvent)
			{
				element.addEventListener(handler, action, false);
			}
			else
			{
				element.attachEvent('on' + handler, action);
			}
		},
    sniff : 
        {
            IE6 : function () 
            {
                return (!!window.ActiveXObject && typeof(window.XMLHttpRequest) == "undefined");
            },
            IE7 : function ()
            {
                return (!!window.ActiveXObject && typeof(window.XMLHttpRequest) == "object");
            },
            IE : function ()
            {
                return (!!window.ActiveXObject);
            }
        },
    measure :
        { 
            height : function(element)
            {
                if(element.clientHeight)
                    return element.clientHeight;
                return element.offsetHeight;
            },
            width : function(element)
            {
                if(element.clientWidth)
                    return element.clientWidth;
                return element.offsetWidth;
            }
        },
    window :
        {
            height : function ()
            {
                return !doc.sniff.IE() ? window.innerHeight : document.documentElement.clientHeight;       
            },
            width : function ()
            {
                return !doc.sniff.IE() ? window.innerWidth : document.documentElement.clientWidth;
            }
        },
    scroll :
        {
            y : function ()
            {
                return !doc.sniff.IE() ? document.body.scrollTop : document.documentElement.scrollTop;
            },
            x : function ()
            {
                return !doc.sniff.IE() ? document.body.scrollLeft : document.documentElement.scrollLeft;
            }
        },
    document :
        {
            height : function ()
            {
                return document.body.offsetHeight;       
            },
            width : function ()
            {
                return document.body.offsetWidth;
            }
        },
    style : 
        function(element, property)
        {
        	if (element.currentStyle)
		        return element.currentStyle[property];
	        else if (window.getComputedStyle)
		        return document.defaultView.getComputedStyle(element,null).getPropertyValue(property);
	        return "";
        },
	scripts : {},
	runScripts : 
		function()
		{
			for(var i in this.scripts)
				this.scripts[i]();
		}
	
}
