﻿/***************************/
//@Author: Kenneth Pierce
//@website: www.miscarchives.com
//@email: knyrii@gmail.com
/***************************/
var PopUpForm=function(id){
	var t=this;
	t.status=0;
	t.id='#'+id;
	t.load=function(){
		if(this.status==0){
			$('#backgroundPopup').css({'opacity':'0.7'});
			$('#backgroundPopup').fadeIn('slow');
			$(this.id).fadeIn('slow');
			this.status=1;
		}
	}
	t.disable=function(){
		if(this.status==1){
			$('#backgroundPopup').fadeOut('slow');
			$(this.id).fadeOut('slow');
			this.status=0;
		}
	}
	t.center=function(){
		var wh=$(window).height();
		var ww=$(window).width();
		var ph=$(this.id).height();
		var pw=$(this.id).width();
		$(this.id).css({
			'position':'absolute',
			'top':wh/2-ph/2+$(window).scrollTop(),
			'left':ww/2-pw/2+$(window).scrollLeft()
		});
		$('#backgroundPopup').css({'height':wh});
	}
	$(t.id+'button').click(function(e){t.center();t.load();e.preventDefault();});
	$(t.id+' .close').click(function(e){t.disable();e.preventDefault();});
	$('#backgroundPopup').click(function(){t.disable();});
}
