  function CheckNum(f) {
       if (isNaN(f.value)) {
	      alert ('Error: You Entered \n'+f.value+'\n Trường này phải là kiểu số. \n Number require.');
		  f.value = "";
		  f.focus();
		  return false;
	   }
	   return true;
   }

  function CheckDate(f, msg) {
       if (f.value == "") {
	      return true;
	   }
       ParseDay = f.value.substring(0, f.value.indexOf("/"));
	   ParseMonth = f.value.substring(f.value.indexOf("/") + 1, f.value.lastIndexOf("/"));
	   ParseYear = f.value.substring(f.value.lastIndexOf("/") + 1, f.value.length);
	   EnterDate = new Date (ParseMonth + "/" + ParseDay + "/" + ParseYear);
	   EnterDay = EnterDate.getDate();
	   EnterMonth = EnterDate.getMonth() + 1;
       if ((ParseDay != EnterDay) || (ParseMonth != EnterMonth)) {
	      alert (msg);
		  f.value = "";
		  f.focus();
		  return false;
	   }
	   return true;
   }

function changeUser( intUser ) {
	window.navigate( "default.asp?User=" + intUser );
}
function showDiv( strDiv ) {
	if (document.getElementById( strDiv ).style.display == 'block') {
		document.getElementById( strDiv ).style.display = 'none';
	} else {
		document.getElementById( strDiv ).style.display = 'block';
	}
}
function changeCheck() {
	if (document.getElementById( 'chkMineOnly' ).checked == false) {
		window.navigate( "default.asp?Checked=2" );
	} else {
		window.navigate( "default.asp?Checked=1" );
	}
}
function incTime( obj ) {
	var fltParsed = parseFloat( obj.value );
	
	if (event.button == 2) event.cancelBubble = true;
	if (isNaN(fltParsed)) {
		obj.value = 0;
	} else {
		if (fltParsed > 50) {
			// Do nothing!
		} else {
			obj.value = event.shiftKey ? fltParsed + 1 : fltParsed + .25;
		}
	}
}
function decTime( obj ) {
	var fltParsed = parseFloat( obj.value );
	
	if (isNaN(fltParsed)) {
		obj.value = 0;
	} else {
		if (fltParsed < .25) {
			// Do nothing!
		} else {
			obj.value = event.shiftKey ? fltParsed - 1 : fltParsed - .25;
		}
	}
}
function incPercent( obj, strDefault ) {
	var intParsed = parseInt( obj.value );
	
	if (isNaN(intParsed)) {
		obj.value = strDefault;
	} else {
		if (intParsed > 95) {
			// Do nothing!
		} else {
			obj.value = event.shiftKey ? intParsed + 10 : intParsed + 5;
		}
	}
}
function decPercent( obj, strDefault ) {
	var intParsed = parseInt( obj.value );
	
	if (isNaN(intParsed)) {
		obj.value = strDefault;
	} else {
		if (intParsed < 5) {
			// Do nothing!
		} else {
			obj.value = event.shiftKey ? intParsed - 10 : intParsed - 5;
		}
	}
}

function incDate( obj ) {
	// Construct a date object to utilize Date methods.
	var dat = new Date( obj.value );
	
	// If shift is down, modify by a week, else only 1 day.
	event.shiftKey ? dat.setDate( dat.getDate() + 7) : dat.setDate( dat.getDate() + 1);
	if (obj.name == "txtBegin") {
		datBegin = (dat.getMonth()+1) + "/" + dat.getDate() + "/" + dat.getYear();
	}
	else {
		datExpected = (dat.getMonth()+1) + "/" + dat.getDate() + "/" + dat.getYear();
	}
		
	// Trim the time off of the string by not taking the last 12 characters.
	// Hopefully this will be the length of the time + am/pm indicator on 
	// every system.
	obj.value = dat.toLocaleString().substr( 0, dat.toLocaleString().length - 12);
}
function decDate( obj ) {
	// Construct a date object to utilize Date methods.
	var dat = new Date( obj.value );
	
	// If shift is down, modify by a week, else only 1 day.
	event.shiftKey ? dat.setDate( dat.getDate() - 7) : dat.setDate( dat.getDate() - 1);
	if (obj.name == "txtBegin") {
		datBegin = (dat.getMonth()+1) + "/" + dat.getDate() + "/" + dat.getYear();
	}
	else {
		datExpected = (dat.getMonth()+1) + "/" + dat.getDate() + "/" + dat.getYear();
	}
	
	// Trim the time off of the string by not taking the last 12 characters.
	// Hopefully this will be the length of the time + am/pm indicator on 
	// every system.
	obj.value = dat.toLocaleString().substr( 0, dat.toLocaleString().length - 12);
}
function convertDates() {
	document.frmNew.txtBegin.value = datBegin;
	document.frmNew.txtExpected.value = datExpected;				
}
function keyCheck() {
	// TAB = 9
	// + = 187 
	// - = 189
	// Shift = 17  
	// CRLF = 13
	if (event.keyCode == 187) {
		incDate( event.srcElement );
	} else if (event.keyCode == 189) {
		decDate( event.srcElement );
	} else if (event.keyCode == 9) {
		return;
	} else if (event.keyCode == 13) {
		return;
	}
	event.returnValue = false;
}

function confirmCheck( strAction ) {
	var strConfirm = "Are you sure you would like to " + strAction + " this item?\n\n";
	
	if (strAction == "complete") 
		strConfirm += 
			"(Note: Currently you can not undo this operation.\n" +
			"If you wish to get an item back that has been completed, you must\n" +
			"go into the database and null out the 'COMPLETE' fields in either the\n" +
			"task or project.)";
	else
		strConfirm +=
			"(Note: Currently you can not undo this operation.\n" +
			"If you delete an item, all time that you have logged on it\n" +
			"will be lost.  If you would like to keep the time for reporting\n" +
			"purposes, you must 'complete' the item instead.  Deleting can not\n" +
			"be undone.)";
			
	if (confirm( strConfirm ) == 1)
		event.returnValue = true;
	else
		event.returnValue = false;
}

function voteRemind() {
	if (confirm( "Even though this program has already won the November coding contest at " +
		"Planet Source Code, \nyou can still show your support for this product by giving it a " +
		"rating.  If you click 'OK' below you will\n be brought to this code's screen " +
		"on PSC. Scroll down to the 'Your Vote' section and cast\n your vote.  You may click " +
		"cancel at this time to stay on this screen." ) == 1)
		event.returnValue = true;
	else
		event.returnValue = false;
}
function ShowDate(oDoc,cDate)
{
if (cDate=="")
	{
		today = new Date();
		date = today.getDate();
		month = today.getMonth()+1;
		year = today.getYear();
		cDate=month+'/'+date+'/'+year;
	}
window.open("datepicker.asp?backf="+oDoc+"&cDate="+cDate,"window", "height=210, width=300, resizeable=no,","");
}
