﻿
// Common variables
var READYSTATE_UNINITIALIZED = 0;
var READYSTATE_LOADING = 1;
var READYSTATE_LOADED = 2;
var READYSTATE_INTERACTIVE = 3;
var READYSTATE_COMPLETE = 4;

// Common values for HTTP status codes
var HTTPSTATUS_OK = 200;
var HTTPSTATUS_NOTFOUND = 404;
var HTTPSTATUS_SERVERERROR = 500;

// create http request object
function CreateXmlHttpRequestObject() {
    
    if (window.XMLHttpRequest) {
        xmlHttpObj = new XMLHttpRequest();
    }
    else
    {
        try
        {
            xmlHttpObj = new ActiveXObject("Microsoft.XMLHTTP");
        }
        catch(e)
        {
            xmlHttpObj = new ActiveXObject("Msxml2.XMLHTTP");
        }
     }
     
     return xmlHttpObj;
}

function clearCombo(combo)
{
   // alert(combo.type);
	if (combo.type != 'text')
	{
		combo.options.length = 0;
	}
}

function MouseEvent(e)
{
    if (e)
    {
        this.e = e;
    }
    else
    {
        this.e = window.event;
    }

    if (this.e.pageX)
    {
        this.x = this.e.pageX;
    }
    else
    {
        this.x = this.e.clientX;
    }

    if (this.e.pageY)
    {
        this.y = this.e.pageY;
    }
    else
    {
        this.y = this.e.clientY;
    }
    
    if (this.e.target)
    {
        this.target = this.e.target;
    }
    else
    {
        this.target = this.e.srcElement;
    }

    if (self.pageYOffset) // all except Explorer
    {
        //this.scrollX = self.pageXOffset;
        //this.scrollY = self.pageYOffset;
        this.scrollX = 0;
        this.scrollY = 0;
    }
    else if (document.documentElement && document.documentElement.scrollTop)
        // Explorer 6 Strict
    {
        this.scrollX = document.documentElement.scrollLeft;
        this.scrollY = document.documentElement.scrollTop;
    }
    else if (document.body) // all other Explorers
    {
        this.scrollX = document.body.scrollLeft;
        this.scrollY = document.body.scrollTop;
    }

}

function addListener (type, callback)
{
    if (window.addEventListener)
    {
        window.addEventListener (type, callback, false);
    }
    else if (window.attachEvent)
    {
        window.attachEvent ("on" + type, callback, false);
    }
       
}
function removeListener (type, callback)
{
    if (document.removeEventListener)
    {
        document.removeEventListener (type, callback, false);
    }
    else if (document.detachEvent)
    {
        document.detachEvent ("on" + type, callback, false);
    }
       
}

function setTransparency (target, amount)
{
     target.style.opacity = amount/100;
     target.style.filter = "alpha(opacity=" + amount + ")";

}