function PopulateCourses()
{var ddl_qualification=document.getElementById('ddl_qualification');var ddlcourses=document.getElementById('ddl_courses');var PagePath="Ajax/AjaxGetCourses.aspx";populateCourses(ddl_qualification,ddlcourses,PagePath)
return false;}
function PopulateStates()
{var ddlcourses=document.getElementById('ddl_courses');var ddlstates=document.getElementById('ddl_States');var PagePath="Ajax/AjaxGetStates.aspx";populateStates(ddlcourses,ddlstates,PagePath);return false;}
function PopulateCentres()
{var ddlCourses=document.getElementById('ddl_courses');var CourseName=ddlCourses.options[ddlCourses.selectedIndex].value
var ddlstates=document.getElementById('ddl_States');var ddlcentres=document.getElementById('ddl_centres');document.getElementById('hdn_city').value='';var PagePath="Ajax/AjaxGetCentre.aspx";populateCentres(ddlstates,ddlcentres,CourseName,PagePath);return false;}
function assignCity()
{var ddlcentres=document.getElementById('ddl_centres');document.getElementById('hdn_city').value=ddlcentres.options[ddlcentres.selectedIndex].value}
function PopulateCity()
{var ddl_state=document.getElementById('ddl_currstate');var ddl_city=document.getElementById('ddl_currcity');var PagePath="Ajax/AjaxCitymaster.aspx";populateCity(ddl_state,ddl_city,PagePath);if(document.getElementById('ddl_currstate').selectedIndex!='0')
{document.getElementById('txtState').value=document.getElementById('ddl_currstate').options[document.getElementById('ddl_currstate').selectedIndex].text;document.getElementById('txtCity').value='';document.getElementById('tb_city').style.display='none';}
else
{document.getElementById('txtState').value='';document.getElementById('txtCity').value='';document.getElementById('tb_city').style.display='none';}
return false;}
function funcCitySelection()
{if(document.getElementById('ddl_currcity').options[document.getElementById('ddl_currcity').selectedIndex].text=='Others')
{document.getElementById('tb_city').style.display='';document.getElementById('txtCity').value=document.getElementById('ddl_currcity').options[document.getElementById('ddl_currcity').selectedIndex].text;}
else
{document.getElementById('tb_city').style.display='none';document.getElementById('txtCity').value=document.getElementById('ddl_currcity').options[document.getElementById('ddl_currcity').selectedIndex].text;}}
function funcCatchCity()
{document.getElementById('txtCity').value=document.getElementById('tb_city').value;}
function OnFocusFName()
{var txtFname=document.getElementById('txtFName');if(txtFname.value.toUpperCase()=="FIRST NAME")
txtFname.value='';return false;}
function OnBlurFName()
{var txtFname=document.getElementById('txtFName');if(txtFname.value.toUpperCase()=='')
txtFname.value='First Name';return false;}
function OnFocusLName()
{var txtLname=document.getElementById('txtLName');if(txtLname.value.toUpperCase()=="LAST NAME")
txtLname.value='';return false;}
function OnBlurLName()
{var txtLname=document.getElementById('txtLName');if(txtLname.value.toUpperCase()=='')
txtLname.value='Last Name';return false;}
function OnFocusEmail()
{var txtEmail=document.getElementById('txtEmail');if(txtEmail.value.toUpperCase()=="EMAIL ID")
txtEmail.value='';return false;}
function OnBlurEmail()
{var txtEmail=document.getElementById('txtEmail');if(txtEmail.value.toUpperCase()=='')
txtEmail.value='Email ID';return false;}
function OnFocusPhone()
{var txtPhone=document.getElementById('txtLandLine');if(txtPhone.value.toUpperCase()=="LANDLINE")
txtPhone.value='';return false;}
function OnBlurPhone()
{var txtPhone=document.getElementById('txtLandLine');if(txtPhone.value.toUpperCase()=='')
txtPhone.value='Landline';return false;}
function OnFocusCity()
{var txtCity=document.getElementById('txtCity');if(txtCity.value.toUpperCase()=="CITY")
txtCity.value='';return false;}
function OnBlurCity()
{var txtCity=document.getElementById('txtCity');if(txtCity.value.toUpperCase()=='')
txtCity.value='City';return false;}
function OnFocusPinCode()
{var txtPinCode=document.getElementById('txtPinCode');if(txtPinCode.value.toUpperCase()=="PIN CODE")
txtPinCode.value='';return false;}
function OnBlurPinCode()
{var txtPinCode=document.getElementById('txtPinCode');if(txtPinCode.value.toUpperCase()=='')
txtPinCode.value='Pin code';return false;}
function OnFocusComments()
{var txtComments=document.getElementById('txtComments');if(txtComments.value.toUpperCase()=="QUESTIONS (IF ANY)")
txtComments.value='';return false;}
function OnBlurComments()
{var txtComments=document.getElementById('txtComments');if(txtComments.value.toUpperCase()=='')
txtComments.value='Questions (if any)';return false;}
function OnFocusMobile(){var txtMobile=document.getElementById('tb_phone')
if(txtMobile.value.toUpperCase()=="MOBILE")
txtMobile.value=''
return false}
function OnBlurMobile(){var txtMobile=document.getElementById('tb_phone')
if(txtMobile.value.toUpperCase()=='')
txtMobile.value='Mobile'
return false}
function OnFocusSTDCode(){var txtSTDCode=document.getElementById('txtStdCode')
if(txtSTDCode.value.toUpperCase()=="STD")
txtSTDCode.value=''
return false}
function OnBlurSTDCode(){var txtSTDCode=document.getElementById('txtStdCode')
if(txtSTDCode.value.toUpperCase()=='')
txtSTDCode.value='STD'
return false}

function validation()
{
    if(document.getElementById('txtFName').value.toUpperCase()=="FIRST NAME"&&document.getElementById('txtLName').value.toUpperCase()=="LAST NAME")
    {
        alert('Please enter your Name');
        document.getElementById('txtFName').focus();
        return false;
    }
    if(document.getElementById('txtFName').value.toUpperCase()!="FIRST NAME")
    {
        var val=document.getElementById('txtFName').value;
		//alert(val);
		var len=val.length;
		//alert(len)
		var chars="0123456789!@#$%^&*()_+?";
		//alert(chars);
		var flag=false;
		
		var name ="";
		for(i=0;i<len;i++)
		{
		    name=val.charAt(i);
			//alert(abc);
			if(chars.indexOf(name)!=-1)
			{
			    alert('Please enter a valid name (A-Z, a-z,special chars)');
			    document.getElementById('txtFName').focus();
				//flag=true;
				return false;
				break;
				//document.getElementById('Name_Error_valid').style.display='none';
				//alert(name);
			}
			/*else
			{
				//document.getElementById('Name_Error_valid').style.display='none';
				//alert(name);
			}*/
		}
			
    }
    if(document.getElementById('txtLName').value.toUpperCase()!="LAST NAME")
    {
        var val=document.getElementById('txtLName').value;
		//alert(val);
		var len=val.length;
		//alert(len)
		var chars="0123456789!@#$%^&*()_+?";
		//alert(chars);
		var flag=false;
		
		var name ="";
		for(i=0;i<len;i++)
		{
		    name=val.charAt(i);
			//alert(abc);
			if(chars.indexOf(name)!=-1)
			{
			    alert('Please enter a valid name (A-Z, a-z,special chars)');
			    document.getElementById('txtLName').focus();
				//flag=true;
				return false;
				break;
				//document.getElementById('Name_Error_valid').style.display='none';
				//alert(name);
			}
			/*else
			{
				//document.getElementById('Name_Error_valid').style.display='none';
				//alert(name);
			}*/
		}
			
    }

    if(document.getElementById('ddL_DOTDate').selectedIndex=='0')
	{
	    alert('Please select your Date of Birth');
        document.getElementById('ddL_DOTDate').focus();
        return false;
	}
	if(document.getElementById('ddl_DOTMonth').selectedIndex=='0')
	{
	    alert('Please select your Month of Birth');
        document.getElementById('ddl_DOTMonth').focus();
        return false;
	}
	if(document.getElementById('ddl_DOTYear').selectedIndex=='0')
	{
	    alert('Please select your Year of Birth');
        document.getElementById('ddl_DOTYear').focus();
        return false;
	}
    if(document.getElementById('txtEmail').value.toUpperCase()=="EMAIL ID")
    {
        alert('Please enter your Email ID');
        document.getElementById('txtEmail').focus();
        return false;
    }
    if(echeck(document.getElementById('txtEmail').value)==false)
    {
        document.getElementById('txtEmail').focus();
        return false;
    }
    if((document.getElementById('tb_phone').value.toUpperCase()=="MOBILE")&&(document.getElementById('txtLandLine').value.toUpperCase()=="LANDLINE"))
    {
        alert('Please enter your Phone Number');
        document.getElementById('tb_phone').focus();
        return false;
    }
    /*if(isNaN(document.getElementById('tb_phone').value)||document.getElementById('tb_phone').value.length<6)
    {
        alert('Please enter a valid phone number');
        document.getElementById('tb_phone').focus();
        return false;
    }*/
    if(document.getElementById('tb_phone').value.toUpperCase()!="MOBILE")
    {
        if(isNaN(document.getElementById('tb_phone').value) || (document.getElementById('tb_phone').value.charAt(0)!='9' && document.getElementById('tb_phone').value.charAt(0)!='8') || document.getElementById('tb_phone').value.length!='10')
	    {
    	    alert('Please enter a valid Phone Number');
            document.getElementById('tb_phone').focus();
            return false;
	    }
	}
    if(document.getElementById('txtLandLine').value.toUpperCase()!="LANDLINE")
    {
        if(isNaN(document.getElementById('txtLandLine').value)||document.getElementById('txtLandLine').value.length<6)
        {
            alert('Please enter a valid Phone Number');
            document.getElementById('txtLandLine').focus();
            return false;
        }
    }
    if(document.getElementById('ddl_currstate').selectedIndex=='0')
    {
        alert('Please select your State');
        document.getElementById('ddl_currstate').focus();
        return false;
    }
    if(document.getElementById('ddl_currcity').selectedIndex=='0')
    {
        alert('Please select your City');
        document.getElementById('ddl_currcity').focus();
        return false;
    }
    if(document.getElementById('ddl_currcity').options[document.getElementById('ddl_currcity').selectedIndex].text=='Others'&&document.getElementById('tb_city').value=='')
    {
        alert('Please enter your City');
        document.getElementById('tb_city').focus();
        return false;
    }
    if(document.getElementById('txtPinCode').value.toUpperCase()=="PIN CODE")
    {
        alert('Please enter your Pin code');
        document.getElementById('txtPinCode').focus();
        return false;
    }
    if(isNaN(document.getElementById('txtPinCode').value))
    {
        alert('Please enter a valid Pin code (numbers 0 - 9)');
        document.getElementById('txtPinCode').focus();
        return false;
    }
    if(document.getElementById('ddl_qualification').selectedIndex==0)
    {
        alert('Please select your qualification');
        document.getElementById('ddl_qualification').focus();
        return false;
    }
    if(document.getElementById('ddl_courses').selectedIndex==0)
    {
        alert('Please select Course Interested in');
        document.getElementById('ddl_courses').focus();
        return false;
    }
    if(document.getElementById('ddl_States').selectedIndex==0)
    {
        alert('Please select your Preferred Aptech State');
        document.getElementById('ddl_States').focus();
        return false;
    }
    if(document.getElementById('ddl_centres').selectedIndex==0)
    {
        alert('Please select your Preferred Aptech Centre');
        document.getElementById('ddl_centres').focus();
        return false;
    }
    return true;
}
function echeck(str){var at="@"
var dot="."
var lat=str.indexOf(at)
var lstr=str.length
var ldot=str.indexOf(dot)
if(str.indexOf(at)==-1){alert("Please enter a valid Email ID")
return false}
if(str.indexOf(at)==-1||str.indexOf(at)==0||str.indexOf(at)==lstr){alert("Please enter a valid Email ID")
return false}
if(str.indexOf(dot)==-1||str.indexOf(dot)==0||str.indexOf(dot)==lstr){alert("Please enter a valid Email ID")
return false}
if(str.indexOf(at,(lat+1))!=-1){alert("Please enter a valid Email ID")
return false}
if(str.substring(lat-1,lat)==dot||str.substring(lat+1,lat+2)==dot){alert("Please enter a valid Email ID")
return false}
if(str.indexOf(dot,(lat+2))==-1){alert("Please enter a valid Email ID")
return false}
if(str.indexOf(" ")!=-1){alert("Please enter a valid Email ID")
return false}
return true}

// Form Tracker
function FNameData() {
    var brand = "ACE"; 
    var txtFName=document.getElementById('txtFName');
    var PagePath="Ajax/InsertFormEntry.aspx?brand=" + brand + "&FName=" + txtFName.value;
    InsertFormsData(brand,PagePath);
    return false;
}
function LNameData() {
    var brand = "ACE"; 
    var txtLName=document.getElementById('txtLName');
    var PagePath="Ajax/InsertFormEntry.aspx?brand=" + brand + "&LName=" + txtLName.value;
    InsertFormsData(brand,PagePath);
    return false;
}
function DayData() {
    var brand = "ACE"; 
    var ddL_DOTDate=document.getElementById('ddL_DOTDate');
    var PagePath="Ajax/InsertFormEntry.aspx?brand=" + brand + "&DOB=" + ddL_DOTDate.options[ddL_DOTDate.selectedIndex].value;
    InsertFormsData(brand,PagePath);
    return false;
}
function MonthData() {
    var brand = "ACE"; 
    var ddL_DOTDate=document.getElementById('ddL_DOTDate');
    var ddl_DOTMonth=document.getElementById('ddl_DOTMonth');
    var PagePath="Ajax/InsertFormEntry.aspx?brand=" + brand + "&DOB=" + ddL_DOTDate.options[ddL_DOTDate.selectedIndex].value + "/" + ddl_DOTMonth.options[ddl_DOTMonth.selectedIndex].value;
    InsertFormsData(brand,PagePath);
    return false;
}
function YearData() {
    var brand = "ACE"; 
    var ddL_DOTDate=document.getElementById('ddL_DOTDate');
    var ddl_DOTMonth=document.getElementById('ddl_DOTMonth');
    var ddl_DOTYear=document.getElementById('ddl_DOTYear');
    var PagePath="Ajax/InsertFormEntry.aspx?brand=" + brand + "&DOB=" + ddL_DOTDate.options[ddL_DOTDate.selectedIndex].value + "/" + ddl_DOTMonth.options[ddl_DOTMonth.selectedIndex].value+ "/" + ddl_DOTYear.options[ddl_DOTYear.selectedIndex].value;
    InsertFormsData(brand,PagePath);
    return false;
}
function MaleData() {
    var brand = "ACE"; 
    var PagePath="Ajax/InsertFormEntry.aspx?brand=" + brand + "&Gender=Male";
    InsertFormsData(brand,PagePath);
    return false;
}
function FemaleData() {
    var brand = "ACE"; 
    var PagePath="Ajax/InsertFormEntry.aspx?brand=" + brand + "&Gender=Female";
    InsertFormsData(brand,PagePath);
    return false;
}
function EmailData() {
    var brand = "ACE"; 
    var txtEmail=document.getElementById('txtEmail');
    var PagePath="Ajax/InsertFormEntry.aspx?brand=" + brand + "&Email=" + txtEmail.value;
    InsertFormsData(brand,PagePath);
    return false;
}
function TelNoData() {
    var brand = "ACE"; 
    var tb_phone=document.getElementById('tb_phone');
    var PagePath="Ajax/InsertFormEntry.aspx?brand=" + brand + "&TelNo=" + tb_phone.value;
    InsertFormsData(brand,PagePath);
    return false;
}
function PhoneData() {
    var brand = "ACE"; 
    var txtStdCode=document.getElementById('txtStdCode');
    var txtLandLine=document.getElementById('txtLandLine');
    var PagePath="Ajax/InsertFormEntry.aspx?brand=" + brand + "&PhoneNo=" + txtStdCode.value + "-" +txtLandLine.value;
    InsertFormsData(brand,PagePath);
    return false;
}
function CurrStateData() {
    var brand = "ACE"; 
    var ddl_currstate=document.getElementById('ddl_currstate');
    var PagePath="Ajax/InsertFormEntry.aspx?brand=" + brand + "&State=" + ddl_currstate.options[ddl_currstate.selectedIndex].value;
    InsertFormsData(brand,PagePath);
    return false;
}
function CurrCityData() {
    var brand = "ACE"; 
    var ddl_currcity=document.getElementById('ddl_currcity');
    var PagePath="Ajax/InsertFormEntry.aspx?brand=" + brand + "&City=" + ddl_currcity.options[ddl_currcity.selectedIndex].value;
    InsertFormsData(brand,PagePath);
    return false;
}
function PinData() {
    var brand = "ACE"; 
    var txtPinCode=document.getElementById('txtPinCode');
    var PagePath="Ajax/InsertFormEntry.aspx?brand=" + brand + "&Pin=" + txtPinCode.value;
    InsertFormsData(brand,PagePath);
    return false;
}
function CourseData() {
    var brand = "ACE"; 
    var ddl_courses=document.getElementById('ddl_courses');
    var PagePath="Ajax/InsertFormEntry.aspx?brand=" + brand + "&Course=" + ddl_courses.options[ddl_courses.selectedIndex].value;
    InsertFormsData(brand,PagePath);
    return false;
}
function StateData() {
    var brand = "ACE"; 
    var ddl_States=document.getElementById('ddl_States');
    var PagePath="Ajax/InsertFormEntry.aspx?brand=" + brand + "&PrefState=" + ddl_States.options[ddl_States.selectedIndex].value;
    InsertFormsData(brand,PagePath);
    return false;
}
function CityData() {
    var brand = "ACE"; 
    var ddl_centres=document.getElementById('ddl_centres');
    var PagePath="Ajax/InsertFormEntry.aspx?brand=" + brand + "&PrefCentre=" + ddl_centres.options[ddl_centres.selectedIndex].value;
    InsertFormsData(brand,PagePath);
    return false;
}
function CommentsData() {
    var brand = "ACE"; 
    var txtComments=document.getElementById('txtComments');
    var PagePath="Ajax/InsertFormEntry.aspx?Comments=" + brand + "&Pin=" + txtComments.value;
    InsertFormsData(brand,PagePath);
    return false;
}

