﻿// JScript File : Ajax used for Job sub location dropdown and job list
function SetSubLoc(loc)
{  
    indexcm.GetSubLoc(loc,fillSubLoc_CallBack);
}
function fillSubLoc_CallBack(response) 
{  
    var faval = response.value; 
    var htmlfdc = new Array(); 
    var id;  	
    if(faval!= null && typeof(faval) == "object" && faval.Rows!= null) 
    {   
	    htmlfdc[0] = "<option value=-1 align='center'>" + "select location" + "</option>"; 				
	    for(var i=0;i<faval.Rows.length;i++) 
	    {
	          htmlfdc[htmlfdc.length+1] = "<option value=" + faval.Rows[i].JobLocationId + ">" + faval.Rows[i].JobLocation + "</option>"; 
	    }
	    document.getElementById("LocSpan").innerHTML = "<select id=\"falist\" class=\"listbox_big\" onchange=\" onChangeCL(this.options[this.selectedIndex].value,this.options[this.selectedIndex].text);\" >" + htmlfdc.join("") + "</select>"; 	 
     }
     else
        document.getElementById("LocSpan").innerHTML = "<select id=\"falist\" class=\"listbox_big\" >" + "<option value=-1 align='center'>select location</option>" + "</select>"; 	 
}


function onChangeCL(index,cvalue)
{ 
  CLName=cvalue;
  CLId=index;
  
  if(index != -1)
  {
      indexcm.GetJobList(index,FillJobList_Callback);
      document.getElementById('divJobs').innerText=CLName;
  }
 } 
function FillJobList_Callback(response) 
{   if(response != null)
	document.getElementById('divJobs').innerHTML = response.value;
}  

