// 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 IsNumeric(input)
{
    return (input - 0) == input && input.length > 0;
}

var winW = 630;
var winH = 460;
var winX = 0;
var winY = 0;
function getWindowSize() {
		if (document.body && document.body.offsetWidth) {
		 winW = document.body.offsetWidth;
		 winH = document.body.offsetHeight;
		}
		if (document.compatMode=='CSS1Compat' &&
			document.documentElement &&
			document.documentElement.offsetWidth ) {
		 winW = document.documentElement.offsetWidth;
		 winH = document.documentElement.offsetHeight;
		}
		if (window.innerWidth && window.innerHeight) {
		 winW = window.innerWidth;
		 winH = window.innerHeight;
		}
		winX = (document.all)?window.screenLeft:window.screenX;
		winY = (document.all)?window.screenTop:window.screenY;
}

var audioplayermenu;

function newWindowMobile(URL, wname) {
	window.wname = winopen(URL, wname,
		'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no' );
	window.wname.focus();
	return false;
}

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 (IsNumeric(level)) {
		if (level<0) {
			leftpos = (screenwidth - wwidth)/2;
			toppos = (screenheight - wheight)/2;
			wname= '';
		} else {
			leftpos = level*wmargin;
			toppos = (maxlevel-level)*wmargin;
			wname= 'Window_' + level;
		}
	} else {
		wname= level;
		leftpos = (screenwidth - wwidth);
		toppos = (screenheight - wheight)/2;
	}
	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);

	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';
	}

	if ((typeof audioplayermenu == 'undefined') 
		 || (audioplayermenu.closed)){
		audioplayermenu = winopen(URL,'audioplayermenu',
			wsize
			+ ',left='+leftpos
			+ ',top='+toppos
			+ ',screenX='+leftpos
			+ ',screenY='+toppos
			+ woptions);
		audioplayermenu.focus();
//	win = window.open(URL,wname,'width='+wwidth+',height='+wheight+',left='+leftpos+',top='+toppos+woptions);
	} else {
		audioplayermenu.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;
}

