	var heights = new Array ();
	var widths = new Array ();
	var srcd = new Array ();
	
	var initialized = 0;

	$(document).ready(function () {
		$('#ppp').hide(100);
	});
	
	function initMe () {
		  $('img').each(function (i) {
			var src = this.src;
			if (src.match(/_t.jpg/) && $(this).parent().attr('href') === undefined) {
				this.id = "img_" + i;
				var n = $(this).attr('width') / $(this).attr('height');
				var wh = $(window).height()-40;
				if (wh > 600) wh = 600;
				if (wh < 200) wh = 200;
				heights[this.id] = wh;
				widths[this.id] = Math.round(wh*n);
				src = src.replace(/_t.jpg/,"_d.jpg");
				srcd[this.id] = src;
				$(this).bind("click", function(e){
					popMe(this);
				});
				
				$(this).bind("mouseover", function(e){
					overppp = 1;
				});
				$(this).bind("mouseout", function(e){
					overppp = 0;
				});
				
			}
		  });
		initialized = 1;
	}


	var poppedUp = 0;
	var poppingUp = 0;
	
	var overppp = 0;
	var pppx = 0;
	var pppy = 0;
	
	// var mouseDown = 0;
	
	
	function pppMouseDown (x) {
		// mouseDown = 1;
		pppy = $("#ppp").position().top;
		pppx = $("#ppp").position().left;
	}
	
	function pppMouseUp () {
		var npppy = $("#ppp").position().top;
		var npppx = $("#ppp").position().left;
		if (npppy == pppy && npppx == pppx)
			downAll ();
	}
	
	
	function downAll () {
		if (overppp == 1)
			return;
		if (initialized == 0)
			return;
		if (poppingUp == 1)
			return;
		if (poppedUp == 1) {
			$('#ppp').hide(1000);
			poppedUp = 0;
		}
	}
	
	function popMe (me) {
		if (initialized == 0)
			return;
		if (poppingUp == 1)
			return;
		if (poppedUp == 1) {
			poppingup = 1;
			var ID = me.id;
			var I = $('#'+ID);
			var theight = heights[ID];
			var twidth = widths[ID];
			var tsrc = srcd[ID];
			$('#ddd').attr('src',tsrc);
			$('#ppp').css({
				'width': twidth,
				'height': theight
			}, 750 );
			$('#ddd').animate({
				'width': twidth,
				'height': theight
			}, 750 );
			
			$('#ddd').animate({'opacity': 1}, 2000,function () { poppingup = 0; } );
			return;
		}
		poppingUp = 1;
		var ID = me.id;
		var I = $('#'+ID);
		var vtop = I.position().top;
		var vleft = I.position().left+5;
		var vscroll = $(window).scrollTop();
		var vheight = I.height();
		var vwidth = I.width();
		
		var theight = heights[ID];
		var twidth = widths[ID];
		var tsrc = srcd[ID];
		
		var wwidth = $(window).width();
		
		var ttop = vscroll+10;
		if (ttop < 450)
			ttop = 450;
		var tleft = Math.round((wwidth - twidth) / 2);
		
		$('#ppp').css({'top':vtop, 'left':vleft, 'scrollTop':vscroll, 'height': vheight, 'width': vwidth, 'opacity':0});
		$('#ddd').css({'height': vheight, 'width': vwidth});
		$('#ddd').attr('src',tsrc);
		$('#ddd').animate({
			'width': twidth,
			'height': theight
		}, 750 );
		$('#ppp').animate({
			'width': twidth,
			'opacity': 1,
			'height': theight,
			'top': ttop,
			'left':tleft
		}, 1500, function() {
			poppedUp = 1;
			poppingUp = 0;
		});
	}
