function sp (event){
	event.stopPropagation();
}

// #centerscreen

$.fn.centerscreen = function(options){
	var options = $.extend({
		horizontal : true,
		vertical : true,
		animate : true,
		speed : 500,
		parent : false,
		vertical_adjustment : 0,
		horizontal_adjustment : 0,
		w : 0,
		h : 0,
		onresize : 1,
		onresizeanimate : 0
	}, options);
	
	return this.each(function(){
		var el = $(this);

		var ew = el.outerWidth(true);
		var eh = el.outerHeight(true);
		
		if(options.parent){
			var w = el.parent().outerWidth();
			var h = el.parent().outerHeight();
		} else {
			var w = $(window).width();
			var h = $(window).height();
		}
		
		// auto positioning
		if(el.css('position') != 'absolute'){
			el.css('position', 'relative');
		}
		
		if(options.w >0){
			w = options.w-1+1;
		}
		
		if(options.h>0){
			h = options.h-1+1;
		}
		
		var w = (options.horizontal_adjustment-1+1)+w;
		var h = (options.vertical_adjustment-1+1)+h;

		var cssoptions = '';
		var cssoptions = {};

		if(ew < w){
			if(options.horizontal){
				cssoptions.left = (w-ew)/2+'px';
			}
		} else {
			cssoptions.left = 0;
		}

		if(eh < h) {
			if(options.vertical){
				cssoptions.top = (h-eh)/2+'px';
			}
		} else {
			cssoptions.top = 0;
		}
		if(options.animate){
			el.stop().animate(cssoptions, {queue : false, duration : options.speed});
		} else {
			el.stop().css(cssoptions);
		}

		if(options.onresize){
		options.onresize = 0;
		options.animate = options.onresizeanimate;
		$(window).bind('resize', function(){
			el.centerscreen(options);
		});
		}

		el.show();

	});

};

