//<script language="javascript">
var winImgView

function imagePreview(url, guid, size, mode) {
	if (!mode) mode = '';
  var left = screen.availWidth - 480;
  var top = 100;
	if (navigator.userAgent.indexOf('MSIE')!=-1) {
	  if (url!=null) {
	    var s  = '<html><title>image</title>'
	        s += '<body leftmargin=0 topmargin=0 scroll=auto>'
	        s += '<img src="'+url+'" onload="window.opener.resizeImageWindow(window, this.width, this.height)">'
	        s += '</body></html>'
	  }
	  if (guid!=null) {
	    var s  = '<html><title>image</title>'
	        s += '<body leftmargin=0 topmargin=0 scroll=auto><center>'
	        s += '<img src="view.php?type=image&guid='+guid+'&mode='+mode+'&size=original" onload="window.opener.resizeImageWindow(window, this.width, this.height)">'
	        s += '</center></body></html>'
	  }
	  winImgView = window.open('','viewimage','left='+left+',top='+top+',width=480,height=360,scrollbars=1,location=0,resizable=1,modal=1');
	  var o = winImgView.document.open("text/html", "replace");
	  o.write(s);
	} else {
	  if (url!=null) imgurl = url;
	  if (guid!=null) var imgurl = 'view.php?type=image&guid='+guid+'&mode='+mode+'&size=original'
		winImgView = window.open(imgurl,'viewimage','left='+left+',top='+top+',width=480,height=360,scrollbars=1,location=0,resizable=1,modal=1');
	}
}

function resizeImageWindow(win, w, h) {
  var maxW = screen.availWidth * 0.75;
  var maxH = screen.availHeight * 0.75;
  if (w>maxW) w = maxW
  if (h>maxH) h = maxH
  win.resizeTo(w+64, h+64)
  win.moveTo(screen.availWidth - (w+164), 100)
  win.focus()
}

function unitPopup(guid) {
  var left = 600, top = 200;
  window.popup = window.open('index.php?pop=yes&unit='+guid, 'popup', 'left='+left+',top='+top+',width=480,height=360,scrollbars=1,location=0,resizable=1,modal=1')
}

function void_() { }

function goto(anchor) {
	self.location = '#'+anchor;
}

function openWin(href, name, width, height, mode, scroll) {
	var posX = 5; var posY = 5;

	if (mode=="center") {
		posX = (screen.width)?(screen.width-whichWidth)/2:100;
		posY = (screen.height)?(screen.height-whichHeight)/2:100;
	}

	if (navigator.appName == "Microsoft Internet Explorer" && navigator.appVersion.substring(0,1) >= 4) {
	  var features = "toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars="+scroll+",resizable=0,width="+width+",height="+height+",left="+posX+",top="+posY;
		var win = window.open(href, name, features);
		win.opener = self;
	}
	else
	// Open a new window...
	// if (navigator.appName == "Netscape" && navigator.appVersion.substring(0,1) >= 3)
	{
	  var features = "toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars="+scroll+",resizable=0,width="+width+",height="+height+",screenX="+posX+",screenY="+posY;
		var win = window.open(href, name, features);
		siteWindow.opener=self;
	}

}
//</script>