
function addLoadEvent(func) {
  var oldonload = window.onload;
  if (typeof window.onload != 'function') {
    window.onload = func;
  } else {
    window.onload = function() {
      if (oldonload) {
        oldonload();
      }
      func();
    }
  }
}

addLoadEvent (initShortList);

function helpWindow () {

	helpW = window.open("browserHelp/pages/helpResults.jsp","helpWindow","width=800, height=700, scrollbars=yes");
	helpW.focus();
}

function initShortList () {

		var shortListButtons = new Array("selectAll","deselectAll","invertSelection");
		
	for (i=0; i<shortListButtons.length;i++) {	
	
		if (document.getElementById(shortListButtons[i])) {
		
			var button = document.getElementById(shortListButtons[i]);	
			if  (window.addEventListener){ // Mozilla, Netscape, Firefox
				button.addEventListener('click', shortList, false);
		
			} 
			else { // IE
				button.attachEvent('onclick', shortList);
		
			}	
		}						   
	}
}

function shortListFunctionsDo(action) {
    var input = document.createElement("input");
    input.setAttribute("type", "hidden");
    input.setAttribute("name", action) ;
    input.setAttribute("value", action);
    document.resultsForm.appendChild(input);
    document.resultsForm.submit();
}


function shortList (e) {
		
		var buttonObject = new callingElement(e);
		
		var button = buttonObject.callerId;
	
		if (button=="selectAll") {
			
			var checkboxes = document.getElementsByName("shortListIds");
			
			for (i=0; i<checkboxes.length;i++) {
				checkboxes[i].checked=true;
			}	
		}
		if (button=="deselectAll") {
			
		var checkboxes = document.getElementsByName("shortListIds");
			
			for (i=0; i<checkboxes.length;i++) {
				checkboxes[i].checked=false;
			}	
		}		
		if (button=="invertSelection") {
			
			var checkboxes = document.getElementsByName("shortListIds");
			
			for (i=0; i<checkboxes.length;i++) {
				var action="";	
			
					
				if (action!="changedStatus") {
					if	(checkboxes[i].checked==false) {
						checkboxes[i].checked=true;
						action ="changedStatus";
					
					}
				}		
				if (action!="changedStatus") {
					if	(checkboxes[i].checked==true) {	
						checkboxes[i].checked=false;
					
					}	
				}	
				
			}
		}
};	
		
