﻿ 
function isChecked()
{
   var arr=new Array();
   var chkid;
   arr=strcode.split('~');
   if(arr.length>0)
   {
        for(var i=0;i<arr.length;i++)
        {
            chkid='chk'+arr[i];
            if(document.getElementById(chkid).checked==true)
                return true;
        }
     }
     return false;
     
}
function MessageBox1()
{
   var flag=getCookie((".usertv"));
   if(isChecked()==true)
   {
       if(flag=="1")
       {
         alert('Đã lưu');
         return true;
        }
   }
   else
   {
        alert("Bạn chưa chọn việc làm");
        return false;
   }
   return true;  
}
function MessageBoxDeleteJobSave()
{
   var flag=getCookie((".usertv"));
   if(isChecked()==true)
   {
       if(flag=="1")
       {
         alert('Đã xóa');
         return true;
        }
   }
   else
   {
        alert("Bạn chưa chọn việc làm");
        return false;
   }
   return true;  
}
function MessageBoxHTML1()
{
   var flag=getCookie((".usertv"));
   if(flag=="1")
     alert('Đã lưu');
}
function MessageBoxNopDonTrucTuyen()
{

   var flag=getCookie((".usertv"));
   if(flag=="1")
     alert('Đã nộp đơn');
}
function MessageBoxHTML2()
{
   var flag=getCookie((".usertv"));
   if(flag=="2")
     alert('Đã lưu');
}

function XoaViecLamDaLuu()
{
   
    var giatri=getCookie('CookieJob_NTVDel');
    if(giatri.length>3)
    {
        question=confirm('Bạn có thật sự muốn xóa không?');
        if(question!="0")
        {
            get_url01("Load_XuLy,,NTV_frmDelete.aspx?delete=1&Time=" + GetTime(),1); 
            setTimeout("SaveCookie('CookieJob_NTVDel',' ')",500);
            window.location.href="NTV_frmViecLamDaLuu.aspx";
        }
    }
    else
        alert('Bạn chưa chọn việc làm cần xóa!');
}
function XoaNopDonTrucTuyen()
{
   
   
    var giatri=getCookie('CookieJob_ndttd');
    if(giatri.length>3)
    {
        question=confirm('Bạn có thật sự muốn xóa không?');
        if(question!="0")
        {
            get_url01("Load_XuLy,,NTV_frmDelete.aspx?delete=2&Time=" + GetTime(),1); 
            setTimeout("SaveCookie('CookieJob_ndttd',' ')",500);
            window.location.href="NTV_frmNopDonTrucTuyen.aspx";
        }
    }
    else
        alert('Bạn chưa chọn hồ sơ cần xóa!');
}
function XoaThongBaoViecLam()
{
   
   
    var giatri=getCookie('CookieJob_tbvld');
    if(giatri.length>3)
    {
        question=confirm('Bạn có thật sự muốn xóa không?');
        if(question!="0")
        {
            get_url01("Load_XuLy,,NTV_frmDelete.aspx?delete=3&Time=" + GetTime(),1); 
            setTimeout("SaveCookie('CookieJob_tbvld',' ')",500);
            window.location.href="NTV_frmThongBaoViecLam.aspx";
            
        }
    }
    else
        alert('Bạn chưa chọn việc làm cần xóa!');
}
 function LuuDonTrucTuyen(codejob)
    {
        //Ham NopDonTrucTuyen khi xem chi tiet nhatuyendung trong file.html
        //Trong thu muc EmployerJob
        if(getCookie("userflag")=="1")
        {
            var CapThuMuc="../../../../";
            var strhref=CapThuMuc+'NTV_frmLuuViecLam.aspx?Trang=1&CongViec=0' +'&codejob=' + codejob;
            get_url01("Save,,"+strhref,1);
        }
        else
            window.location.href="../../../../NTV_frmLogIn.aspx";
            
    }
 function LuuViecLam(trang)
    {
        
        var strArr=getCookie("CookieJob");
        if(getCookie("userflag")=="1")
        {
            if(strArr!=null && strArr!=' ')
             { 
                 var strhref='NTV_frmLuuViecLam.aspx?Trang='+trang+'&CongViec=1&time=' +  GetTime();
                 //window.location.href=strhref;
                 //Khi save cong viec xong thi xoa cac cong viec do di
                 get_url01("Save,,"+strhref,1);
                 alert("Đã lưu việc làm được chọn");
                 setTimeout("SaveCookie('CookieJob',' ')",500);
             }
            else
            {
                alert("Bạn chưa chọn việc làm cần lưu");
                setTimeout("SaveCookie('CookieJob',' ')",500);
            }
        }
        else
            window.location.href="NTV_frmLogIn.aspx";

    }
    function LuuViecLamHTML2(trang)
    {
      //Ham LuuViecLam trong chua trong file.html ghi file viec lam theo nghanh luu cung luc nhieu nghanh nghe
      //Trang=2 de luu cung mot luc nhieu cong viec
      // Luu trong thu muc ApplicantCareer
         var strArr=getCookie("CookieJob");

         if(getCookie("userflag")=="1")
         {   
             if(strArr!=null && strArr!=' ')
             { 
                
                 var CapThuMuc="../../../";
                 var strhref=CapThuMuc+'NTV_frmLuuViecLam.aspx?Trang='+trang+'&CongViec=1&time=' +  GetTime();
                             alert(strhref);
                 //Khi save cong viec xong thi xoa cac cong viec do di
                
                 get_url01("Save,,"+strhref,1);
                         
                 alert("Đã lưu việc làm được chọn");
                
                setTimeout("SaveCookie('CookieJob',' ')",500);
             }
            else
            {
                alert('Bạn chưa chọn công việc');
                SaveCookie('CookieJob',' ');
            }
         }
         else
             window.location.href="../../../NTV_frmLogIn.aspx";
         
    }
    function LuuViecLamHTML1(codejob)
    {
        //Ham luu viec lam khi nguoi dung chon chuc nang luu o trang xem Chitietnhatuyendung.html
        // Luu trong thu muc con cua thu muc EmloyerJob 
        if(getCookie("userflag")=="1")
        {
             var CapThuMuc="../../../../";
             var strhref=CapThuMuc+'NTV_frmLuuViecLam.aspx?codejob='+codejob+'&Trang=1&CongViec=1';
             
             get_url01("Save,,"+strhref,1);
             alert("Đã lưu việc làm được chọn");
         }
         else
             window.location.href="../../../../NTV_frmLogIn.aspx";
    }
        //Tim Nhanh viec lam
    function TimNhanhViecLam()
    {
        var TuKhoa="";
        
        var NganhID= document.getElementById('cboNganh').value;
        var NoiLamViecID= document.getElementById('cboDiaDiem').value;
        var url="";
        SaveCookie("KeySearch1",TuKhoa);
        SaveCookie("IdNghanhSearch1",NganhID);
        SaveCookie("IdNoiLamViecSearch1",NoiLamViecID);
        
        if(NganhID!=0 && NoiLamViecID==0)//Neu co nghanh va noi lam viec la tat ca thi load file .html
        {
            loadXML('DanhSachViecLamTheoNghanh.xml');
            var root=xmlDoc.documentElement;
            var lenght=root.childNodes.length;
            var duongdan="";
            var id="";
          
            for(var i=0;i<lenght;i++)
            {
                id=root.childNodes(i).getAttribute("MaNghanh")
                if(NganhID==id)
                {
                   
                     duongdan=root.childNodes(i).getAttribute("DuongDan");
                     break;
                }
               
            }       
            url="HTML/Applicant/ApplicantCareer/"+duongdan;
         }//Neu chon tat ca cac nghanh va cac linh vuc thi chon file .html
         else if(NganhID==0&&NoiLamViecID==0)
             url="HTML/Applicant/ApplicantCareer/ketquatimnhanh.html";
         else//Nguoc lai goi trang .aspx
           url="NTV_frmDSTimNhanh.aspx?TuKhoa=" + TuKhoa + "&NganhID=" + NganhID + "&NoiLamViecID=" + NoiLamViecID
        window.location.href=url;
     }
     
    function setSearch()
    {
        if(getCookie("KeySearch1")!=null)
        {
            if(getCookie("KeySearch1")!='')
                document.getElementById("txtTuKhoa").value=getCookie("KeySearch1");
            else
                document.getElementById("txtTuKhoa").value='từ khóa';
        }
        if(getCookie("IdNghanhSearch1")!=null)
             if(getCookie("IdNghanhSearch1")!='')
                document.getElementById("cboNganh").value=getCookie("IdNghanhSearch1");
        if(getCookie("IdNoiLamViecSearch1")!=null)
             if(getCookie("IdNoiLamViecSearch1")!='')
                document.getElementById("cboDiaDiem").value=getCookie("IdNoiLamViecSearch1");
    }
    function TimNhanhViecLamTheoTuKhoa()
    {
         var TuKhoa="";
        if(document.getElementById('txtTuKhoa')!=null); 
            TuKhoa=document.getElementById('txtTuKhoa').value;
         var NganhID= document.getElementById('cboNganh').value;
         var NoiLamViecID= document.getElementById('cboDiaDiem').value;
         if(TuKhoa=='từ khóa')
            TuKhoa='';
        SaveCookie("KeySearch1",TuKhoa);
        SaveCookie("IdNghanhSearch1",NganhID);
        SaveCookie("IdNoiLamViecSearch1",NoiLamViecID);
        
        
        if(TuKhoa=='' && NganhID!=0 && NoiLamViecID==0)//Neu co nghanh va noi lam viec la tat ca thi load file .html
        {
             
            loadXML('DanhSachViecLamTheoNghanh.xml');
            var root=xmlDoc.documentElement;
            var lenght=root.childNodes.length;
            var duongdan="";
            var id="";
          
            for(var i=0;i<lenght;i++)
            {
                id=root.childNodes(i).getAttribute("MaNghanh")
                if(NganhID==id)
                {
                     duongdan=root.childNodes(i).getAttribute("DuongDan");
                      break;
                }
               
            }       
               
            window.location.href="HTML/Applicant/ApplicantCareer/"+duongdan;
         }//Neu chon tat ca cac nghanh va cac linh vuc thi chon file .html
         else if(TuKhoa==''&&NganhID==0&&NoiLamViecID==0)
             window.location.href="HTML/Applicant/ApplicantCareer/ketquatimnhanh.html";
         else//Nguoc lai goi trang .aspx
            window.location.href="NTV_frmDSTimNhanh.aspx?page=1&TuKhoa=" + TuKhoa + "&NganhID=" + NganhID + "&NoiLamViecID=" + NoiLamViecID
     }
   function TimNhanhViecLamTheoTuKhoaHTML()
    {
        var CapThuMuc="../../../";
        var TuKhoa="";
        if(document.getElementById('txtTuKhoa')!=null); 
            TuKhoa=document.getElementById('txtTuKhoa').value;
         var NganhID= document.getElementById('cboNganh').value;
         var NoiLamViecID= document.getElementById('cboDiaDiem').value;
         if(TuKhoa=='từ khóa')
            TuKhoa='';
            
        SaveCookie("KeySearch1",TuKhoa);
        SaveCookie("IdNghanhSearch1",NganhID);
        SaveCookie("IdNoiLamViecSearch1",NoiLamViecID);
        
        if(TuKhoa=='' && NganhID!=0 && NoiLamViecID==0)//Neu co nghanh va noi lam viec la tat ca thi load file .html
        {
             
            loadXML(CapThuMuc+'DanhSachViecLamTheoNghanh.xml');
            var root=xmlDoc.documentElement;
            var lenght=root.childNodes.length;
            var duongdan="";
            var id="";
          
            for(var i=0;i<lenght;i++)
            {
                id=root.childNodes(i).getAttribute("MaNghanh")
                if(NganhID==id)
                {
                     duongdan=root.childNodes(i).getAttribute("DuongDan");
                      break;
                }
               
            }       
               
            window.location.href=duongdan;
         }//Neu chon tat ca cac nghanh va cac linh vuc thi chon file .html
         else if(TuKhoa==''&&NganhID==0&&NoiLamViecID==0)
             window.location.href="HTML/Applicant/ApplicantCareer/ketquatimnhanh.html";
         else//Nguoc lai goi trang .aspx
            window.location.href=CapThuMuc+"NTV_frmDSTimNhanh.aspx?page=1&TuKhoa=" + TuKhoa + "&idNganh=" + NganhID + "&NoiLamViecID=" + NoiLamViecID
     }
    function Load_DSTimNangCao()
    { 
        var TuKhoa=EnCodeSearch(document.getElementById('txtTuKhoa').value);
        var NganhID= document.getElementById('cboNganh').value;
        var DiaDiemID= document.getElementById('cboDiaDiem').value;
        var TrinhDoID= document.getElementById('cboTrinhDo').value;
        var HinhThucLamViecID= document.getElementById('cboHinhThucViecLam').value;
        var Luong= document.getElementById('salary').value;
        var ThoiGianDang= document.getElementById('idThoiGian').value;
        var strhref= 'NTV_frmDSTimNangCao.aspx?TuKhoa=' + TuKhoa + '&idNganh=' + NganhID + '&NoiLamViecID=' + DiaDiemID + '&HinhThucLamViecID=' + HinhThucLamViecID + '&TrinhDoID=' + TrinhDoID + '&Luong=' + Luong + '&ThoiGian=' + ThoiGianDang;
        window.location.href=strhref;   
    }
//Ham luu job (cua ung vien)
	 function SaveJob(CookieName,chk_id)
     {
       var ArrayID_Job="",CookieValue="",ID_Job="";
       var i=0,j=0;
       if(document.getElementById(chk_id).checked==true)
       {
         ID_Job=document.getElementById(chk_id).id;
         CookieValue=getCookie(CookieName);
         if(CookieValue.indexOf(ID_Job)<0)
         {
            ArrayID_Job=CookieValue + "~" + ID_Job;
            SaveCookie(CookieName,ArrayID_Job);
         }
       }
       else
       {
         ID_Job=document.getElementById(chk_id).id;
         CookieValue=getCookie(CookieName);
         if(CookieValue.indexOf(ID_Job)>0)
         {
            ArrayID_Job=CookieValue.replace("~"+ID_Job,"");
            SaveCookie(CookieName,ArrayID_Job);
         }
       }
     }
   //Ham check all


////////////////////////////////////////////////////DanhSachViecLamTheoNghanhNghe///////////////////////////////
function DanhSachViecLamTheoNghanh(Message)
{
    var chuoi="";
    chuoi = "<table>";
    chuoi = chuoi + "<tr>";
    chuoi = chuoi + "<td align='left' colspan='2' style='width: 909px; height: 30px; background-color: #ffffff'>";
    chuoi = chuoi + "</td>";
    chuoi = chuoi + "</tr>";
    chuoi = chuoi + "<tr>";
    chuoi = chuoi + "<td align='left' colspan='2' style='width: 909px; height: 128px; background-color: #ffffff'>";
    chuoi = chuoi + " <table border='0' cellpadding='0' cellspacing='0'>";
    chuoi+="<tr>";
    chuoi+="<td align='left' colspan='2' style='width: 572px; background-color: #ffffff' valign='top'>";
    chuoi+="<table border='0' cellpadding='0' cellspacing='0' width='909'>";
    chuoi+="<tr>";
    chuoi+="<td style='width: 3px; height: 27px; background-color: #3e5aa4'>";
    chuoi+=" </td>";
    chuoi+="<td style='width: 8px; height: 27px; background-color: #e3e5f2'>";
    chuoi+="</td>";
    chuoi+="<td style='width: 898px; height: 27px; background-color: #e3e5f2' valign='middle'>";
    chuoi+="<span style='font-weight: bold; font-size: 11px; color: #284087; font-family: Verdana'>";
    chuoi+=Message+"</span></td>";
    chuoi+=" </tr>";
    chuoi+="</table>";
    chuoi+="</td>";
    chuoi+="</tr>";
    chuoi+=" <tr>";
    chuoi+="<td colspan='2' style='width: 572px; height: 14px; background-color: #ffffff' valign='top'>";
    chuoi+="&nbsp;</td>";
    chuoi+="</tr>";
    chuoi+="<tr>";
    chuoi+="<td colspan='2' style='width: 572px; height: 44px; background-color: #ffffff' valign='top'>";
    chuoi+=LoadDachSachViecLamTheoNghanh();
    chuoi+=" </td>";
    chuoi+="</tr>";
    chuoi+=" </table>";
    chuoi+="</td>";
    chuoi+=" </tr>";
    chuoi+="</table>";
    return chuoi;
}
function LoadDachSachViecLamTheoNghanh()
{      
   
     var chuoi ="";
     var CapThuMuc="HTML/Applicant/ApplicantCareer/";
    loadXML("../../../DanhSachViecLamTheoNghanh.xml");
 
     var root=xmlDoc.documentElement;
     var lenght=root.childNodes.length;
     if (lenght > 31)
          lenght = 31;
           
     chuoi = "<table width='906' border='0' cellspacing='0' cellpadding='0'>";
        for (var i = 0; i < lenght-1;)
        {
            id=root.childNodes(i).getAttribute("MaNghanh");
            duongdan=root.childNodes(i).getAttribute("DuongDan");
            var IdNghanh1 = "", IdNghanh2 = "", IdNghanh3 = "";
            var TenNghanh1 = "", TenNghanh2 = "", TenNghanh3 = "";
            var SoLuongTuyen1 = "", SoLuongTuyen2 = "", SoLuongTuyen3 = "";
            IdNghanh1 = root.childNodes(i).getAttribute("MaNghanh");
            IdNghanh2 =root.childNodes(i+1).getAttribute("MaNghanh");
            IdNghanh3 = root.childNodes(i+2).getAttribute("MaNghanh");
            
             
            TenNghanh1 = root.childNodes(i).getAttribute("TenNghanh");
                if (TenNghanh1.Length > 33)
                    TenNghanh1 = TenNghanh1.substring(0, 33) + " ...";
            TenNghanh2 = root.childNodes(i+1).getAttribute("TenNghanh");
                if (TenNghanh2.Length > 30)
                    TenNghanh2 = TenNghanh2.substring(0, 25) + " ...";
            TenNghanh3 = root.childNodes(i+2).getAttribute("TenNghanh");
                if (TenNghanh3.Length > 30)
                    TenNghanh3 = TenNghanh3.substring(0, 25) + " ...";
            var SoLuongTuyen1 = root.childNodes(i).getAttribute("SoLuongTuyen");
            var SoLuongTuyen2 = root.childNodes(i+1).getAttribute("SoLuongTuyen");
            var SoLuongTuyen3 = root.childNodes(i+2).getAttribute("SoLuongTuyen");
            var href1 = root.childNodes(i).getAttribute("DuongDan");
            var href2 = root.childNodes(i+1).getAttribute("DuongDan");
            var href3 = root.childNodes(i+2).getAttribute("DuongDan");
            chuoi += "<tr><td width='22' height='23' align='center' valign='middle'><img src='"+CapThuMuc+"images/dot_03.jpg' width='4' height='4' /></td>";
            chuoi += "<td height='23' width='302' align='left' ><a  href='"+href1+"'> <font style='font-family:Verdana; font-size:11.5px; color:#161616'>" + TenNghanh1 + "<span style='color:#284087'>&nbsp;(" + SoLuongTuyen1 + ")</span></font></a></td>";
            chuoi += "<td width='22' height='23' align='center' valign='middle' ><img src='"+CapThuMuc+"images/dot_03.jpg' width='4' height='4' /></td>";


            chuoi += "<td height='23' width='302' align='left' ><a href='"+href2+"' > <font style='font-family:Verdana; font-size:11.5px; color:#161616'>" + TenNghanh2 + "<span style='color:#284087'>&nbsp;(" + SoLuongTuyen2 + ")</span></font></a></td>";
            chuoi += "<td width='22' height='23' align='center' valign='middle'><img src='images/dot_03.jpg' width='4' height='4' /></td>";

            chuoi += "<td height='23' width='302' align='left' ><a  href='"+href3+"' > <font style='font-family:Verdana; font-size:11.5px; color:#161616'>" + TenNghanh3 + "<span style='color:#284087'>&nbsp;(" + SoLuongTuyen3 + ")</span></font></a></td>";


            chuoi += "</tr>";
            i += 3;
             
        }
        chuoi += "</table>";
        return chuoi;
        
}