/*
 * @File        $RCSfile: openwindow.js,v $
 * @Version     $Revision: 1.5 $
 * @Author      $Author: dirk $ (last checked in by)
 * @Date        $Date: 2003/01/02 09:55:47 $ (UTC date of last check in)
 */

/*
function openWindow('','','') {
	//copyhistory,directories,height=,location,menubar,resizable,scrollbars,status,toolbar,width=
	window.open(URL,windowName,windowFeatures);
}
*/
var w;

function openWindow() {
	var windowpath  = '';
	var windowname  = 'popupWindow';
	var windowWidth = 600;
	var windowHeight = 400;
	var scrollBars = 'no';

	switch(arguments.length) {
		case 0: //e.g. openWindow();
			break;
		case 1: //e.g. openWindow(windowpath);
			windowpath = arguments[0]; break;
		case 2: //e.g. openWindow(windowpath,windowname);
			windowpath = arguments[0];
			windowname = arguments[1]; break;
		case 3: //e.g. openWindow(windowpath,windowname,windowWidth);
			windowpath = arguments[0];
			windowname = arguments[1];
			windowWidth = arguments[2];
			windowHeight = (arguments[2] * 0.75); break;
		case 4: //e.g. openWindow(windowpath,windowname,windowWidth,windowHeight);
			windowpath = arguments[0];
			windowname = arguments[1];
			windowWidth = arguments[2];
			windowHeight = arguments[3]; break;
		case 5: //e.g. openWindow(windowpath,windowname,windowWidth,windowHeight,scrollBars);
			windowpath = arguments[0];
			windowname = arguments[1];
			windowWidth = arguments[2];
			windowHeight = arguments[3];
			scrollBars = arguments[4];
	}
	var windowprops = 'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars='+ scrollBars +',resizable=0,top=100,left=165,width='+ windowWidth +',height='+ windowHeight;
  
	if(windowpath != '') {
   // alert('w = ' + w);
    w = window.open(windowpath,windowname,windowprops);
    w.focus();
  }
	else {
    alert('Please give a windowpath argument with this function');
  }
}

function resizeToFit() {
	var desiredHeight, initialHeight;

	if(b.domie && b.win) {
		desiredHeight = document.body.scrollHeight;
		initialHeight = document.body.clientHeight;
	} else if(b.dom1) {
		desiredHeight = document.height;
		initialHeight = window.innerHeight;
	} else {
		desiredHeight = document.documentElement.scrollHeight;
		initialHeight = document.documentElement.clientHeight;
	}
	if(desiredHeight > initialHeight) { for(i=initialHeight; i<=desiredHeight; i++) { window.resizeBy(0,1); } }
}

function openPictureWindow(urlBegin,pictureURL, width, height, altText) {
  var url = urlBegin + "showpicture.php?picurl=" + pictureURL + "&width=" + width;
  url += "&height=" + height + "&alttext=" + altText;
  openWindow(url, "pic", width + 0, height + 0,0);
}