var isMac = (navigator.appVersion.indexOf("Mac") != -1);

function popImage1(pic,imgWid,imgHei,title,trackimageview) {
  var wid = imgWid, hei = imgHei;
  var left = (screen.availWidth-wid)/2;
  var top = (screen.availHeight-hei)/2;
  var cURL = '/imgviewer.html?img=' + pic + ((title)?"&title="+escape(title):"") + '&w='+imgWid + '&h='+imgHei + '&trackview='+trackimageview;
 
  return openWin(cURL,'selffipop','width='+wid+',height='+hei+',top='+top+',screenY='+top+',left='+left+',screenX='+left);
}


var objWin = null;

function openWin(theURL,winName,features) {
  if (objWin && !isMac && objWin.open) objWin.close();
  objWin = window.open('',winName,features);
  if (objWin.focus) objWin.focus();
  if (theURL) objWin.document.location.replace(theURL);
  return false;
}

function resizeWin() {
  /***********************************************
   * Auto resize Window Script- © Dynamic Drive (www.dynamicdrive.com)
   * This notice must stay intact for use
   * Visit http://www.dynamicdrive.com/ for this script and 100's more.
   ***********************************************/

  var newwidth = 800;
  var newheight = 600;
  
  if (window.resizeTo) {
    window.resizeTo(newwidth,newheight);
  }
  else if (window.outerHeight) {
    if (window.outerHeight<=newheight||window.outerWidth<=newwidth) {
      window.outerHeight = newheight;
      window.outerWidth = newwidth;
    }
  }
  if (window.moveTo) window.moveTo((screen.width-newwidth)/2,(screen.height-newheight)/2);
}

// from scottandrew.com/junkyard/js/
// copyright 2001 scott andrew lepera, damn you!
// addEvent and removeEvent
// cross-browser event handling for IE5+,  NS6 and Mozilla
 
function addEvent(elm, evType, fn, useCapture)
{
  if (elm.addEventListener){
    elm.addEventListener(evType, fn, useCapture);
    return true;
  } else if (elm.attachEvent){
    var r = elm.attachEvent("on"+evType, fn);
    return r;
  } else {
    alert("Event handler could not be added");
  }
} 
 
function removeEvent(elm, evType, fn, useCapture)
{
  if (elm.removeEventListener){
    elm.removeEventListener(evType, fn, useCapture);
    return true;
  } else if (elm.detachEvent){
    var r = elm.detachEvent("on"+evType, fn);
    return r;
  } else {
    alert("Event handler could not be removed");
  }
}
 