/* js.php, made by GamingG */

gDoc = { // build 8 - 3 Feb 2008
    'all' : (document.all ? document.all : null),
    'oCookies' : new Object(),
    'bCookiesLoaded' : false,

    'updateCookies' : function()
    {
        gDoc.oCookies = new Object();
        var aCookies = (new String(document.cookie)).split('; ');

        for(var x = 0; x < aCookies.length; x++)
        {
            var aCookieParts = aCookies[x].split('=');
            gDoc.oCookies[aCookieParts[0]] = aCookieParts[1];
        }
    },

    'getCookie' : function(sName)
    {
        if(!gDoc.bCookiesLoaded)
        {
            gDoc.updateCookies();
            gDoc.bCookiesLoaded = true;
        }

        if(gDoc.oCookies.length == 0)
        {
            gDoc.updateCookies();
        }

        if(gDoc.oCookies[sName])
        {
            return gDoc.oCookies[sName];
        }

        return null;
    },

    'setCookie' : function(sName, sValue, iExpires, sPath, sDomain, bSecure)
    {
        var oDate = new Date();
        oDate.setTime(oDate.getTime());

        document.cookie = sName+'='+escape(sValue)+(iExpires ? ';expires='+(new Date()).setTime(iExpires).toGMTString() : '')+(sPath ? ';path='+sPath : '')+(sDomain ? ';domain='+sDomain : '')+(bSecure ? ';secure' : '');
    },

    'delCookie' : function (sName, sPath, sDomain)
    {
        document.cookie = sName+'='+(sPath ? ';path=' + sPath : '')+(sDomain ? ';domain=' + sDomain : '')+';expires=Thu, 01-Jan-1970 00:00:01 GMT';
    },

    'create' : function(sElem)
    {
        var oElem;
        try
        {
            oElem = document.createElement(sElem);
        }
        catch(e)
        {
            var oTempElem = this.create('div');
            try
            {
                oTempElem.innerHTML = sElem;
                oElem = oTempElem.firstChild;
            }
            catch(e)
            {
                oElem = null;
            }
        }

        return gDoc.addFuncs(oElem);
    },

    'elemInArray' : function(oElem, aElems)
    {
        var fTest = Math.random();
        oElem.__gDocElemInArrayTest = fTest;

        for(var x = 0; x < aElems.length; x++)
        {
            if(aElems[x].__gDocElemInArrayTest == fTest)
            {
                aElems[x].__gDocElemInArrayTest = null;

                return true;
            }
        }

        return false;
    },

    'addFuncs' : function(oElem)
    {
        if(!oElem)
        {
            return null;
        }

        try
        {
            var sNodeName = (new String(oElem.nodeName)).toLowerCase();

            if(sNodeName == 'applet' || sNodeName == 'object') // causes cross-browser problems sometimes
            {
                throw new Object();
            }

            for(var x in this.oFunctions)
            {
                if(!oElem[x])
                {
                    oElem[x] = this.oFunctions[x];
                }
            }
        }
        catch(e)
        {
            oObject = new Object();
            oObject._oElem = oElem;

            for(var x in this.oFunctions)
            {
                oObject['__'+x] = this.oFunctions[x];
                oObject[x] = function()
                {
                    var sEval = 'this.__'+x+'.call(this._oElem';
                    for(var x in arguments)
                    {
                        sEval += ', arguments['+x+']';
                    }

                    sEval += ');';

                    return eval(sEval);
                }
            }

            return oObject;
        }

        return oElem;
    },

    'oFunctions' : {
        'insert' : function(oElem, oBeforeElem)
        {
            var oThis = ((this == gDoc) ? document.body : this);
            if(oBeforeElem)
            {
                return oThis.insertBefore(oElem, oBeforeElem);
            }
            else
            {
                return oThis.appendChild(oElem);
            }
        },

        'append' : function(oElem, oBeforeElem)
        {
            this.insert(oElem, oBeforeElem);
        },

        'remove' : function(oElem)
        {
            oElem = ((this == gDoc) ? oElem : this);

            return oElem.parentNode.removeChild(oElem);
        },

        'replace' : function(oNewElem, oOldElem)
        {
            return gDoc.addFuncs(oOldElem.parentNode.replaceChild(oNewElem, oOldElem));
        },

        'get' : function(sElem)
        {
            if(sElem.match(/^([a-zA-Z]+|\*)$/)) // alphanumeric; must be a tag name
            {
                return this.getByTag(sElem);
            }
            if(sElem.match(/^#/))
            {
                return this.getById(sElem.substr(1));
            }
            if(sElem.match(/^\./))
            {
                return this.getByClass(sElem.substr(1));
            }
            if(sElem.match(/^([a-zA-Z]+|\*)#.+$/))
            {
                return this.getById(sElem.substr(sElem.indexOf('#') + 1), sElem.substr(0, sElem.indexOf('#')));
            }
            if(sElem.match(/^([a-zA-Z]+|\*)\..+$/))
            {
                return this.getByClass(sElem.substr(sElem.indexOf('.') + 1), sElem.substr(0, sElem.indexOf('.')));
            }

            return null;
        },

        'getByTag' : function(sTagName)
        {
            var oThis = ((this == gDoc) ? document : this);
            var aElems = oThis.getElementsByTagName(sTagName);

            for(var x = 0; x < aElems.length; x++)
            {
                gDoc.addFuncs(aElems[x]);
            }

            return aElems;
        },

        'getById' : function(sElemId, sTagName)
        {
            var oThis = ((this == gDoc) ? document : this);
            var oElem = oThis.getElementById(sElemId);

            if(sTagName && sTagName != '*' && sTagName.toLowerCase() != oElem.nodeName.toLowerCase())
            {
                return null;
            }

            return gDoc.addFuncs(oElem);
        },

        'getByClass' : function(oClassNames, sTagName)
        {
            sTagName = sTagName || '*';
            var aElems = (((sTagName == '*') && this.all) ? this.all : this.getByTag(sTagName));
            var aRetElems = new Array();
            var aRegExps = new Array();

            if(typeof(oClassNames) != 'object')
            {
                var oTemp = oClassNames;
                oClassNames = new Array();
                oClassNames[0] = oTemp;
            }

            for(var x = 0; x < oClassNames.length; x++)
            {
                aRegExps[aRegExps.length] = new RegExp('(^|\\s)'+oClassNames[x].replace(/\-/g, '\\-')+'(\\s|$)');
            }

            var oElem;
            var bIsMatch;

            for(var x = 0; x < aElems.length; x++)
            {
                oElem = aElems[x];
                bIsMatch = true;

                for(var y = 0; y < aRegExps.length; y++)
                {
                    if(!aRegExps[y].test(oElem.className))
                    {
                        bIsMatch = false;
                        break;
                    }
                }

                if(bIsMatch)
                {
                    aRetElems[aRetElems.length] = gDoc.addFuncs(oElem);
                }
            }

            aRetElems.item = function(iIndex)
            {
                return this[iIndex];
            }

            return aRetElems;
        },

        'attr' : function(sAttrName, sAttrValue)
        {
            if(sAttrValue == undefined)
            {
                return (this.getAttribute ? this.getAttribute(sAttrName) : null);
            }
            if(sAttrValue == null)
            {
                return (this.removeAttribute ? this.removeAttribute(sAttrName) : null);
            }

            return (this.setAttribute ? this.setAttribute(sAttrName, sAttrValue) : null);
        },

        'attribute' : function(sAttrName, sAttrValue)
        {
            this.attr(sAttrName, sAttrValue);
        },

        'parent' : function()
        {
            return gDoc.addFuncs(this.parentNode);
        },

        'traverse' : function(sElem, oRelElem, sRelProp)
        {
            var aElems = this.parent().get(sElem);
            var oCurElem = oRelElem;
            do
            {
                if(gDoc.elemInArray(oCurElem, aElems))
                {
                    return gDoc.addFuncs(oCurElem);
                }
            } while(oCurElem = oCurElem[sRelProp]);

            return null;
        },

        'next' : function(sElem)
        {
            if(!sElem)
            {
                return gDoc.addFuncs(this.nextSibling);
            }

            return this.traverse(sElem, this.nextSibling, 'nextSibling');
        },

        'prev' : function(sElem)
        {
            if(!sElem)
            {
                return gDoc.addFuncs(this.previousSibling);
            }

            return this.traverse(sElem, this.previousSibling, 'previousSibling');
        },

        'previous' : function(sElem)
        {
            prev(sElem);
        },

        'first' : function(sElem)
        {
            if(!sElem)
            {
                return gDoc.addFuncs(this.firstChild);
            }

            return this.traverse(sElem, this.firstChild, 'nextSibling');
        },

        'last' : function(sElem)
        {
            if(!sElem)
            {
                return gDoc.addFuncs(this.lastChild);
            }

            return this.traverse(sElem, this.lastChild, 'previousSibling');
        },

        'onEvent' : function(sEvent, oFunc)
        {
            if(sEvent.substr(0, 2) == 'on')
            {
                sEvent = sEvent.substr(2);
            }

            var sFuncsName = '__'+sEvent+'Funcs';
            if(typeof(this[sFuncsName]) != 'object' || !this[sFuncsName].length)
            {
                this[sFuncsName] = new Array();
            }

            this[sFuncsName] = this[sFuncsName].concat(oFunc);

            var oThis = this;
            var oTimeoutFunc = function()
            {
                this.lol = 'o rly';
                this['on'+sEvent] = function()
                {
                    var mReturn;
                    var evalStr = 'this[sFuncsName][x].call(this';
                    for(var y = 0; y < arguments.length; y++)
                    {
                        evalStr += ', arguments['+y+']';
                    }
                    evalStr += ');';

                    for(var x = 0; x < this[sFuncsName].length; x++)
                    {
                        if(typeof(this[sFuncsName][x]) == 'function')
                        {
                            mReturn = eval(evalStr);
                        }
                    }

                    return mReturn;
                }
            }
            this['_on'+sEvent] = this['on'+sEvent]; // IE7 randomly destroys variables by setting them to null without this line.  Usually only effects window.onload.

            oTimeoutFunc.call(this);

            setTimeout(function()
            {
                oTimeoutFunc.call(this);
            }, 0);
        },

        'on' : function(sEvent, oFunc)
        {
            this.onEvent(sEvent, oFunc);
        },

        'addEvent' : function(sEvent, oFunc)
        {
            this.onEvent(sEvent, oFunc);
        },

        'getRealObject' : function()
        {
            return (this._oElem ? this._oElem : this);
        }
    }
}

gDoc.addFuncs(gDoc);

function $(oElem)
{
    return gDoc.addFuncs(oElem);
}

document.ondomready = function(){};
document.DOMIsReady = false;

if (document.addEventListener)
{
    try
    {
        document.addEventListener("DOMContentLoaded", function()
        {
            document.ondomready();
            document.DOMIsReady = true;
        }, false);
    }
    catch(e){};
}
else if (document.all && !window.opera)
{
    try
    {
        var DOMReadyElem = gDoc.create('<script type="text/javascript" id="contentloadtag" defer="defer" src="javascript:void(0)"></script>');
        DOMReadyElem.onreadystatechange = function()
        {
            document.ondomready();
            document.DOMIsReady = true;
        }
        $(document).get('head').item(0).append(DOMReadyElem);
    }
    catch(e){};
}

$(window).on('load', function()
{
    setTimeout(function()
    {
        if(!document.DOMIsReady)
        {
            document.ondomready();
        }
    }, 0);
});

var AdBrite_Title_Color = 'CC9900';
var AdBrite_Text_Color = 'FFFFFF';
//if(window.ActiveXObject)
//{
  var AdBrite_Background_Color = '000000';
//}
//var AdBrite_Background_Color = '000000 transparent';
var AdBrite_Border_Color = 'FFFFFF';

function changeImgSize(img, multiple)
{
  var oldHeight = img.height;
  var oldWidth = img.width;

  img.height = oldHeight * multiple;
  img.width = oldWidth * multiple;
}

function removeAllChildNodes(theParent)
{
  for(x in theParent.childNodes.item)
  {
    if(typeof(theParent.childNodes) == "object")
    {
      theParent.removeChild(theParent.childNodes.item(x));
    }
  }
}

function parseXMLString(xmlString)
{
  if (window.ActiveXObject)
  {
    var doc = new ActiveXObject("Microsoft.XMLDOM");
    doc.async = "false";
    doc.loadXML(xmlString);
  }
  else
  {
    var parser = new DOMParser();
    var doc = parser.parseFromString(xmlString, "application/xml");
  }

  return doc;
}

function showAds()
{
  var adObj = document.getElementById('adspace');
  adObj.style.display = 'block';
  adObj.style.visibility = 'visible';
  for(var x = 0; x < adObj.childNodes.length; x++)
  {
    adObj.style.display = 'inline';
    adObj.style.visibility = 'visible';
  }
}

function include(sFile)
{
    var oScript = document.createElement('script');
    oScript.setAttribute('type', 'text/javascript');

    if(typeof(sFile) == 'function') // argument is actually a Javascript function to be ran instead of a remote script
    {
        oScript.appendChild(document.createTextNode('('+sFile+')();'));
    }
    else
    {
        oScript.setAttribute('src', sFile);
    }

    document.getElementsByTagName('head').item(0).appendChild(oScript);
}


/*document.write = function(writeString)
{
  try {
    var nodes = new DOMParser().parseFromString("<parse>"+writeString+"</parse>", 'text/xml').documentElement;
    var range = document.createRange();
    range.selectNodeContents(document.writeElement);
    range.deleteContents();
    for (var i = 0; i < nodes.childNodes.length; i++)
    {
      document.writeElement.appendChild(document.importNode(nodes.childNodes[i], true));
    }
    return true;
  } catch (e) {
    var range = document.createRange();
    var writeFrag = range.createContextualFragment(writeString);
    return true;
    try {
      document.writeElement.innerHTML = writeString;
      return true;
    } catch(ee) {
      return false;
    }
  }
}*/

function onloadHandler()
{
  //showAds();
}

$(window).on('load', onloadHandler);

var pageTracker;

var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
include(gaJsHost+'google-analytics.com/ga.js');
include(function()
{
    pageTracker = _gat._getTracker("UA-4573502-2");
    pageTracker._initData();
    pageTracker._trackPageview();
});
