function SeachFilter(option,id,name){
    if(option=="PAGER"){
      document.mainform.p_pageindx.value= id; 
    }
    if(option=="SECTOR"){
      document.mainform.p_SectorID.value= id; 
      document.mainform.p_SectorName.value= name; 
    }
    if(option=="CLEARSECTOR"){
      document.mainform.p_SectorID.value= ""; 
      document.mainform.p_SectorName.value= ""; 
    }
    if(option=="LOCATION"){
      document.mainform.p_LocationID.value= id; 
      document.mainform.p_LocationName.value= name; 
    }
    if(option=="CLEARLOCATION"){
      document.mainform.p_LocationID.value= ""; 
      document.mainform.p_LocationName.value= ""; 
    }
    if(option=="EXPERIENCE"){
      document.mainform.p_ExperienceID.value= id; 
      document.mainform.p_ExperienceName.value= name; 
    }
    if(option=="CLEAREXPERIENCE"){
      document.mainform.p_ExperienceID.value= ""; 
      document.mainform.p_ExperienceName.value= ""; 
    }
    if(option=="EDUCATION"){
      document.mainform.p_EducationID.value= id; 
      document.mainform.p_EducationName.value= name; 
    }
    if(option=="CLEAREDUCATION"){
      document.mainform.p_EducationID.value= ""; 
      document.mainform.p_EducationName.value= ""; 
    }
    if(option=="LANGUAGE"){
      document.mainform.p_LanguageID.value= id; 
      document.mainform.p_LanguageName.value= name; 
    }
    if(option=="CLEARLANGUAGE"){
      document.mainform.p_LanguageID.value= ""; 
      document.mainform.p_LanguageName.value= ""; 
    }
    if(option=="GENDER"){
      document.mainform.p_GenderID.value= id; 
      document.mainform.p_GenderName.value= name; 
    }
    if(option=="CLEARGENDER"){
      document.mainform.p_GenderID.value= ""; 
      document.mainform.p_GenderName.value= ""; 
    } 
    if(option=="CLEAR"){
      document.mainform.p_SectorID.value= ""; 
      document.mainform.p_SectorName.value= ""; 
      document.mainform.p_LocationID.value= ""; 
      document.mainform.p_LocationName.value= ""; 
      document.mainform.p_ExperienceID.value= ""; 
      document.mainform.p_ExperienceName.value= ""; 
      document.mainform.p_EducationID.value= ""; 
      document.mainform.p_EducationName.value= ""; 
      document.mainform.p_LanguageID.value= ""; 
      document.mainform.p_LanguageName.value= ""; 
      document.mainform.p_GenderID.value= ""; 
      document.mainform.p_GenderName.value= ""; 
    }                                                
    document.mainform.submit();
}                           
        
function CompareCV(p_option,p_resumeid){
    //Log the action
    if (window.XMLHttpRequest) {
            http = new XMLHttpRequest();
        }
        // IE
        else if (window.ActiveXObject) {
            http = new ActiveXObject("Microsoft.XMLHTTP");
    }
    //alert('compare_01.php?p_resumeid='+p_resumeid+'&p_option='+p_option+"&p_t="+new Date().getTime());
    http.open('get', 'compare_01.php?p_resumeid='+p_resumeid+'&p_option='+p_option+"&p_t="+new Date().getTime(),true);
    http.send(null);
    http.onreadystatechange = function() {
        if (http.readyState == 4) {
            document.getElementById('p_CompareDiv').innerHTML = http.responseText;
        }
    }
    
}



function FavoriteCV(p_option,p_resumeid){
    //Log the action
    if (window.XMLHttpRequest) {
            http = new XMLHttpRequest();
        }
        // IE
        else if (window.ActiveXObject) {
            http = new ActiveXObject("Microsoft.XMLHTTP");
    }
    //alert('compare_01.php?p_resumeid='+p_resumeid+'&p_option='+p_option+"&p_t="+new Date().getTime());
    http.open('get', 'favorite_01.php?p_resumeid='+p_resumeid+'&p_option='+p_option+"&p_t="+new Date().getTime(),true);
    http.send(null);
    http.onreadystatechange = function() {
        if (http.readyState == 4) {
            if(p_option=="ADD")
                document.getElementById('p_FavoriteDiv'+p_resumeid).innerHTML = "<img src=images/removefavorite.jpg height=24 width=24>";
            else if(p_option=="REMOVE")
                document.getElementById('p_FavoriteDiv'+p_resumeid).innerHTML = "<img src=images/addfavorite.jpg height=24 width=24>";
            
        }
    }
    
}
         
// Cookie functions         
function createCookie(name,value,days) {
    if (days) {
        var date = new Date();
        date.setTime(date.getTime()+(days*24*60*60*1000));
        var expires = "; expires="+date.toGMTString();
    }
    else var expires = "";
    document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name) {
    var nameEQ = name + "=";
    var ca = document.cookie.split(';');
    for(var i=0;i < ca.length;i++) {
        var c = ca[i];
        while (c.charAt(0)==' ') c = c.substring(1,c.length);
        if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
    }
    return null;
}

function eraseCookie(name) {
    createCookie(name,"",-1);
}

function anyCheck(form) {
    var total = 0;
    var strcompare="(";
    var max = form.p_compcvs.length;
    for (var idx = 0; idx < max; idx++) {
        if (eval("document.mainform.p_compcvs[" + idx + "].checked") == true) {
            total += 1;
            if(total<4){
                if(total==1)
                    strcompare=strcompare+form.p_compcvs[idx].value;
                else    
                    strcompare=strcompare+","+form.p_compcvs[idx].value;
            }else{
                alert("Вы можете выбрать не более 3 резюме!");
                form.p_compcvs[idx].checked=false;
                total -= 1;
            }
        }
    }
    strcompare=strcompare+")";
    //alert("You selected " + total + " boxes-"+strcompare);
    document.mainform.p_compare.value=strcompare;
    document.mainform.p_comparecount.value=total;
}

function compareresumecount() {
    if(document.mainform.p_comparecount.value=="" || document.mainform.p_comparecount.value=="0"  || document.mainform.p_comparecount.value=="1")
        alert("Пожалуйста, выберите не менее 2 резюме!");
    else
        document.mainform.submit();
}


function isNumberKey(evt)
      {
         var charCode = (evt.which) ? evt.which : event.keyCode
         if (charCode > 31 && (charCode < 48 || charCode > 57))
            return false;

         return true;
      }
