﻿jQuery.fn.centerHorizontal = function(container)
{
    if (container != undefined)
    {
        return this.each(function()
        {
            var element = jQuery(this);

            element.css(
        {
            left: ($('#' + container).width() / 2) - (jQuery(this).width() / 2)
        });

        });
    }
    else
    {
        return this.each(function()
        {
            var element = jQuery(this);

            element.css(
        {
            left: ($(window).width() / 2) - (jQuery(this).width() / 2)
        });
        });
    }
};

jQuery.fn.centerVertical = function(container)
{
    if (container != undefined)
    {
        return this.each(function()
        {
            var element = jQuery(this);

            element.css(
        {
            top: ($('#' + container).height() / 2) - (jQuery(this).height() / 2)
        });
        });
    }
    else
    {
        return this.each(function()
        {
            var element = jQuery(this);

            element.css(
        {
            top: ($(window).height() / 2) - (jQuery(this).height() / 2)
        });
        });
    }
};
