// window.onload = changeScreenSize;

var debugging= false;

function changeScreenSize()
{
	screenwidth= 800;
	screenheight= 600;
	if (screen) {
		screenwidth= screen.width;
		screenheight= screen.height;
	}
	window.resizeTo(screenwidth,screenheight);
}

function newWindow(URL, woptions, level, wwidth, wheight) {
	screenwidth= 800;
	screenheight= 600;
	windowpadtop= 40;
	windowpadleft= 10;
	wmargin= 20;
	maxlevel= 3;
    if (screen) {
		screenwidth= screen.width;
		screenheight= screen.height;
	}
	if (level<0) {
		leftpos = (screenwidth - wwidth)/2;
		toppos = (screenheight - wheight)/2;
		wname= '';
	} else {
		leftpos = level*wmargin;
		toppos = (maxlevel-level)*wmargin;
		wname= 'Window_' + level;
	}
	maxwidth=  screenwidth - leftpos;
	maxheight= screenheight - toppos;
	if (wwidth==0) {
		wwidth= maxwidth;
	}
	if (wheight==0) {
		wheight= maxheight;
	}
	wwidth= Math.min(maxwidth, wwidth);
	wheight= Math.min(maxheight, wheight);

	if (window.outerWidth) {
		wsize= 'outerWidth='+wwidth
		+ ',outerHeight ='+wheight;
	} else {
		wsize= 'width='+ (wwidth-windowpadtop)
		+ ',height='+ (wheight-windowpadleft)
	}

	if (debugging)
		document.write("<BR>maxheight="+ maxheight +"<BR>screenheight=" +screenheight+ "<BR>toppos=" +toppos+ "<BR>");

	// "dependable=yes, modal=yes,copyhistory=no 
	if (woptions == 'normal') {
		woptions= '';
	} else if (woptions == 'plain') {
		woptions= 
',toolbar=no,location=yes,directories=no,status=yes,menubar=no,scrollbars=yes,resizable=yes';
	} else if (woptions == 'fixed') {
		woptions= 
',toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no';
	}
	win = winopen(URL,wname,
		wsize
		+ ',left='+leftpos
		+ ',top='+toppos
		+ ',screenX='+leftpos
		+ ',screenY='+toppos
		+ woptions);
//	win = window.open(URL,wname,'width='+wwidth+',height='+wheight+',left='+leftpos+',top='+toppos+woptions);
	win.focus();
	return false;
}

function newWindowTest(URL, woptions, level, wwidth, wheight) {
	debugging= true;
	return newWindow(URL, woptions, level, wwidth, wheight);
}

function winopen(URL,wname,woptions)
{
	if (debugging) {
		document.write("URL=" +URL+ "<BR>wname=" +wname+ "<BR>woptions=" +woptions+ "<BR>");
	}
	return window.open(URL,wname,woptions);
}

function empty(item)
{
	if (typeof(item)=="undefined") return true; 
	if (item==null) return true;
	return false; 
}

function form_submit ( ths )
{
  if ( ths.elements['_SUBMITTED'].value=='true' )
  {
    alert ( 'Your form has already been submitted. Thank you.' );
    return false;
  }
  else
  {
    ths.elements['_SUBMITTED'].value = 'true';
    return true;
  }
}

function form_revise ( ths )
{
    ths.form.elements['_SUBMITTED'].value = '';
	return true;
}
