/*********************************************************************
'***    Program: PopupViewWindow( strURL, strWindow, nWidth, nHeight )
'***    Type: Function
'***
'***    Function: Pops up a new window with displaying the URL passed
'***
'***    Parameters: 
'***		strURL  - the URL to display within the new window
'***
'***
'***
'***    Returns: String
'***    Remarks: none
'***
'***    Created by: Jeffl
'***    Changed by: Jeffl
'***    Last change: 08/10/01
'*********************************************************************/
function PopupViewWindow( strURL, strWindow, nWidth, nHeight, strToolbar, strStatus, strLocation, strDirectories, strMenubar) {
   //Default Page
   var strWindowVal = "New";
   //Default Width
   var nWidthVal = new Number(520);
   //Default Height
   var nHeightVal = new Number(600);
   //Default Toolbar
   var strToolbarVal = "no";
   //Default Statusbar
   var strStatusVal = "no";
   //Default Location
   var strLocationVal = "no";
   //Default Directories
   var strDirectoriesVal = "no";
   //Default Menubar
   var strMenubarVal = "no";

   if (strWindow){
     strWindowVal = strWindow
   }
   if (nWidth){
     nWidthVal = nWidth
   }
   if (nHeight){
     nHeightVal = nHeight
   }
   if (strToolbar){
     strToolbarVal = "yes"
   }
   if (strStatus){
     strStatusVal = "yes"
   }
   if (strLocation){
     strLocationVal = "yes"
   }
   if (strDirectories){
     strDirectoriesVal = "yes"
   }
   if (strMenubar){
     strMenubarVal = "yes"
   }


   aPopupViewWindow = window.open( strURL,strWindowVal,"toolbar=" + strToolbarVal + ",location=" + strLocationVal + ",directories=" + strDirectoriesVal + ",status=" + strStatusVal + ",scrollbars=yes,resizable=yes,width="+nWidthVal.toString()+",height="+nHeightVal.toString()+ ",menubar=" + strMenubarVal);
   aPopupViewWindow.focus();
}
/*********************************************************************
'***    Program: SelectAllCheckBox()
'***    Type: Function
'***
'***    Function: select all checkbox
'***
'***    Parameters: 
'***		none
'***
'***
'***
'***    Created by: jzhou
'***    Changed by: jzhou
'***    Last change: 03/05/2007
'*********************************************************************/
function SelectAllCheckBoxes(){
	var blnFirstCheckValue = GetFirstCheckBox();
	var aDivs = document.getElementsByTagName('input');
	if (blnFirstCheckValue){
		for(var i = 0; i < aDivs.length; i++)
			aDivs[i].checked = false;
	}
	else{
		for(var i = 0; i < aDivs.length; i++)
			aDivs[i].checked = true;		
	}
}

function GetFirstCheckBox(){
	var aDivs = document.getElementsByTagName('input');
	
	for(var i = 0; i < aDivs.length; i++)
	{
		if(aDivs[i].type == "checkbox");
			return aDivs[i].checked;
	}	
}

/*********************************************************************
'***    Program: getSelectedItems( lstWhereToLook )
'***    Type: Function
'***
'***    Function: Enumerates through a list box and returns a comma separated list of selected
'***		items
'***
'***    Parameters: 
'***		lstWhereToLook  - select object to look in
'***
'***    Returns: String
'***    Remarks: none
'***
'***    Created by: Dimab
'***    Changed by: Dimab
'***    Last change: 9/30/99
'*********************************************************************/
function getSelectedItems( lstWhereToLook ) {
	if (lstWhereToLook == null) {
		return "";
	}

	var strResult = "" ;
	for (intItemIndex = 0; intItemIndex < lstWhereToLook.length; intItemIndex++ ) {
		if (lstWhereToLook[intItemIndex].selected) {
			strResult += "," + lstWhereToLook[intItemIndex].value;
		}
	}
	if (strResult.length > 0) {
		return strResult.substring(1); // all but first comma
	}
	return strResult
}

/* function returns [multi]-listbox selected value (if no defaultValue) defaultValue=''   */
function getListBoxSelectedValue(listboxId,defaultValue){
    if (!defaultValue) defaultValue = "";
    var strResult = getSelectedItems(document.getElementById(listboxId));
    return ((Trim(strResult) == "" || strResult == null) ? defaultValue : strResult);
}
