/***********************************************************

QTL - DHTML Menu System For ASP.Net Applications.
Version 1.0
Copyright 2005 (c) QTLogic. All Rights Reserved.
This is a commercial software product, please visit http://www.QTLogic.com/ for more information.
All Copyright statements must always remain in place in all files at all times
******* PLEASE NOTE: THIS IS NOT FREE SOFTWARE, IT MUST BE LICENSED FOR ALL USE ******* 

***********************************************************/ 
			
function QTL_Point(objMe) {
	this.X = null;
	this.Y = null;
	this.Z = null;
}

QTL_ControlCoords.prototype.Width = function (intWidth) {
	if (intWidth != null) {
		this.Me.style.width = intWidth;
	}
	return this.Me.offsetWidth;
};

QTL_ControlCoords.prototype.Height = function (intHeight) {
	if (intHeight != null) {
		this.Me.style.height = intHeight;
	}
	return this.Me.offsetHeight;
};			

QTL_ControlCoords.prototype.MoveTo = function (intX, intY) {
	this.Me.style.position = "absolute";
	this.Me.style.left = intX + "px";
	this.Me.style.top = intY + "px";
	//debugger;
	//this.Me.offsetLeft = intX;
	//this.Me.offsetTop = intY;	
};

function QTL_GetCenterCoords(intWidth, intHeight, objDocHolder) {
	if (objDocHolder == null) {
		objDocHolder = window;
	}
	var intPWidth = objDocHolder.document.body.clientWidth;
	var intPHeight = objDocHolder.document.body.clientHeight;

	var intSLeft = objDocHolder.document.body.scrollLeft;
	var intSTop = objDocHolder.document.body.scrollTop;

	var intMyWidth = intWidth;
	var intMyHeight = intHeight;

	var intHPos = Math.round(intSLeft + ((intPWidth - intMyWidth) / 2));
	var intVPos = Math.round(intSTop + ((intPHeight - intMyHeight) / 2));

	intHPos = (intHPos < 0) ? 0 : intHPos;
	intVPos = (intVPos < 0) ? 0 : intVPos;
	
	var arrCoords = new Array();
	
	arrCoords[0] = intHPos;
	arrCoords[1] = intVPos;
	
	return arrCoords;
}

function QTL_GetCenterCoordsView(intWidth, intHeight, objDocHolder) {
	if (objDocHolder == null) {
		objDocHolder = window;
	}
	var intPWidth = objDocHolder.document.documentElement.clientWidth;
	var intPHeight = objDocHolder.document.documentElement.clientHeight;

	var intSLeft = objDocHolder.document.documentElement.scrollLeft;
	var intSTop = objDocHolder.document.documentElement.scrollTop;

	var intMyWidth = intWidth;
	var intMyHeight = intHeight;

	var intHPos = Math.round(intSLeft + ((intPWidth - intMyWidth) / 2));
	var intVPos = Math.round(intSTop + ((intPHeight - intMyHeight) / 2));

	intHPos = (intHPos < 0) ? 0 : intHPos;
	intVPos = (intVPos < 0) ? 0 : intVPos;
	
	var arrCoords = new Array();
	
	arrCoords[0] = intHPos;
	arrCoords[1] = intVPos;
	
	return arrCoords;
}

QTL_ControlCoords.prototype.MoveToCenter = function (objDocHolder) {
	if (objDocHolder == null) {
		objDocHolder = window;
	}

	//var intPWidth = objDocHolder.document.body.clientWidth;
	//var intPHeight = objDocHolder.document.body.clientHeight;
	
	var intPWidth = objDocHolder.document.documentElement.clientWidth;
	var intPHeight = objDocHolder.document.documentElement.clientHeight;

	//var intSLeft = objDocHolder.document.body.scrollLeft;
	//var intSTop = objDocHolder.document.body.scrollTop;
	
	var intSLeft = 0;
	var intSTop = 0;

	var intMyWidth = this.Me.offsetWidth;
	var intMyHeight = this.Me.offsetHeight;
	
	if (intMyWidth == 0) {
		if (isNaN(parseInt(this.Me.style.width)) == false) {
			intMyWidth = parseInt(this.Me.style.width);
		}
	}
	
	if (intMyHeight == 0) {
		if (isNaN(parseInt(this.Me.style.height)) == false) {
			intMyHeight = parseInt(this.Me.style.height);
		}
	}	

	var intHPos = Math.round(intSLeft + ((intPWidth - intMyWidth) / 2));
	var intVPos = Math.round(intSTop + ((intPHeight - intMyHeight) / 2));

	intHPos = (intHPos < 0) ? 0 : intHPos;
	intVPos = (intVPos < 0) ? 0 : intVPos;
	
	this.Me.style.position = "absolute";
	this.Me.style.left = intHPos + "px";
	this.Me.style.top = intVPos + "px";
};

QTL_ControlCoords.prototype.MoveToCenterView = function (objDocHolder) {
	if (objDocHolder == null) {
		objDocHolder = window;
	}
	var intPWidth = objDocHolder.document.documentElement.clientWidth;
	var intPHeight = objDocHolder.document.documentElement.clientHeight;

	var intSLeft = objDocHolder.document.documentElement.scrollLeft;
	var intSTop = objDocHolder.document.documentElement.scrollTop;

	var intMyWidth = this.Me.offsetWidth;
	var intMyHeight = this.Me.offsetHeight;
	
	if (intMyWidth == 0) {
		if (isNaN(parseInt(this.Me.style.width)) == false) {
			intMyWidth = parseInt(this.Me.style.width);
		}
	}
	
	if (intMyHeight == 0) {
		if (isNaN(parseInt(this.Me.style.height)) == false) {
			intMyHeight = parseInt(this.Me.style.height);
		}
	}	

	var intHPos = Math.round(intSLeft + ((intPWidth - intMyWidth) / 2));
	var intVPos = Math.round(intSTop + ((intPHeight - intMyHeight) / 2));

	intHPos = (intHPos < 0) ? 0 : intHPos;
	intVPos = (intVPos < 0) ? 0 : intVPos;
	
	this.Me.style.position = "absolute";
	this.Me.style.left = intHPos + "px";
	this.Me.style.top = intVPos + "px";
};

QTL_ControlCoords.prototype.MoveToZ = function (intX, intY, intZ) {
	this.Me.style.position = "absolute";
	this.Me.style.left = intX + "px";
	this.Me.style.top = intY + "px";
	this.Me.style.zIndex = intZ;
};

QTL_ControlCoords.prototype.NormalizePage = function () {
	this.Me.style.position = "absolute";			
	this.Me.style.left = "0px";
	this.Me.style.top = "0px";
};

QTL_ControlCoords.prototype.ZIndex = function (intZ) {
	this.Me.style.position = "absolute";
	this.Me.style.zIndex = intZ;
};			

QTL_ControlCoords.prototype.Hide = function () {
	this.Me.style.visibility = "hidden";
};

QTL_ControlCoords.prototype.Show = function () {
	this.Me.style.visibility = "visible";		
};

QTL_ControlCoords.prototype.HideDiv = function (objDocHolder) {
	if (objDocHolder == undefined) {
		objDocHolder = window;
	}
	if ((this.flgMoz == false) && (objDocHolder.document.getElementById("iFrame" + this.Me.id) != null)) {
		objDocHolder.document.body.removeChild(objDocHolder.document.getElementById("iFrame" + this.Me.id));
	}
	this.Me.style.visibility = "hidden";
};

QTL_ControlCoords.prototype.ShowDiv = function (objDocHolder) {
	if (objDocHolder == undefined) {
		objDocHolder = window;
	}
	
	if (this.flgMoz == false) {
		var frameDiv = objDocHolder.document.createElement('iframe');
		frameDiv.id = "iFrame" + this.Me.id;
		frameDiv.setAttribute('class','');
		frameDiv.setAttribute('src','javascript;;')
		frameDiv.style.position = 'absolute';
		frameDiv.style.zindex = 5;
		//frameDiv.style.width = this.Me.style.width;
		//frameDiv.style.height = this.Me.style.height;
		frameDiv.style.width = QTL_CInt(this.Me.offsetWidth);
		frameDiv.style.height = QTL_CInt(this.Me.offsetHeight);	
		frameDiv.style.display = 'block';
		frameDiv.style.backgroundColor='#333333';
		frameDiv.style.left = QTL_CInt(this.Me.style.left) + "px";
		frameDiv.style.top = QTL_CInt(this.Me.style.top) + "px";
		frameDiv.setAttribute("frameBorder","0"); 
		frameDiv.setAttribute("hspace","0"); 
		frameDiv.setAttribute("vspace","0"); 
		frameDiv.setAttribute("marginheight","0"); 
		frameDiv.setAttribute("marginwidth","0"); 
		frameDiv.setAttribute("scrolling","no");	
		frameDiv.style.visibility = "visible";	
		objDocHolder.document.body.appendChild(frameDiv);
	}
	this.Me.style.display = "";					
	this.Me.style.visibility = "visible";	
	this.Me.style.zIndex = 6;
};

QTL_ControlCoords.prototype.ID = function () {
	return this.Me.id;
};

function OTB_ControlCoords(objControl) {
	return new QTL_ControlCoords(objControl);
}		

function QTL_ControlCoords(objControl) {
	var Self = objControl;
	
	if (window.ActiveXObject) {
		this.flgMoz = false;
	}
	else {
		this.flgMoz = true;
	}
	
	this.Me = objControl;
	
	var NormalizeLeft = function () {
		var objTestParent = Self.offsetParent;
		var intPixels = 0
		
		while (objTestParent != null) {
			intPixels += objTestParent.offsetLeft;
			objTestParent = objTestParent.offsetParent;
		}
		return intPixels;
	};
	
	var NormalizeTop = function () {
		var objTestParent = Self.offsetParent;
		var intPixels = 0
		
		while (objTestParent != null) {
			intPixels += objTestParent.offsetTop;
			objTestParent = objTestParent.offsetParent;
		}
		return intPixels;
	};
	
	var Width = function () {
		return Self.offsetWidth;
	};
	
	var Height = function () {
		//return Self.offsetParent.offsetHeight;
		return Self.offsetHeight;					
	};
	
	var OffsetLeft = function () {
		return Self.offsetLeft;
	};
	
	var OffsetTop = function () {
		return Self.offsetTop
	};
	
	this.ParentTopLeft = new QTL_Point();
	this.ParentBottomLeft = new QTL_Point();
	this.ParentTopRight = new QTL_Point();
	this.ParentBottomRight = new QTL_Point();
	this.ParentTopLeft.X = function () { return OffsetLeft(); };
	this.ParentTopLeft.Y = function () { return OffsetTop(); };
	this.ParentBottomLeft.X = function () { return OffsetLeft(); };
	this.ParentBottomLeft.Y = function () { return (OffsetTop() + Height() - 1); };
	this.ParentTopRight.X = function () { return (OffsetLeft() + Width() - 1); };
	this.ParentTopRight.Y = function () { return OffsetTop(); };
	this.ParentBottomRight.X = function () { return (OffsetLeft() + Width() - 1); };
	this.ParentBottomRight.Y = function () { return (OffsetTop() + Height() - 1); };
	this.Parent = null;
	this.PageTopLeft = new QTL_Point();
	this.PageBottomLeft = new QTL_Point();
	this.PageTopRight = new QTL_Point();
	this.PageBottomRight = new QTL_Point();
	this.PageTopLeft.X = function () { return (OffsetLeft() + NormalizeLeft()); };
	this.PageTopLeft.Y = function () { return (OffsetTop() + NormalizeTop()); };
	this.PageBottomLeft.X = function () { return (OffsetLeft() + NormalizeLeft()); };
	this.PageBottomLeft.Y = function () { return (OffsetTop() + Height() - 1 + NormalizeTop()); };
	//alert(OffsetTop() + " - " + (Height() - 1) + " - " + NormalizeTop()); 
	this.PageTopRight.X = function() { return (OffsetLeft() + Width() - 1 + NormalizeLeft()); };
	this.PageTopRight.Y = function() { return (OffsetTop() + NormalizeTop()); };
	this.PageBottomRight.X = function () { return (OffsetLeft() + Width() - 1 + NormalizeLeft()); };
	this.PageBottomRight.Y = function () { return (OffsetTop() + Height() - 1 + NormalizeTop()); };
}