      //var oPopup = window.createPopup();
      //var oPopBody = oPopup.document.body;
      var menuX = 150;
      var menuY = 150;
      var menuW = 195;
      var menuH = 200;
      var menuBGColor;
      var blnCompile = false;
// ------------------------------------------------------------------------------------------------------------
function fnPrintReport(divId,_autoclose)
{
    w=window.open('','newwin')
    w.document.write('<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" \
   "http://www.w3.org/TR/html4/loose.dtd">');
    w.document.write('<html><head> \
	<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">');
    if(navigator.appName == 'Microsoft Internet Explorer')
    {
      w.document.write('<LINK href=\"../Includes/eTIME_IE.css\" type=\"text/css\" rel=STYLESHEET>');
    }
    else
    {
      w.document.write('<LINK href=\"../Includes/eTIME.css\" type=\"text/css\" rel=STYLESHEET>');
    }
    w.document.write('<title></title>');
    w.document.write('</head>');
    w.document.write('<body bgcolor="white">'+document.getElementById(divId).innerHTML+'</body>');
    w.document.write('</html>');
		if(_autoclose=="yes")
		{
    window.opener='';
    	w.document.close();
		}
    //print(document);

    //window.close();
    //return false
}
// ------------------------------------------------------------------------------------------------------------
function fnPopulateCatForUpdate()
{
  document.getElementById('catID').value = document.getElementById('selCategory').options[document.getElementById('selCategory').selectedIndex].value;
  document.getElementById('catTEXT').value = document.getElementById('selCategory').options[document.getElementById('selCategory').selectedIndex].text;
}
// ------------------------------------------------------------------------------------------------------------
function fnCreatePopup(_content, _owner)
{

      switch(_owner)
        {
          case "menu":
            menuX = event.clientX;
            menuY = event.clientY;
            menuW = 250;
            menuH = 25;
            menuBGColor = "white";
            break;

          case "profile":
            menuX = event.clientX;
            menuY = event.clientY;
            menuW = 300;
            menuH = 200;
            menuBGColor = "";
            break;

          case "uid":
            menuX = event.clientX;
            menuY = event.clientY;
            menuW = 200;
            menuH = 100;
            menuBGColor = "";
            break;

        }

      oPopBody.style.backgroundColor = menuBGColor;
      oPopBody.style.border = "solid 2px silver";
      oPopBody.style.font = "caption";
      oPopBody.innerHTML = "<b>" + _content + "</b>";
      setTimeout('oPopup.show(menuX, menuY, menuW, menuH, document.body)',300);
      //window.clearTimeout();
}
// ------------------------------------------------------------------------------------------------------------
function fnHidePopUp()
{
  oPopup.hide();
}
// ------------------------------------------------------------------------------------------------------------
/*function fnOpenCal(_target)
//{
        /*settings="toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,width=450,height=300,left=250,top=250";
        window.open("calendar.php?target=" + _target ,"cal",settings);*/
    //var sRtn;
    //sRtn = showModalDialog("cal.htm","","center=yes;resizable:no;scroll:no;status:no;dialogWidth=250px;dialogHeight=350px;dialogLeft:500;dialogTop:200");
    //sRtn = window.open("cal.htm","","center=yes;resizable:no;scroll:no;status:no;dialogWidth=250px;dialogHeight=350px;dialogLeft:500;dialogTop:200");
   // _target.value = sRtn;
//}
// ------------------------------------------------------------------------------------------------------------
function fnOpenAbs(_absid)
{
        settings="toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,width=250,height=200,left=250,top=250";
        AbsenceWindow=window.open("EditAbsent.php?absentid=" + _absid ,'Absence',settings);
}
// ------------------------------------------------------------------------------------------------------------
function fnPTOBYDATE(_ptobydate)
{
        settings="toolbar=no,location=no,directories=yes,status=yes,menubar=yes,scrollbars=yes,resizable=yes,width=800,height=500,left=100,top=150";
        //PTOWindow=window.open("PTOByDate.php?ptodate=" + _ptobydate ,'PTOBYDATE',settings);
        PTOWindow=window.open("PTOForm.php?ptodate=" + _ptobydate ,'PTOBYDATE',settings);
}

// ------------------------------------------------------------------------------------------------------------
function fnOpenActionWindow(_url)
{
        settings="toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=yes,resizable=yes,width=800,height=200,left=100,top=250";
        window.open(_url ,"Action",settings);
}
// ------------------------------------------------------------------------------------------------------------
function fnOpenAddWindow(_url)
{
        settings="toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=yes,resizable=yes,width=450,height=275,left=250,top=250";
        window.open(_url ,"Action",settings);
        //setTimeout('window.close();',2000);
}
// ------------------------------------------------------------------------------------------------------------
function fnOpenPasswordWindow()
{
        settings="toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=no,resizable=no,width=450,height=350,left=250,top=250";
        window.open('Workspace/Password.php',"Action",settings);
}
// ------------------------------------------------------------------------------------------------------------
function fnCopy(show)
{

  var mydata = document.getElementById(show).innerHTML;

//      window.clipboardData.setData("Text", mydata);
//      alert('Copying data was successfully completed. \n You may now open Excel and Paste data .');
if (window.clipboardData) { // IE send-to-clipboard method.
          window.clipboardData.setData('Text', mydata);

     } else if (window.netscape) {
          // You have to sign the code to enable this or allow the action in about:config by changing user_pref("signed.applets.codebase_principal_support", true);
          netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');

          // Store support string in an object.
          var str = Components.classes["@mozilla.org/supports-string;1"].createInstance(Components.interfaces.nsISupportsString);
          if (!str) return false;
          str.data=mydata;

          // Make transferable.
          var trans = Components.classes["@mozilla.org/widget/transferable;1"].createInstance(Components.interfaces.nsITransferable);
          if (!trans) return false;

          // Specify what datatypes we want to obtain, which is text in this case.
          trans.addDataFlavor("text/unicode");
          trans.setTransferData("text/unicode",str,mydata.length*2);

          var clipid=Components.interfaces.nsIClipboard;
          var clip = Components.classes["@mozilla.org/widget/clipboard;1"].getService(clipid);
          if (!clip) return false;

          clip.setData(trans,null,clipid.kGlobalClipboard);
     }
  if(document.getElementById('divStatus'))
    {
      document.getElementById('divStatus').innerHTML = '<b>Data was successfully copied to clipboard</b>';
    }
  else
    {
      alert('Data was successfully copied to clipboard.');
    }

}
// ------------------------------------------------------------------------------------------------------------
function fnSubmit(_action)
{
  switch(_action)
    {
      case "EditClient":
        document.frmEditClient.action = "ClientsManager.php";
        document.frmEditClient.submit();
        break;
    }
}
// ------------------------------------------------------------------------------------------------------------
function fnToggleColor(_line)
{
  var thisline = _line;

  if(thisline.style.backgroundColor == 'white')
    {
      thisline.style.backgroundColor='LemonChiffon';
    }
  else
    {
      thisline.style.backgroundColor='white';
    }

}
// ------------------------------------------------------------------------------------------------------------
function fnToggleOverflow(_div)
{
  var thisdiv = document.getElementById(_div);
  if(thisdiv.style.overflow == 'auto')
    {
      thisdiv.style.overflow = '';
      document.getElementById('divStatus').innerHTML = '<b>No Scroll</b>';
    }
  else
    {
      thisdiv.style.overflow = 'auto';
      document.getElementById('divStatus').innerHTML = '<b>Auto Scroll</b>';
    }
}
// ------------------------------------------------------------------------------------------------------------
function fnMakeUserID(fname,lname)
{
  var UserID = fname.substring(1) + lname;
  alert(UserID);
}
// ------------------------------------------------------------------------------------------------------------
function fnTest()
{
  alert(date);
}
// ------------------------------------------------------------------------------------------------------------
function fnCheckAdjustedHours()
{
  if(document.forms.frmRejectRow.adjhrs.value > document.forms.frmRejectRow.rhours.value)
    {
      alert('Adjusted hours must me less than original hours.');
      document.forms.frmRejectRow.adjhrs.value = 0;
      document.getElementById("submit").disabled=true;
    }
  else
    {
      document.forms.frmRejectRow.getElementById("submit").disabled=false;
    }
}

// ------------------------------------------------------------------------------------------------------------
function fnToggleTree(item)
{
  var _item = document.getElementById(item);
  alert(_item.style.display);

  //var _parent = document.getElementById(parent);
  //var _img = document.getElementById(imgX);

  /*if(_item.style.display=='none')
    {
      _item.style.display = '';
      //_parent.style.color="red";
      //_img.src = "../../images/more.gif";
    }
  else
    {
      _item.style.display = 'none';
      //_parent.style.color="black";
      //_img.src = "../../images/arrow.gif";
    }*/
}
// -------------
function fnGetClientProfile(_client,_id)
{
  var _to_parse_client = _client;
  var _parsed_client = _to_parse_client.split("-");

  document.forms.frmProfile.c_client.value = _parsed_client[0];
  document.forms.frmProfile.c_deptid.value = _id;
}
// --------------
function fnToggleMail()
{
	if(document.getElementById("tblMail").style.display == "none")
	 {
        	document.getElementById("tblMail").style.display="";
	 }
	else
	 {
	        document.getElementById("tblMail").style.display="none";
	 }
}

// --------------
function fnToggleTree(item,img)
{
   //var _item = document.getElementById(item);
  if(document.getElementById(item).style.display =='none')
    {
      document.getElementById(item).style.display = '';
      document.getElementById(img).src = "../../images/exp.gif" ;
    }
  else
    {
      document.getElementById(item).style.display = 'none';
      document.getElementById(img).src = "../../images/details.gif" ;
    }
}
// --------------
function fnPersistTimeFormat(_ptotime)
{
	var strTime = _ptotime;

	if(strTime.length != 6)
	        {
	                alert('Invalid time format. Time must be entered as hhmmss. \r\n Please Try Again');
	                document.getElementById('submit').disabled=true;
	                return false;
		}
	else
	        {
	                document.getElementById('submit').disabled=false;

	        }
}
// -----------------------------------------------------------------------------
function fnCalculateWorkedHours()
{
date1 = new Date();
date2 = new Date();
date3 = new Date();
date4 = new Date();

diff  = new Date();
diff1  = new Date();

diffFINAL = 0;


var FA,FD,SA,SD;
 FA = document.getElementById('FirstArrival').value;
 FD = document.getElementById('FirstDepart').value;
 SA = document.getElementById('SecondArrival').value;
 SD = document.getElementById('SecondDepart').value;

// Validate Time Format --------------------------------------------------------
// Validate First Arrival :
if(FA.indexOf("p") == -1 && FA.indexOf("a") == -1 || FA.indexOf(":") == -1)
 {
	alert('First Arrival Has Invalid Time Format. The Proper Format is : \r\n\r\n\t 7:45am or 12:15pm');
	document.getElementById('FirstArrival').style.backgroundColor = "red";
	document.getElementById('FirstArrival').value = "ERROR";
	document.getElementById('FirstArrival').focus();
	document.getElementById('FirstArrival').select();
	document.getElementById('submit').disabled=true;
        return false;
 }
else
 {
        document.getElementById('FirstArrival').style.backgroundColor = "white";
        document.getElementById('submit').disabled=false;
 }

// Validate First Departure :
if(FD.indexOf("p") == -1 && FD.indexOf("a") == -1 || FD.indexOf(":") == -1)
 {
        alert('First Departure Has Invalid Time Format. The Proper Format is : \r\n\r\n\t 7:45am or 12:15pm');
        document.getElementById('FirstDepart').style.backgroundColor = "red";
	document.getElementById('FirstDepart').value = "ERROR";
	document.getElementById('FirstDepart').focus();
	document.getElementById('FirstDepart').select();
	document.getElementById('submit').disabled=true;
        return false;
 }
else
 {
        document.getElementById('FirstDepart').style.backgroundColor = "white";
        document.getElementById('submit').disabled=false;
 }

// Validate Second Arrival :
if(SA.indexOf("p") == -1 && SA.indexOf("a") == -1 || SA.indexOf(":") == -1)
 {
        alert('First Arrival Has Invalid Time Format. The Proper Format is : \r\n\r\n\t 7:45am or 12:15pm');
        document.getElementById('SecondArrival').style.backgroundColor = "red";
	document.getElementById('SecondArrival').value = "ERROR";
	document.getElementById('SecondArrival').focus();
	document.getElementById('SecondArrival').select();
	document.getElementById('submit').disabled=true;
        return false;
 }
else
 {
        document.getElementById('SecondArrival').style.backgroundColor = "white";
        document.getElementById('submit').disabled=false;
 }

// Validate Second Departure :
if(SD.indexOf("p") == -1 && SD.indexOf("a") == -1 || SD.indexOf(":") == -1)
 {
        alert('Final Departure Has Invalid Time Format. The Proper Format is : \r\n\r\n\t 7:45am or 12:15pm');
        document.getElementById('SecondDepart').style.backgroundColor = "red";
	document.getElementById('SecondDepart').value = "ERROR";
	document.getElementById('SecondDepart').focus();
	document.getElementById('SecondDepart').select();
	document.getElementById('submit').disabled=true;
        return false;
 }
else
 {
        document.getElementById('SecondDepart').style.backgroundColor = "white";
        document.getElementById('submit').disabled=false;
 }

// Starts calculations *********************************

if(FD !="0:00am")
 {

	// First Set of Dates
	date1temp = new Date(document.getElementById('JSDate').value + " " + FA);
	date1.setTime(date1temp.getTime());

	date2temp = new Date(document.getElementById('JSDate').value + " " + FD);
	date2.setTime(date2temp.getTime());

        diff.setTime(Math.abs(date1.getTime() - date2.getTime()))
	timediff = diff.getTime();
		hours1 = Math.floor(timediff / (1000 * 60 * 60));
		timediff -= hours1 * (1000 * 60 * 60);

		mins1 = Math.floor(timediff / (1000 * 60));
		timediff -= mins1 * (1000 * 60);
	// -----------------------------------------------------------------------------

	// Second Set of Dates
       	date3temp = new Date(document.getElementById('JSDate').value + " " + SA);
	date3.setTime(date3temp.getTime());

	date4temp = new Date(document.getElementById('JSDate').value + " " + SD);
	date4.setTime(date4temp.getTime());

        diff1.setTime(Math.abs(date3.getTime() - date4.getTime()))
	timediff1 = diff1.getTime();
		hours2 = Math.floor(timediff1 / (1000 * 60 * 60));
		timediff1 -= hours2 * (1000 * 60 * 60);

		mins2 = Math.floor(timediff1 / (1000 * 60));
		timediff1 -= mins2 * (1000 * 60);
        // -----------------------------------------------------------------------------

	totalMins = parseInt(mins1) + parseInt(mins2)
	totalHours = parseInt(hours1) + parseInt(hours2)

        diffFINAL = totalHours + '.' + totalMins;
 }
else
 {

	date1temp = new Date(document.getElementById('JSDate').value + " " + FA);
	date1.setTime(date1temp.getTime());

	date2temp = new Date(document.getElementById('JSDate').value + " " + SD);
	date2.setTime(date2temp.getTime());

        diff.setTime(Math.abs(date2.getTime() - date1.getTime()))
	timediff = diff.getTime();
		hours1 = Math.floor(timediff / (1000 * 60 * 60));
		timediff -= hours1 * (1000 * 60 * 60);

		mins1 = Math.floor(timediff / (1000 * 60));
		timediff -= mins1 * (1000 * 60);

	totalMins = parseInt(mins1);
	totalHours = parseInt(hours1);

	diffFINAL = totalHours + '.' + totalMins;

 }

if(SA == "0:00am" && SD == "0:00am")
 {
	date1temp = new Date(document.getElementById('JSDate').value + " " + FA);
	date1.setTime(date1temp.getTime());

	date2temp = new Date(document.getElementById('JSDate').value + " " + FD);
	date2.setTime(date2temp.getTime());

        diff.setTime(Math.abs(date2.getTime() - date1.getTime()))
	timediff = diff.getTime();
		hours1 = Math.floor(timediff / (1000 * 60 * 60));
		timediff -= hours1 * (1000 * 60 * 60);

		mins1 = Math.floor(timediff / (1000 * 60));
		timediff -= mins1 * (1000 * 60);

	totalMins = parseInt(mins1);
	totalHours = parseInt(hours1);

	diffFINAL = totalHours + '.' + totalMins;




 }

document.getElementById('TotalHours').value = diffFINAL;
}
// -----------------------------------------------------------------------------
function fnControlOK()
{
	document.getElementById('aOK').style.display="";
}
// -----------------------------------------------------------------------------
function fnCreateDateContainter(_user, container_id,_date,_type,_seldays)
{
	//alert(container_id);
	document.getElementById(container_id).innerHTML = _user + "," + _date + "," + _type + "," + _seldays;
}
// -----------------------------------------------------------------------------
function fnParsePTOIntoArray(_tblid,_container)
{
	var _ycont;
        var _xcont;
        var _rx;
        var _sel;
        var _idx;
        var _datevalue;
        var _dur;

        _sel = document.getElementsByName("selPTOTYPE");
        _dur = document.getElementsByName("selDays");

        for(var _s=0; _s <= _sel.length-1; _s++)
	 {
	        //alert(_sel[_s].value);
	        if(_sel[_s].value == "NA" || _dur[_s].value == 0)
		 {
		        _idx = _sel[_s].id.indexOf("_");
			_datevalue = _sel[_s].id.slice(_idx+1);
		        alert('Please select a valid type and duration for ' + _datevalue);
		        return false;
		 }
	 }


    // Initialize array, get table length and number of rows
    var _fArray = '';
    var lr=document.getElementById(_tblid).rows.length;
    var cont = document.getElementById(_tblid).rows;
    // Loop through all rows in table lr
    for( var rx = 1; rx < lr; rx++)
      {
        if(_fArray.length == 0)
	 {
	        if(document.getElementById(_tblid).rows[rx].cells[4].innerHTML == "N/A")
		 {
		        _fArray = "";
		 }
		else
		 {
                        _fArray = document.getElementById(_tblid).rows[rx].cells[4].innerHTML + "#";
		 }
	 }
	else
	 {
	        if(document.getElementById(_tblid).rows[rx].cells[4].innerHTML == "N/A")
		 {
                 	_fArray = _fArray + "";
		 }
		else
		 {
		 	_fArray = _fArray + document.getElementById(_tblid).rows[rx].cells[4].innerHTML + "#";
		 }
	 }
      		//alert(document.getElementById(_tblid).rows[rx].cells[4].innerHTML);
      }
      document.getElementById(_container).value = _fArray ;
      blnCompile=false;
      document.getElementById('submitpto').style.visibility="visible";
}