/*

REQUIRE:
/_js/var/path.js
/_js/data/numberdirectory.js (for write photo url, wri())


MS=milestone
o=object name
mid = milestoneId
pid = projectId
_PB = photo site base
MS.swt(iid) = switch thumbnail photo (imageFileId)
MS.swc(iid) = switch caption (imageFileId)
MS.pp(iid) = pop photo (imageFileId)
MS.gettc() = get thumbnail container
MS.getc() = get caption div
MS.getcc() = get caption container
MS.hac() = hide all caption
MS.wri(iid, t) = write image tag (imageFileId, type['p'|'t'|'m'])

*/

function MS(o, mid, pid) {

var _PB = photoRootUrl;

this.swt = function(iid) {
	var tc = this.gettc();
	se(tc.id); // ensure display
	tc.innerHTML = this.wri(iid,'t');
	this.swc(iid);
}

this.swc = function(iid) {
	var c = this.getc(iid);
	this.hac();
	if(c) c.style.display = 'block';
}

this.pp = function(iid) {
	var w = window.open(null, 'pp'+iid, 'width=840,height=640,resizable=yes,toolbar=no,status=yes');
	w.focus();
	w.document.write(this.wri(iid,'p'));
	w.document.close();
}

this.hac = function() {
	var cc = this.getcc();
	var ac = gt(cc,'div');
	for (var i=0;i<ac.length;i++) {
		if (ac[i].className == 'c') {
			ac[i].style.display = 'none';
		}
	}
}

this.gettc = function() {
	return ge('t'+mid);
}

this.getcc = function() {
	return ge('cc'+mid);
}

this.getc = function(iid) {
	return ge('c'+iid);
}

this.wri = function(iid, t) {
	var ot;
	if (t=='t') ot = 'onClick="'+o+'.pp('+iid+')"';
	var pstr = NumberDirectory.prototype.write(pid);
	return '<img src="'+_PB+'/p/'+pstr+'/m/'+mid+'/p/'+t+'/'+iid+'.jpg" '+ot+'>';

}

}