var Photo=Class.create();
Photo.prototype={
    initialize:function(obj){
        this.max=obj.parentNode.href;
        this.min=obj.src;
        this.src=obj;
        obj.controller=this;
    },
    state:false,
    toggle:function(){
        if(this.state==false){ this.open(); }
        else{ this.close(); }
    },
    open: function(){
        if(this.state==true) return;
        var temp=this;
        new Effect.Scale(temp.src,210,{
            direction:'bottom-left',
            afterFinish:function(){ with(temp.src){ src=temp.max; style.width="320px"; style.height="320px"; } }
        });
        temp.state=true;
    },
    close:function(){
        if(this.state==false) return;
        var temp=this;
        new Effect.Scale(temp.src,50,{
            direction:'top-right',
            afterFinish:function(){ with(temp.src){ src=temp.min; style.width="120px"; style.height="120px"; } }
        });
        temp.state=false;
    }
}
var note;
var images=[];
window.onload=function(){
    with(document.getElementById("figure").getElementsByTagName("img")){
        for(var i=0;i<length;i++) images.push(new Photo(item(i)));
    }
};
function zoomImage(obj){
    obj.firstChild.controller.toggle();
    for(var i=0;i<images.length;i++){
        if(images[i]==obj.firstChild.controller) continue;
        images[i].close();
    }
    return false;
}

