/**
 * javascript for ajax chained select
 */

var ajax = new sack();

/**************************************************/
/* search box ajax drop down multi chained select */
/**************************************************/
/**
 * function to get location and sub-location
 */
function getSubLocationSearchList(sel)
{
	var location_id = sel.options[sel.selectedIndex].value;
	document.getElementById('sublocation_id').options.length = 0;	// empty select box
	if(location_id.length > 0){
		ajax.requestFile = 'getSubLocation.php?location_id='+location_id+'&searchbox=1';	// specifying which file to get
		ajax.onCompletion = createSubLocationSearchList;	// specify function that will be executed after file has been found
		ajax.runAJAX();		// execute ajax function
	}
}

function createSubLocationSearchList()
{
	var obj = document.getElementById('sublocation_id');
	eval(ajax.response);	// executing the response from ajax as javascript code	
}

/**
 * function to get location and sub-location
 */
function getSubSectorSearchList(sel)
{
	var sector_id = sel.options[sel.selectedIndex].value;
	document.getElementById('subsector_id').options.length = 0;	// empty select box
	if(sector_id.length > 0){
		ajax.requestFile = 'getSubSector.php?sector_id='+sector_id+'&searchbox=1';	// specifying which file to get
		ajax.onCompletion = createSubSectorSearchList;	// specify function that will be executed after file has been found
		ajax.runAJAX();		// execute ajax function
	}
}

/**
 * function to get sub-locations
 * for Salary Survey
 */
function getSubSectorSearchListSalarySurvey(sel)
{
	var sector_id = sel.options[sel.selectedIndex].value;
	document.getElementById('subsector_id').options.length = 0;	// empty select box
	if(sector_id.length > 0){
		ajax.requestFile = 'getSubSector.php?sector_id='+sector_id+'&searchbox=0';	// specifying which file to get
		ajax.onCompletion = createSubSectorSearchList;	// specify function that will be executed after file has been found
		ajax.runAJAX();		// execute ajax function
	}
}


function createSubSectorSearchList()
{
	var obj = document.getElementById('subsector_id');
	eval(ajax.response);	// executing the response from ajax as javascript code	
}
/**************************************************/
/* search box ajax drop down multi chained select */
/**************************************************/

/**
 * function to get location and sub-location
 */
function getSubLocationList(sel)
{
	var location_id = sel.options[sel.selectedIndex].value;
	document.getElementById('sublocation_id').options.length = 0;	// empty select box
	if(location_id.length > 0){
		ajax.requestFile = 'getSubLocation.php?location_id='+location_id;	// specifying which file to get
		ajax.onCompletion = createSubLocation;	// specify function that will be executed after file has been found
		ajax.runAJAX();		// execute ajax function
	}
}

function createSubLocation()
{
	var obj = document.getElementById('sublocation_id');
	eval(ajax.response);	// executing the response from ajax as javascript code	
}

/**
 * function to get location and sub-location 1
 */
function getSubLocationList1(sel)
{
	var location_id_1 = sel.options[sel.selectedIndex].value;
	document.getElementById('sublocation_id_1').options.length = 0;	// empty select box
	if(location_id_1.length > 0){
		ajax.requestFile = 'getSubLocation.php?location_id='+location_id_1;	// specifying which file to get
		ajax.onCompletion = createSubLocation1;	// specify function that will be executed after file has been found
		ajax.runAJAX();		// execute ajax function
	}
}

function createSubLocation1()
{
	var obj = document.getElementById('sublocation_id_1');
	eval(ajax.response);	// executing the response from ajax as javascript code	
}

/**
 * function to get location and sub-location 2
 */
function getSubLocationList2(sel)
{
	var location_id_2 = sel.options[sel.selectedIndex].value;
	document.getElementById('sublocation_id_2').options.length = 0;	// empty select box
	if(location_id_2.length > 0){
		ajax.requestFile = 'getSubLocation.php?location_id='+location_id_2;	// specifying which file to get
		ajax.onCompletion = createSubLocation2;	// specify function that will be executed after file has been found
		ajax.runAJAX();		// execute ajax function
	}
}

function createSubLocation2()
{
	var obj = document.getElementById('sublocation_id_2');
	eval(ajax.response);	// executing the response from ajax as javascript code	
}

/**
 * function to get location and sub-location 3
 */
function getSubLocationList3(sel)
{
	var location_id_3 = sel.options[sel.selectedIndex].value;
	document.getElementById('sublocation_id_3').options.length = 0;	// empty select box
	if(location_id_3.length > 0){
		ajax.requestFile = 'getSubLocation.php?location_id='+location_id_3;	// specifying which file to get
		ajax.onCompletion = createSubLocation3;	// specify function that will be executed after file has been found
		ajax.runAJAX();		// execute ajax function
	}
}

function createSubLocation3()
{
	var obj = document.getElementById('sublocation_id_3');
	eval(ajax.response);	// executing the response from ajax as javascript code	
}

/**
 * function to get location and sub-location 4
 */
function getSubLocationList4(sel)
{
	var location_id_4 = sel.options[sel.selectedIndex].value;
	document.getElementById('sublocation_id_4').options.length = 0;	// empty select box
	if(location_id_4.length > 0){
		ajax.requestFile = 'getSubLocation.php?location_id='+location_id_4;	// specifying which file to get
		ajax.onCompletion = createSubLocation4;	// specify function that will be executed after file has been found
		ajax.runAJAX();		// execute ajax function
	}
}

function createSubLocation4()
{
	var obj = document.getElementById('sublocation_id_4');
	eval(ajax.response);	// executing the response from ajax as javascript code	
}

/**
 * function to get location and sub-location 5
 */
function getSubLocationList5(sel)
{
	var location_id_5 = sel.options[sel.selectedIndex].value;
	document.getElementById('sublocation_id_5').options.length = 0;	// empty select box
	if(location_id_5.length > 0){
		ajax.requestFile = 'getSubLocation.php?location_id='+location_id_5;	// specifying which file to get
		ajax.onCompletion = createSubLocation5;	// specify function that will be executed after file has been found
		ajax.runAJAX();		// execute ajax function
	}
}

function createSubLocation5()
{
	var obj = document.getElementById('sublocation_id_5');
	eval(ajax.response);	// executing the response from ajax as javascript code	
}

/**
 * function to get sector and sub-sector 1
 */
function getSubSectorList1(sel)
{
	var sector_id_1 = sel.options[sel.selectedIndex].value;
	document.getElementById('subsector_id_1').options.length = 0;	// empty select box

	if(sector_id_1.length > 0){
		ajax.requestFile = 'getSubSector.php?sector_id='+sector_id_1;	// specifying which file to get
		ajax.onCompletion = createSubSector1;	// specify function that will be executed after file has been found
		ajax.runAJAX();		// execute ajax function
	}
}

function createSubSector1()
{
	var obj = document.getElementById('subsector_id_1');
	eval(ajax.response);	// executing the response from ajax as javascript code	
}

/**
 * function to get sector and sub-sector 2
 */
function getSubSectorList2(sel)
{
	var sector_id_2 = sel.options[sel.selectedIndex].value;
	document.getElementById('subsector_id_2').options.length = 0;	// empty select box

	if(sector_id_2.length > 0){
		ajax.requestFile = 'getSubSector.php?sector_id='+sector_id_2;	// specifying which file to get
		ajax.onCompletion = createSubSector2;	// specify function that will be executed after file has been found
		ajax.runAJAX();		// execute ajax function
	}
}

function createSubSector2()
{
	var obj = document.getElementById('subsector_id_2');
	eval(ajax.response);	// executing the response from ajax as javascript code	
}

/**
 * function to get sector and sub-sector 3
 */
function getSubSectorList3(sel)
{
	var sector_id_3 = sel.options[sel.selectedIndex].value;
	document.getElementById('subsector_id_3').options.length = 0;	// empty select box

	if(sector_id_3.length > 0){
		ajax.requestFile = 'getSubSector.php?sector_id='+sector_id_3;	// specifying which file to get
		ajax.onCompletion = createSubSector3;	// specify function that will be executed after file has been found
		ajax.runAJAX();		// execute ajax function
	}
}

function createSubSector3()
{
	var obj = document.getElementById('subsector_id_3');
	eval(ajax.response);	// executing the response from ajax as javascript code	
}

/**
 * function to get sector and sub-sector 4
 */
function getSubSectorList4(sel)
{
	var sector_id_4 = sel.options[sel.selectedIndex].value;
	document.getElementById('subsector_id_4').options.length = 0;	// empty select box

	if(sector_id_4.length > 0){
		ajax.requestFile = 'getSubSector.php?sector_id='+sector_id_4;	// specifying which file to get
		ajax.onCompletion = createSubSector4;	// specify function that will be executed after file has been found
		ajax.runAJAX();		// execute ajax function
	}
}

function createSubSector4()
{
	var obj = document.getElementById('subsector_id_4');
	eval(ajax.response);	// executing the response from ajax as javascript code	
}

/**
 * function to get sector and sub-sector 5
 */
function getSubSectorList5(sel)
{
	var sector_id_5 = sel.options[sel.selectedIndex].value;
	document.getElementById('subsector_id_5').options.length = 0;	// empty select box

	if(sector_id_5.length > 0){
		ajax.requestFile = 'getSubSector.php?sector_id='+sector_id_5;	// specifying which file to get
		ajax.onCompletion = createSubSector5;	// specify function that will be executed after file has been found
		ajax.runAJAX();		// execute ajax function
	}
}

function createSubSector5()
{
	var obj = document.getElementById('subsector_id_5');
	eval(ajax.response);	// executing the response from ajax as javascript code	
}
