function FormatIt(obj) {
	if (obj.value.length == 2)
		obj.value = obj.value + "/";
	if (obj.value.length == 5)
		obj.value = obj.value + "/";
}
function isNumberKey(evt) {
	var charCode = (evt.which) ? evt.which : event.keyCode;
	if (charCode > 31 && (charCode < 48 || charCode > 57)) {
		return false;
	}
	else {
		var mobile = document.getElementById("MobileNoTextBox").value;
		var DOB = document.getElementById("BirthDateTextBox").value;
		if (mobile != "") {
			document.getElementById("mobilenull").style.display = 'none';
		}
		if (DOB != "") {
			document.getElementById("dobdnull").style.display = 'none';
		}
	}
}
function isNumberKeyZip(evt) {
	var charCode = (evt.which) ? evt.which : event.keyCode
	if (charCode > 31 && (charCode < 48 || charCode > 57)) {
		return false;
	}
}
function OnlyNumericEntry() {
	if ((event.keyCode < 48 || event.keyCode > 57 || event.keyCode == 13 || event.keyCode == 176)) {
		event.returnValue = false;
	}
	else {
		var mobile = document.getElementById("MobileNoTextBox").value;
		var DOB = document.getElementById("BirthDateTextBox").value;
		if (mobile != "") {
			document.getElementById("mobilenull").style.display = 'none';
		}
		if (DOB != "") {
			document.getElementById("dobdnull").style.display = 'none';
		}
	}
}
function checkNum() {
	if ((event.keyCode > 64 && event.keyCode < 91) || (event.keyCode > 96 && event.keyCode < 123) || event.keyCode == 8 || event.keyCode == 32 || event.keyCode == 13 || event.keyCode == 176) {
		var fname = document.getElementById("FirstNameTextBox").value;
		var lname = document.getElementById("LastNameTextBox").value;
		if (fname != "") {
			document.getElementById("fnamenull").style.display = 'none';
		}
		if (lname != "") {
			document.getElementById("lnamenull").style.display = 'none';
		}
	}
	else {
		event.returnValue = false;
	}
}
function ValidateNull() {
	var fname = document.getElementById("FirstNameTextBox").value;
	var lname = document.getElementById("LastNameTextBox").value;
	var gender = document.getElementById("GenderDropDownList").value;
	var org = document.getElementById("OrgDropDownList").value;
	var batch = document.getElementById("BatchDropDownList").value;
	var standard = document.getElementById("StandardDropDownList").value;
	var DOB = document.getElementById("BirthDateTextBox").value;
	var mobile = document.getElementById("MobileNoTextBox").value;
	if (fname == "" || lname == "" || gender == "-1" || org == "-1" || batch == "-1" || standard == "-1" || DOB == "" || mobile == "") {
		if (!(/^\d{10}$/.test(mobile))) {
			document.getElementById("mobilenull").style.display = 'block';
		}
		if (mobile == "") {
			document.getElementById("mobilenull").style.display = 'block';
			$('#ctl00_CP_MobileNoTextBox').focus();
		}
		if (DOB == "") {
			document.getElementById("dobdnull").style.display = 'block';
			$('#ctl00_CP_BirthDateTextBox').focus();
		}
		if (gender == "-1") {
			document.getElementById("gendernull").style.display = 'block';
			$('#ctl00_CP_GenderDropDownList').focus();
		}
		if (lname == "") {
			document.getElementById("lnamenull").style.display = 'block';
			$('#ctl00_CP_LastNameTextBox').focus();
		}
		if (fname == "") {
			document.getElementById("fnamenull").style.display = 'block';
			$('#ctl00_CP_FirstNameTextBox').focus();
		}
		if (org == "-1") {
			document.getElementById("orgnull").style.display = 'block';
		}
		if (batch == "-1") {
			document.getElementById("batchnull").style.display = 'block';
		}
		if (standard == "-1") {
			document.getElementById("standardnull").style.display = 'block';
		}
		return false;
	}
	else if (fname != "" && lname != "" && gender != "-1" && org != "-1" && batch != "-1" && standard != "-1" && DOB != "" && mobile != "") {
		var mobilenumber = document.getElementById("MobileNoTextBox");
		var textLength = mobilenumber.value.length;
		if (textLength <= 9) {
			document.getElementById("mobilenull").style.display = 'block';
			$('#ctl00_CP_MobileNoTextBox').focus();
			return false;
		}
		var pattern = /^([0-9]{2})\/([0-9]{2})\/([0-9]{4})$/;
		if (!pattern.test(DOB)) {
			alert("Date Should be in dd/mm/yyyy format");
			$('#<ctl00_CP_BirthDateTextBox').focus();
			return false;
		}
	}
}
function DropDownCheck(obj) {
	var value = document.getElementById(obj.id).value;
	if (value == "-1") {
		if (obj.id == "GenderDropDownList") {
			document.getElementById("gendernull").style.display = 'block';
		}
		if (obj.id == "OrgDropDownList") {
			document.getElementById("orgnull").style.display = 'block';
		}
		if (obj.id == "BatchDropDownList") {
			document.getElementById("batchnull").style.display = 'block';
		}
		if (obj.id == "StandardDropDownList") {
			document.getElementById("standardnull").style.display = 'block';
		}
		return false;
	}
	else {
		if (obj.id == "GenderDropDownList") {
			document.getElementById("gendernull").style.display = 'none';
		}
		if (obj.id == "OrgDropDownList") {
			document.getElementById("orgnull").style.display = 'none';
		}
		if (obj.id == "BatchDropDownList") {
			document.getElementById("batchnull").style.display = 'none';
		}
		if (obj.id == "StandardDropDownList") {
			document.getElementById("standardnull").style.display = 'none';
		}
		return false;
	}
}
$(function () {
	var currentYear = (new Date).getFullYear();
	$("#BirthDateTextBox").datepicker({
		dateFormat: 'dd/mm/yy',
		changeYear: true,
		changeMonth: true,
		yearRange: "1900:currentYear"
	}).val();
});