﻿
function checkFormOther()
{   
    var msg =0;
    var objFrm = document.forms[0];
    if(objFrm.ctl00_ContentPlaceHolder1_txtApplied.value=="")
    {
        AlertMassgess(objFrm.ctl00_ContentPlaceHolder1_txtApplied,msg);msg=1;
    }
    if(objFrm.ctl00_ContentPlaceHolder1_txtRelateEmployee.value=="")
    {
        AlertMassgess(objFrm.ctl00_ContentPlaceHolder1_txtRelateEmployee,msg);msg=1;
    }    
    if(objFrm.ctl00_ContentPlaceHolder1_txtTeam.value=="")
    {
        AlertMassgess(objFrm.ctl00_ContentPlaceHolder1_txtTeam,msg);msg=1;
    }
    if(objFrm.ctl00_ContentPlaceHolder1_txtYourRole.value=="")
    {
        AlertMassgess(objFrm.ctl00_ContentPlaceHolder1_txtYourRole,msg);msg=1;
    }
    if(objFrm.ctl00_ContentPlaceHolder1_txtYourContribution.value=="")
    {
        AlertMassgess(objFrm.ctl00_ContentPlaceHolder1_txtYourContribution,msg);msg=1;
    }
    if(objFrm.ctl00_ContentPlaceHolder1_txtProblem.value=="")
    {
        AlertMassgess(objFrm.ctl00_ContentPlaceHolder1_txtProblem,msg);msg=1;
    }
    if(objFrm.ctl00_ContentPlaceHolder1_txtWhatYouDid.value=="")
    {
        AlertMassgess(objFrm.ctl00_ContentPlaceHolder1_txtWhatYouDid,msg);msg=1;
    }
    if(objFrm.ctl00_ContentPlaceHolder1_txtOutCome.value=="")
    {
        AlertMassgess(objFrm.ctl00_ContentPlaceHolder1_txtOutCome,msg);msg=1;
    }    
    
    if(objFrm.ctl00_ContentPlaceHolder1_txtWorkForKPMG.value=="")
    {
        AlertMassgess(objFrm.ctl00_ContentPlaceHolder1_txtWorkForKPMG,msg);msg=1;
    }
    if(objFrm.ctl00_ContentPlaceHolder1_txtYourHobbies.value=="")
    {
        AlertMassgess(objFrm.ctl00_ContentPlaceHolder1_txtYourHobbies,msg);msg=1;
    }
    if(objFrm.ctl00_ContentPlaceHolder1_txtWordOne.value=="")
    {
        AlertMassgess(objFrm.ctl00_ContentPlaceHolder1_txtWordOne,msg);msg=1;
    }
    if(objFrm.ctl00_ContentPlaceHolder1_txtWordOneReason.value=="")
    {
        AlertMassgess(objFrm.ctl00_ContentPlaceHolder1_txtWordOneReason,msg);msg=1;
    }
    if(objFrm.ctl00_ContentPlaceHolder1_txtWordTwo.value=="")
    {
        AlertMassgess(objFrm.ctl00_ContentPlaceHolder1_txtWordTwo,msg);msg=1;
    }
    if(objFrm.ctl00_ContentPlaceHolder1_txtWordTwoReason.value=="")
    {
        AlertMassgess(objFrm.ctl00_ContentPlaceHolder1_txtWordTwoReason,msg);msg=1;
    }
    if(objFrm.ctl00_ContentPlaceHolder1_txtWordThree.value=="")
    {
        AlertMassgess(objFrm.ctl00_ContentPlaceHolder1_txtWordThree,msg);msg=1;
    }
    if(objFrm.ctl00_ContentPlaceHolder1_txtWordThreeReason.value=="")
    {
        AlertMassgess(objFrm.ctl00_ContentPlaceHolder1_txtWordThreeReason,msg);msg=1;
    }
    if(objFrm.ctl00_ContentPlaceHolder1_hdfInternShip.value=="0")
    {
        AlertMassgess(objFrm.ctl00_ContentPlaceHolder1_txtStartDate,msg);msg=1;
        AlertMassgess(objFrm.ctl00_ContentPlaceHolder1_txtEndDate,msg);msg=1;
        AlertMassgess(objFrm.ctl00_ContentPlaceHolder1_txtOrganisation,msg);msg=1;
        AlertMassgess(objFrm.ctl00_ContentPlaceHolder1_txtResponsibilities,msg);msg=1;
    }
    if(objFrm.ctl00_ContentPlaceHolder1_hdfActionPlan.value=="0")
    {
        AlertMassgess(objFrm.ctl00_ContentPlaceHolder1_txtGoal,msg);msg=1;
        AlertMassgess(objFrm.ctl00_ContentPlaceHolder1_txtActionPlan,msg);msg=1;
    }
    if(msg==0)
    {
        return true;
    }else{
        alert("Please input and save information in the highlighted boxes");
        return false;
    }
}

function checkFormPersonal()
{
    var msg =0;
    var objFrm = document.forms[0];
    if(objFrm.ctl00_ContentPlaceHolder1_ddlOffice.options[objFrm.ctl00_ContentPlaceHolder1_ddlOffice.selectedIndex].value=="")
    {
        AlertMassgess(objFrm.ctl00_ContentPlaceHolder1_ddlOffice,msg);msg=1;
    }
    if(objFrm.ctl00_ContentPlaceHolder1_ddlDept.options[objFrm.ctl00_ContentPlaceHolder1_ddlDept.selectedIndex].value=="")
    {
        AlertMassgess(objFrm.ctl00_ContentPlaceHolder1_ddlDept,msg);msg=1;
    }
    
    if(objFrm.ctl00_ContentPlaceHolder1_txtFirstName.value=="")
    {
        AlertMassgess(objFrm.ctl00_ContentPlaceHolder1_txtFirstName,msg);msg=1;
    }
    if(objFrm.ctl00_ContentPlaceHolder1_txtLastName.value=="")
    {
        AlertMassgess(objFrm.ctl00_ContentPlaceHolder1_txtLastName,msg);msg=1;
    }
    if(objFrm.ctl00_ContentPlaceHolder1_ddlGender.options[objFrm.ctl00_ContentPlaceHolder1_ddlGender.selectedIndex].value=="")
    {
        AlertMassgess(objFrm.ctl00_ContentPlaceHolder1_ddlGender,msg);msg=1;
    }    
    if(objFrm.ctl00_ContentPlaceHolder1_ddlDay.options[objFrm.ctl00_ContentPlaceHolder1_ddlDay.selectedIndex].value=="")
    {
        AlertMassgess(objFrm.ctl00_ContentPlaceHolder1_ddlDay,msg);msg=1;
    }
    if(objFrm.ctl00_ContentPlaceHolder1_ddlMonth.options[objFrm.ctl00_ContentPlaceHolder1_ddlMonth.selectedIndex].value=="")
    {
        AlertMassgess(objFrm.ctl00_ContentPlaceHolder1_ddlMonth,msg);msg=1;
    }
    if(objFrm.ctl00_ContentPlaceHolder1_ddlYear.options[objFrm.ctl00_ContentPlaceHolder1_ddlYear.selectedIndex].value=="")
    {
        AlertMassgess(objFrm.ctl00_ContentPlaceHolder1_ddlYear,msg);msg=1;
    }
    if(objFrm.ctl00_ContentPlaceHolder1_txtIDCardNo.value=="")
    {
        AlertMassgess(objFrm.ctl00_ContentPlaceHolder1_txtIDCardNo,msg);msg=1;
    }
    if(objFrm.ctl00_ContentPlaceHolder1_txtNationality.value=="")
    {
        AlertMassgess(objFrm.ctl00_ContentPlaceHolder1_txtNationality,msg);msg=1;
    }
    if(objFrm.ctl00_ContentPlaceHolder1_txtTelephone.value=="" && objFrm.ctl00_ContentPlaceHolder1_txtMobilePhone.value=="")
    {
        AlertMassgess(objFrm.ctl00_ContentPlaceHolder1_txtTelephone,msg);msg=1;
    }
    if(objFrm.ctl00_ContentPlaceHolder1_txtPermanentAddress.value=="")
    {
        AlertMassgess(objFrm.ctl00_ContentPlaceHolder1_txtPermanentAddress,msg);msg=1;
    }
    if(objFrm.ctl00_ContentPlaceHolder1_txtEmail.value=="")
    {
        AlertMassgess(objFrm.ctl00_ContentPlaceHolder1_txtEmail,msg);msg=1;
    }else{
        if(objFrm.ctl00_ContentPlaceHolder1_txtEmail.value.indexOf("@") < 0 || objFrm.ctl00_ContentPlaceHolder1_txtEmail.value.indexOf(".")<0)
        {
            alert("Your email is not correct");
            return false;
        }
    }
    if(objFrm.ctl00_ContentPlaceHolder1_txtMailingAddress.value=="")
    {
        AlertMassgess(objFrm.ctl00_ContentPlaceHolder1_txtMailingAddress,msg);msg=1;
    }      
    if(msg==0)
    {
        if(objFrm.ctl00_ContentPlaceHolder1_FileUpload.value=="" && objFrm.ctl00_ContentPlaceHolder1_hdfCheckImage.value=="0")
        {
            AlertMassgess(objFrm.ctl00_ContentPlaceHolder1_FileUpload,msg);
            var flag = confirm(" Please attach your picture.\n\t - Click [OK] to attach now\n\t - Click [Cancel] to continue and attach later");
            if(flag==true)
            {
                return false;
            }else{
                return true;
            }
        }else{
            return true;
        }
    }else{
        msg = "Please input information into the highlighted boxes";
        alert(msg);
        return false;
    }
}
//   Submission cannot be proceeded because your picture is not yet enclosed.
//   Click [Save Draft]
function checkImageSubmit()
{
    var objFrm = document.forms[0];
    if(checkFormOther()==true)
    {
        if(objFrm.ctl00_ContentPlaceHolder1_hdfCheckImage.value == "0")
        {
            alert("Submission cannot be proceeded because your picture is not yet enclosed.\n Click [Save Draft]");
            return false;
        }else{
            return confirm("Once being submitted, this application form cannot be revised or withdrawn. Do you want to submit now?");
        }
    }else{
        return false;
    }
}
function AlertMassgess(ctrControl,msg)
{
    ctrControl.className="FillBackgroundColor";    
}
function checkFormEducation()
{
    var msg =0;
    var objFrm = document.forms[0];
    if(objFrm.ctl00_ContentPlaceHolder1_ddlUniversityName.options[objFrm.ctl00_ContentPlaceHolder1_ddlUniversityName.selectedIndex].value=="" && objFrm.ctl00_ContentPlaceHolder1_txtUniversityOtherName.value=="")
    {
        AlertMassgess(objFrm.ctl00_ContentPlaceHolder1_ddlUniversityName,msg);msg=1;        
    }else{
        if(objFrm.ctl00_ContentPlaceHolder1_ddlUniversityName.options[objFrm.ctl00_ContentPlaceHolder1_ddlUniversityName.selectedIndex].value=="15" && objFrm.ctl00_ContentPlaceHolder1_txtUniversityOtherName.value=="")
        {
            AlertMassgess(objFrm.ctl00_ContentPlaceHolder1_txtUniversityOtherName,msg);msg=1;
        }
    }
    if(objFrm.ctl00_ContentPlaceHolder1_ddlMajor.options[objFrm.ctl00_ContentPlaceHolder1_ddlMajor.selectedIndex].value=="" && objFrm.ctl00_ContentPlaceHolder1_txtOtherMajor.value=="")
    {
        AlertMassgess(objFrm.ctl00_ContentPlaceHolder1_ddlMajor,msg);msg=1;
    }else{
        if(objFrm.ctl00_ContentPlaceHolder1_ddlMajor.options[objFrm.ctl00_ContentPlaceHolder1_ddlMajor.selectedIndex].text=="Others (specify)" && objFrm.ctl00_ContentPlaceHolder1_txtOtherMajor.value=="")
        {
            AlertMassgess(objFrm.ctl00_ContentPlaceHolder1_txtOtherMajor,msg);msg=1;
        }
    }
    if(objFrm.ctl00_ContentPlaceHolder1_ddlStartMonth.options[objFrm.ctl00_ContentPlaceHolder1_ddlStartMonth.selectedIndex].value=="" || objFrm.ctl00_ContentPlaceHolder1_ddlStartYear.options[objFrm.ctl00_ContentPlaceHolder1_ddlStartMonth.selectedIndex].value=="")
    {
        AlertMassgess(objFrm.ctl00_ContentPlaceHolder1_ddlStartMonth,msg);msg=1;
        AlertMassgess(objFrm.ctl00_ContentPlaceHolder1_ddlStartYear,msg);        
    }
    if(objFrm.ctl00_ContentPlaceHolder1_ddlMonthGraduation.options[objFrm.ctl00_ContentPlaceHolder1_ddlMonthGraduation.selectedIndex].value=="" || objFrm.ctl00_ContentPlaceHolder1_ddlYearGraduation.options[objFrm.ctl00_ContentPlaceHolder1_ddlYearGraduation.selectedIndex].value=="")
    {
        AlertMassgess(objFrm.ctl00_ContentPlaceHolder1_ddlMonthGraduation,msg);msg=1;
        AlertMassgess(objFrm.ctl00_ContentPlaceHolder1_ddlYearGraduation,msg);
    }
    if(objFrm.ctl00_ContentPlaceHolder1_txtGPG.value=="")
    {
        AlertMassgess(objFrm.ctl00_ContentPlaceHolder1_txtGPG,msg);msg=1;
    }
    if(objFrm.ctl00_ContentPlaceHolder1_FileUploadTranscript.value=="" && objFrm.ctl00_ContentPlaceHolder1_hdfTranscript.value=="0")
    {
        AlertMassgess(objFrm.ctl00_ContentPlaceHolder1_FileUploadTranscript,msg);msg=1;
    }
    if(objFrm.ctl00_ContentPlaceHolder1_hdfLanguage.value=="0")
    {
        AlertMassgess(objFrm.ctl00_ContentPlaceHolder1_txtLanguage,msg);msg=1;
    }
    if(objFrm.ctl00_ContentPlaceHolder1_hdfAchievement.value=="0")
    {
        AlertMassgess(objFrm.ctl00_ContentPlaceHolder1_txtCourse,msg);msg=1;
        AlertMassgess(objFrm.ctl00_ContentPlaceHolder1_txtOrganisation,msg);msg=1;
        AlertMassgess(objFrm.ctl00_ContentPlaceHolder1_txtStartDate,msg);msg=1;
        AlertMassgess(objFrm.ctl00_ContentPlaceHolder1_txtEndDate,msg);msg=1;
    }
    if(msg==0)
    {
        return true;
    }else{
        alert("Please input and save information in the highlighted boxes");
        return false;
    }
}


function ajaxFunction()
{
    var xmlHttp=null;
    try
      {
      // Firefox, Opera 8.0+, Safari
      xmlHttp=new XMLHttpRequest();
      }
    catch (e)
      {
      // Internet Explorer
      try
        {
        xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
        }
      catch (e)
        {
        try
          {
          xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
          }
        catch (e)
          {
          alert("Your browser does not support AJAX!");
          return false;
          }
        }
      }
      return xmlHttp;
  } 


function StoreAchievement()
{
    var objFrm = document.forms[0];
    var course, organisation, startDate, endDate,candidateID;
    course ="";
    var arrCourse = document.getElementsByName("course");
    var arrOrganisation = document.getElementsByName("organisation");
    var arrStartDate = document.getElementsByName("startDate");
    var arrEndDate = document.getElementsByName("endDate");
    candidateID =0;
    candidateID = objFrm.ctl00_ContentPlaceHolder1_hdfCandidateID.value;
    for(var i=0;i< arrCourse.length;i++)
    {
        if(arrCourse[i].value !="" && arrOrganisation[i].value !="" && arrStartDate[i].value !="" && arrEndDate[i].value !="")
        {
            if(course=="")
            {
                course = arrCourse[i].value;
                organisation = arrOrganisation[i].value;
                startDate = arrStartDate[i].value;
                endDate  = arrEndDate[i].value;
            }else{
                course += ";" + arrCourse[i].value;
                organisation += ";" + arrOrganisation[i].value;
                startDate += ";" + arrStartDate[i].value;
                endDate  += ";" + arrEndDate[i].value;
            }
        }
    }
    var result='';
    var sURL = '';
    var http_obj = new ActiveXObject("Microsoft.XMLHTTP");//ajaxFunction();
    var sResult = '';
    if(http_obj==null)
    {
        alert("Your browser does not support AJAX!");
        return;
    }
    sURL = 'StoreAchievement.aspx?course='+ course +'&organisation='+ organisation +'&startDate='+ startDate +'&endDate='+ endDate + '&candidateID='+ candidateID;
    http_obj.Open('GET',sURL,false);
    http_obj.Send('');
    if (http_obj.readyState==4)
    {
        sResult = http_obj.responseText;
    }
    var arrResult = new Array();
    arrResult =sResult.split("#");
    if(arrResult[0]=="1")
    {
        return true;
    }else{
        return false;
    }
}
function StoreLanguage()
{
    var language, speaking, reading, writing, candidateID;
    var objFrm = document.forms[0];
    language ="";
    speaking = "";
    reading ="";
    writing ="";
    candidateID =0;
    candidateID = objFrm.ctl00_ContentPlaceHolder1_hdfCandidateID.value;
    var arrLanguage = document.getElementsByName("language");
    var arrSpeaking = document.getElementsByName("speaking");
    var arrReading = document.getElementsByName("reading");
    var arrWriting = document.getElementsByName("writing");
    for(var i =0;i< arrLanguage.length;i++)
    {
        if(arrLanguage[i].value != "")
        {
            if(language=="")
            {
                language = arrLanguage[i].value;
                speaking = arrSpeaking[i].options[arrSpeaking[i].selectedIndex].value;
                reading =  arrReading[i].options[arrReading[i].selectedIndex].value;
                writing =  arrWriting[i].options[arrWriting[i].selectedIndex].value;
            }else{
                language += ";" + arrLanguage[i].value;
                speaking += ";" + arrSpeaking[i].options[arrSpeaking[i].selectedIndex].value;
                reading += ";" + arrReading[i].options[arrReading[i].selectedIndex].value;
                writing += ";" + arrWriting[i].options[arrWriting[i].selectedIndex].value;
            }
        }
    }
    var result='';
    var sURL = '';
    var http_obj = new ActiveXObject("Microsoft.XMLHTTP"); // ajaxFunction();
    var sResult = '';
    if(http_obj==null)
    {
        alert("Your browser does not support AJAX!");
        return;
    }
    sURL = 'StoreLanguage.aspx?language='+ language +'&speaking='+ speaking +'&reading='+ reading +'&writing='+ writing + '&candidateID='+ candidateID;
    http_obj.Open('GET',sURL,false);
    http_obj.Send('');
    if (http_obj.readyState==4)
    {
        sResult = http_obj.responseText;
    }
    var arrResult = new Array();
    arrResult = sResult.split("#");
    if(arrResult[0]=="1")
    {        
        return StoreAchievement();
    }else{
        alert(sResult);
        alert("Errors! please contact with HR department.");
        return false;
    }
}

function addAchievement()
{
    var objFrm = document.forms[0];
    var objTable = document.getElementById('tblAchievement');
    var objInsertRow = objTable.insertRow(1);
    objInsertRow.className='alignLeft';
    objInsertRow.insertCell(0).innerHTML="<input type='text' name='course' style='text-align:left; width:100px;' value='' />";
    objInsertRow.insertCell(1).innerHTML="<input type='text' name='organisation' style='text-align:left; width:100px;' value='' />";
    objInsertRow.insertCell(2).innerHTML="<input type='text' name='startDate' style='text-align:left; width:60px;' maxlength='12' value='' />";
    objInsertRow.insertCell(3).innerHTML="<input type='text' name='endDate' style='text-align:left; width:60px;' maxlength='12' value='' />";
    objInsertRow.insertCell(4).innerHTML="<a href='#' onclick='RemoveAchievement(this);'>Remove</a>";
}
function RemoveAchievement(obj)
{
    var objFrm = document.forms[0];
    var index =obj.parentNode.parentNode.rowIndex; //parentNode
    var objTable;
    objTable = document.getElementById('tblAchievement');
    objTable.deleteRow(index);
}
function AddLanguage()
{
    var objFrm = document.forms[0];
    var objTable = document.getElementById('tblLanguage');
    var objInsertRow = objTable.insertRow(1);
    objInsertRow.className='alignLeft';
    objInsertRow.insertCell(0).innerHTML="<input type='text' name='language' style='text-align:left; width:100px;' value='' />";
    objInsertRow.insertCell(1).innerHTML="<select name='speaking' style='width:60px; text-align:center;'><option value='1'>1</option><option value='2'>2</option><option value='3'>3</option><option value='4' selected='selected'>4</option></select>";
    objInsertRow.insertCell(2).innerHTML="<select name='reading' style='width:55px; text-align:center;'><option value='1'>1</option><option value='2'>2</option><option value='3'>3</option><option value='4' selected='selected'>4</option></select>";
    objInsertRow.insertCell(3).innerHTML="<select name='writing' style='width:55px; text-align:center;'><option value='1'>1</option><option value='2'>2</option><option value='3'>3</option><option value='4' selected='selected'>4</option></select>";
    objInsertRow.insertCell(4).innerHTML="<a href='#' onclick='RemoveLanguage(this);'>Remove</a>";
}
function RemoveLanguage(obj)
{
    var objFrm = document.forms[0];
    var index =obj.parentNode.parentNode.rowIndex; //parentNode
    var objTable;
    objTable = document.getElementById('tblLanguage');
    objTable.deleteRow(index);
}
function popupCenterMoreUniversity(width, height)
{
 var left   = (screen.width  - width)/2 -40;
 var top    = (screen.height - height)/2 - 30;
 var candidateID=0;
 var objFrm = document.forms[0];
 candidateID = objFrm.ctl00_ContentPlaceHolder1_hdfCandidateID.value;
 var newwin = window.open("MoreUniversity.aspx?candidateID=" + candidateID, "","width=840,left=" + left  + ",height=340,top=" + top + ",scrollbars=yes,statusbar=no,toolbar=no, status=no,menubar=no,location=no,resizable=yes,directories=no");// , "More University","width=750,left=" + left  + ",height=200,top=" + top + ",scrollbars=yes,statusbar=no,toolbar=no, status=no,menubar=no,location=no,resizable=yes,directories=no");
 if (window.focus) {newwin.focus();}
 return false;
}
function popupCenterAttach(width, height)
{
 var left   = (screen.width  - width)/2 -40;
 var top    = (screen.height - height)/2 - 30;
 var candidateID=0;
 var objFrm = document.forms[0];
 candidateID = objFrm.ctl00_ContentPlaceHolder1_hdfCandidateID.value;
 var newwin = window.open("UploadDoc.aspx?candidateID=" + candidateID, "","width=840,left=" + left  + ",height=340,top=" + top + ",scrollbars=yes,statusbar=no,toolbar=no, status=no,menubar=no,location=no,resizable=yes,directories=no");
 if (window.focus) {newwin.focus();}
 return false;
}

function popupCenterPreview(width, height)
{
 var left   = (screen.width  - width)/2;
 var top    = (screen.height - height)/2;
 var candidateID=0;
 var objFrm = document.forms[0];
 candidateID = objFrm.ctl00_ContentPlaceHolder1_hdfCandidateID.value;
 var newwin = window.open("Preview.aspx?candidateID=" + candidateID, "","width=840,left=" + left  + ",height=340,top=" + top + ",scrollbars=yes,statusbar=no,toolbar=no, status=no,menubar=no,location=no,resizable=yes,directories=no");
 if (window.focus) {newwin.focus();}
 return false;
}

function IsFloatNumbers(e)
{
    var keynum;
    var keychar;
    var numcheck;
    if(window.event) // IE
	    {
	    keynum = e.keyCode;
	    }
    else if(e.which) // Netscape/Firefox/Opera
	    {
	    keynum = e.which;
	    }
    keychar = String.fromCharCode(keynum);
    numcheck =  /^([0-9]*[.]*[0-9]*)$/;
    return numcheck.test(keychar);
}
function AddGoalSetting()
{
    var objFrm = document.forms[0];
    var objTable = document.getElementById('tblGoalSetting');
    var objInsertRow = objTable.insertRow(1);
    objInsertRow.className='alignLeft';
    objInsertRow.insertCell(0).innerHTML="<input  type='text' name='txtGoal' style='width:179px;' />";
    objInsertRow.insertCell(1).innerHTML="&nbsp; <input  type='text' name='txtActionPlan' style='width:515px;' />";
    objInsertRow.insertCell(2).innerHTML="<a href='#' onclick='RemoveGoalSetting(this);'>Remove</a>";
}
function RemoveGoalSetting(obj)
{
    var objFrm = document.forms[0];
    var index =obj.parentNode.parentNode.rowIndex; //parentNode
    var objTable;
    objTable = document.getElementById('tblGoalSetting');
    objTable.deleteRow(index);
}
function RemoveInternShip(obj)
{
    var objFrm = document.forms[0];
    var index =obj.parentNode.parentNode.rowIndex; //parentNode
    var objTable;
    objTable = document.getElementById('tblInternShip');
    objTable.deleteRow(index);
}
function AddInternShip()
{
    var objFrm = document.forms[0];
    var objTable = document.getElementById('tblInternShip');
    var objInsertRow = objTable.insertRow(1);
    objInsertRow.className='alignLeft';
    objInsertRow.insertCell(0).innerHTML="<input type='text' name='txtStartDate' style='text-align:left; width:100px;' value='' />";
    objInsertRow.insertCell(1).innerHTML="&nbsp;<input type='text' name='txtEndDate' style='text-align:left; width:100px;' value='' />";
    objInsertRow.insertCell(2).innerHTML="&nbsp;<input type='text' name='txtOrganisation' style='text-align:left; width:176px;' maxlength='10' value='' />";
    objInsertRow.insertCell(3).innerHTML="&nbsp;<input type='text' name='txtResponsibilities' style='text-align:left; width:302px;' maxlength='10' value='' />";
    objInsertRow.insertCell(4).innerHTML="<a href='#' onclick='RemoveInternShip(this);'>Remove</a>";
}
function StoreGoalSetting()
{
    var objFrm = document.forms[0];
    var goal, actionPlan;
    var arrGoal, arrActionPlan;
    var candidateID=0;
    candidateID = objFrm.ctl00_ContentPlaceHolder1_hdfCandidateID.value;
    arrGoal = document.getElementsByName("txtGoal");
    arrActionPlan = document.getElementsByName("txtActionPlan");
    goal="";actionPlan="";
    actionPlan="";
    for(var i =0; i<arrGoal.length;i++)
    {
        if(arrGoal[i].value != "" && arrActionPlan[i].value != "")
        {
            if(goal == "")
            {
                goal = arrGoal[i].value;
                actionPlan = arrActionPlan[i].value;
            }else{
                goal += "#" + arrGoal[i].value;
                actionPlan += "#" + arrActionPlan[i].value;
            }
        }
    }
     
    // Ajax
    var result='';
    var sURL = '';
    var http_obj = new ActiveXObject("Microsoft.XMLHTTP"); // ajaxFunction();
    var sResult = '';
    if(http_obj==null)
    {
        alert("Your browser does not support AJAX!");
        return;
    }
    sURL = 'StoreGoalSetting.aspx?goal='+ goal +'&actionplan='+ actionPlan + '&candidateID='+ candidateID;
    http_obj.Open('GET',sURL,false);
    http_obj.Send('');
    if (http_obj.readyState==4)
    {
        sResult = http_obj.responseText;
    }
    var arrResult = new Array();
    arrResult =sResult.split("#");
    if(arrResult[0]=="1")
    {        
        return StoreInternShip();
        //alert("thansh cong");
    }else{
        alert("Your browser does not support AJAX! Please use ");
        return false;
    }
}
function StoreInternShip()
{
    var objFrm = document.forms[0];   
    var candidateID=0;
    candidateID = objFrm.ctl00_ContentPlaceHolder1_hdfCandidateID.value;
    var startDate, endDate, organisation, responsibilities;
    var arrStartDate, arrEndDate, arrOrganisation, arrResponsibilities;
    startDate =""; endDate=""; organisation=""; responsibilities="";
    arrStartDate = document.getElementsByName("txtStartDate");
    arrEndDate = document.getElementsByName("txtEndDate");
    arrOrganisation = document.getElementsByName("txtOrganisation");
    arrResponsibilities = document.getElementsByName("txtResponsibilities");
    for(var i =0;i<arrOrganisation.length;i++)
    {
        if(arrStartDate[i].value !="" && arrEndDate[i].value !="" && arrOrganisation[i].value!="" && arrResponsibilities[i].value != "")
        {
            if(organisation=="")
            {
                startDate = arrStartDate[i].value;
                endDate = arrEndDate[i].value;
                organisation = arrOrganisation[i].value;
                responsibilities = arrResponsibilities[i].value;
            }else{
                startDate += "#" + arrStartDate[i].value;
                endDate += "#" + arrEndDate[i].value;
                organisation += "#" + arrOrganisation[i].value;
                responsibilities += "#" + arrResponsibilities[i].value;
            }
        }
    }
    // Ajax StoreInternShip.aspx
    var result='';
    var sURL = '';
    var http_obj = new ActiveXObject("Microsoft.XMLHTTP"); // ajaxFunction();
    var sResult = '';
    if(http_obj==null)
    {
        alert("Your browser does not support AJAX!");
        return;
    }
    sURL = 'StoreInternShip.aspx?startDate='+ startDate +'&endDate='+ endDate + '&organisation='+ organisation + '&responsibilities=' + responsibilities +'&candidateID='+ candidateID;
    http_obj.Open('GET',sURL,false);
    http_obj.Send('');
    if (http_obj.readyState==4)
    {
        sResult = http_obj.responseText;
    }
    var arrResult = new Array();
    arrResult =sResult.split("#");
    if(arrResult[0]=="1")
    {        
        return true;
        //alert("thansh cong");
    }else{
        alert("Your browser does not support AJAX! Please use ");
        return false;
    }
}
function Back()
{
    window.history.go(-1);
}




