// Added win2col, close, print from BP - 30.10.2006 - MT

function findItem(optionList, text)
{
	if(text.length > 0)
	{
		for(x = 0; x < optionList.options.length; x++)
		{
			if( optionList.options[x].label.substring(0,text.length).toLowerCase() == text.toLowerCase() )
			{
				optionList.selectedIndex = x;
				return;
			}
		}
	}
}

var windowObject;
var popupWindows = new Array();
function popup(url, name, width, height)
{
	var w = screen.availWidth, h = screen.availHeight;
	
	if(width > w)
	{
		width = w;
	}
	
	if(height > h)
	{
		height = h;
	}
	
	var leftPos = (w-width)/2, topPos = (h-height)/2;

	windowObject = window.open(url, '', 'dependent=true;toolbar=no,status=no,scrollbars=yes,location=no,resizable=yes,menubar=no,directories=no,width='+width+',height='+height+ ',top=' + topPos + ',left=' + leftPos);
	if(windowObject != null)
	{
		popupWindows.push(windowObject);
	
		windowObject.focus();
	}
}

function popupWithOptions(url, name, width, height, options)
{
	var w = screen.availWidth, h = screen.availHeight;
	
	if(width > w)
	{
		width = w;
	}
	
	if(height > h)
	{
		height = h;
	}
	
	var leftPos = (w-width)/2, topPos = (h-height)/2;

	windowObject = window.open(url, '', options+',width='+width+',height='+height+ ',top=' + topPos + ',left=' + leftPos);
	if(windowObject != null)
	{
		popupWindows.push(windowObject);
	
		windowObject.focus();
	}
}

function newWindow(url, width, height)
{
	popup(url, '', width, height);
}


function closeAllPopups()
{
	if(window.closed == true)
	{
		for(x=0; x < popupWindows.length; x++)
		{
			if(popupWindows[x] != null)
			{
				if(popupWindows[x].closed == false)
				{
					popupWindows[x].close();
				}
			}
		}
	}
}

function setWindowSize(width, height)
{

	var w = screen.availWidth, h = screen.availHeight;
	
	if(width > w)
	{
		width = w;
	}
	
	if(height > h)
	{
		height = h;
	}
	
	var leftPos = (w-width)/2, topPos = (h-height)/2;
	
	if (document.all) 
	{
					// IE5+ Code
					// note, this code would also run in IE5+, which has partial support
  					// for the W3C DOM. You could also add check for !DOM 
                    // here (&& !(document.getElementById)) and equate dissimilar IE/W3C
                    // DOMs with prototype function, and run all IE5+/NS6+ browsers with
                    // only DOM-standards-compliant code. IE5+ browsers would then drop 
                    // down to third elseif below. 

		self.moveTo(leftPos, topPos);
		self.resizeTo(width,height);
	}
	else if (document.layers)
	{
				  	// NS4+ code 
		window.outerHeight = height;
		window.outerWidth = width; 
		self.moveTo(leftPos, topPos);
	}
	else if (document.getElementById)
	{
  					// NS6+ code         
  					// and IE5+ code you flatten differences between MS DOM and W3C DOM
		window.outerHeight = height;
		window.outerWidth = width; 
		self.moveTo(leftPos, topPos);
	} 
	
}



var sURL;

function doLoad(aURL, timeOut)
{
	if(timeOut == null)
	{
		timeOut = 180000;
	}
    // the timeout value should be the same as in the "refresh" meta-tag
    if(aURL != null)
    {
	    sURL = aURL;
	    setTimeout( "refresh()", timeOut );
    }
}

function refresh()
{
    //  This version does NOT cause an entry in the browser's
    //  page view history.  Most browsers will always retrieve
    //  the document from the web-server whether it is already
    //  in the browsers page-cache or not.
    // 
    window.location.replace( sURL );
}

function trimString (str) 
{
  str = this != window? this : str;
  return str.replace(/^\s+/g, '').replace(/\s+$/g, '');
}

function win2col(url2col){
	window.open(url2col,'BP','width=433,height=500,status=no,resizable=no,top=110,left=200,toolbar=no,menubar=no,scrollbars=yes')
}

function CloseWindow() 
{ 
	window.close(); 
}

function PrintWindow()
{
	window.print();
}

function getBoolValue(value)
{
	return (value === 'true');
}

