/**
 * Creator: khastie
 * Date: Jun 22, 2009
 * Time: 12:01:12 PM
 * Contents are property of Cappex.com LLC, and strictly confidential.
 */

/*******************************/
/******* EXTEND MOOTOOLS *******/
/*******************************/

/* The following functions are meant to bypass some of the slower mootools calls, especially when doing effects. */

var MootoolsExtender = new Class({

		getInternetExplorerVersion : function () {

		var rv = -1; // Return value assumes failure.

		if (navigator.appName == 'Microsoft Internet Explorer') {

			var ua = navigator.userAgent;

			var re = new RegExp("MSIE ([0-9]{1,}[\.0-9]{0,})");

			if (re.exec(ua) != null)

				rv = parseFloat(RegExp.$1);

		}

		return rv;

	}
});

Element.extend({

	getWidth : function () {
		return this.offsetWidth;
	},

	getHeight : function () {
		return this.offsetHeight;
	},

	setWidth : function (sizeIncludingPx) {
		this.style['width'] = sizeIncludingPx;
	},

	setHeight : function (sizeIncludingPx) {
		this.style['height'] = sizeIncludingPx;
	},

	getPagePosition : function () {

		var currentElem = this;
		var posY = 0;
		var posX = 0;

		while (currentElem != null) {
			posY += currentElem.offsetTop;
			posX += currentElem.offsetLeft;
			currentElem = currentElem.offsetParent;
		}

		return {
			x : posX,
			y : posY,
			width : this.getWidth(),
			height: this.getHeight()

		};
	},

	debugPosition : function () {

		global.debug(
			'this.style.top: ' + this.style.top +
			'\nthis.style.left: ' + this.style.left +
			'\nthis.style.width: ' + this.style.width +
			'\nthis.style.height: ' + this.style.height +
			'\nthis.offsetTop: ' + this.offsetTop +
			'\nthis.offsetLeft: ' + this.offsetLeft +
			'\nthis.offsetWidth: ' + this.offsetWidth +
			'\nthis.offsetHeight: ' + this.offsetHeight +
			'\nthis.getPagePosition: ' + this.getPagePosition().x + ', ' + this.getPagePosition().y

		);
	}
});

function checkVersion() {

    var msg = "You're not using Windows Internet Explorer.";

    var ver = mootoolsExtender.getInternetExplorerVersion();

    if (ver > -1) {

        if (ver >= 8.0)

            msg = "You're using a recent copy of Windows Internet Explorer."

        else

            msg = "You should upgrade your copy of Windows Internet Explorer.";

    }

    alert(msg);

}

var mootoolsExtender = new MootoolsExtender();

window.ie7 = window.ie && mootoolsExtender.getInternetExplorerVersion() >= 7.0 && mootoolsExtender.getInternetExplorerVersion() < 8.0;
window.ie8 = window.ie && mootoolsExtender.getInternetExplorerVersion() >= 8.0 && mootoolsExtender.getInternetExplorerVersion() < 9.0;