function photoAlbum(w,h,n,c,r,ct) {
this.photos=new Array();
this.cimgs=new Array(null,null,null,null,null,null);
this.width=w;
this.height=h;
this.name=n;
this.css=c;
this.resizable=r;
this.controls=ct;
this.curImg=0;
this.buttons=new Array(null,null,null);
this.winRef=null;
this.show=paOpenImg;
this.add=paAddImg;
this.setImg=paSetImg;
this.pSwitch=paSwitch;
}

function paSetImg(i,s) {
if(i>-1 && i<6) {
this.cimgs[i]=new Image();
this.cimgs[i].src=s;
}
}

function paSwitch(i,s) {
eval("this.winRef.document.pbt"+i+".src=this.cimgs["+((i<<1)+s)+"].src");
}

function makeButtons(o) {
for(i=0; i<3; i++) {
var j=i<<1;
wrd=i==0 ? "Prev" : i==1 ? "Next" : "Close";
fn=(i==0) ? "opener."+o.name+".show("+(o.curImg-1)+");" : (i==1) ? "opener."+o.name+".show("+(o.curImg+1)+");" : "window.close();";
o.buttons[i]="<a href='' onclick='"+fn+"return false;'"+(o.cimgs[j] ? (o.cimgs[j+1] ? " onmouseover='opener."+o.name+".pSwitch("+i+",1);' onmouseout='opener."+o.name+".pSwitch("+i+",0);'" : "")+"><img name='pbt"+i+"' src='"+o.cimgs[j].src+"' border=0 alt='"+wrd+"'>" : ">"+wrd)+"</a>";
}
}

function paOpenImg(n) {
var o=this.photos[n];
this.curImg=n;
makeButtons(this);
var nw=window.open("", "photoAlbum", "toolbar=0,location=0,menubar=0,scrollbars=1,resizable="+(this.resizable ? "1" : "0")+",width="+this.width+",height="+this.height);
this.winRef=nw;
var paStr="<html><head><title>"+o.title+"</title><link rel='stylesheet' href='"+this.css+"' type='text/css'></head>";
paStr+="<body marginwidth=0 marginheight=0 topmargin=0 leftmargin=0 bottommargin=0 rightmargin=0>";
paStr+="<table width="+o.width+" cellpadding=0 cellspacing=0 border=0 align='center'><tr><td colspan=3 align='center'>";
paStr+="<span class='pTitle'>"+o.title+"</span></td></tr><tr><td colspan=3>";
o.title=o.title.replace(/'/,"`");
paStr+="<img src='"+o.src+"' width="+o.width+" height="+o.height+" border=0 alt='"+o.title+"'>";
if(this.controls) {
paStr+="</td></tr><tr><td colspan=3 height=5><span class='empty'>&nbsp;</span></td></tr><tr><td width='33%' align='left'>";
paStr+=(n-1<0) ? "<span class='empty'>&nbsp;</span>" : this.buttons[0];
paStr+="</td><td width='34%' align='center'>";
paStr+=this.buttons[2];
paStr+="</td><td width='33%' align='right'>";
paStr+=(n+1<this.photos.length) ? this.buttons[1] : "<span class='empty'>&nbsp;</span>";
}
paStr+="</td></tr></table>";
nw.document.open();
nw.document.write(paStr);
nw.document.close();
nw.focus();
}

function paAddImg(s,w,h,t) {
var o=new Object();
o.src=s;
o.width=w;
o.height=h;
o.title=t;
this.photos=this.photos.concat(o);
}

