// JavaScript Document

$(document).ready(function(){
			//Examples of how to assign the ColorBox event to elements
			$("a[rel='example1']").colorbox({transition:"none", width:"350px", height:"400px"});
			
			//Example of preserving a JavaScript event for inline calls.
			$("#click").click(function(){ 
				$('#click').css({"background-color":"#f00", "color":"#fff", "cursor":"inherit"}).text("Open this window again and this message will still be here.");
				return false;
			});
		});

jQuery.fn.center = function (args) {
    var defaults = { vertical: true, horizontal: true, fixed: false }, settings = $.extend({}, defaults, args);
    return this.each(function () {
        var $this = $(this); $window = $(window);
        jsCenterScreen();
        if (settings.fixed) { $window.bind('resize', function () { jsCenterScreen(); }); }
        function jsCenterScreen() {
            if (settings.fixed) {
                $width = $this.outerWidth(); $height = $this.outerHeight(); $css = { position: 'fixed' };
                if (settings.vertical) { $css.top = $window.height() / 2 - $height / 2 + "px" }
                if (settings.horizontal) { $css.left = $window.width() / 2 - $width / 2 + "px" }
            } else {
                $width = $this.width(); $height = $this.height(); $css = { position: 'absolute' };
                if (settings.vertical) { $css.top = ($window.height() - $height) / 2 + $window.scrollTop() + "px" }
                if (settings.horizontal) { $css.left = ($window.width() - $width) / 2 + $window.scrollLeft() + "px" }
            }
            $this.css($css);
        }
    });
};

function showForm() {
        $('body').append('<div class="divShowForm-overlay"></div>').fadeIn("600");
        $('.divShowForm').center({ fixed: true }).fadeIn("600");
		$('.divShowForm-overlay').click(function (e) { hideForm(); });     
    return false;
}

hideForm = function () {
    $('.divShowForm').fadeOut("400");
    $('.divShowForm-overlay').fadeOut("600").remove();
    return false;
}
