﻿
jQuery.fn.locate = function(thisMode, thisOption1, thisOption2, thisPosition) {
	return this.each(function () {
		var _WindowWidth = $(window).width();
		var _WindowHeight = $(window).height();
		var _Top, _Right, _Bottom, _Left;
		var _LocationPoint;
		var _Position = "fixed";
			
		_Top = (_WindowHeight - $(this).height()) / 2; 
		_Left = (_WindowWidth - $(this).width()) / 2;
		
		if(thisPosition) { _Position = "fixed"; }
		
		if(thisMode.toLowerCase() == "grid") {
			_LocationPoint = thisOption1;
			
			switch(_LocationPoint) {
				case 1:
					$(this).css({"position": _Position, "top": 0, "left": 0});
					break;
				case 2:
					$(this).css({"position": _Position, "top": 0, "left": _Left});
					break;
				case 3: 
					$(this).css({"position": _Position, "top": 0, "right": 0});
					break;
				case 4:
					$(this).css({"position": _Position, "top": _Top, "left": 0});
					break;
				case 5:
					$(this).css({"position": _Position, "top": _Top, "left": _Left});
					break;
				case 6:
					$(this).css({"position": _Position, "top": _Top, "right": 0});
					break;
				case 7: 
					$(this).css({"position": _Position, "bottom": 0, "left": 0});
					break;
				case 8:
					$(this).css({"position": _Position, "bottom": 0, "left": _Left});
					break;
				case 9: 
					$(this).css({"position": _Position, "bottom": 0, "right": 0});
					break;
			}
		} else {
			$(this).css({"position": thisPosition, "top": thisOption1, "left": thisOption2});
		}
	});
};


jQuery.fn.locateEL = function() {
	this.each(function () {
		alert("EL TEST");
	});
};
