//	pdi_js.js
// 12/01/2008 by TEG
//	This file contains all commonly used js functions
//	on the PDI internet site

	//ShowHideLayer (expand/collapse buttons)
	function ShowHideLayer(boxID) {
		/* Obtain reference for the selected boxID layer and its button */
		var box = document.getElementById("box"+boxID);
		var boxbtn = document.getElementById("btn"+boxID);
		
		/* If the selected box is currently invisible, show it */
		if(box.style.display == "none" || box.style.display=="") {
			box.style.display = "block";
	 		boxbtn.src = "/images/collapse.gif";
		}
		/* otherwise hide it */
		else {
			box.style.display = "none";
			boxbtn.src = "/images/expand.gif";
		}
	}
	
	//popUp(URL, width, height, left, top)
	function popUp(URL,wdth,hght,lt,tp) {
		day = new Date();
		id = day.getTime();
		eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=1,width=" + wdth + ",height=" + hght + ",left = " + lt + ",top = " + tp + "');");
	}
	
	//popUpLB(URL, width, height, left, top) :: with location bar
	function popUpLB(URL,wdth,hght,lt,tp) {
		day = new Date();
		id = day.getTime();
		eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=1,location=1,statusbar=0,menubar=0,resizable=1,width=" + wdth + ",height=" + hght + ",left = " + lt + ",top = " + tp + "');");
	}
	
	//ClearFrame clears contents of iFrame
	function ClearFrame(whichFrame){
		BlankFrame = "<html><BODY  bgcolor=\"#F3F5FA\"></Body></Html>"
  		top.frames[whichFrame].document.open()
  		top.frames[whichFrame].document.write(BlankFrame)
 	}
 	
 	//FormReset(formName) resets form fields on submit
 	function FormReset(whichForm) {
 		setTimeout("document." + whichForm + ".reset()", 500)
 	}
 	
 	//set the background color of onFocus form elements
 	//used by aspx apps
 	var bkColor = "#CCCCFF";
	function getEvent(e){
	  if(window.event != null) {
	    return event;
	  }
	  return e;
	}
	function setBGColor(e){
	 e = getEvent(e);
	 var src =  e.srcElement || e.target;
	 if(src != null) {
	   src.style.bkColor = src.style.backgroundColor;
	   src.style.backgroundColor = bkColor;
	 }
	}
	function reSetBGColor(e){
	 e = getEvent(e);
	 var src =  e.srcElement || e.target;
	 if(src != null) {
	   src.style.backgroundColor = src.style.bkColor;
	 }
	}
	
	//used by aspx pages to pop up calendar
	function GetDate(CtrlName){
   	ChildWindow = window.open('/Apps/include/Calendar.aspx?FormName=' + document.forms[0].name + '&CtrlName=' + CtrlName, "PopUpCalendar", "width=270,height=300,top=200,left=200,toolbars=no,scrollbars=no,status=no,resizable=yes");
   }		
   function CheckWindow(){
   	ChildWindow.close();
   }
   
   //used to (un)check all checkboxes on a form
   function checkAll(id, checked) {
		var el = document.getElementById(id);
		for (var i = 0; i < el.elements.length; i++) {
		  el.elements[i].checked = checked;
		}
   }
   
   