﻿function TieuDeDangNhapTuyenDung()
{
    var flag=getCookie((".usertv"));
    var chuoi="";
    if (flag == "1")
    {
        chuoi = "<table style='width:80px;'><tr><td width='80px' height='40' valign='top' style='padding-top:15px;padding-left:3px'>";
        chuoi += "<a id='hpldangxuat' href='../../../frmThoat.aspx' style='text-decoration:none;font-family:Verdana;font-size:11.5px;color:#161616;' onmousemove=UnderLineOver('hpldangxuat') onmouseout=UnderLineOut('hpldangxuat')>Đăng xuất</a></td></tr></table>";

    }
    else if (flag == "2")
    {
        chuoi = "<table style='width:80px;'><tr><td width='80px' height='40' valign='top' style='padding-top:15px;padding-left:3px'>";
        chuoi += "<a id='hpldangxuat' href='../../../frmThoat.aspx?NextPage=TD_frmMainTuyenDung.aspx' style='text-decoration:none;' onmousemove=UnderLineOver('hpldangxuat') onmouseout=UnderLineOut('hpldangxuat')><font style='font-family:Verdana;font-size:11.5px;color:#161616;'>Đăng xuất</font></a></td></tr></table>";

    }
    else
    {
        chuoi = "<table style='width:80px;'><tr><td width='80px' height='40' valign='top' style='padding-top:8px;'>";
        chuoi += "<a id='hpldangnhap'  href='../../../NTV_frmLogIn.aspx' style='text-decoration:none;font-family:Verdana;font-size:11.5px;color:#161616;' onmousemove=UnderLineOver('hpldangnhap') onmouseout=UnderLineOut('hpldangnhap')>Đăng nhập</a><br>";
        chuoi += "<a id='hpldangky'  href='../../../NTV_frmDangKy.aspx' style='text-decoration:none;font-family:Verdana;font-size:11.5px;color:#161616;' onmousemove=UnderLineOver('hpldangky') onmouseout=UnderLineOut('hpldangky')>Đăng ký</a></td></tr></table>";
    }
    return chuoi;
}

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 MessageBox2()
{
   var flag=getCookie((".usertv"));
   if(isChecked()==true)
   {
       if(flag=="2")
       {
         alert('Đã lưu');
         return true;
        }
   }
   else
   {
        alert("Bạn chưa chọn ứng viên");
        return false;
   }
   return true;  
}

function MessageBoxDelete()
{
   var flag=getCookie((".usertv"));
   if(isChecked()==true)
   {
       if(flag=="2")
       {
         alert('Đã xóa');
         return true;
        }
   }
   else
   {
        alert("Bạn chưa chọn ứng viên");
        return false;
   }
   return true;  
}


 function XoaTuyenDungDaDang(JobCode)
    {
        question=confirm("Bạn có thật sự muốn xóa tin tuyển dụng này chứ");
        if(question!="0")
            window.location.href='TD_frmTuyenDungDaDang.aspx?time='+ GetTime() + '&JobCode=' + JobCode ;
    }
function LuuUngVien(XuLy,applicantcode)
    {
       //Ham LuuHoSo luu ho thong tin ho so cua ung vien trong file chitiet ung vien .html
       //Trong thu muc ApplicantJob
        if(getCookie("userflag")=="2")
        {
            var CapThuMuc="../../../../";    
            var strhref=CapThuMuc+'TD_frmLuuUngVien.aspx?XuLy=' + XuLy + '&ApplicantCode=' + applicantcode;
            get_url02("Save,,"+strhref,1);
            ///Xoa cookie danh sach ung vien vua luu
             alert("Đã lưu ứng viên");
             setTimeout("SaveCookie('CookieApplicantCode',' ')",500);
         }
         else
            window.location.href="../../../../NTD_frmLogIn.aspx";
    }
function LuuUngVien2(XuLy)
    {
        var strArr=getCookie('CookieApplicantCode');
        if(getCookie("userflag")=="2")
        {
            if(strArr!=null && strArr!=' ')
            {
                var strhref='TD_frmLuuUngVien.aspx?XuLy=' + XuLy + '&time=' + GetTime();
                get_url01("Save,,"+strhref,1);
                ///Xoa cookie danh sach ung vien vua luu
                alert("Đã lưu ứng viên");
                setTimeout("SaveCookie('CookieApplicantCode',' ')",500);
            }
            else
            {
               alert('Bạn chưa chọn ứng viên');
               setTimeout("SaveCookie('CookieApplicantCode',' ')",500);
            }
          }
          else
            window.location.href="NTD_frmLogIn.aspx";
           
     }
    function LuuUngVien2HTML(XuLy)
    {
         //Thuc hien khi nha tuyen dung chon chuc nang LuuHoSo o trang Tim Ung vien theo nghanh .html hay trang tuong tu. Luu cung mot luc nhieu ung vien
         //Luu trong thu muc EmployerCareer
       
        var strArr=getCookie('CookieApplicantCode');
        
        strArr=trim(strArr,' ');
        
        if(getCookie("userflag")=="2")
        {
            if(strArr!=null && strArr!='')
            {
                var strhref='../../../TD_frmLuuUngVien.aspx?XuLy=' + XuLy + '&time=' + GetTime();
                get_url01("Save,,"+strhref,1);
                    ///Xoa cookie danh sach ung vien vua luu
                alert("Đã lưu ứng viên");
                ///Xoa cookie danh sach ung vien vua luu
                setTimeout("SaveCookie('CookieApplicantCode',' ')",500);
            }
            else
            {
                alert('Bạn chưa chọn ứng viên');
                SaveCookie('CookieApplicantCode',' ');
            }
         }
         else
             window.location.href="../../../NTD_frmLogIn.aspx";
    }
   function setSearch2()
    {
        if(getCookie("KeySearch2")!=null)
        {
            if(getCookie("KeySearch2")!='')
                document.getElementById("txtTuKhoa").value=getCookie("KeySearch2");
            else
                document.getElementById("txtTuKhoa").value='từ khóa';
        }
        if(getCookie("IdNghanhSearch2")!=null)
             if(getCookie("IdNghanhSearch2")!='')
                document.getElementById("cboNganh").value=getCookie("IdNghanhSearch2");
        if(getCookie("IdNoiLamViecSearch2")!=null)
             if(getCookie("IdNoiLamViecSearch2")!='')
                document.getElementById("cboDiaDiem").value=getCookie("IdNoiLamViecSearch2");

    }
  function TimNhanhUngVien()//Tim Nhanh Ung vien
    {
        var TuKhoa="";

        if(document.getElementById("txtTuKhoa")!=null) 
            TuKhoa=document.getElementById("txtTuKhoa").value;
        if(TuKhoa=='từ khóa')
            TuKhoa='';
       
         var NganhID= document.getElementById('cboNganh').value;
         var NoiLamViecID= document.getElementById('cboDiaDiem').value;
               
        SaveCookie("KeySearch2",TuKhoa);
        SaveCookie("IdNghanhSearch2",NganhID);
        SaveCookie("IdNoiLamViecSearch2",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("DuongDanUngVien");
                      break;
                }
               
            }       
           
            window.location.href="HTML/Employer/EmployerCareer/"+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/Employer/EmployerCareer/danhsachungvien_0.html";
         else//Nguoc lai goi trang .aspx
            window.location.href="TD_frmDSTimNhanh.aspx?Trang=page=1" + "&NganhID=" + NganhID + "&NoiLamViecID=" + NoiLamViecID+"&TuKhoa="+TuKhoa;
          // window.location.href="frmMain_TDTimUngVien.aspx?Trang=TD_frmDSTimNhanh.aspx" + "&NganhID=" + NganhID + "&NoiLamViecID=" + NoiLamViecID;
    }
    function TimNhanhUngVienHTML()//Tim Nhanh Ung vien
    {
        var CapThuMuc="../../../";
        var TuKhoa="";
        if(document.getElementById('txtTuKhoa')!=null)
            TuKhoa=document.getElementById('txtTuKhoa').value;
        if(TuKhoa=='từ khóa')
            TuKhoa='';
         var NganhID= document.getElementById('cboNganh').value;
         var NoiLamViecID= document.getElementById('cboDiaDiem').value;
         
        SaveCookie("KeySearch2",TuKhoa);
        SaveCookie("IdNghanhSearch2",NganhID);
        SaveCookie("IdNoiLamViecSearch2",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("DuongDanUngVien");
                      break;
                }
               
            }       
           
            window.location.href=+duongdan;
         }//Neu chon tat ca cac nghanh va cac linh vuc thi chon file .html
         if(TuKhoa==''&&NganhID==0&&NoiLamViecID==0)
             window.location.href="danhsachungvien_0.html";
       
         else//Nguoc lai goi trang .aspx
            window.location.href=CapThuMuc+"TD_frmDSTimNhanh.aspx?Trang=page=1" + "&NganhID=" + NganhID + "&NoiLamViecID=" + NoiLamViecID+"&TuKhoa="+TuKhoa;
    }
    //Tim ung vien nang cao
    function TimUngVienNangCao()
         {
            
             var HonNhan="-1";
             var TuKhoa='';
             var GioiTinh="-1";
             if(document.getElementById('rbDaKetHon').checked==true)
                HonNhan="1";
             if(document.getElementById('rbChuaKetHon').checked==true)
                HonNhan="0";
             if (document.getElementById('rbNu').checked == true)
                GioiTinh = "2";//nu
             if (document.getElementById('rbNam').checked == true)
                GioiTinh = "1";//nam
             if(document.getElementById('txtTuKhoa').value!='từ khóa')
                TuKhoa=EnCodeSearch(document.getElementById('txtTuKhoa').value);
             var NganhID= document.getElementById('cboNganh1').value;
             var DiaDiemID= document.getElementById('cboDiaDiem1').value;
             var KinhNghiemID=document.getElementById('cboKinhNghiem1').value;
             var TrinhDoID= document.getElementById('cboTrinhDo1').value;
             var HinhThucLamViecID= document.getElementById('cboHinhThucLamViec1').value;
             var ChucDanhID= document.getElementById('cboChucDanh').value;
             var Luong= document.getElementById('salary').value;
             var TuoiTu= document.getElementById('cboTuoiTu').value;
             var TuoiDen= document.getElementById('cboTuoiDen').value;
             var NgayCapNhat= document.getElementById('cboNgayCapNhat').value;
             
             
                         
             var chuoi = "TD_frmKetQuaTimNangCao.aspx?TuKhoa=" + TuKhoa + "&NganhID=" + NganhID + "&ChucDanhID=" + ChucDanhID + "&TrinhDoID=" + TrinhDoID;
             chuoi += "&HinhThucLamViecID=" + HinhThucLamViecID + "&Luong=" + Luong + "&KinhNghiemID=" + KinhNghiemID;
             chuoi += "&TuoiTu=" + TuoiTu + "&TuoiDen=" + TuoiDen + "&GioiTinh=" + GioiTinh + "&HonNhan=" + HonNhan + "&NgayCapNhat=" + NgayCapNhat + "&NoiLamViecID=" + DiaDiemID;
            
            window.location.href=chuoi;
                  
                
         }
//        function XoaHoSoNhan(XuLy,ApplicantCode,JobCode)
//        {
//            question=confirm("Bạn có thật sự muốn xóa không?");
//            if(question!="0")
//            {
//                get_url01('Load_XuLyLuuUngVien,,TD_frmLuuUngVien.aspx?XuLy=' + XuLy + '&ApplicantCode=' + ApplicantCode + '&JobCode=' + JobCode  + '&time=' + GetTime(),1); 
//                window.location.href="frmMain_TDUngVien.aspx?Trang=TD_frmAllUngVienUngTuyen.aspx";
//            }

//        }
        
             
        function openWin1(href) 
        { 
            window.open(href,"mywindow","location=1,status=1,scrollbars=0,width=700,height=300"); 
        } 


////////////////////////////////////////////////DanhSachUngVienTheoNghanh/////////////////////////////////////
function DanhSachUngVienTheoNghanh(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+=LoadDachSachUngVienTheoNghanh();
    chuoi+=" </td>";
    chuoi+="</tr>";
    chuoi+=" </table>";
    chuoi+="</td>";
    chuoi+=" </tr>";
    chuoi+="</table>";
    return chuoi;
}
function LoadDachSachUngVienTheoNghanh()
{      
   
     var chuoi ="";
     var CapThuMuc="HTML/Employer/EmployerCareer/";
     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("DuongDanUngVien");
            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("SoLuongUngVien");
            var SoLuongTuyen2 = root.childNodes(i+1).getAttribute("SoLuongUngVien");
            var SoLuongTuyen3 = root.childNodes(i+2).getAttribute("SoLuongUngVien");
            var href1 = root.childNodes(i).getAttribute("DuongDanUngVien");
            var href2 = root.childNodes(i+1).getAttribute("DuongDanUngVien");
            var href3 = root.childNodes(i+2).getAttribute("DuongDanUngVien");
       
            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+"' style='font-family:Verdana; font-size:11.5px; color:#161616'>" + TenNghanh1 + "<span style='color:#284087'>&nbsp;(" + SoLuongTuyen1 + ")</span></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 style='font-family:Verdana; font-size:11.5px; color:#161616' href='"+href2+"' >" + TenNghanh2 + "<span style='color:#284087'>&nbsp;(" + SoLuongTuyen2 + ")</span></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 style='font-family:Verdana; font-size:11.5px; color:#161616' href='"+href3+"' >" + TenNghanh3 + "<span style='color:#284087'>&nbsp;(" + SoLuongTuyen3 + ")</span></a></td>";


            chuoi += "</tr>";
            i += 3;
        }
        chuoi += "</table>";
        return chuoi;
}
