function FillDropDown(EmployeeId)
{
    if(document.getElementById("ctl00_ContentPlaceHolder1_hdnEmpConsultantFlag").value == 'Employee')
        document.getElementById("lblMessage").innerHTML = "EMPLOYEE REGISTRATION";
    else if(document.getElementById("ctl00_ContentPlaceHolder1_hdnEmpConsultantFlag").value == 'Consultant')
        document.getElementById("lblMessage").innerHTML = "CONSULTANT REGISTRATION";

    // Fills Dropdwon of Secret Question, City, State
    var strConnection = EmployeeReg.GetConnectionString();
    FillCityList(strConnection.value);
    FillStateList(strConnection.value);
    FillYearList(strConnection.value);
    FillSecretQuestionList(strConnection.value);
    FillAnnualSalaryExpList(strConnection.value);
    FillAllQualifiationList(strConnection.value);
    FillFunctionalAreaList(strConnection.value);
    FillIndustryList(strConnection.value);
    FillPreferedJobLocation(strConnection.value);
    DisplayRole();
    
    if(EmployeeId!=0)
    {
        var dsEmpConsDet = EmployeeReg.GetEmpConsultantDetails(strConnection.value,EmployeeId);
        if(dsEmpConsDet.value.Tables[0].Rows.length>0)
        {
            document.getElementById('txtLoginID').value = dsEmpConsDet.value.Tables[0].Rows[0].LoginID ;
            document.getElementById('txtPassword').value = dsEmpConsDet.value.Tables[0].Rows[0].Password ;
            document.getElementById('txtConfirmPassword').value = dsEmpConsDet.value.Tables[0].Rows[0].Password ;
            
            var SecretQuestionId = dsEmpConsDet.value.Tables[0].Rows[0].SecretQuestionID ;
            
            for(var i=0; i<document.getElementById('DDLSecretQuestion').length;i++)
            {
                if(document.getElementById('DDLSecretQuestion').options[i].value==SecretQuestionId)
                {
                    document.getElementById('DDLSecretQuestion').selectedIndex=i;
                    i=document.getElementById('DDLSecretQuestion').length;
                }
            }
            
            
            document.getElementById('txtSecretAnswer').value = dsEmpConsDet.value.Tables[0].Rows[0].SecretQuestionAnswer;
            document.getElementById('txtFullName').value = dsEmpConsDet.value.Tables[0].Rows[0].FullName;
            document.getElementById('txtAddress').value = dsEmpConsDet.value.Tables[0].Rows[0].Address;
            
            var CityID = dsEmpConsDet.value.Tables[0].Rows[0].CityID ;
            
            for(var i=0; i<document.getElementById('DDLCity').length;i++)
            {
                if(document.getElementById('DDLCity').options[i].value==CityID)
                {
                    document.getElementById('DDLCity').selectedIndex=i;
                    i=document.getElementById('DDLCity').length;
                }
             
            }
            document.getElementById('txtPinCode').value = dsEmpConsDet.value.Tables[0].Rows[0].PinCode
            
            var StateID = dsEmpConsDet.value.Tables[0].Rows[0].StateID ;
            
            for(var i=0; i<document.getElementById('DDLState').length;i++)
            {
                if(document.getElementById('DDLState').options[i].value==StateID)
                {
                    document.getElementById('DDLState').selectedIndex=i;
                    i=document.getElementById('DDLState').length;
                }
             
            }
 
            document.getElementById('txtTelephone').value = dsEmpConsDet.value.Tables[0].Rows[0].Telephone;
            document.getElementById('txtMobile').value = dsEmpConsDet.value.Tables[0].Rows[0].Mobile;
            document.getElementById('txtEMailID').value = dsEmpConsDet.value.Tables[0].Rows[0].EMailID;
            
            var DOBDay = dsEmpConsDet.value.Tables[0].Rows[0].DOBDay ;
            
            for(var i=0; i<document.getElementById('DDLDay').length;i++)
            {
                if(document.getElementById('DDLDay').options[i].value==DOBDay)
                {
                    document.getElementById('DDLDay').selectedIndex=i;
                    i=document.getElementById('DDLDay').length;
                }
             
            }
            var DOBMonth = dsEmpConsDet.value.Tables[0].Rows[0].DOBMonth ;
            
            for(var i=0; i<document.getElementById('DDLMonth').length;i++)
            {
                if(document.getElementById('DDLMonth').options[i].value==DOBMonth)
                {
                    document.getElementById('DDLMonth').selectedIndex=i;
                    i=document.getElementById('DDLMonth').length;
                }
             
            }
            var DOBYear = dsEmpConsDet.value.Tables[0].Rows[0].DOBYear ;
            
            for(var i=0; i<document.getElementById('DDLYear').length;i++)
            {
                if(document.getElementById('DDLYear').options[i].value==DOBYear)
                {
                    document.getElementById('DDLYear').selectedIndex=i;
                    i=document.getElementById('DDLYear').length;
                }
             
            }
      
            document.getElementById('txtTotalExperiance').value = dsEmpConsDet.value.Tables[0].Rows[0].TotalExp;
            var FunctionalAreaID = dsEmpConsDet.value.Tables[0].Rows[0].FunctionalAreaID ;
            
            for(var i=0; i<document.getElementById('DDLFunctionalArea').length;i++)
            {
                if(document.getElementById('DDLFunctionalArea').options[i].value==FunctionalAreaID)
                {
                    document.getElementById('DDLFunctionalArea').selectedIndex=i;
                    i=document.getElementById('DDLFunctionalArea').length;
                }
             
            }
            DisplayRole();
            var RoleID = dsEmpConsDet.value.Tables[0].Rows[0].RoleID ;
            
            for(var i=0; i<document.getElementById('DDLRole').length;i++)
            {
                if(document.getElementById('DDLRole').options[i].value==RoleID)
                {
                    document.getElementById('DDLRole').selectedIndex=i;
                    i=document.getElementById('DDLRole').length;
                }
             
            }

            var IndustryID = dsEmpConsDet.value.Tables[0].Rows[0].IndustryID ;
            
            for(var i=0; i<document.getElementById('DDLIndustry').length;i++)
            {
                if(document.getElementById('DDLIndustry').options[i].value==IndustryID)
                {
                    document.getElementById('DDLIndustry').selectedIndex=i;
                    i=document.getElementById('DDLIndustry').length;
                }
             
            }

            document.getElementById('txtKeySkills').value = dsEmpConsDet.value.Tables[0].Rows[0].KeySkills;
            var ComputerKnowledge = dsEmpConsDet.value.Tables[0].Rows[0].ComputerKnowledge;
            if(ComputerKnowledge=="N")
            {
                document.getElementById('optComputerKnowledgeNo').checked=true;
            }
            else
            {
                document.getElementById('optComputerKnowledgeYes').checked=true;
            }
//          
           var BasicQualificationID = dsEmpConsDet.value.Tables[0].Rows[0].BasicQualificationID ;
            
            for(var i=0; i<document.getElementById('DDLBasicQualification').length;i++)
            {
                if(document.getElementById('DDLBasicQualification').options[i].value==BasicQualificationID)
                {
                    document.getElementById('DDLBasicQualification').selectedIndex=i;
                    i=document.getElementById('DDLBasicQualification').length;
                }
             
            }

           var PostGraduationID = dsEmpConsDet.value.Tables[0].Rows[0].PostGraduationID ;
            
            for(var i=0; i<document.getElementById('DDLPostGraduation').length;i++)
            {
                if(document.getElementById('DDLPostGraduation').options[i].value==PostGraduationID)
                {
                    document.getElementById('DDLPostGraduation').selectedIndex=i;
                    i=document.getElementById('DDLPostGraduation').length;
                }
             
            }
            
            var DoctorateID = dsEmpConsDet.value.Tables[0].Rows[0].DoctorateID ;
            
            for(var i=0; i<document.getElementById('DDLDoctorate').length;i++)
            {
                if(document.getElementById('DDLDoctorate').options[i].value==DoctorateID)
                {
                    document.getElementById('DDLDoctorate').selectedIndex=i;
                    i=document.getElementById('DDLDoctorate').length;
                }
             
            }


            document.getElementById('txtSpecialisation').value = dsEmpConsDet.value.Tables[0].Rows[0].Specialisation;
            var SameAsCity = dsEmpConsDet.value.Tables[0].Rows[0].SameAsCity;
            if(SameAsCity=="Y")
            {
                document.getElementById('chkSameAsCurrentCity').checked=true;
            }
            else
            {
                if(dsEmpConsDet.value.Tables[1].Rows.length>0)
                {
                    for(var j=0; j<dsEmpConsDet.value.Tables[1].Rows.length;j++)
                    {
                        var PJL= dsEmpConsDet.value.Tables[1].Rows[j].CityID;
                        
                         for(var i=0; i<document.getElementById('lstPreferredJobLocation').length;i++)
                        {
                            if(document.getElementById('lstPreferredJobLocation').options[i].value==PJL)
                            {
                                document.getElementById('lstPreferredJobLocation').options[i].selected=true;
                            }
                          
                         
                        }
                   }     
                }
                
            }
            
            var JobTypeID=dsEmpConsDet.value.Tables[0].Rows[0].JobTypeID;
            var EmploymentStatusID=dsEmpConsDet.value.Tables[0].Rows[0].EmploymentStatusID;
            
            if(JobTypeID==1)
            {
                document.getElementById('optJobTypePermanent').checked=true;
            }
            else if(JobTypeID==2)
            {
                document.getElementById('optJobTypeTemporary').checked=true;
            }
            else if(JobTypeID==3)
            {
                document.getElementById('optJobTypeEither').checked=true;
            }
            
            
            if(EmploymentStatusID==1)
            {
                document.getElementById('optEmpStatusFullTime').checked=true;
            }
            else if(EmploymentStatusID==2)
            {
                document.getElementById('optEmpStatusPartTime').checked=true;
            }
            else if(EmploymentStatusID==3)
            {
                document.getElementById('optEmpStatusEither').checked=true;
            }
            
//         
            var AnnualSalaryExpID = dsEmpConsDet.value.Tables[0].Rows[0].AnnualSalaryExpID ;
            
            for(var i=0; i<document.getElementById('DDLAnnualSalaryExpected').length;i++)
            {
                if(document.getElementById('DDLAnnualSalaryExpected').options[i].value==AnnualSalaryExpID)
                {
                    document.getElementById('DDLAnnualSalaryExpected').selectedIndex=i;
                    i=document.getElementById('DDLAnnualSalaryExpected').length;
                }
             
            }
           
            if(dsEmpConsDet.value.Tables[0].Rows[0].Attachment=="Y")
            {
                document.getElementById('ctl00_ContentPlaceHolder1_HdnGUID').value = dsEmpConsDet.value.Tables[0].Rows[0].GUID;
                document.getElementById('btnUpload').value='View Uploaded Resume';
                document.getElementById('lblResumeUploaded').innerHTML='&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Resume Uploaded Successfully.';
            }    
            //document.getElementById('btnSubmit').style.visibility="hidden";
            document.getElementById('btnSubmit').value='Update Resume';
            document.getElementById('ctl00_ContentPlaceHolder1_HdnEmployeeId').value =EmployeeId;
        }
    }
    
}
function FillSecretQuestionList(ConnectionString)
{
    // To Fill DropDown List Of SecretQuestions From 'SecretQuestionMaster' Table
    var dsSecretQuestion = EmployeeReg.FillSecretQuestionDropDown(ConnectionString);
    // Flush Table DropDown
    document.getElementById('DDLSecretQuestion').options.length = 0;

    if(dsSecretQuestion.value.Tables[0].Rows.length > 0)
    {
        for(var i=0; i < dsSecretQuestion.value.Tables[0].Rows.length; i++)
        {
            document.getElementById('DDLSecretQuestion').options[i] = new Option(dsSecretQuestion.value.Tables[0].Rows[i].SecretQuestion, dsSecretQuestion.value.Tables[0].Rows[i].SecretQuestionID);
        }
    }
    else
    {
        document.getElementById('DDLSecretQuestion').options[0] = new Option("<-- No Secret Question Defined -->", -1);
    }  
}
function FillCityList(ConnectionString)
{
    // To Fill DropDown List Of City From CityMaster Table
    var dsCity = EmployeeReg.FillCityDropDown(ConnectionString);
    // Flush Table DropDown
    document.getElementById('DDLCity').options.length = 0;

    if(dsCity.value.Tables[0].Rows.length > 0)
    {
        for(var i=0; i < dsCity.value.Tables[0].Rows.length; i++)
        {
            document.getElementById('DDLCity').options[i] = new Option(dsCity.value.Tables[0].Rows[i].CityName, dsCity.value.Tables[0].Rows[i].CityID);
        }
    }
    else
    {
        document.getElementById('DDLCity').options[0] = new Option("<-- No City Defined -->", -1);
    }  
}
function FillStateList(ConnectionString)
{
    // To Fill DropDown List Of State From StateMaster Table
   var dsState = EmployeeReg.FillStateDropDown(ConnectionString);
    // Flush Table DropDown
    document.getElementById('DDLState').options.length = 0;
    
    if(dsState.value.Tables[0].Rows.length > 0)
    {
        for(var i = 0; i < dsState.value.Tables[0].Rows.length; i++)
        {
            document.getElementById('DDLState').options[i] = new Option(dsState.value.Tables[0].Rows[i].StateName, dsState.value.Tables[0].Rows[i].StateID);
        }
    }
    else
    {
        document.getElementById('DDLState').options[0] = new Option("<!-- No State Defined -->", -1);
    }
}
function FillYearList(ConnectionString)
{
    // To Fill DropDown List Of State From StateMaster Table
   var dsYear = EmployeeReg.FillYearDropDown(ConnectionString);
    // Flush Table DropDown
    document.getElementById('DDLYear').options.length = 0;
    
    if(dsYear.value.Tables[0].Rows.length > 0)
    {
        for(var i = 0; i < dsYear.value.Tables[0].Rows.length; i++)
        {
            document.getElementById('DDLYear').options[i] = new Option(dsYear.value.Tables[0].Rows[i].Years, dsYear.value.Tables[0].Rows[i].Years);
        }
    }
    else
    {
        document.getElementById('DDLYear').options[0] = new Option("<!--No State Defined -->", -1);
    }
}
function FillAnnualSalaryExpList(ConnectionString)
{
    // To Fill DropDown List Of Annual Salary Expected From 'AnnualSalaryExpMaster' Table
    var dsAnnualSalaryExp = EmployeeReg.FillAnnualSalaryExpList(ConnectionString);
    // Flush Table DropDown
    document.getElementById('DDLAnnualSalaryExpected').options.length = 0;

    if(dsAnnualSalaryExp.value.Tables[0].Rows.length > 0)
    {
        for(var i=0; i < dsAnnualSalaryExp.value.Tables[0].Rows.length; i++)
        {
            document.getElementById('DDLAnnualSalaryExpected').options[i] = new Option(dsAnnualSalaryExp.value.Tables[0].Rows[i].AnnualSalaryExpDesc, dsAnnualSalaryExp.value.Tables[0].Rows[i].AnnualSalaryExpID);
        }
    }
    else
    {
        document.getElementById('DDLAnnualSalaryExpected').options[0] = new Option("<-- Not Defined -->", -1);
    }  
}
function FillAllQualifiationList(ConnectionString)
{
    // To Fill DropDown List Of Basic Qualification From 'BasicQualifiationMaster' Table
    var intQualificationType;
    var dsBasicQualification;
    // For Basic Qualification
    intQualificationType = 1;
    dsBasicQualification = EmployeeReg.FillQualifiationList(ConnectionString, intQualificationType);
    // Flush Table DropDown
    document.getElementById('DDLBasicQualification').options.length = 0;

    if(dsBasicQualification.value.Tables[0].Rows.length > 0)
    {
        for(var i=0; i < dsBasicQualification.value.Tables[0].Rows.length; i++)
        {
            document.getElementById('DDLBasicQualification').options[i] = new Option(dsBasicQualification.value.Tables[0].Rows[i].Qualification, dsBasicQualification.value.Tables[0].Rows[i].QualificationID);
        }
    }
    else
    {
        document.getElementById('DDLBasicQualification').options[0] = new Option("<-- Not Defined -->", -1);
    }  
    
    // For Post Graudate
    intQualificationType = 2;
    dsBasicQualification = EmployeeReg.FillQualifiationList(ConnectionString, intQualificationType);
    // Flush Table DropDown
    document.getElementById('DDLPostGraduation').options.length = 0;

    if(dsBasicQualification.value.Tables[0].Rows.length > 0)
    {
        for(var i=0; i < dsBasicQualification.value.Tables[0].Rows.length; i++)
        {
            document.getElementById('DDLPostGraduation').options[i] = new Option(dsBasicQualification.value.Tables[0].Rows[i].Qualification, dsBasicQualification.value.Tables[0].Rows[i].QualificationID);
        }
    }
    else
    {
        document.getElementById('DDLPostGraduation').options[0] = new Option("<-- Not Defined -->", -1);
    }
    
    // For Post Graudate
    intQualificationType = 3;
    dsBasicQualification = EmployeeReg.FillQualifiationList(ConnectionString, intQualificationType);
    // Flush Table DropDown
    document.getElementById('DDLDoctorate').options.length = 0;

    if(dsBasicQualification.value.Tables[0].Rows.length > 0)
    {
        for(var i=0; i < dsBasicQualification.value.Tables[0].Rows.length; i++)
        {
            document.getElementById('DDLDoctorate').options[i] = new Option(dsBasicQualification.value.Tables[0].Rows[i].Qualification, dsBasicQualification.value.Tables[0].Rows[i].QualificationID);
        }
    }
    else
    {
        document.getElementById('DDLDoctorate').options[0] = new Option("<-- Not Defined -->", -1);
    }
}
function FillFunctionalAreaList(ConnectionString)
{
    // To Fill DropDown List Of Functional Areas From 'FunctionalAreaMaster' Table
    var dsFunctionalArea = EmployeeReg.FillFunctionalAreaList(ConnectionString);
    // Flush Table DropDown
    document.getElementById('DDLFunctionalArea').options.length = 0;

    if(dsFunctionalArea.value.Tables[0].Rows.length > 0)
    {
        for(var i=0; i < dsFunctionalArea.value.Tables[0].Rows.length; i++)
        {
            document.getElementById('DDLFunctionalArea').options[i] = new Option(dsFunctionalArea.value.Tables[0].Rows[i].FunctionalAreaDesc, dsFunctionalArea.value.Tables[0].Rows[i].FunctionalAreaID);
        }
    }
    else
    {
        document.getElementById('DDLFunctionalArea').options[0] = new Option("<-- No Functional Area Defined -->", -1);
    }  
}
function DisplayRole()
{
    var SelIndexofFuntionalAreaID = document.getElementById("DDLFunctionalArea").selectedIndex;
    var FuntionalAreaID = document.getElementById("DDLFunctionalArea").options[SelIndexofFuntionalAreaID].value;
    var strConnection = EmployeeReg.GetConnectionString();
    var dsRole = EmployeeReg.GetRoleList(strConnection.value, FuntionalAreaID);
    var sel = document.getElementById('DDLRole');
    while (sel.firstChild)
    {
        sel.removeChild(sel.firstChild);
    }
    document.getElementById('DDLRole').length = 0;
    var cnt=0;
    if(dsRole.value.Tables[0].Rows.length > 0)
    {
        for(var i=0; i < dsRole.value.Tables[0].Rows.length; i++)
        {
            if(dsRole.value.Tables[0].Rows[i].Flag==0)
            {
                    cnt=cnt + 1;
                    var opt = document.createElement('OPTGROUP');
					opt.label = dsRole.value.Tables[0].Rows[i].RoleDesc;
					opt.id = "optg_"+ i ;
					opt.style.background = "#D0E0F1";
					opt.style.color = "#000";
					document.getElementById('DDLRole').appendChild(opt);
            }
            else
            {
                document.getElementById('DDLRole').options[i] = new Option(dsRole.value.Tables[0].Rows[i].RoleDesc, dsRole.value.Tables[0].Rows[i].RoleID);    	
                document.getElementById('DDLRole').options[i-cnt].style.background="#FFFFFF";
            }
            
        }
    }
    else
    {
        document.getElementById('DDLRole').options[0] = new Option("<--No role Defined -->", -1);
    }     
}
function FillIndustryList(ConnectionString)
{
    // To Fill DropDown List Of Industry List From 'IndustryMaster' Table
    var dsIndustry = EmployeeReg.FillIndustryList(ConnectionString);
    // Flush Table DropDown
    document.getElementById('DDLIndustry').options.length = 0;

    if(dsIndustry.value.Tables[0].Rows.length > 0)
    {
        for(var i=0; i < dsIndustry.value.Tables[0].Rows.length; i++)
        {
            document.getElementById('DDLIndustry').options[i] = new Option(dsIndustry.value.Tables[0].Rows[i].IndustryDesc, dsIndustry.value.Tables[0].Rows[i].IndustryID);
        }
    }
    else
    {
        document.getElementById('DDLIndustry').options[0] = new Option("<-- No Industry Defined -->", -1);
    }  
}
function FillPreferedJobLocation(ConnectionString)
{
    // To Fill DropDown List Of Industry List From 'IndustryMaster' Table
    var dsFillPreferedJobLocation = EmployeeReg.FillPreferedJobLocation(ConnectionString);
    // Flush Table DropDown
    document.getElementById('lstPreferredJobLocation').options.length = 0;

    if(dsFillPreferedJobLocation.value.Tables[0].Rows.length > 0)
    {
        for(var i=0; i < dsFillPreferedJobLocation.value.Tables[0].Rows.length; i++)
        {
            
            if(dsFillPreferedJobLocation.value.Tables[0].Rows[i].CityID == 0)
            {
                    document.getElementById('lstPreferredJobLocation').options[i] = new Option(dsFillPreferedJobLocation.value.Tables[0].Rows[i].CityName, dsFillPreferedJobLocation.value.Tables[0].Rows[i].CityID);
                    document.getElementById('lstPreferredJobLocation').options[i].style.background = "#D0E0F1"
                    document.getElementById('lstPreferredJobLocation').options[i].disabled="disabled";
            }
            else
            {
                document.getElementById('lstPreferredJobLocation').options[i] = new Option(dsFillPreferedJobLocation.value.Tables[0].Rows[i].CityName, dsFillPreferedJobLocation.value.Tables[0].Rows[i].CityID);
            }
        }
    }
    else
    {
        document.getElementById('lstPreferredJobLocation').options[0] = new Option("<-- Job Location Not Defined -->", -1);
    }  
}
function CheckValidation()
{
    // Triming All Parameters
    document.getElementById('txtLoginID').value = Trim(document.getElementById('txtLoginID').value);
    document.getElementById('txtPassword').value = Trim(document.getElementById('txtPassword').value);
    document.getElementById('txtConfirmPassword').value = Trim(document.getElementById('txtConfirmPassword').value);
    document.getElementById('txtSecretAnswer').value = Trim(document.getElementById('txtSecretAnswer').value);
    
    document.getElementById('txtFullName').value = Trim(document.getElementById('txtFullName').value);
    document.getElementById('txtAddress').value = Trim(document.getElementById('txtAddress').value);
    document.getElementById('txtPinCode').value = Trim(document.getElementById('txtPinCode').value);
    document.getElementById('txtTelephone').value = Trim(document.getElementById('txtTelephone').value);
    document.getElementById('txtMobile').value = Trim(document.getElementById('txtMobile').value);
    document.getElementById('txtEMailID').value = Trim(document.getElementById('txtEMailID').value).toLowerCase();

    document.getElementById('txtKeySkills').value = Trim(document.getElementById('txtKeySkills').value).toLowerCase();
    document.getElementById('txtSpecialisation').value = Trim(document.getElementById('txtSpecialisation').value).toLowerCase();
    
    // Checking All Validations
    if(document.getElementById('txtLoginID').value == '')
    {
        alert('Login ID should not be blank.');
        document.getElementById('txtLoginID').focus();
        return false;
    }
    if(document.getElementById('txtLoginID').value.length < 8)
    {
        alert('Login ID should be at least 8 characters.');
        document.getElementById('txtLoginID').focus();
        return false;
    }
    if(document.getElementById('txtPassword').value == '')
    {
        alert('Password should not be blank.');
        document.getElementById('txtPassword').focus();
        return false;
    }
    if(document.getElementById('txtPassword').value.length < 8)
    {
        alert('Password should be at least 8 characters.');
        document.getElementById('txtPassword').focus();
        return false;
    }
    if(document.getElementById('txtPassword').value != document.getElementById('txtConfirmPassword').value)
    {
        alert('Passwords typed do not match, please re-enter your passwords.');
        document.getElementById('txtPassword').focus();
        return false;
    }
    
    var SelIndexofSecretQuestionID = document.getElementById("DDLSecretQuestion").selectedIndex;
    var intSecretQuestionID = document.getElementById("DDLSecretQuestion").options[SelIndexofSecretQuestionID].value;
    if(intSecretQuestionID == -1)
    {
        alert('Please select secret question.');
        document.getElementById('DDLSecretQuestion').focus();
        return false;
    }
    if(document.getElementById('txtSecretAnswer').value == '')
    {
        alert('Secret answer should not be blank.');
        document.getElementById('txtSecretAnswer').focus();
        return false;
    }
    if(document.getElementById('txtFullName').value == '')
    {
        alert('Full Name can not be blank.');
        document.getElementById('txtFullName').focus();
        return false;
    }
    if(document.getElementById('txtAddress').value == '')
    {
        alert('Address should not be blank.');
        document.getElementById('txtAddress').focus();
        return false;
    }
    if(document.getElementById('txtAddress').value.length > 256)
    {
        alert('Address should be maximum 256 Characters.');
        document.getElementById('txtAddress').focus();
        return false;
    }

    var SelIndexofCityId = document.getElementById("DDLCity").selectedIndex;
    var intCityID = document.getElementById("DDLCity").options[SelIndexofCityId].value;
    if(intCityID == -1)
    {
        alert('Please select city.');
        document.getElementById('DDLCity').focus();
        return false;
    }
    if(IsNumeric(document.getElementById('txtPinCode').value, 'Pin Code', false, false, false, 1000000) == false)
    {
        document.getElementById('txtPinCode').focus();
        return false;
    }
    if(document.getElementById('txtPinCode').value.length < 6)
    {
        alert('Invalid Pin Code.');
        document.getElementById('txtPinCode').focus();
        return false;
    }
    var SelIndexofStateId = document.getElementById("DDLState").selectedIndex;
    var intStateID = document.getElementById("DDLState").options[SelIndexofStateId].value;
    if(intStateID == -1)
    {
        alert('Please select state.');
        document.getElementById('DDLState').focus();
        return false;
    }
    if(document.getElementById('txtTelephone').value == '')
    {
        alert('Telephone number should not be blank.');
        document.getElementById('txtTelephone').focus();
        return false;
    }
    if(CheckValidCharacter('0123456789 +:-[](),', document.getElementById('txtTelephone').value) == false)
    {
        alert('Invalid Telephone No.');
        document.getElementById('txtTelephone').focus();
        return false;
    }
    if(CheckValidCharacter('0123456789 +:-[](),', document.getElementById('txtMobile').value) == false)
    {
        alert('Invalid Mobile No.');
        document.getElementById('txtMobile').focus();
        return false;
    }
    if(EMailCheck(document.getElementById('txtEMailID').value, false) == false)
    {
        document.getElementById('txtEMailID').focus();
        return false;
    }
    if(IsNumeric(document.getElementById('txtTotalExperiance').value, 'Total Experience', false, false, false, 99) == false)
    {
        document.getElementById('txtTotalExperiance').focus();
        return false;
    }

    var SelIndexofFunctionalAreaID = document.getElementById("DDLFunctionalArea").selectedIndex;
    var intFunctionalAreaID = document.getElementById("DDLFunctionalArea").options[SelIndexofFunctionalAreaID].value;
    if(intFunctionalAreaID == -1)
    {
        alert('Please select Functional Area.');
        document.getElementById('DDLFunctionalArea').focus();
        return false;
    }
    var SelIndexofRoleID = document.getElementById("DDLRole").selectedIndex;
    var intRoleID = document.getElementById("DDLRole").options[SelIndexofRoleID].value;
    if(intRoleID == -1)
    {
        alert('Please select Role.');
        document.getElementById('DDLRole').focus();
        return false;
    }
    var SelIndexofIndustryID = document.getElementById("DDLIndustry").selectedIndex;
    var intIndustryID = document.getElementById("DDLIndustry").options[SelIndexofIndustryID].value;
    if(intIndustryID == -1)
    {
        alert('Please select Industry.');
        document.getElementById('DDLIndustry').focus();
        return false;
    }
    if(document.getElementById('txtKeySkills').value == '')
    {
        alert('Key Skills should not be blank.');
        document.getElementById('txtKeySkills').focus();
        return false;
    }
    if(document.getElementById('txtKeySkills').value.length > 1024)
    {
        alert('Key Skills should be maximum 1024 Characters.');
        document.getElementById('txtKeySkills').focus();
        return false;
    }
    var SelIndexofBasicQualificationID = document.getElementById("DDLBasicQualification").selectedIndex;
    var intBasicQualificationID = document.getElementById("DDLBasicQualification").options[SelIndexofBasicQualificationID].value;
    if(intBasicQualificationID == -1)
    {
        alert('Please select Basic Qualification.');
        document.getElementById('DDLBasicQualification').focus();
        return false;
    }
    if(document.getElementById('txtSpecialisation').value.length > 1024)
    {
        alert('Specialisation should be maximum 1024 Characters.');
        document.getElementById('txtSpecialisation').focus();
        return false;
    }

    if(document.getElementById('chkSameAsCurrentCity').checked == false)
    {
        var strJobLocations = "";
        for(var i=0; i < document.getElementById('lstPreferredJobLocation').length;i++)
        {
            if(document.getElementById('lstPreferredJobLocation').options[i].selected==true)
            {
                strJobLocations = strJobLocations + document.getElementById('lstPreferredJobLocation').options[i].value + ";";
                if (strJobLocations == '0;')
                break;
            }
        }
        strJobLocations = replaceAll(strJobLocations, "-1;","");
        if(strJobLocations == '')
        {
            alert('Please select Prefered job location.');
            document.getElementById('lstPreferredJobLocation').focus();
            return false;
        }
    }

    if(document.getElementById('chkTermsNConditions').checked == false)
    {
        alert('Please read the terms and conditions and check the check box');
        document.getElementById('chkTermsNConditions').focus();
        return false;
    }
    return true;
}
function SaveRecord()
{
    if (CheckValidation() == false)
    {
        return false;
    }
    
    var strConnection = EmployeeReg.GetConnectionString();
    var strEmpConsultantFlag = document.getElementById("ctl00_ContentPlaceHolder1_hdnEmpConsultantFlag").value;

    var strLoginID = document.getElementById('txtLoginID').value;
    var strPassword = document.getElementById('txtPassword').value;

    var SelIndexofSecretQuestionID = document.getElementById("DDLSecretQuestion").selectedIndex;
    var intSecretQuestionID = document.getElementById("DDLSecretQuestion").options[SelIndexofSecretQuestionID].value;
    var strSecretQuestionAnswer = document.getElementById('txtSecretAnswer').value;

    var strFullName = document.getElementById('txtFullName').value;
    var strAddress = document.getElementById('txtAddress').value;
    var SelIndexofCityId = document.getElementById("DDLCity").selectedIndex;
    var intCityID = document.getElementById("DDLCity").options[SelIndexofCityId].value;

    var strPinCode = document.getElementById('txtPinCode').value;

    var SelIndexofStateId = document.getElementById("DDLState").selectedIndex;
    var intStateID = document.getElementById("DDLState").options[SelIndexofStateId].value;

    var strTelephone = document.getElementById('txtTelephone').value;
    var strMobile = document.getElementById('txtMobile').value;

    var strEMailID = document.getElementById('txtEMailID').value;

    var SelIndexofDayId = document.getElementById("DDLDay").selectedIndex;
    var strDayID = document.getElementById("DDLDay").options[SelIndexofDayId].value;
    
    var SelIndexofMonthId = document.getElementById("DDLMonth").selectedIndex;
    var strMonthID = document.getElementById("DDLMonth").options[SelIndexofMonthId].value;
    
    var SelIndexofYearId = document.getElementById("DDLYear").selectedIndex;
    var strYearID = document.getElementById("DDLYear").options[SelIndexofYearId].value;
    
    var strDOB = strYearID + '-' + strMonthID + '-' + strDayID
    
    var intTotalExp = document.getElementById('txtTotalExperiance').value;

    var SelIndexofFunctionalAreaID = document.getElementById("DDLFunctionalArea").selectedIndex;
    var intFunctionalAreaID = document.getElementById("DDLFunctionalArea").options[SelIndexofFunctionalAreaID].value;

    var SelIndexofRoleID = document.getElementById("DDLRole").selectedIndex;
    var intRoleID = document.getElementById("DDLRole").options[SelIndexofRoleID].value;

    var SelIndexofIndustryID = document.getElementById("DDLIndustry").selectedIndex;
    var intIndustryID = document.getElementById("DDLIndustry").options[SelIndexofIndustryID].value;

    var strKeySkills = document.getElementById('txtKeySkills').value;

    var strComputerKnowledge = 0;
    if(document.getElementById('optComputerKnowledgeYes').checked == true)
        strComputerKnowledge = 'Y';
    else if(document.getElementById('optComputerKnowledgeNo').checked == true)
        strComputerKnowledge = 'N';

    var SelIndexofBasicQualificationID = document.getElementById("DDLBasicQualification").selectedIndex;
    var intBasicQualificationID = document.getElementById("DDLBasicQualification").options[SelIndexofBasicQualificationID].value;

    var SelIndexofPostGraduationID = document.getElementById("DDLPostGraduation").selectedIndex;
    var intPostGraduationID = document.getElementById("DDLPostGraduation").options[SelIndexofPostGraduationID].value;

    var SelIndexofDoctorateID = document.getElementById("DDLDoctorate").selectedIndex;
    var intDoctorateID = document.getElementById("DDLDoctorate").options[SelIndexofDoctorateID].value;

    var strSpecialisation = document.getElementById('txtSpecialisation').value;
    
    var strSameAsCurrentCity = '';

    if(document.getElementById('chkSameAsCurrentCity').checked == true)
        strSameAsCurrentCity = 'Y';
    else
        strSameAsCurrentCity = 'N';

    var strJobLocations = "";
    if(document.getElementById('chkSameAsCurrentCity').checked == true)
    {
        strJobLocations = intCityID + ';'
    }
    else
    {
        for(var i=0; i < document.getElementById('lstPreferredJobLocation').length;i++)
        {
            if(document.getElementById('lstPreferredJobLocation').options[i].selected==true)
            {
                strJobLocations = strJobLocations + document.getElementById('lstPreferredJobLocation').options[i].value + ";";     
                if (strJobLocations == '0;')
                break;
            }
        }
        strJobLocations = replaceAll(strJobLocations, "-1;","");
    }
    var intJobTypeID = 0;
    if(document.getElementById('optJobTypePermanent').checked == true)
        intJobTypeID = 1;
    else if(document.getElementById('optJobTypeTemporary').checked == true)
        intJobTypeID = 2;
    else
        intJobTypeID = 3;

    var intEmploymentStatusID = 0;
    if(document.getElementById('optEmpStatusFullTime').checked == true)
        intEmploymentStatusID = 1;
    else if(document.getElementById('optEmpStatusPartTime').checked == true)
        intEmploymentStatusID = 2;
    else
        intEmploymentStatusID = 3;

    var SelIndexofAnnualSalaryExpID = document.getElementById("DDLAnnualSalaryExpected").selectedIndex;
    var intAnnualSalaryExpID = document.getElementById("DDLAnnualSalaryExpected").options[SelIndexofAnnualSalaryExpID].value;

    var strAttachment = 'N';
    var strGUID = document.getElementById('ctl00_ContentPlaceHolder1_HdnGUID').value;
    var strResume   = document.getElementById('lblResumeUploaded').innerHTML;
    
    if(strResume != '')
    {
        strAttachment = 'Y';
    }
    
    if(document.getElementById('btnSubmit').value!="Update Resume")
    {
        var strErrMsg = EmployeeReg.InsertEmployeeReg(strConnection.value, strEmpConsultantFlag.substring(0, 1), strLoginID, strPassword, intSecretQuestionID, strSecretQuestionAnswer, strFullName, strAddress, intCityID, strPinCode, intStateID, strTelephone, strMobile, strEMailID, strDOB, intTotalExp, intFunctionalAreaID, intRoleID, intIndustryID, strKeySkills, strComputerKnowledge, intBasicQualificationID, intPostGraduationID, intDoctorateID, strSpecialisation, strSameAsCurrentCity, strJobLocations, intJobTypeID, intEmploymentStatusID, intAnnualSalaryExpID, strAttachment, strGUID)
        if(strErrMsg.value[1].substring(0, 21) == 'Successful Message : ')
        {
           var EmployeeId = strErrMsg.value[0];
           var LoginType = "Employee";
           
           var strMailMessage="Hi, Gopinath, <br/><br/>You have received one more entry in the database for Employee : " + strFullName + "<br/><br/>-DignitySecondCareers.org";
           var SendMail = EmployeeReg.SendEmail(strMailMessage);
           if(SendMail.value!="")
           {
                alert(SendMail.value);
           }
         
           alert('Your Job Application has been received sucessfully');
           window.open("EmployeeWelcome.aspx?Message=Welcome, <B>" + strFullName + "</B>&EmployeeId="+ EmployeeId +"&LoginType="+ LoginType,"_self");
        }
        else
        {
            alert(strErrMsg.value[1]);
            document.getElementById('txtLoginID').focus();
        }
    }
    else
    {
        var EmployeeId = document.getElementById('ctl00_ContentPlaceHolder1_HdnEmployeeId').value;
        var strErrMsg = EmployeeReg.UpdateEmployeeReg(EmployeeId,strConnection.value, strEmpConsultantFlag.substring(0, 1), strLoginID, strPassword, intSecretQuestionID, strSecretQuestionAnswer, strFullName, strAddress, intCityID, strPinCode, intStateID, strTelephone, strMobile, strEMailID, strDOB, intTotalExp, intFunctionalAreaID, intRoleID, intIndustryID, strKeySkills, strComputerKnowledge, intBasicQualificationID, intPostGraduationID, intDoctorateID, strSpecialisation, strSameAsCurrentCity, strJobLocations, intJobTypeID, intEmploymentStatusID, intAnnualSalaryExpID, strAttachment, strGUID)
        if(strErrMsg.value[0].substring(0, 21) == 'Successful Message : ')
        {
           var LoginType = "Employee";
            alert('Profile Modified Sucessfully');
            window.open("EmployeeWelcome.aspx?Message=Welcome, <B>" + strFullName + "</B>&EmployeeId="+ EmployeeId +"&LoginType="+ LoginType,"_self");
        }  
        else
        {
            alert(strErrMsg.value[0]);
            document.getElementById('txtLoginID').focus();
        }  
    }
}
function OpenAttachmentWindow()
{

    var GUID=document.getElementById('ctl00_ContentPlaceHolder1_HdnGUID').value;
    var Flag=0;
    if(document.getElementById('btnUpload').value=="View Uploaded Resume")
    {
        Flag=1;
    }
    MyWindow=window.open('AttachmentPage.aspx?GUID='+ GUID + '&Flag=' + Flag, 'MyWindow', 'Width=380, height=325, Top = 50, left = 50;'); 
    MyWindow.moveTo(237,155);
}

