
$.fn.createwindow = function ()
{
	
	var windowwidth		=	$(window).width();
	var windowheight 	= 	$(window).height();
	var height			= 	$(document).height();
	var srciz_width 	= 	$(this).width();
	var srciz_height 	=	$(this).height();

	if(srciz_width<=0)
	{
		alert('Popup content is not loaded properly, please try again..')
		return false;
	}
	
	var left = (windowwidth-srciz_width)/2;
	var top  = (windowheight - srciz_height)/2
	
	/*if(windowsTop<200)
		$('html, body').animate( {scrollTop: 250},500);*/
	
	$("#overlayByN").css({
		"background": '#00000C',  
		"opacity": "0.85",
		"height": height
	});
	$("#overlayByN").fadeIn();
	
	$(this).css({
		position:'fixed',		
		top:top,
		left:left
	});
	$(this).fadeIn();
	//alert(windowwidth+','+windowheight+','+windowsTop+','+srciz_width+','+srciz_height+','+left+','+top)
	
}

$.fn.closewindow = function ()
{
	$(this).fadeOut();
	$("#overlayByN").fadeOut();
}

$(document).ready(function(){
	$("#overlayByN").click(function(){$(".popup").closewindow(1);});						   
	$(document).keypress(function(e){
		if(e.keyCode==27){
			$(".popup").closewindow(1);
		}
	});
});
