
var Photos = {
	body:null,
	matte:null,
	img:null,
	make:function(){
		//alert("load ")
		var imgs = document.getElementById("page").getElementsByTagName("img");
		for(var i = 0; i < imgs.length; i++){
			var src = imgs[i].getAttribute("src");
			if(imgs[i].className.indexOf("photo") >= 0 && src.match(/_square|_small|_medium/)){
				imgs[i].style.cursor = "pointer";
				imgs[i].onclick = Photos.enlarge;
			}
		}
	},
	enlarge:function(e){
		var ei = new EventInfo(e, true);
		var src = ei.source.getAttribute("src");
		Photos.body = new Element(document.body);
		Window.construct();
		var matte = Photos.body.append("div", "<span>LOADING</span>", 'class="photomatte" style="width:100%;height:100%;" onclick="Photos.delarge();"');
			matte.style.height = Window.height + 'px';
			matte.style.top = Window.scrolledy + 'px';
			
		Photos.matte = new Animation(matte, {alpha:0.01});
		Photos.matte.element.show('block');
		Photos.matte.effect({alpha:90, duration:0.2, fps:1/50, trans:physics.easeOut});
				
		src = src.replace(/_small|_medium|_square/,'_large');
		var img = Photos.body.append("img", false, 'src="'+src+'" style="visiblity:hidden;position:absolute;top:0;left:0;z-index:6002;"');
			img.onload = Photos.onload;
							
		Photos.img = new Animation(img,{alpha:0.01});	
	},
	onload:function(e){
		Window.construct();
		var ei = new EventInfo(e, true);
		Photos.matte.element.setContent("");

		var left = (Window.width/2) - Photos.img.element.getRealWidth()/2;
		var top = (Window.height/2) + Window.scrolledy - (Photos.img.element.getRealHeight()/2);
		
		Photos.img.element.element.style.top = top + 'px';
		Photos.img.element.element.style.left = left + 'px';
		
		Photos.img.element.show();
		Photos.img.effect({alpha:99.9, duration:0.2, fps:1/50, trans:physics.easeOut});
	},
	delarge:function(){
		Photos.img.effect({alpha:0.01});
		Photos.matte.effect({alpha:0.01}, function(){ 
			Photos.body.element.removeChild(Photos.img.element.element);
			Photos.body.element.removeChild(Photos.matte.element.element);
		});
		
	}
	
}

//addWindowEventListener("load",Photos.make());