$(document).ready(function() {
	OverLay.initialize();
	CloseHanlder.close();
});

if (!OverLay) var OverLay = {  }
if (!CloseHanlder) var CloseHanlder = {  }

CloseHanlder.close = function()
{
	$( "#overlay-form-container>img" ).click( function(){

		var width = $( "#overlay-form-container" ).width()/2;
		var height = $( "#overlay-form-container" ).height()/2;
		$( "#overlay-form-container" ).hide();
		$( "#overlay-container").hide();
//		$( "#overlay-form-container" ).animate({  "width": width, "height": height },200,function() { $( "#overlay-form-container" ).hide()  }); 
	});
}
OverLay.hide = function()
{
	$( "#overlay-form-container" ).css( {"display":"none"} );
}
OverLay.initTop = 0;
OverLay.initialize = function()
{
	OverLay.opacityBody();
	OverLay.Move();
}
OverLay.Move = function()
{
	$(document).scroll( function(){
		var bodyTop = $(document).scrollTop();
		var top = OverLay.initTop + bodyTop;

		$( "#overlay-form-container" ).animate( { "top": top  }, 100, function(){} );
	});
	$(window).scroll( function(){
	}) ;
}


OverLay.opacityBody = function ()
{
	document.getElementById( "overlay-container" ).style.width = document.body.offsetWidth + "px";
	document.getElementById( "overlay-container" ).style.height = document.body.offsetHeight + "px";
	var left = ($( "#overlay-container").width() - $( "#overlay-form-container" ).width())/2;

	var screenSize = getViewPort();
	var top = (screenSize.height - $( "#overlay-form-container" ).height())/2;

	OverLay.initTop = top;
	$( "#overlay-form-container" ).css( {"left": left + "px", "top": top + "px" } );

//1	alert( document.getElementById( "overlay-container" ).style.zIndex );
}
function getViewPort()
{
 
	 // the more standards compliant browsers (mozilla/netscape/opera/IE7) use window.innerWidth and window.innerHeight
	 
	 if (typeof window.innerWidth != 'undefined')
	 {
		  this.viewportwidth = window.innerWidth;
		  this.viewportheight = window.innerHeight;
	 }
	 
	// IE6 in standards compliant mode (i.e. with a valid doctype as the first line in the document)

	 else if (typeof document.documentElement != 'undefined'
		 && typeof document.documentElement.clientWidth !=
		 'undefined' && document.documentElement.clientWidth != 0)
	 {
		   this.viewportwidth = document.documentElement.clientWidth;
		   this.viewportheight = document.documentElement.clientHeight;
	 }
	 
	 // older versions of IE
	 
	 else
	 {
		   this.viewportwidth = document.getElementsByTagName('body')[0].clientWidth;
		   this.viewportheight = document.getElementsByTagName('body')[0].clientHeight;
	 }

	 g_width = this.viewportwidth;
	 g_height = this.viewportheight;
	 return {"width":g_width, "height":g_height };
}




