function showmodal(id){
		var scroll = jQuery(window).scrollTop();
		var screenH = jQuery(window).height();
		var screenW = jQuery(window).width();
		
		if(jQuery.browser.safari){
		var screenH = window.innerHeight;	
		}
		
		var winH = jQuery(id).height();
		var winW = jQuery(id).width();			
				
		var docH = jQuery(document).height();
		var docW = jQuery(document).width();
		
		
	

		var maxH = parseInt(winH*0.7);
		var maxW = parseInt(winW*0.8);
		
		var Top_pos = ((screenH/2)-(winH/2));
		//alert(screenH/2);
		var Left_pos = ((screenW/2)-(winW/2));

		//displaying the mask
		jQuery('.mask').css({'width':docW,'height':docH});
		jQuery('.mask').fadeIn(500);	
		jQuery('.mask').fadeTo("slow",0.8);		
		jQuery(id).css('top',  Top_pos);
		jQuery(id).css('left', Left_pos);

		jQuery(id).fadeIn();		
}

function showajax(url){
	if(jQuery("#ajaxbox").length==0){
	jQuery("body").append('<div id="ajaxbox" class="window"><center><img src="../img/loader.gif" /></center></div>')
	}
		jQuery.ajax({
		  url: url,
		  success: function(data) {
		    jQuery('#ajaxbox').html(data);
		    jQuery('#ajaxbox .exit').click(function(){
		    	close_modal();
		    	return false;
		    });
		    showmodal('#ajaxbox');
		  }
		});	
}
function close_modal(){
	jQuery('.mask').hide();
	jQuery('.window').hide();	
	}
this.modal = function() { 
	
jQuery(".ajax").click(function(){
	showajax(jQuery(this).attr('href'));
	return false;	
});	

jQuery(".modal").click(function(){
	var id = jQuery(this).attr('href');
	showmodal(id);	
	return false;	
});

jQuery('.window .exit').live("click",function(){
	close_modal();
	return false;
});	

	//Checking if the mask div exists
	if(jQuery(".mask").length==0){
	jQuery("body").append('<div class="mask"></div>');
	}
};
jQuery(document).ready(function($){modal();}) 
