function Coordinates(x, y)
{
	this._x = x;
	this._y = y; 
}

Coordinates.prototype._x;
Coordinates.prototype._y;

Coordinates.prototype.getX = function()
{
	return this._x;
}

Coordinates.prototype.getY = function()
{
	return this._y;
}

Coordinates.prototype.setX = function(x)
{
	this._x = x;
}

Coordinates.prototype.setY = function(y)
{
	this._y = y;
}


function getViewportPosition()
{
	position_y = 0;
	position_x = 0;
	
	if (window.pageYOffset != undefined)
	{
		position_y = window.pageYOffset;
	}
	else if (document.documentElement.scrollTop != undefined)
	{
		position_y = document.documentElement.scrollTop;
	}

	if (window.pageXOffset != undefined)
	{
		position_x = window.pageXOffset;
	}
	else if (document.documentElement.scrollLeft != undefined)
	{
		position_x = document.documentElement.scrollLeft;
	}
	
	coordinates = new Coordinates(position_x, position_y);
	return coordinates;
}

function placeElementOnScreenCenter(element)
{
	view_pos = getViewportPosition();
	scrollX = view_pos.getX();
	scrollY = view_pos.getY();
	
	position_x = document.documentElement.clientWidth/2 + scrollX - jQuery(element).width()/2;
	position_y = document.documentElement.clientHeight/2 + scrollY - jQuery(element).height()/2;
	element.style.position = "absolute";
	element.style.left = position_x + 'px';
	element.style.top = position_y + 'px';
}

function placeElementOnScreenCenterInJoystampsWrapper(element)
{
	/* Stosowac do elementow umieszczonych wewnatrz diva wrapper w template Joystamps*/
	view_pos = getViewportPosition();
	scrollX = view_pos.getX();
	scrollY = view_pos.getY();
	
	clientWidth = document.documentElement.clientWidth;
	clientHeight = document.documentElement.clientHeight;
	position_x = clientWidth/2 + scrollX - jQuery(element).width()/2 - (clientWidth - 950)/2;
	position_y = clientHeight/2 + scrollY - jQuery(element).height()/2;
	element.style.position = "absolute";
	element.style.left = position_x + 'px';
	element.style.top = position_y + 'px';
}

function placeElementAtMousePointer(element, mouse_event, offset_x, offset_y)
{
	view_pos = getViewportPosition();
	scrollX = view_pos.getX();
	scrollY = view_pos.getY();
    element.style.position = 'absolute';
	position_x = mouse_event.clientX + scrollX + offset_x;
	position_y = mouse_event.clientY + scrollY + offset_y;
	element.style.left=position_x + "px";
	element.style.top=position_y + "px";
}
