var win = null;
function centrepop(mypage,myname,w,h,scroll,resize){
leftedge = (screen.width) ? (screen.width-w)/2 : 0;
topedge = (screen.height) ? (screen.height-h)/2 : 0;
settings ='height='+h+',width='+w+',top='+topedge+',left='+leftedge+',scrollbars='+scroll+',resizable='+resize+''
win = window.open(mypage,myname,settings)
}


function popup(url,windowname,width,height) {
  width=(width)?width:screen.width/3;
  height=(height)?height:screen.height/3;
  var screenX = (screen.width/2 - width/2);
  var screenY = (screen.height/2 - height/2);
  var features= "width=" + width + ",height=" + height;
  features += ",screenX=" + screenX + ",left=" + screenX;
  features += ",screenY=" + screenY  +",top=" + screenY;
  var mywin=window.open(url, windowname, features);
  if (mywin) 
    mywin.focus();
  return mywin;
}

var myimage = new Image();
var popupwin=null;

myimage.onload=function(){popupwin=popup(this.src,"pic",this.width,this.height)}

function popIt(what){
if (popupwin && !popupwin.closed)popupwin.close();
myimage.src=what;}

function LightboxDelegate(url,caption) {
var objLink = document.createElement('a');
objLink.setAttribute('href',url);
objLink.setAttribute('rel','lightbox');
objLink.setAttribute('title',caption);
Lightbox.prototype.start(objLink);
}
