//3.20.8.99 11/27/2006  
function ElementStuff(pElement, pString)  //3.20.8.99 11/27/2006 added
  {
    try{document.getElementById(pElement).innerHTML = pString;}
       catch(exception)
	    {alert('ElementStuff - Error:' + pElement + ' ' + pString);
	    }  
  }
function ElementGrab(pElement)  //3.20.8.99 11/27/2006 added
  {try{return document.getElementById(pElement).innerHTML}
   catch(exception)
	{alert('ElementGrab - Error:' + pElement);
	}
  }
function ElementExists(pElementName)
  {
  if (document.getElementById(pElementName) == null)
    {return false;}
  else
    {return true;}
  }
function SMD(pStuff, pGrab)
{
if (ElementExists(pStuff) == true && ElementExists(pGrab) == true)
  {
    ElementStuff(pStuff, ElementGrab(pGrab));
  }
}

 function createCookie(name,value,days)
{
	if (days)
	{
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name)
{
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++)
	{
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}
function eraseCookie(name)
{
	createCookie(name,"",-1);
}

function GotoPage(pstrPage)
  {window.location.href = pstrPage;}
function GotoPageDCMagic(pstrPage)
  {window.dcMagic.location.href = pstrPage;}  //3.20.19.0
function SetFocus(pstrForm, pstElement, pblnNoErrorMsg)
  {
    try{
		document.forms[pstrForm].elements[pstElement].focus();
		document.forms[pstrForm].elements[pstElement].select();
	   }
	catch(exception)
		{if (pblnNoErrorMsg != true)
		  {alert('Error:SetFocus ' + pstrForm +'.' + pstElement);}
		}
  }
	function ExportWindow(pUrl, pType) 
		{ 
		var ExportWindow = null; 
		if (pType == 'D')
		  {ExportWindow = window.open(pUrl,"Export","status,width=650,height=525,resizable=yes, scrollbars=yes"); }
		else
		  {ExportWindow = window.open(pUrl,"ExportChoice","status,width=450,height=210,resizable=yes, scrollbars=yes"); }
		ExportWindow.focus()
		}		
	function HelpWindow() 
		{ 
		var HelpWindow = null; 
		HelpWindow = window.open("Help/User/dynacaluser.htm","Help","status,width=700,height=500,resizable=yes"); 
		HelpWindow.focus()
		}				
	function OneDayWindow(pUrl) 
		{ 
		var OneDayWindow = null; 
		OneDayWindow = window.open(pUrl,"","status,width=700,height=500,resizable=yes,scrollbars=yes"); 
		OneDayWindow.focus()
		}
	function OpenWindowEventDetail(pUrl) 
		{ 
		var OpenWindowEventDetail = null; 
		
		var args = parseQueryString();
		for (var arg in args)
			{
			if (arg == 'trurl')
				{
				
				var args1 = parseQueryString(args[arg]);
				for (var arg1 in args1)
				  {
				  if (arg1 == 'trans')
				    {
					pUrl = pUrl + escape('&trans='+args1[arg1]);
				    }
				  }
				}
			}
		
		OpenWindowEventDetail = window.open(pUrl,"EventDetailWindow","status,width=700,height=500,resizable=yes,scrollbars=yes"); 
		OpenWindowEventDetail.focus()
		}		
				
	function DeleteWindow(pUrl)
		{
		var Dw = null; 
		Dw  = window.open(pUrl,"DeleteUserCalendar","status,width=450,height=75,resizable=no,scrollbars=no"); 
		Dw .focus();
		}

	function SWordOnOff()
		{
		document.getElementById('SMsg').style.display = 'none';
		
		if (document.getElementById('SWord').style.display == 'none')
			{
			 document.getElementById('SWord').style.display = '';
			 document.getElementById('SCat').style.display = 'none';
			}
		else
			{
			 document.getElementById('SWord').style.display = 'none';
			 document.getElementById('SCat').style.display = '';
			}
		}
	function SCatOnOff()
		{
		document.getElementById('SMsg').style.display = 'none';
		
		if (document.getElementById('SCat').style.display == 'none')
			{
			 document.getElementById('SCat').style.display = '';
			 document.getElementById('SWord').style.display = 'none';
			}
		else
			{
			 document.getElementById('SCat').style.display = 'none';
			 document.getElementById('SWord').style.display = ''; 
			}
			
		}
		
		
	 function CheckWSDates(pForm)
	 {
	   var blnContinue = true;
		if (isDate(pForm.WSS.value) == false)
			{blnContinue = false;}
		if (isDate(pForm.WSE.value) == false)
			{blnContinue = false;}
		
		if (blnContinue == true)
		  {
		  if (getDays(pForm.WSS.value, form.WSE.value) > 365)
		    {
		    alert('Please limit the date range to one year or less.');
		    blnContinue = false;
		    }
		  }		  
		
		if (blnContinue == true)
		  {
		  return(true);}
		else
		  {
		  return(false);}
		 
	 }
	 
	function getDays(pdtmStart, pdtmEnd) 
		{
		var dteStartDate = new Date(pdtmStart);
		var dteEndDate = new Date(pdtmEnd);
		var iDateDiff = dteEndDate - dteStartDate; // number of milliseconds between the two
		return(iDateDiff / 86400000);
		}
	
	function isDate(dateStr) 
	{

		var datePat = /^(\d{1,2})(\/|-)(\d{1,2})(\/|-)(\d{4})$/;
		var matchArray = dateStr.match(datePat); // is the format ok?

		if (matchArray == null) {
		    alert("Please enter date as either mm/dd/yyyy or mm-dd-yyyy.");
		    return false;
		}

		month = matchArray[1]; // parse date into variables
		day = matchArray[3];
		year = matchArray[5];

		if (month < 1 || month > 12) { // check month range
		    alert("Month must be between 1 and 12.");
		    return false;
		}

		if (day < 1 || day > 31) {
		    alert("Day must be between 1 and 31.");
		    return false;
		}

		if ((month==4 || month==6 || month==9 || month==11) && day==31) {
		    alert("Month "+month+" doesn't have 31 days!")
		    return false;
		}

		if (month == 2) { // check for february 29th
		    var isleap = (year % 4 == 0 && (year % 100 != 0 || year % 400 == 0));
		    if (day > 29 || (day==29 && !isleap)) {
		        alert("February " + year + " doesn't have " + day + " days!");
		        return false;
		    }
		}
		return true;                           // date is valid
	}		
	function SearchDeptFill(pValue)
	  {
	  document.form1.SD.value = pValue;
	  document.form1.submit();  
	  }
	function SearchCatFill(pValue)
	  {
	  document.form1.SC.value = pValue;
	  document.form1.submit();  
	  }
	  
//if SearchMultiCategories = true and  len0(mstrSearchDept) = true then

	  			function check(field1,field2)
			 {
				if (field1.checked == true) {
					for (i = 0; i < field2.length; i++) {
					field2[i].checked = true;}
				}
				else {
					for (i = 0; i < field2.length; i++) {
					field2[i].checked = false; }
				  }
			}
			function unall(field,field2)
			{
				if (field.checked == true) {
					field2.checked = false; 
				}
			 }
			 
			function checkToggle(fieldchecked,field2) //3.20.18.16 2/4/2008
			{   var blnChecked=true;
				if (fieldchecked == true) 
				    {blnChecked = true;}
				else {blnChecked = false;}

				for (i = 0; i < field2.length; i++) 
				    {field2[i].checked = blnChecked; }
			 }
			 
			function CheckForm(theForm)
			{
				isval = false
				
				if (theForm.SD.length > 0) {
					for (i = 0; i < theForm.SD.length; i++) {
						if (theForm.SD[i].checked == true)	{
							isval = true;
						}
					}
				} else { 
						if (theForm.SD.checked == true){
							isval = true;
						}	
				}
												
				if (isval == false)	{
					alert("Please Select a Department");
				    return(false);
				} 
				
				return (true);
			}
//end if


  function ChameleonCmd(pUrl)
    {
    window.opener.window.location.href = pUrl
    window.close();
    }
  function ChameleonCmd1(pUrl)
    {
    var OneDayWindow = null; 
	OneDayWindow = window.open(pUrl,"DatePicker","status,width=200,height=500,resizable=yes,scrollbars=yes"); 
	OneDayWindow.focus()
    window.close();
    }

   var bSearchPaths = false
   function SearchInfo()
     {
      if (bSearchPaths == false)
        {
		document.getElementById('SearchPaths').style.display='';
		bSearchPaths = true;
		}
	  else
        {
		document.getElementById('SearchPaths').style.display='none';
		bSearchPaths = false;
		}	  
     }
     
function ToggleMultiAnnouncment()
{
    ElementHide('aAnnT');
    ElementShow('aAnn');
    var ele = window.document.forms['frmAnnounce'].elements['txtAnn'];

    if (typeof ele.length == 'undefined') 
        {
         ele.style.display = '';
         ele.style.visibility = 'visible';
        }

    for (i = 0; i < ele.length; i++)
	    {
            ele[i].style.display = '';
            ele[i].style.visibility = 'visible';
	    }
} 

function RunMultiAnnouncment(pUrl)
{
    var str = '';
    var ele = window.document.forms['frmAnnounce'].elements['txtAnn'];

    for (i = 0; i < ele.length; i++)
	    {
	        if (ele[i].checked == true)
	            {str=str+ele[i].value+',';}
	    }
	    window.location.href = 'calendar.asp?' + pUrl + '&SC=' + str;
}    
//3.20.12.35 2/22/2007 added PopWinRegED, isIE, isMac 
function PopWinRegED(pFID)
{
    var OneDayWindow = null; 
    var url = 'Registration_EventDetails.asp?FID='+pFID;
    OneDayWindow = window.open(url,"winRegED","status,width=800,height=800,resizable=yes,scrollbars=yes"); 
    if (isIE() != true && isMac() != true)
      {
    	OneDayWindow.focus();	}
}    
function isIE()
{
	var isNN,blnIE;
	if (parseInt(navigator.appVersion.charAt(0))>=4){
		isNN=(navigator.appName=="Netscape")?1:0;
		blnIE=(navigator.appName.indexOf("Microsoft")!=-1)?1:0;}
	if (blnIE)
		{return true;}
	else
		{return false;}
}
function isMac()
{
	var agt		= navigator.userAgent.toLowerCase();
	var isMac  = (agt.indexOf("mac")!=-1);
		if (isMac)
		  {return true;}
		else
		  {return false;}
}

    function ElementShow(pElement)
      {
        try{
		    document.getElementById(pElement).style.display = '';
		    document.getElementById(pElement).style.visibility = 'visible';
		    }
        catch(exception)
          {alert('ElementShow - Error:' + pElement);}
      }
    function ElementHide(pElement)
      {
        try{document.getElementById(pElement).style.display = 'none';
		    document.getElementById(pElement).style.visibility = ''; }
        catch(exception)
          {alert('ElementHide - Error:' + pElement);}
      }
    function isElementShow(pElement)
      {
        try{if (document.getElementById(pElement).style.display == '' )
			    return true
		    else
			    return false
		    }
        catch(exception)
          {alert('isElementShow - Error:' + pElement);}
      }
	 function CalendarPopup(n, fe) 
	{ 
		var NewWindow = null; 
		NewWindow = window.open("maint/EMSelectDatePopUp.asp?FField=" + n + "&CalSelectDT=" + fe.value ,"SelectDate","status,width=180,height=250,resizable=Yes,scrollbars=no"); 
		NewWindow.focus()
	}  

function ElementClass(pElement, pClassName)
  {
  
	try{document.getElementById(pElement).className = pClassName;}
	catch(exception)
	  {alert('ElementClass - Error:' + pElement);}
  }
function toggleNav(pNav)
{
if (isObject2('divNavEvents') == true)   {ElementClass('divNavEvents', 'divLeftNavOff');}
if (isObject2('divNavEventsB') == true)  {ElementHide('divNavEventsB');}
if (isObject2('divNavCom') == true)      {ElementClass('divNavCom', 'divLeftNavOff');}
if (isObject2('divNavComB') == true)     {ElementHide('divNavComB');}
if (isObject2('divMyDC') == true)        {ElementClass('divMyDC', 'divLeftNavOff');}
if (isObject2('divNavRes') == true)      {ElementClass('divNavRes', 'divLeftNavOff');}
if (isObject2('divNavReg') == true)      {ElementClass('divNavReg', 'divLeftNavOff');}

if (isObject2('divNav'+pNav) == true)      {ElementClass('divNav'+pNav, 'divLeftNavOn');}
if (isObject2('divNav'+pNav) == true)      {ElementShow('divNav'+pNav+'B');}

}	
function isObject2(pElm)
{
  if (document.getElementById(pElm)) {return true;}
    else
        {return false;}

}
function cmdSearch(pThis)
{
if (pThis.txtSearch.value.length == 0)
  {alert('Please provide search criteria.');
   return false;
  }
else
  {
   if (GetComboBoxValue('frm', 'txtSearchType') == 'E' )
    {pThis.action = 'calSearchWord.asp';}
   return true;
  }
}
 function GetComboBoxValue(pForm, pElement)
   {
   var src = GetFormElement(pForm, pElement)
   return src[src.selectedIndex].value
   }
function GetFormElement(pForm, pElement)
	  {
		 var ele = window.document.forms[pForm].elements[pElement];
		return ele;
	  }
   