
function SalAjxSearchJob(strSearchJobTitle)
{
    strSearchJobTitle = strSearchJobTitle.replace(/(\s*Jobs$)/gi,"");
    strSearchJobTitle = strSearchJobTitle.replace(/(\s*Job$)/gi,"");
    if(trim(strSearchJobTitle) == "")
    {
        alert("Please enter the job title you want to search.");
        return;
    }
        
    var arrParam =  new Object();    
    arrParam.jobtitle=strSearchJobTitle;
    if(typeof AjaxPro != 'undefined' && AjaxPro !== null)
    {
        AjaxPro.timeoutPeriod=12000000;
    }
    else
    {
        alert('AjaxPro not exists');
    }    
    SalaryCom.IfjElements.IfjGadgetScripts.Ifjg_CommonAjaxCall.SalAjxSearchJob(arrParam,SalAjxSearchJob_CallBack);        
}

function SalAjxSearchJob_CallBack(r)
{   
    var strJobID = r.value[0];
    var strJobTitleFriendly = r.value[1]; 
    
    var strURL = "/" + strJobTitleFriendly + "-jobs";    
    var strMetro = "";
    var strState = "";
    var strGeoMetroCode = "";
    
    if(document.getElementById("metro"))
    {
        strMetro = trim(document.getElementById("metro").value).replace(/ /g,"-");
    } 
    
    if(document.getElementById("state"))
    {
        strState = trim(document.getElementById("state").value).replace(/ /g,"-");
    }

    if(document.getElementById("geometrocode"))
    {
        strGeoMetroCode = trim(document.getElementById("geometrocode").value).replace(/ /g,"-");
    }
    
    if(strState!="" ||  strMetro!="")
    {
         strURL = strURL + "_in";
    }              
    
    if(strMetro!="")
    {
        strURL = strURL + "_" + strMetro;
    }
    
    if(strState!="")
    {
        strURL = strURL + "_" + strState;
    }
    
    strURL = strURL + "/" + strGeoMetroCode + "-" + strJobID;                           
    location.href = strURL;
}

function clickButton(event, txtSearchJobTitle)
{  
      if (event.keyCode == 13)
      { 
            SalAjxSearchJob(txtSearchJobTitle.value);
            return false; 
      }    
}
