function resetFilters()
{
    
    document.getElementById('_ctl2_tbWSTicketNumber').value = "";
    document.getElementById('_ctl2_ddlWSType').options[parseInt(document.getElementById('_ctl2_ddlWSType').options.length -1)].selected = true;
    document.getElementById('_ctl2_tbWSTask').value = "";
    document.getElementById('_ctl2_ddlWSRoute').options[parseInt(document.getElementById('_ctl2_ddlWSRoute').options.length -1)].selected = true;
    document.getElementById('_ctl2_ddlWinTeamCompanies').options[parseInt(document.getElementById('_ctl2_ddlWinTeamCompanies').options.length -1)].selected = true;
    document.getElementById('_ctl2_cbNotDone').checked = false;
    document.getElementById('_ctl2_cbSkipped').checked = false;
    document.getElementById('_ctl2_cbWaived').checked = false;
    document.getElementById('_ctl2_cbDone').checked = false;
    document.getElementById('tbDateCompletedFromDate').value = document.getElementById('tbFromDate').value;
    document.getElementById('tbDateCompletedToDate').value = document.getElementById('tbToDate').value;
    dateCompletedShow();
}

    function FindControl(ctrlID, ctrlType) {
        var inps = document.getElementsByTagName(ctrlType);
        for (var t = 0, inp; inp = inps[t]; t++) {
            if (inp.id.match(ctrlID)) {
                return inp;
            }
        }
    }
	

	var cookieText = "WebTeam";
	var YouWrote;
	function cookieGet() {
		if (document.cookie) {
		index = document.cookie.indexOf(cookieText);
		if (index != -1) {
			namestart = (document.cookie.indexOf("=", index) + 1);
			nameend = document.cookie.indexOf(";", index);
			if (nameend == -1) {
				nameend = 0;
			}
			YouWrote = document.cookie.substring(namestart, nameend);
			return YouWrote;
		}else{
			return ""
		}
		}else{
			return ""
		}
	}

function OpenDTKScreenModal() {
    document.getElementById("overDiv").style.display = "block";
    document.getElementById("overDiv").style.width = "100%";
    document.getElementById("overDiv").style.height = "100%";
    document.getElementById("frame1").src  = "http://" +  location.host + "/ehub35Screens/Screens/TKRHost.aspx";
}

function OpenApprovalsModal(WTuserID) {
    document.getElementById("overDiv").style.display = "block";
    document.getElementById("overDiv").style.width = "100%";
    document.getElementById("overDiv").style.height = "100%";
    document.getElementById("frame1").src = "http://" +  location.host + "/ehub35Screens/Screens/TKRHost.aspx?PageType=Approvals&WinteamUserID=" +  WTuserID + "";
}

function CloseDTKScreenModal() {
    document.getElementById("overDiv").style.display = "none";
    document.getElementById("overDiv").style.width = "0";
    document.getElementById("overDiv").style.height = "0";
    document.getElementById("frame1").src = "about:blank";
alert(document.getElementById("overDiv").style.display);
}

function gup( name ){  
    name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");  
    var regexS = "[\\?&]"+name+"=([^&#]*)";  
    var regex = new RegExp( regexS );  
    var results = regex.exec( window.location.href );  
    if( results == null )    
    return "";  
    else    
    return results[1];
}


function resizeCalendar()
{
    //alert( document.getElementById('calendarHeight').value + '\n' + document.getElementById('calendarWidth').value);
    var calH = '' + document.getElementById('calendarHeight').value
    var calW = '' + document.getElementById('calendarWidth').value

    if(calH.length > 0 && calW.length > 0 ) 
    {
     //Reset cal size to match originating size before post
        //alert(calH + '\n' + calW)
        document.getElementById('_ctl2_pnlMainCalendar').style.height=calH;
        document.getElementById('_ctl2_pnlMainCalendar').style.width=calW;
     }
     else
     {
        document.getElementById('_ctl2_pnlMainCalendar').style.height='210px';
        document.getElementById('_ctl2_pnlMainCalendar').style.width='950px';
     }
}
function dateCompletedShow()
{
    //var currentHeight = '' + document.getElementById('_ctl2_DateCompletedPanel').style.height + '';
    //if(currentHeight=='1px')
    var isChecked = false;
    if(document.getElementById('_ctl2_cbSkipped').checked == true || document.getElementById('_ctl2_cbWaived').checked == true || document.getElementById('_ctl2_cbDone').checked == true)
    {
        isChecked = true;
    }

    if(document.getElementById('_ctl2_cbSkipped').checked == false && document.getElementById('_ctl2_cbWaived').checked == false && document.getElementById('_ctl2_cbDone').checked == false)
    {
        isChecked = false;
    }
        
    //alert(isChecked)
    if(isChecked == true)
    {
        document.getElementById('_ctl2_DateCompletedPanel').style.height='60px';
        document.getElementById('_ctl2_DateCompletedPanel').style.width='75px';
    }
    //if(currentHeight=='30px')
    if(isChecked ==  false)
    {
        document.getElementById('_ctl2_DateCompletedPanel').style.height='1px';
        document.getElementById('_ctl2_DateCompletedPanel').style.width='75px';
    }    
    
    return isChecked;  
}

function filterShow()
{
    var currentHeight = '' + document.getElementById('_ctl2_pnlMoreFilters').style.height + '';
    if(currentHeight=='1px')
    {
        document.getElementById('_ctl2_pnlMoreFilters').style.height='70px';
        document.getElementById('_ctl2_pnlMoreFilters').style.width='972px';
    }
    if(currentHeight=='70px')
    {
        document.getElementById('_ctl2_pnlMoreFilters').style.height='1px';
        document.getElementById('_ctl2_pnlMoreFilters').style.width='972px';
    }

}

function calendarShow()
{
    var currentHeight = '' + document.getElementById('_ctl2_pnlMainCalendar').style.height + '';
    if(currentHeight=='1px')
    {
        document.getElementById('_ctl2_pnlMainCalendar').style.height='210px';
        document.getElementById('_ctl2_pnlMainCalendar').style.width='950px';
    }
    if(currentHeight=='210px')
    {
        document.getElementById('_ctl2_pnlMainCalendar').style.height='540px';
        document.getElementById('_ctl2_pnlMainCalendar').style.width='950px';
    }
    if(currentHeight=='540px')
    {
        document.getElementById('_ctl2_pnlMainCalendar').style.height='1px';
        document.getElementById('_ctl2_pnlMainCalendar').style.width='950px';
    }
    
   document.getElementById('calendarHeight').value = document.getElementById('_ctl2_pnlMainCalendar').style.height
   document.getElementById('calendarWidth').value = document.getElementById('_ctl2_pnlMainCalendar').style.width
}

function setDate(switchTo)
{						 
	//alert(document.getElementById('hdnDateArray').value);
	document.body.style.cursor='wait';
	document.getElementById('lblMarquee').innerHTML='<span style=\'background-color: #FFFFCC\'>&nbsp;Loading&nbsp;<marquee width=\'30\'  direction=\'right\'  loop=\'10\' scrolldelay=\'20\' name=myheader id=myheader onmouseover=\'slowMarquee(1000)\' onmouseout=\'slowMarquee(20)\' >...</marquee></span>';

	var chrtrArry = document.getElementById('hdnDateArray').value.split(",");

	if(document.getElementById('tbSwitchDate').value.length == 0)
	{
		document.getElementById('tbSwitchDate').value = 0;
	}
	
	switch(switchTo)
	{
		case'1': //First
		//alert(document.getElementById('tbSwitchDate').value + '\n' + chrtrArry[parseInt(document.getElementById('tbSwitchDate').value)]);
		document.getElementById('tbSwitchDate').value = 0;
		break;
		case'2': //-1
		//alert(document.getElementById('tbSwitchDate').value + '\n' + chrtrArry[parseInt(document.getElementById('tbSwitchDate').value)]);		
		if(parseInt(document.getElementById('tbSwitchDate').value) - 1 < 0)
		{
			document.getElementById('tbSwitchDate').value = 0;
		}
		else
		{
			document.getElementById('tbSwitchDate').value = parseInt(document.getElementById('tbSwitchDate').value) - 1;
		}
		break;
		case'3': //+1
		//alert(document.getElementById('tbSwitchDate').value + '\n' + chrtrArry[parseInt(document.getElementById('tbSwitchDate').value)]);
		if(parseInt(document.getElementById('tbSwitchDate').value) + 1 > (chrtrArry.length - 1))
		{
			document.getElementById('tbSwitchDate').value = chrtrArry.length - 1;
		}
		else
		{
			document.getElementById('tbSwitchDate').value = parseInt(document.getElementById('tbSwitchDate').value) + 1;
		}
		break;
		case'4': //Last
		//alert(document.getElementById('tbSwitchDate').value + '\n' + chrtrArry[parseInt(document.getElementById('tbSwitchDate').value)]);
		document.getElementById('tbSwitchDate').value = chrtrArry.length - 1;
		break;				
		
	}       		
	
	//alert(document.getElementById('tbSwitchDate').value);
	//alert(document.getElementById('tbSwitchDate').value + '\n' + chrtrArry[parseInt(document.getElementById('tbSwitchDate').value)]);
	if(checkChanges())
	{
		document.getElementById('tbCurrentDate').value = chrtrArry[parseInt(document.getElementById('tbSwitchDate').value)];
		//alert(document.frmHost.tbCurrentDate.value + '\n' + document.getElementById('tbSwitchDate').value)

		//alert(document.forms['frmHost'].elements['_ctl2_tbCurrentDate'].value);
		document.getElementById('tbDoWhat').value = 1;
		__doPostBack('_ctl2$dgDetail$_ctl1$_ctl0','')
		//document.frmHost.submit();
	}
}


function addNewEquipmentTracker()
{
            document.getElementById('doWhatIR').value = "1"
			document.getElementById('lblMarquee').innerHTML='<span style=\'background-color: #FFFFCC\'>&nbsp;Loading&nbsp;<marquee width=\'30\'  direction=\'right\'  loop=\'10\' scrolldelay=\'20\' name=myheader id=myheader onmouseover=\'slowMarquee(1000)\' onmouseout=\'slowMarquee(20)\' >...</marquee></span>';
			document.frmHost.submit();
}

function refreshNewEquipmentTracker()
{
            document.getElementById('doWhatIR').value = "2"
			document.getElementById('lblMarquee').innerHTML='<span style=\'background-color: #FFFFCC\'>&nbsp;Loading&nbsp;<marquee width=\'30\'  direction=\'right\'  loop=\'10\' scrolldelay=\'20\' name=myheader id=myheader onmouseover=\'slowMarquee(1000)\' onmouseout=\'slowMarquee(20)\' >...</marquee></span>';
			document.frmHost.submit();
}

function submitNewEquipmentTracker()
{
            document.getElementById('doWhatIR').value = "3"
			document.getElementById('lblMarquee').innerHTML='<span style=\'background-color: #FFFFCC\'>&nbsp;Loading&nbsp;<marquee width=\'30\'  direction=\'right\'  loop=\'10\' scrolldelay=\'20\' name=myheader id=myheader onmouseover=\'slowMarquee(1000)\' onmouseout=\'slowMarquee(20)\' >...</marquee></span>';
			document.frmHost.submit();
}

function addNewInventoryRequest()
{
            document.getElementById('doWhatIR').value = "1"
			document.getElementById('lblMarquee').innerHTML='<span style=\'background-color: #FFFFCC\'>&nbsp;Loading&nbsp;<marquee width=\'30\'  direction=\'right\'  loop=\'10\' scrolldelay=\'20\' name=myheader id=myheader onmouseover=\'slowMarquee(1000)\' onmouseout=\'slowMarquee(20)\' >...</marquee></span>';
			document.frmHost.submit();
}

function refreshNewInventoryRequest()
{
            document.getElementById('doWhatIR').value = "2"
			document.getElementById('lblMarquee').innerHTML='<span style=\'background-color: #FFFFCC\'>&nbsp;Loading&nbsp;<marquee width=\'30\'  direction=\'right\'  loop=\'10\' scrolldelay=\'20\' name=myheader id=myheader onmouseover=\'slowMarquee(1000)\' onmouseout=\'slowMarquee(20)\' >...</marquee></span>';
			document.frmHost.submit();
}

function submitNewInventoryRequest()
{
            document.getElementById('doWhatIR').value = "3"
			document.getElementById('lblMarquee').innerHTML='<span style=\'background-color: #FFFFCC\'>&nbsp;Loading&nbsp;<marquee width=\'30\'  direction=\'right\'  loop=\'10\' scrolldelay=\'20\' name=myheader id=myheader onmouseover=\'slowMarquee(1000)\' onmouseout=\'slowMarquee(20)\' >...</marquee></span>';
			document.frmHost.submit();
}



function showWait(controlID)
{
	    document.getElementById('' + controlID + '').innerHTML = "<img src='../Images/Loading.gif' onmouseover='document.body.style.cursor=\"wait\";' onload='document.body.style.cursor=\"wait\";' border='0' name='img2' id='img2' width='70' height='13'>&nbsp;Loading..."
}
    

function goHome()
{
    parent.location.replace('/eHub/ESS/Portal.asp');
}

function checkImage(imgID)
{
	
}
function RequestedOn(myDate)
{
	
}
function checkChanges()
{
	//alert(document.frmHost.tbChangesMade.value);
	if(parseInt(document.frmHost.tbChangesMade.value) <= 0)
	{
		return true;
	}
	else
	{
		if(confirm('You have ' + document.frmHost.tbChangesMade.value + ' change\(s\) pending\nClick OK to disregard pending changes\nClick Cancel to return to your active screen so you can submit changes\nand process all pending records.'))
		{
			document.frmHost.tbChangesMade.value = 0;
			return true;
		}
		else
		{
			return false;
			//break;
		}
	}
}
function checkWTChanges()
{
	//alert(document.frmHost.tbChangesMade.value);
	resetFilters();	
	if(parseInt(document.frmHost.tbChangesMade.value) <= 0)
	{
		return true;
	}
	else
	{
		if(confirm('You have ' + document.frmHost.tbChangesMade.value + ' change\(s\) pending\nClick OK to disregard pending changes\nClick Cancel to return to your active screen so you can submit changes\nand process all pending records.'))
		{
			document.frmHost.tbChangesMade.value = 0;
			return true;
		}
		else
		{
			return false;
			//break;
		}
	}
}
function Maximize_onclick() 
{
window.parent.frames.TopBot.rows = "0,*"
window.parent.frames.LeftRight.cols = "0,*"
window.parent.frames.TopBotRight.rows = "0,*,0"
}
function Restore_onclick() 
{
window.parent.frames.TopBot.rows = "0,*"
//window.parent.frames.LeftRight.cols = "200,*"
window.parent.frames.LeftRight.cols = "0,*"
window.parent.frames.TopBotRight.rows = "60,*,0"
}
function Close_onclick() 
{
//window.parent.frames.TopBot.rows = "0,*"
//window.parent.frames.LeftRight.cols = "0,*"
//window.parent.frames.TopBotRight.rows = "0,*,0"
Restore_onclick();
document.location.replace('Blank.aspx');
}
function waitRedirect(redirURL)
{
		dims = "width=650,height=250,status=yes,resizable=yes,scrollbars=no";
		//redirURL = 	escape("Host.aspx?cID=15&cPath=~/Controls/Employee/ShiftTimesPayInfoByEmployee.ascx&jobNum=" + jobNum + "&wrkDate=" + wrkDate + "&empNum=" + empNum + "")
	
		//popUpWin = window.open("WaitRedirect.aspx?redirPath=" + redirURL + "", "HostPopWin",dims);
		//popUpWin.opener = self;
		

		var srcVal = "WaitRedirect.aspx?redirPath=" + escape(redirURL) + "";
		popUpWin = window.open("","HostPopWin",dims);
		with(popUpWin.document)
		{
			write("<title></title>");
			write("<frameset rows=* border=0 frameborder=0 framespacing=0>");
			write("<frame name=popup_result scrolling=yes marginheight=0 marginwidth=0 noresize src=");
			write(srcVal);
			write(">");
			write("</frameset>");			
		}
		popUpWin.focus();				
}

function buildInLineFrame(srcVal)
{
	//overDiv.innerHTML = "";
	redirURL = 	escape("" + srcVal + "")	
	srcVal = "WaitRedirect.aspx?redirPath=" + redirURL + "";
	/*
	frameHTML = "" + 
	"<title>Shift Times - Pay Information</title>" + 
	"<frameset rows=* border=0 frameborder=0 framespacing=0>" + 
	"<frame name=popup_result scrolling=no marginheight=0 marginwidth=0 noresize src=" + 
	"" + srcVal + "" + 
	">" + 
	"</frameset>";	
	*/
	
	frameHTML = "<iframe name=\"iFrameHost\" id=\"iFrameHost\" title=\"Report Viewer\" tabIndex=\"0\" marginWidth=\"0\" "+
														"marginHeight=\"0\" scrolling=\"no\" frameBorder=\"no\" src=\"" + srcVal + "\" "+
														"width=\"175\" height=\"125\">Your browser does not support inline frames or is "+
														"currently configured not to display inline frames. </iframe> ";
															
	//frameHTML = "<iframe src=" + srcVal + "></iframe>";
	
	document.forms[0].hdnHTML.value = "" + frameHTML;
	//alert(document.forms[0].hdnHTML.value);
	//overDiv.innerHTML = "" + frameHTML;
	//alert(overDiv.innerHTML);
}

function switchST_PI(jobNum,wrkDate,empNum)
{
		dims = "width=450,height=150,status=no,resizable=yes,top=200,left=200,scrollbars=no";
		redirURL = 	escape("Host.aspx?cID=15&cPath=~/Controls/Employee/ShiftTimesPayInfoByEmployee.ascx&jobNum=" + jobNum + "&wrkDate=" + wrkDate + "&empNum=" + empNum + "")
	
		//popUpWin = window.open("WaitRedirect.aspx?redirPath=" + redirURL + "", "HostPopWin",dims);
		//popUpWin.opener = self;
		

		var srcVal = "WaitRedirect.aspx?redirPath=" + redirURL + "";
		popUpWin = window.open("","HostPopWin",dims);
		with(popUpWin.document)
		{
			write("<title>Shift Times - Pay Information</title>");
			write("<frameset rows=* border=0 frameborder=0 framespacing=0>");
			write("<frame name=popup_result scrolling=no marginheight=0 marginwidth=0 noresize src=");
			write(srcVal);
			write(">");
			write("</frameset>");			
		}
		popUpWin.focus();				
}

function openCRItem(itemID,empID)
{
		var dims = "width=550,height=350,status=no,resizable=yes,top=200,left=200,scrollbars=yes";

		popUpWin = window.open("ChangeRequestItem.aspx?crID=" + itemID + "&empID=" + empID + "", "SearchFieldItemsWin",dims);
}
function closeMe(myID)
{
	nd();
}
function Toggle(hostName)
{
	//if(document.frmHost.play.src == '../Images/pause.gif')
	var root = 'http://' + hostName + '/eHub/';
	//alert(document.frmHost.play.src + '\n' + root + 'Images/play.gif');

	if(document.frmHost.play.src == root + 'Images/pause.gif')
	{
		document.frmHost.play.src = root + 'Images/play.gif';
		document.frmHost.play.alt='Click to PLAY'
		myheader.stop();
		//alert(document.frmHost.play.src)
		
	}
	else
	{
		document.frmHost.play.src = root + 'Images/pause.gif'
		document.frmHost.play.alt='Click to PAUSE'
		myheader.start();
		//alert(document.frmHost.play.src)
		
	}
}
function slowMarquee(delayMe)
{
	myheader.scrollDelay = delayMe;
}
function slowUpdatesPerformedMarquee(delayMe)
{
	slowUpdatesPerformedMarquee.scrollDelay = delayMe;
}
function resetMe()
{
		/*
		<input type=hidden id=frmName name=frmName value="frmHost" >
		<input type=hidden id=fldName name=fldName value="phDesc1" >
		*/
		
		var myForm = '' + document.frmPopUpHost.frmName.value + '';
		var myField = '' + document.frmPopUpHost.fldName.value + '';
		//alert(myForm + '\n' + myField);
		self.opener.document.forms['' + myForm + ''].elements['' + myField + ''].value = '';
		window.close();
		
}
function validateDates()
{

	var fromDate = document.getElementById('tbFromDate').value;
	var toDate = document.getElementById('tbToDate').value;
	var alert1 = "";
	var alert2 = "";
	var alert3 = "";
	var alert4 = "";
	var alert5 = "";
	
	var fromDateOK = false;
	var toDateOK = false;
	 //alert(fromDate);
	 //alert(toDate);
	fromDateOK = validateDateValues(fromDate);
	toDateOK = validateDateValues(toDate);
	if(!fromDateOK)
	{
		alert1 = "\n - Please enter only digit characters in the \"From\" date field.";
		document.frmHost.tbFromDate.focus();
	}		

	if(!toDateOK)
	{
		alert2 = "\n - Please enter only digit characters in the \"To\" date field.";
		document.frmHost.tbToDate.focus();
	}		
	
	if(fromDate.length < 10 || fromDate.length > 10)
	{
		alert3 = "\n - Invalid date format. The \"From\" date field must be the following format MM/DD/YYYY.";		
	}
	
	if(toDate.length < 10 || toDate.length > 10)
	{
		alert4 = "\n - Invalid date format. The \"To\" date field must be the following format MM/DD/YYYY.";		
	}


				var fDate	= '' + fromDate + '';
				var tDate	= '' + toDate + ''; 
				var fDateDate = new Date(fDate);
				var tDateDate = new Date(tDate);
				
				
				var fMonth	= '' + fDate.substring(0,2) + '';
				var fDay	= '' + fDate.substring(3,5) + '';		
				var fYear	= '' + fDate.substring(6,10) + '';		
				
				var tMonth	= '' + tDate.substring(0,2) + '';
				var tDay	= '' + tDate.substring(3,5) + '';
				var tYear	= '' + tDate.substring(6,10) + '';
				
				
				var currentDate = new Date();		
				var currentMonth = currentDate.getMonth() +1;
				var currentDay = currentDate.getDate();
				var currentYear = currentDate.getFullYear();
				
				var myDate = '' + currentMonth + '/' + currentDay + '/' + currentYear + '';
				var cDate = new Date( myDate );
				
				var cMonth = cDate.getMonth();
				var cDay = cDate.getDate();
				var cYear = cDate.getFullYear();				
	
				
				if(tDateDate.getTime() < fDateDate.getTime())
				{
					alert5 = "\n - \"To\" Date must be later than \"From\" date";
				}				


	if (alert1.length > 0 || alert2.length >0 || alert3.length > 0 || alert4.length >0 || alert5.length >0)
	{
		alert('Please correct the following' + alert1 + ' ' +  alert2 + ' ' + alert3 + ' ' + alert4 + ' ' + alert5);
	}
	else
	{		    	
		if(checkChanges())
		{
			document.getElementById('lblMarquee').innerHTML='<span style=\'background-color: #FFFFCC\'>&nbsp;Loading&nbsp;<marquee width=\'30\'  direction=\'right\'  loop=\'10\' scrolldelay=\'20\' name=myheader id=myheader onmouseover=\'slowMarquee(1000)\' onmouseout=\'slowMarquee(20)\' >...</marquee></span>';
			document.frmHost.submit();
		}
	}

}

function validateWTDates()
{

	var fromDate = document.getElementById('tbFromDate').value;
	var toDate = document.getElementById('tbToDate').value;
	var alert1 = "";
	var alert2 = "";
	var alert3 = "";
	var alert4 = "";
	var alert5 = "";
	
	var fromDateOK = false;
	var toDateOK = false;
	 //alert(fromDate);
	 //alert(toDate);
	fromDateOK = validateDateValues(fromDate);
	toDateOK = validateDateValues(toDate);
	if(!fromDateOK)
	{
		alert1 = "\n - Please enter only digit characters in the \"From\" date field.";
		document.frmHost.tbFromDate.focus();
	}		

	if(!toDateOK)
	{
		alert2 = "\n - Please enter only digit characters in the \"To\" date field.";
		document.frmHost.tbToDate.focus();
	}		
	
	if(fromDate.length < 10 || fromDate.length > 10)
	{
		alert3 = "\n - Invalid date format. The \"From\" date field must be the following format MM/DD/YYYY.";		
	}
	
	if(toDate.length < 10 || toDate.length > 10)
	{
		alert4 = "\n - Invalid date format. The \"To\" date field must be the following format MM/DD/YYYY.";		
	}


				var fDate	= '' + fromDate + '';
				var tDate	= '' + toDate + ''; 
				var fDateDate = new Date(fDate);
				var tDateDate = new Date(tDate);
				
				
				var fMonth	= '' + fDate.substring(0,2) + '';
				var fDay	= '' + fDate.substring(3,5) + '';		
				var fYear	= '' + fDate.substring(6,10) + '';		
				
				var tMonth	= '' + tDate.substring(0,2) + '';
				var tDay	= '' + tDate.substring(3,5) + '';
				var tYear	= '' + tDate.substring(6,10) + '';
				
				
				var currentDate = new Date();		
				var currentMonth = currentDate.getMonth() +1;
				var currentDay = currentDate.getDate();
				var currentYear = currentDate.getFullYear();
				
				var myDate = '' + currentMonth + '/' + currentDay + '/' + currentYear + '';
				var cDate = new Date( myDate );
				
				var cMonth = cDate.getMonth();
				var cDay = cDate.getDate();
				var cYear = cDate.getFullYear();				
	
				
				if(tDateDate.getTime() < fDateDate.getTime())
				{
					alert5 = "\n - \"To\" Date must be later than \"From\" date";
				}				


	if (alert1.length > 0 || alert2.length >0 || alert3.length > 0 || alert4.length >0 || alert5.length >0)
	{
		alert('Please correct the following' + alert1 + ' ' +  alert2 + ' ' + alert3 + ' ' + alert4 + ' ' + alert5);
	}
	else
	{		    	
		if(checkChanges())
		{
			document.getElementById('lblMarquee').innerHTML='<span style=\'background-color: #FFFFCC\'>&nbsp;Loading&nbsp;<marquee width=\'30\'  direction=\'right\'  loop=\'10\' scrolldelay=\'20\' name=myheader id=myheader onmouseover=\'slowMarquee(1000)\' onmouseout=\'slowMarquee(20)\' >...</marquee></span>';
			//document.frmHost.submit();
			//need to excute a server side related post to ensure the grid refreshes controls
			//same as sorting by date
			__doPostBack('_ctl2$dgDetail$_ctl1$_ctl0','')
			//__doPostBack('lblMarquee','')
		}
	}

}
function validateDateRanges(fromDate,toDate)
{

	//var fromDate = document.getElementById('tbFromDate').value;
	//var toDate = document.getElementById('tbToDate').value;
	var allValidDates = false;
	var alert1 = "";
	var alert2 = "";
	var alert3 = "";
	var alert4 = "";
	var alert5 = "";
	
	var fromDateOK = false;
	var toDateOK = false;
	 //alert(fromDate);
	 //alert(toDate);
	 if(fromDate.length > 0 && toDate.length > 0)
	 {
	    fromDateOK = validateDateValues(fromDate);
	    toDateOK = validateDateValues(toDate);
	    if(!fromDateOK)
	    {
		    alert1 = "\n - Please enter only digit characters in the \"From\" date field.";
	    }		

	    if(!toDateOK)
	    {
		    alert2 = "\n - Please enter only digit characters in the \"To\" date field.";
	    }		
    	
	    if(fromDate.length < 10 || fromDate.length > 10)
	    {
		    alert3 = "\n - Invalid date format. The \"From\" date field must be the following format MM/DD/YYYY.";		
	    }
    	
	    if(toDate.length < 10 || toDate.length > 10)
	    {
		    alert4 = "\n - Invalid date format. The \"To\" date field must be the following format MM/DD/YYYY.";		
	    }


				    var fDate	= '' + fromDate + '';
				    var tDate	= '' + toDate + ''; 
				    var fDateDate = new Date(fDate);
				    var tDateDate = new Date(tDate);
    				
    				
				    var fMonth	= '' + fDate.substring(0,2) + '';
				    var fDay	= '' + fDate.substring(3,5) + '';		
				    var fYear	= '' + fDate.substring(6,10) + '';		
    				
				    var tMonth	= '' + tDate.substring(0,2) + '';
				    var tDay	= '' + tDate.substring(3,5) + '';
				    var tYear	= '' + tDate.substring(6,10) + '';
    				
    				
				    var currentDate = new Date();		
				    var currentMonth = currentDate.getMonth() +1;
				    var currentDay = currentDate.getDate();
				    var currentYear = currentDate.getFullYear();
    				
				    var myDate = '' + currentMonth + '/' + currentDay + '/' + currentYear + '';
				    var cDate = new Date( myDate );
    				
				    var cMonth = cDate.getMonth();
				    var cDay = cDate.getDate();
				    var cYear = cDate.getFullYear();				
    	
    				
				    if(tDateDate.getTime() < fDateDate.getTime())
				    {
					    //alert5 = "\n - \"To\" Date must be later than \"From\" date";
					    //alert(dateCompletedShow());
					    if(dateCompletedShow())
					    {
					        //completion date wins and re-sets the original date ranges and current date
					        document.getElementById('tbFromDate').value = document.getElementById('tbDateCompletedFromDate').value;
					        document.getElementById('tbToDate').value = document.getElementById('tbDateCompletedToDate').value;
					    }
				    }	
		
				    if(tDateDate.getTime() > fDateDate.getTime())
				    {
					    //alert5 = "\n - \"To\" Date must be later than \"From\" date";
					    //alert(dateCompletedShow());
					    if(dateCompletedShow())
					    {
					        //completion date wins and re-sets the original date ranges and current date
					        document.getElementById('tbFromDate').value = document.getElementById('tbDateCompletedFromDate').value;
					        document.getElementById('tbToDate').value = document.getElementById('tbDateCompletedToDate').value;
					    }
				    }

	    if (alert1.length > 0 || alert2.length >0 || alert3.length > 0 || alert4.length >0 || alert5.length >0)
	    {
		    alert('Please correct the following' + alert1 + ' ' +  alert2 + ' ' + alert3 + ' ' + alert4 + ' ' + alert5);
		    allValidDates = false;
	    }
	    else
	    {		    	
            allValidDates = true;
	    }
    }
    else
    {
        allValidDates = true;
    }
    return allValidDates;
}

function validate2Dates(fromDate,toDate)
{

	//var fromDate = document.getElementById('tbFromDate').value;
	//var toDate = document.getElementById('tbToDate').value;
	var allValidDates = false;
	var alert1 = "";
	var alert2 = "";
	var alert3 = "";
	var alert4 = "";
	var alert5 = "";
	
	var fromDateOK = false;
	var toDateOK = false;
	 //alert(fromDate);
	 //alert(toDate);
	 if(fromDate.length > 0 && toDate.length > 0)
	 {
	    fromDateOK = validateDateValues(fromDate);
	    toDateOK = validateDateValues(toDate);
	    if(!fromDateOK)
	    {
		    alert1 = "\n - Please enter only digit characters in the \"From\" date field.";
	    }		

	    if(!toDateOK)
	    {
		    alert2 = "\n - Please enter only digit characters in the \"To\" date field.";
	    }		
    	
	    if(fromDate.length < 10 || fromDate.length > 10)
	    {
		    alert3 = "\n - Invalid date format. The \"From\" date field must be the following format MM/DD/YYYY.";		
	    }
    	
	    if(toDate.length < 10 || toDate.length > 10)
	    {
		    alert4 = "\n - Invalid date format. The \"To\" date field must be the following format MM/DD/YYYY.";		
	    }


				    var fDate	= '' + fromDate + '';
				    var tDate	= '' + toDate + ''; 
				    var fDateDate = new Date(fDate);
				    var tDateDate = new Date(tDate);
    				
    				
				    var fMonth	= '' + fDate.substring(0,2) + '';
				    var fDay	= '' + fDate.substring(3,5) + '';		
				    var fYear	= '' + fDate.substring(6,10) + '';		
    				
				    var tMonth	= '' + tDate.substring(0,2) + '';
				    var tDay	= '' + tDate.substring(3,5) + '';
				    var tYear	= '' + tDate.substring(6,10) + '';
    				
    				
				    var currentDate = new Date();		
				    var currentMonth = currentDate.getMonth() +1;
				    var currentDay = currentDate.getDate();
				    var currentYear = currentDate.getFullYear();
    				
				    var myDate = '' + currentMonth + '/' + currentDay + '/' + currentYear + '';
				    var cDate = new Date( myDate );
    				
				    var cMonth = cDate.getMonth();
				    var cDay = cDate.getDate();
				    var cYear = cDate.getFullYear();				
    	
    				
				    if(tDateDate.getTime() < fDateDate.getTime())
				    {
					    alert5 = "\n - \"To\" Date must be later than \"From\" date";
				    }				


	    if (alert1.length > 0 || alert2.length >0 || alert3.length > 0 || alert4.length >0 || alert5.length >0)
	    {
		    alert('Please correct the following' + alert1 + ' ' +  alert2 + ' ' + alert3 + ' ' + alert4 + ' ' + alert5);
		    allValidDates = false;
	    }
	    else
	    {		    	
            allValidDates = true;
	    }
    }
    else
    {
        allValidDates = true;
    }
    return allValidDates;
}

function validate1Date(fromDate)
{

	//var fromDate = document.getElementById('tbFromDate').value;
	//var toDate = document.getElementById('tbToDate').value;
	var allValidDates = false;
	var alert1 = "";
	var alert2 = "";
	var alert3 = "";
	var alert4 = "";
	var alert5 = "";
	
	var fromDateOK = false;
	var toDateOK = false;
	 //alert(fromDate);
	 //alert(toDate);
	 if(fromDate.length > 0)
	 {
	    fromDateOK = validateDateValues(fromDate);
	    //alert(fromDateOK)
	    
	    if(!fromDateOK)
	    {
		    alert1 = "\n - Please enter only digit characters in the date field.";
	    }
    	
	    if(fromDate.length < 10 || fromDate.length > 10)
	    {
		    alert3 = "\n - Invalid date format. The date field must be the following format MM/DD/YYYY.";		
	    }
    	
				    var fDate	= '' + fromDate + '';
				    var fDateDate = new Date(fDate);
    				
    				//alert('Time:' + fDateDate.getTime());
    				
				    var fMonth	= '' + fDate.substring(0,2) + '';
				    var fDay	= '' + fDate.substring(3,5) + '';		
				    var fYear	= '' + fDate.substring(6,10) + '';
				    var myDateString = '' + fDateDate   					    	
    				//alert(myDateString.replace('NaN','').replace('undefined','').length);
    				if(!validateDateValues(fDateDate) || myDateString.replace('NaN','').replace('undefined','').length == 0)
    				{
    				    alert5 = "\n - invalid date";
    				}    				
    			


	    if (alert1.length > 0 || alert2.length >0 || alert3.length > 0 || alert4.length >0 || alert5.length >0)
	    {
		    alert('Please correct the following' + alert1 + ' ' +  alert2 + ' ' + alert3 + ' ' + alert4 + ' ' + alert5);
		    allValidDates = false;
	    }
	    else
	    {		    	
            allValidDates = true;
	    }
    }
    else
    {
        allValidDates = true;
    }
    //alert(allValidDates)
    return allValidDates;
}

function validateTimes(myTime,myControlName,myControl)
{
	var alert1 = "";
	var alert2 = "";
	var alert3 = "";
	var alert4 = "";
	var alert5 = "";
	
	var myTimeOK = false;

	if(myTime.length != 5)
	{
		alert2 = " (check length)";		
	}
	else
	{
		myTimeOK = validateTimeValues(myTime);
	}


	if(!myTimeOK)
	{
		alert1 = "\n - " + myControlName + "";
	}		

				var thisTime	= '' + myTime + '';				
				var thisHours	= '' + thisTime.substring(0,2) + '';
				var thisMinutes	= '' + thisTime.substring(3,5) + '';		
				
				
				if(parseInt(thisHours) > 23)
				{
					alert3 = "\n - Hours should be below 23";
				}


				if(parseInt(thisMinutes) > 59)
				{
					alert4 = "\n - Minutes should be below 59";
				}


	if (alert1.length > 0 || alert2.length >0 || alert3.length > 0 || alert4.length >0 || alert5.length >0)
	{
		//alert(myControl);
		document.getElementById('' + myControl).value = '';//'00:00';
		document.getElementById('' + myControl).focus();
		document.getElementById('' + myControl).select();	
		//alert('Please correct the following: ' + alert1 + ' ' +  alert2 + ' ' + alert3 + ' ' + alert4 + ' ' + alert5);
		//return '' + alert1 + ' ' +  alert2 + ' ' + alert3 + ' ' + alert4 + ' ' + alert5;
	
	}
	else
	{
	    //return '';
	}
	//else
	//{
		//calculate totals
		//alert(myControlName + '\n' + myControl);
		calculateHours(document.getElementById(myControl.replace(myControlName,'In')).value,document.getElementById(myControl.replace(myControlName,'Out')).value,document.getElementById(myControl.replace(myControlName,'Lunch')).value,document.getElementById(myControl.replace(myControlName,'Hours')).value,myControl.replace(myControlName,'Hours'))
        if(document.getElementById(myControl.replace(myControlName,'Hours')).style.backgroundColor.toLowerCase() != "#ccff99")
        {
            //addChangeToLog() //adding individual cell changes to log is only implemented in the new interface
            //alert(document.getElementById(myControl.replace(myControlName,'Hours')).style.backgroundColor);
            //Did not implement this because it will green it even if changes were not made to the IN/OUT/Lunch times. Implemented in Daily View instead.
		    //document.getElementById(myControl.replace(myControlName,'Hours')).style.backgroundColor = "#ccff99";
		}
        return '' + alert1 + '' +  alert2 + '' + alert3 + '' + alert4 + '' + alert5;		
	//}

}

function calculateHours(myIn, myOut, myLunch, myHours, myControl)
{
	
	var decimalIn	 = 0;
	var decimalOut	 = 0;
	var decimalLunch = 0;
	var decimalHours = 0;
	var decimalTotal = 0;
	var finalTotal	 = 0;
	var hasIn = false;
	var hasOut = false;
	var hasLunch = false;
	var hasHours = false;
	
	if(myIn.length > 0 )
	{
				var thisInTime	= '' + myIn + '';				
				var thisInHours	= '' + thisInTime.substring(0,2) + '';
				var thisInMinutes	= '' + thisInTime.substring(3,5) + '';	
				decimalIn = parseFloat(thisInHours) + ((parseFloat(thisInMinutes) * 1)/60 )
				hasIn = true;
	}


	if(myOut.length > 0 )
	{
				var thisOutTime	= '' + myOut + '';				
				var thisOutHours	= '' + thisOutTime.substring(0,2) + '';
				var thisOutMinutes	= '' + thisOutTime.substring(3,5) + '';	
				decimalOut = parseFloat(thisOutHours) + ((parseFloat(thisOutMinutes) * 1)/60 )
				hasOut = true;
	}
	
	if(myLunch.length > 0 )
	{
		hasLunch = true;
	}
	
	if(myHours.length > 0 )
	{
		hasHours = true;
	}

	
	if(decimalOut < decimalIn)
	{
		decimalOut = 24 + decimalOut;
	}
		
	
		if(hasIn && hasOut)//&& parseFloat(myLunch) >= 0 && parseFloat(myHours) >=0 )
		{
		//alert('Lunch' + parseFloat(myLunch));
		//alert('Hours' + parseFloat(myHours));
		
		if(hasLunch == false)
		{
			//set to zero
			myLunch = 0;
		}

		if(hasHours == false)
		{
			//set to zero
			myHours = 0;
		}

			//alert(decimalOut + '\-' + decimalIn);
			decimalTotal = decimalOut-decimalIn;
			finalTotal = roundHours(decimalTotal,'' + document.getElementById('hdnRoundHours').value) - parseFloat(myLunch);
			//alert(roundHours(decimalTotal,'25') + '\-' + parseFloat(myLunch));
			//alert('In' + decimalIn + '\nOut' + decimalOut + '\nLunch' + myLunch + '\nHours' + myHours + '\nNewTotal' + finalTotal );
			//alert(myControl);
			//alert(finalTotal)
			if(finalTotal < 10)
			{
			    if(finalTotal <0)
			    {
    			    if(finalTotal < -9)
    			    {
    			        document.getElementById(myControl).value = finalTotal.toFixed(2);
			        }
			        else
			        {
			            document.getElementById(myControl).value = finalTotal.toFixed(2).replace('-','-0');
			        }
			    }
			    else
			    {
			        document.getElementById(myControl).value = '0' + '' + finalTotal.toFixed(2);
			    }
			}
			else
			{    
			    document.getElementById(myControl).value = finalTotal.toFixed(2);		                
			}
		}
	
}

function roundHours(forWhat, byHowMuch)
{
   var aproxTotal = 0;
   var aproxHours = 0;
   var aproxMinutes=0;
   var aproxTotalHours = 0;
   var aproxTotalMinutes = 0;   
   var finalTotal = 0;
   var wasAprox = false;

	aproxHours = parseInt(forWhat.toFixed(2));
	aproxMinutes = forWhat - parseInt(forWhat);   	
	//aproxMinutes = aproxMinutes.toFixed(2)
	//alert(forWhat + '\n' + aproxHours + '\n' + aproxMinutes + '\n' + parseInt(aproxMinutes*100) );
	if(byHowMuch == '25')
	{
		if(parseInt(aproxMinutes*100) > 12 && parseInt(aproxMinutes*100) < 25)
		{
			aproxTotal = parseFloat(forWhat)  + ((25 - parseInt(aproxMinutes*100))/100 )
			wasAprox = true;
		}
		if(parseInt(aproxMinutes*100) > 37 && parseInt(aproxMinutes*100) < 50)
		{
			aproxTotal = parseFloat(forWhat)  + ((50 - parseInt(aproxMinutes*100))/100 )
			wasAprox = true;
		}
		if(parseInt(aproxMinutes*100) > 62 && parseInt(aproxMinutes*100) < 75)
		{
			aproxTotal = parseFloat(forWhat)  + ((75 - parseInt(aproxMinutes*100))/100 )
			wasAprox = true;
		}
		if(parseInt(aproxMinutes*100) > 87 && parseInt(aproxMinutes*100) < 100)
		{
			//alert(parseFloat(forWhat)  + '\+' + ((100 - parseInt(aproxMinutes*100))/100 ))
			aproxTotal = parseFloat(forWhat)  + ((100 - parseInt(aproxMinutes*100))/100 )
			wasAprox = true;
		}		
		
		
		if(parseInt(aproxMinutes*100) > 0 && parseInt(aproxMinutes*100) < 13)
		{
			aproxTotal = parseFloat(forWhat)  - ((0 + parseInt(aproxMinutes*100))/100 )
			//alert(aproxTotal);
			wasAprox = true;
		}
		if(parseInt(aproxMinutes*100) > 25 && parseInt(aproxMinutes*100) < 38)
		{
			aproxTotal = 0.25 + parseFloat(forWhat)  - ((0 + parseInt(aproxMinutes*100))/100 )
			wasAprox = true;
		}
		if(parseInt(aproxMinutes*100) > 50 && parseInt(aproxMinutes*100) < 63)
		{
			aproxTotal = 0.50 + parseFloat(forWhat)  - (( 0 + parseInt(aproxMinutes*100))/100 )
			wasAprox = true;
		}
		if(parseInt(aproxMinutes*100) > 75 && parseInt(aproxMinutes*100) < 88)
		{
			//alert(parseFloat(forWhat)  + '\+' + ((100 - parseInt(aproxMinutes*100))/100 ))
			aproxTotal = 0.75 + parseFloat(forWhat)  - ((0 + parseInt(aproxMinutes*100))/100 )
			wasAprox = true;
		}	
				
		if(wasAprox == false)
		{
			aproxTotal = parseFloat(forWhat);
		}
		
		aproxTotalHours = parseInt(aproxTotal);

        var aproxTotalString = '' + aproxTotal
        var aproxTotalMinutesString = ''

        if(aproxTotalString.indexOf(".") != -1) 
        { 
            //because of decimals beinf represented as exponetials 8.8e-15 the split is needed or the wrong value will be appended to the actual hours
            aproxTotalMinutesString = '' + aproxTotalString.substring(aproxTotalString.indexOf("."),aproxTotalString.indexOf(".")+3);
		    aproxTotalMinutes = (parseInt(aproxTotal) + aproxTotalMinutesString) - parseInt(aproxTotal);   		            
        } 
        else
        {        
		    aproxTotalMinutes = aproxTotal - parseInt(aproxTotal);   		
		}
		finalTotal = aproxTotalHours + '.' + parseInt(aproxTotalMinutes*100)
		
		//this would've fixed if it did not round the decimals up...
		//known issue with javascript http://www.mredkj.com/javascript/nfbasic2.html
		//finalTotal = aproxTotalHours + '.' + parseInt(aproxTotalMinutes.toFixed(2)*100)		        
        //alert('aproxTotal:' + aproxTotal);
		//alert('aproxTotalHours:' + aproxTotalHours);// = parseInt(aproxTotal);
		//alert('aproxTotalMinutes:' + aproxTotalMinutes);// = aproxTotal - parseInt(aproxTotal);   
		//alert('roundedMinutes:' + aproxTotalMinutes*100)
		//alert('finalTotal:' + finalTotal);// = aproxTotalHours + '.' + parseInt(aproxTotalMinutes*100)
	}
	else
	{
		finalTotal = parseFloat(forWhat).toFixed(2);
	}
	
  return finalTotal;
}

function validateHours(myTime,myControlName,myControl)
{
	var alert1 = "";
	var alert2 = "";
	var alert3 = "";
	var alert4 = "";
	var alert5 = "";
	
	var myTimeOK = false;

	
	if(myTime.replace('-','').length != 5)
	{
		alert2 = " (check length) ";		
	}
	else
	{
		myTimeOK = validateHourValues(myTime.replace('-',''));
	}


	if(!myTimeOK)
	{
		alert1 = "\n - " + myControlName + "";
	}		

				var thisTime	= '' + myTime.replace('-','') + '';				
				var thisHours	= '' + thisTime.substring(0,2) + '';
				var thisMinutes	= '' + thisTime.substring(3,5) + '';		
				
				
				if(parseInt(thisHours) > 23)
				{
					alert3 = "\n - Hours should be below 23";
				}


				if(parseInt(thisMinutes) > 99)
				{
					alert4 = "\n - Minutes should be below 99";
				}


	if (alert1.length > 0 || alert2.length >0 || alert3.length > 0 || alert4.length >0 || alert5.length >0)
	{
		//alert(myControl);
		document.getElementById('' + myControl).value = '';//'00.00';
		document.getElementById('' + myControl).focus();
		document.getElementById('' + myControl).select();	
		//alert('Please correct the following' + alert1 + ' ' +  alert2 + ' ' + alert3 + ' ' + alert4 + ' ' + alert5);
		//return '' + alert1 + ' ' +  alert2 + ' ' + alert3 + ' ' + alert4 + ' ' + alert5;			
	}
	else
	{
	    //return ''
	}
	//else
	//{
		//calculate Hours
		//alert(myControlName + '\n' + myControl);
		//calculateHours(document.getElementById(myControl.replace(myControlName,'In')).value,document.getElementById(myControl.replace(myControlName,'Out')).value,document.getElementById(myControl.replace(myControlName,'Lunch')).value,document.getElementById(myControl.replace(myControlName,'Hours')).value);
		calculateHours(document.getElementById(myControl.replace(myControlName,'In')).value,document.getElementById(myControl.replace(myControlName,'Out')).value,document.getElementById(myControl.replace(myControlName,'Lunch')).value,document.getElementById(myControl.replace(myControlName,'Hours')).value,myControl.replace(myControlName,'Hours'))
   		return '' + alert1 + '' +  alert2 + '' + alert3 + '' + alert4 + '' + alert5;						
	//}
}

function validateDateValues(myDate)
{
		    var checkOK = "0123456789/";
		    var checkStr = myDate;
		    var allValid = true;
		    for (i = 0;  i < checkStr.length;  i++)
		    {
		        ch = checkStr.charAt(i);
		        for (j = 0;  j < checkOK.length;  j++)
		        if (ch == checkOK.charAt(j))
		        break;
		        if (j == checkOK.length)
		        {
		            allValid = false;
		            break;
		        }
		    }
		   // alert(allValid);
	return allValid;

}

function validateTimeValues(myTime)
{
		    var checkOK = "0123456789:";
		    var checkStr = myTime;
		    var allValid = true;
		    
			var thisTime	= '' + myTime + '';				
			var thisHours	= '' + thisTime.substring(0,2) + '';
			var thisMinutes	= '' + thisTime.substring(3,5) + '';		
			
			if(myTime.length != 5)
	        {
	            if(myTime.length > 0)
	            {
		            allValid = false;		
		        }
	        }
		   			
			if(parseInt(thisHours) > 23)
			{
				allValid = false;
			}

			if(parseInt(thisMinutes) > 59)
			{
                allValid = false;
			}
						    
		    for (i = 0;  i < checkStr.length;  i++)
		    {
   		        ch = checkStr.charAt(i);

				if(i != 2)
		        {
					if(ch == ':')
					{
		            allValid = false;
		            break;		        
		            }
		        }
		        else
		        {
					if(ch != ':')
					{
						allValid = false;
						break;		        
					}
		        }
		        
		        for (j = 0;  j < checkOK.length;  j++)

		        if (ch == checkOK.charAt(j))
		        break;
		        if (j == checkOK.length)
		        {
		            allValid = false;
		            break;
		        }

		    }
		   // alert(allValid);
	return allValid;

}


function validateHourValues(myTime)
{
		    var checkOK = "0123456789.";
		    var checkStr = myTime;
		    var allValid = true;
	
        	if(myTime.replace('-','').length != 5)
	        {
	            if(myTime.length > 0)
	            {
	                allValid = false;		
	            }
	        }
			    
		    for (i = 0;  i < checkStr.length;  i++)
		    {
   		        ch = checkStr.charAt(i);

				if(i != 2)
		        {
					if(ch == '.')
					{
		            allValid = false;
		            break;		        
		            }
		        }
		        else
		        {
					if(ch != '.')
					{
						allValid = false;
						break;		        
					}
		        }
		        
		        for (j = 0;  j < checkOK.length;  j++)

		        if (ch == checkOK.charAt(j))
		        break;
		        if (j == checkOK.length)
		        {
		            allValid = false;
		            break;
		        }

		    }
		   // alert(allValid);
	return allValid;

}

function validateDecimal(myDecimal)
{
		    var checkOK = "0123456789.";
		    var checkStr = myDecimal;
		    var allValid = true;
            //alert(parseFloat(myDecimal));
			    
		    for (i = 0;  i < checkStr.length;  i++)
		    {
   		        ch = checkStr.charAt(i);

		        for (j = 0;  j < checkOK.length;  j++)

		        if (ch == checkOK.charAt(j))
		        break;
		        if (j == checkOK.length)
		        {
		            allValid = false;
		            break;
		        }
		    }
		   // alert(allValid);
	return allValid;

}

function submitChangeRequest(doWhat)
{
	var fireUp = '' + doWhat + '';
	if(fireUp.length > 0)
	{
		document.frmHost.EditMe.value = fireUp;
		switch(fireUp)
		{
			case"E D I T":
				document.frmHost.submit();
				break;
			case"C A N C E L":
				document.frmHost.submit();
				break;
			case"S U B M I T  R E Q U E S T":
				if(confirm('Your change request will be submitted when you click \"OK.\"\nChanges will be applied upon review.\nAre you sure you want to submit this request? If no, click \"Cancel.\"'))
				{
					document.frmHost.submit();
				}
				break;
				case"P R E V I E W  C H A N G E S":
				document.frmHost.submit();
				break;				
			case"R E F R E S H":
				document.frmHost.submit();
				break;
		}
	}
}
function searchMe(what,where,refresh,refreshWhat,findWhat,updateWhat,origVal)
{
	//alert('Not implemented\nWe will allow to search for valid values for ' + what + '\n' + where);
	//overlib('<table border=0 cellpadding=0 cellspacing=0 style=border-collapse: collapse bordercolor=#111111 width=100% id=AutoNumber1><tr><td bgcolor=white align=left width=25% nowrap><A HREF=javascript:closeMe(); onclick=closeMe(); ><IMG  border=0 src=littleClose.jpg ></a></td></tr><tr><td bgcolor=white ><iframe name=\"moSelectItem\" src=\"PopUpHost.aspx?fieldName=' + what + '&formName=' + where + '\"></iframe></td></tr></table>', WIDTH, 250, HEIGHT, 50, RIGHT , ABOVE, SNAPX, 10, SNAPY,40,STICKY,TIMEOUT,5000,DELAY,1);
	document.body.style.cursor='wait';	
	var dims = "width=550,height=250,status=no,resizable=yes,top=200,left=200,scrollbars=yes";
	
	var popMe = false;
	var alertMe = '';
	var testfindWhat = '' + findWhat;
	var testupdateWhat = '' + updateWhat;
	var findWhatQS = "";
	var updateWhatQS = "";
	var testOrigVal = '' + origVal;
	var origValQS = "";
	var winName = "SearchFieldItemsWin"
	
			switch(what)
			{
				case"CheckHistory":
					alertMe = 'A check number is needed to be able to preview your pay-stub information';					
					dims = "width=800,height=600,status=no,resizable=yes,top=200,left=200,scrollbars=yes";
					break;	
				case"WorkScheduling":
					alertMe = 'A ticket number is needed to be able to preview your ticket information';					
					dims = "width=625,height=400,status=no,resizable=yes,top=200,left=200,scrollbars=yes";
					break;	
				case"WorkSchedulingNew":
				    winName = "SearchFieldItemsWinNew"
					alertMe = 'A ticket number is needed to be able to preview your ticket information';					
					dims = "width=635,height=595,status=no,resizable=yes,top=100,left=200,scrollbars=yes";
					break;			
				default:
					alertMe = 'Not enough information to drill-down further';
			}
	
	if(testfindWhat == 'undefined')
	{
			//Is OK! - Regular search
			alertMe = '';
	}
	else
	{	
		testfindWhat = '' + findWhat.length;
		if(findWhat.length > 0)
		{
			findWhatQS = "&findWhat=" + findWhat + "&fromDate=" + document.frmHost.tbFromDate.value + "&toDate=" + document.frmHost.tbToDate.value;
			alertMe = '';
		}
	}
	
	if(testupdateWhat == 'undefined')
	{
			//Is OK! - Regular search
			alertMe = '';
			updateWhat = what
	}
	else
	{	
		if(updateWhat.length > 0)
		{
			alertMe = '';
		}
		else
		{
			updateWhat = what
		}
	}

	updateWhatQS = "&updateWhat=" + updateWhat + "";


	if(testOrigVal == 'undefined')
	{
			//Is OK! - Regular search
			alertMe = '';
			origVal = what
	}
	else
	{	
		if(origVal.length > 0)
		{
			alertMe = '';
		}
		else
		{
			origVal = what
		}
	}

	origValQS = "&origVal=" + origVal + "";
		
	if(alertMe.length == 0)
	{
		popMe = true;
	}
	else
	{
		//alert(alertMe + '\n' + testfindWhat );
		alert(alertMe);
	}
		
	
	if(popMe == true)
	{
		var redirURL = "WaitRedirect.aspx?redirPath=" + escape("PopUpHost.aspx?fieldName=" + what + "&formName=" + where + "&refresh=" + refresh + "&refreshWhat=" + refreshWhat + findWhatQS + updateWhatQS + origValQS + "") + "";
		popUpWin = window.open(redirURL, winName,dims);
		//popUpWin = window.showModalDialog("PopUpHost.aspx?fieldName=" + what + "&formName=" + where + "", "SearchFieldItemsWin","width=550,height=250,status=no,resizable=yes,top=200,left=200,scrollbars=yes");
		popUpWin.opener = self;
	}
}
function setBodyBG(myImage)
{
	document.body.style.backgroundAttachment = "fixed";
	document.body.background = "" + myImage + "";
}

function closeMe()
{
	nd();
}
function doWhatTK(doWhat, toWho)
{
	var fireUp = '' + doWhat + '';
	var alertMe = '';
	
	if(fireUp.length > 0)
	{
		switch(fireUp)
		{
			case"0":
				alertMe = 'A new record will be added'
				break;
			case"1":
				alertMe = 'record ' + toWho + ' will be deleted'
				break;
		}
		if(alertMe.length > 0)
		{
			//alert(alertMe);
		}
	}			
}

function getHoursDescription(jobNumber, selectMeID, gridRowID, fieldName, frmName)
{
	var checkJobNumber = '' + escape(jobNumber);
	if(checkJobNumber.length > 0 && checkJobNumber != "%A0" && checkJobNumber != "%20" )
	{
		searchMe(''+ fieldName + '','' + frmName + '','false','R E F R E S H','' + jobNumber + '|' + selectMeID + '|' + gridRowID + '')
	}
	else
	{
		alert('Please enter a Job Number prior to selecting your Hours Description');
	}
	//alert(jobNumber);
	//searchMe(fieldName)
}

function expandParent(jobNumber,additionalHeight,childControl)
{
    pnlDrillDown(childControl);
    var displayStyle = document.getElementById(childControl).style.display;
    //alert(displayStyle);
    if(displayStyle == 'inline')
    {
        //show
        //alert(parent.document.getElementById('pnlSchedulesByJob_' + jobNumber + '').style.height);
        //alert(additionalHeight);
        //iframe
        parent.document.getElementById('pnlSchedulesByJob_' + jobNumber + '').style.height = parseInt(parent.document.getElementById('pnlSchedulesByJob_' + jobNumber + '').style.height.replace('px','').replace('PX','')) + parseInt(additionalHeight+80);
        parent.document.getElementById('iframeSchedulesByJob_' + jobNumber + '').style.height = parseInt(parent.document.getElementById('iframeSchedulesByJob_' + jobNumber + '').style.height.replace('px','').replace('PX','')) + parseInt(additionalHeight+80);
        //alert(parent.document.getElementById('pnlSchedulesByJob_' + jobNumber + '').style.height);
    }
    
    if(displayStyle == 'none')
    {
        var newHeight = 0;
        var oldHeight = 0;
        newHeight = parseInt(additionalHeight+80); //
        oldHeight = parseInt(parent.document.getElementById('pnlSchedulesByJob_' + jobNumber + '').style.height.replace('px','').replace('PX',''));
        //hide
        //alert(parent.document.getElementById('pnlSchedulesByJob_' + jobNumber + '').style.height);
        //alert(additionalHeight);
        //iframe
        parent.document.getElementById('pnlSchedulesByJob_' + jobNumber + '').style.height = parseInt(oldHeight - newHeight);
        parent.document.getElementById('iframeSchedulesByJob_' + jobNumber + '').style.height = parseInt(oldHeight - newHeight);
        //alert(parent.document.getElementById('pnlSchedulesByJob_' + jobNumber + '').style.height);
    } 
       
}


function validatePSDates(submitMe)
{

	var fromDate = document.getElementById('tbFromDate').value;
	var toDate = document.getElementById('tbToDate').value;
	var alert1 = "";
	var alert2 = "";
	var alert3 = "";
	var alert4 = "";
	var alert5 = "";
	var alert6 = "";
	
	var one_day=1000*60*60*24
    var jCount = 0;
    var eCount = 0;
    var jNum = '';
    var eNum = '';	
	var maxDateDiff = 7;
	var dateDiff = 0;
	
	    jCount = parseInt('' + document.getElementById('tbJobSearchCount').value);
        eCount = parseInt('' + document.getElementById('tbEmployeeSearchCount').value);
        //cDate = document.getElementById('tbCurrentDate').value;
        if(jCount < 51)
        {
            jNum = document.getElementById(document.getElementById('ddlJobSearchUniqueID').value).options[document.getElementById(document.getElementById('ddlJobSearchUniqueID').value).selectedIndex].value;
        }
        else
        {
            jNum = document.getElementById(document.getElementById('tbJobSearchUniqueID').value).value;
        }
        
        if(eCount < 51)
        {
            eNum = document.getElementById(document.getElementById('ddlEmployeeSearchUniqueID').value).options[document.getElementById(document.getElementById('ddlEmployeeSearchUniqueID').value).selectedIndex].value;
        }
        else
        {
            eNum = document.getElementById(document.getElementById('tbEmployeeSearchUniqueID').value).value;
        } 
	
	    //alert(jNum + '\n' + eNum);
        if(jNum.length > 0 || eNum.length > 0 )
        {
            if(jNum == '%' && eNum == '%')
            {
                maxDateDiff = 7;
            }
            else
            {
                maxDateDiff = 95;
            }
        }
	
	var fromDateOK = false;
	var toDateOK = false;
	 //alert(fromDate);
	 //alert(toDate);
	fromDateOK = validateDateValues(fromDate);
	toDateOK = validateDateValues(toDate);
	if(!fromDateOK)
	{
		alert1 = "\n - Please enter only digit characters in the \"From\" date field.";
		document.frmHost.tbFromDate.focus();
	}		

	if(!toDateOK)
	{
		alert2 = "\n - Please enter only digit characters in the \"To\" date field.";
		document.frmHost.tbToDate.focus();
	}		
	
	if(fromDate.length < 10 || fromDate.length > 10)
	{
		alert3 = "\n - Invalid date format. The \"From\" date field must be the following format MM/DD/YYYY.";		
	}
	
	if(toDate.length < 10 || toDate.length > 10)
	{
		alert4 = "\n - Invalid date format. The \"To\" date field must be the following format MM/DD/YYYY.";		
	}


				var fDate	= '' + fromDate + '';
				var tDate	= '' + toDate + ''; 
				var fDateDate = new Date(fDate);
				var tDateDate = new Date(tDate);
				
				var tMonth	= '' + tDate.substring(0,2) + '';
				var tDay	= '' + tDate.substring(3,5) + '';
				var tYear	= '' + tDate.substring(6,10) + '';
				var fMonth	= '' + fDate.substring(0,2) + '';
				var fDay	= '' + fDate.substring(3,5) + '';		
				var fYear	= '' + fDate.substring(6,10) + '';		
				
				var tMonth	= '' + tDate.substring(0,2) + '';
				var tDay	= '' + tDate.substring(3,5) + '';
				var tYear	= '' + tDate.substring(6,10) + '';
				
				
				var currentDate = new Date();		
				var currentMonth = currentDate.getMonth() +1;
				var currentDay = currentDate.getDate();
				var currentYear = currentDate.getFullYear();
				
				var myDate = '' + currentMonth + '/' + currentDay + '/' + currentYear + '';
				var cDate = new Date( myDate );
				
				var cMonth = cDate.getMonth();
				var cDay = cDate.getDate();
				var cYear = cDate.getFullYear();				
	
				var maxDate = new Date();
				
				maxDate.setTime( Math.ceil(fDateDate.getTime() + ((1000*60*60*24)*maxDateDiff)) );
				
				
				
				var maxMonth	= parseInt(maxDate.getMonth())+1;
				
				if(maxMonth <10)
				{
				    maxMonth = '0' + maxMonth;
				}
				
				var maxDay	= parseInt(maxDate.getDate());
				
				if(maxDay <10)
				{
				    maxDay = '0' + maxDay;
				}				
				
				var maxYear	= maxDate.getFullYear();
				var maxDateString = '' + maxMonth + '/' + maxDay + '/' + maxYear + '';
				
				if(tDateDate.getTime() < fDateDate.getTime())
				{
					alert5 = "\n - \"To\" Date must be later than \"From\" date";
				}				

                dateDiff = Math.ceil((tDateDate.getTime()-fDateDate.getTime())/(one_day));
                if(dateDiff > maxDateDiff )
                {
                    alert6 = "\n - \"To\" Date can not be later than " + maxDateDiff + " days from the \"From\" date.\n   The \"To\" Date has been reset to " +  maxDateString + ".\n   Click the refresh button to view changes.";
                    document.getElementById('tbToDate').value =   maxDateString;                  
                }
	if (alert1.length > 0 || alert2.length >0 || alert3.length > 0 || alert4.length >0 || alert5.length >0 || alert6.length >0 )
	{
		alert('Please correct the following' + alert1 + ' ' +  alert2 + ' ' + alert3 + ' ' + alert4 + ' ' + alert5 + ' ' + alert6);
		return false;
	}
	else
	{		    	    	    
		if(submitMe == true)
		{
			document.getElementById('lblMarquee').innerHTML='<span style=\'background-color: #FFFFCC\'>&nbsp;Loading&nbsp;<marquee width=\'30\'  direction=\'right\'  loop=\'10\' scrolldelay=\'20\' name=myheader id=myheader onmouseover=\'slowMarquee(1000)\' onmouseout=\'slowMarquee(20)\' >...</marquee></span>';
			document.frmHost.submit();
		}
		return true;
	}

}