/*
 * jQuery position plugin
 * Version 1.0  (07/10/2007)
 * @requires jQuery v1.1.1
 *
 * Copyright (c) 2007 Giuliano Jordao
 */
 (function($) {
/**
 */
$.position = function(el, v, h) {
    $.position.impl.install(el, v, h);
};

// expose version number so other plugins can interogate
$.position.version = 1.00;

// override these in your code to change the default messages and styles
$.position.defaults = {
    vertical:    'center',
    horizontal: 'center'
};

// the gory details
$.position.impl = {
    install: function(el, v, h) {
		var windowFullHeight = $(window).innerHeight();
		var windowFullWidth = $(window).innerWidth();
		
		var popHeight = $(el).height();
		var popWidth = $(el).width();
		var leftPos = 0;
		var topPos = 0;
		
		if (v == "center" && h == "center"){
			leftPos = parseInt((windowFullWidth / 2) - (popWidth / 2)) + "px";
			topPos = parseInt((windowFullHeight / 2) - (popHeight / 2)) + "px";
		}
		if (v == "center"){
			topPos = parseInt((windowFullHeight / 2) - (popHeight / 2)) + "px";
		}
		if (v == "top"){
			topPos = "0px";
		}
		if (v == "bottom"){
			topPos = parseInt(windowFullHeight - popHeight) + "px";
		}
		if (h == "center"){
			leftPos = parseInt((windowFullWidth / 2) - (popWidth / 2)) + "px";
		}
		if (h == "left"){
			leftPos = "0px";
		}
		if (h == "right"){
			leftPos = parseInt(windowFullWidth - popWidth) + "px";
		}

		$(el).css("position", "fixed");
		$(el).css("margin", "0px");
		$(el).css("padding", "0px");
		$(el).css("float", "none");
		$(el).css("display", "block");
		$(el).css("top", topPos);
		$(el).css("left", leftPos);
		
	}
};

})(jQuery);

