// JavaScript Document
jQuery.fn.center = function() {
	return this.each(function(){
			var el = $(this);
			var h = el.height();
			var w = el.width();
			var w_box = $(window).width();
			var h_box = $(window).height();	
			var w_total = (w_box - w)/2; //400
			var h_total = (h_box - h)/2;
			var css = {"position": 'absolute', "left": "0px", "top": h_total+"px", 'opacity' : 0.0,};
			var animate = { "left": w_total+"px", 'opacity' : 1,}
			el.css(css).animate(animate);
			
	});
};



$(function (){
	
   var docHeight = $(document).height();
	
   $("#contactus").click(function(){
	   
	    $("body").append("<div id='overlay'></div>");
	 	$("#overlay")
		  .height(docHeight)
		  .css({
			 'opacity' : 0.0,
			 'position': 'fixed',
			 'top': 0,
			 'left': 0,
			 'background-color': 'black',
			 'width': '100%',
			 'z-index': 5000
          })
		  .animate({	 
			 'opacity' : 0.8,
 
		  }, 500, function(){

			  
		  })
		  .click(function(){
			
			//$(this).remove();		
			
			
		  });  
		  	
		$("#overlay").append("<div id='overlay-box'></div>");
		
		$("#overlay-box")
			.css({
				'width': '690px',
				'height': '300px',
				//'background-color': '#CCC',
				'opacity' : 1,
				'z-index': 7000
			})
			.center();
	   $("#contact-us-form").clone().appendTo("#overlay-box");
	   
	   
	   $("#contact-us-form #close").click(function(){
			
			$("#overlay").remove();		
			
			
		  });  
	});
   
	
	
});
