// Example: obj = findObj("image1");
function findObj(theObj, theDoc)
{
  var p, i, foundObj;
  
  if(!theDoc) theDoc = document;
  if( (p = theObj.indexOf("?")) > 0 && parent.frames.length)
  {
    theDoc = parent.frames[theObj.substring(p+1)].document;
    theObj = theObj.substring(0,p);
  }
  if(!(foundObj = theDoc[theObj]) && theDoc.all) foundObj = theDoc.all[theObj];
  for (i=0; !foundObj && i < theDoc.forms.length; i++) 
    foundObj = theDoc.forms[i][theObj];
  for(i=0; !foundObj && theDoc.layers && i < theDoc.layers.length; i++) 
    foundObj = findObj(theObj,theDoc.layers[i].document);
  if(!foundObj && document.getElementById) foundObj = document.getElementById(theObj);
  
  return foundObj;
}

function disableButtons()
{
	if (oButtons = document.getElementsByName('submitButton')){
		for (i = 0; i < oButtons.length; i++){
			oButtons[i].disabled = true;
		}
	}
}

function enableButtons()
{
	if (oButtons = document.getElementsByName('submitButton')){
		for (i = 0; i < oButtons.length; i++){
			oButtons[i].disabled = false;
		}
	}
}

var genericPopWin;
function popGenericWin(oUrl, oWidth, oHeight){
	if(genericPopWin)
	{
		if (!genericPopWin.closed) genericPopWin.close();
  	}
	var str = '';
	if (window.screen) {
		var ah = screen.availHeight - 30; 
		var aw = screen.availWidth - 10; 
 
		var xc = ( aw - oWidth ) / 2; 
		var yc = ( ah - oHeight ) / 2; 
 
		str += ",left=" + xc + ",screenX=" + xc; 
		str += ",top=" + yc + ",screenY=" + yc; 
	}
	var genericPopWin = window.open(oUrl, 'genericPopWin', 'toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=yes, resizable=yes, copyhistory=no, width='+oWidth+', height='+oHeight+str);
	genericPopWin.focus();
}

var genericModalWin;
function popModalWin(oUrl, oWidth, oHeight, oBlank){
	if(genericModalWin && !oBlank)
	{
		if (!genericModalWin.closed) genericModalWin.close();
  	}
	var str = '';
	if (window.screen) {
		var ah = screen.availHeight - 30; 
		var aw = screen.availWidth - 10; 
 
		var xc = ( aw - oWidth ) / 2; 
		var yc = ( ah - oHeight ) / 2; 
 
		str += ",left=" + xc + ",screenX=" + xc; 
		str += ",top=" + yc + ",screenY=" + yc; 
	}
	if (oBlank || window.opener){
		var blankwin = window.open(oUrl, '', 'toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=yes, resizable=yes, copyhistory=no, modal=yes, dialog=yes, dependent=yes, minimizable=no, width='+oWidth+', height='+oHeight+str);
		blankwin.focus();
	} else {
		var genericModalWin = window.open(oUrl, 'genericModalWin', 'toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=yes, resizable=yes, copyhistory=no, modal=yes, dialog=yes, dependent=yes, minimizable=no, width='+oWidth+', height='+oHeight+str);
		genericModalWin.focus();
	}
}

var popUpPdf=0;
function popPdfWin(oPdf){
	if (oPdf){
		if(popUpPdf)
		{
			if (!popUpPdf.closed) popUpPdf.close();
	  	}
		var str = '';
		var oWidth = 720;
		var oHeight = 520;
		if (window.screen) {
			var ah = screen.availHeight - 30; 
			var aw = screen.availWidth - 10; 
	 
			var xc = ( aw - oWidth ) / 2; 
			var yc = ( ah - oHeight ) / 2; 
	 
			str += ",left=" + xc + ",screenX=" + xc; 
			str += ",top=" + yc + ",screenY=" + yc; 
		}
		popUpPdf = window.open(oPdf, 'popUpPdf', 'toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=yes, resizable=yes, copyhistory=no, width='+oWidth+', height='+oHeight+str);
		popUpPdf.focus();
	}
}
