var modalWindow = {
	parent:"body",
	windowId:null,
	content:null,
	width:null,
	height:null,
	close:function()
	{
		$(".modal-window").remove();
		$("#overlay").remove();
		$("#modalWrap").remove();
	},
	open:function()
	{

		if (typeof document.body.style.maxHeight === "undefined") { //if IE 6
			$("body","html").css({'height' : '100%', 'width' : '100%'});
		}
		
		$('<div>').attr('id', 'modalWrap').appendTo(this.parent);
		var overlay = $('<div>').attr('id', 'overlay').appendTo('#modalWrap');
		
		var modal = $('<div>').attr('id', 'modal-window').appendTo('#modalWrap');
		var imgWidth = this.width;
		var content = this.content;
		
		//content.replace('w=310', imgWidth);
		//alert(this.content);
		$(modal).html('<img src="' + content.replace('w=310', 'w=' + imgWidth) + '" />').css({
																
								  'opacity' : 0, 
								  'width' : this.width + 'px', 
								  'height' : this.height + 'px', 
								  /*'margin-top' : - (this.height /2) + 'px', */
								  'margin-left' : - (this.width / 2) + 'px'
								  });
		
						if ( !(jQuery.browser.msie && jQuery.browser.version < 7)) { // take away IE6
    						$(modal).css({
    							"margin-top": - (this.height /2) + 'px'
    						});
                		}
		
		$(overlay).css({ 'opacity' : 0}).animate({'opacity' : .6}, 1000, function(){
			
			$(modal).animate({'opacity' : 1}, 500);
		});


		$(".modal-window").append("<a class=\"close-window\"></a>");
		$(".close-window").click(function(){modalWindow.close();});
		
		$("#overlay").click(function(){modalWindow.close();});
	}
};
