// JavaScript Document

var ajax = new Array();
function defrole(rolid)
{
	getFunctionalList(document.getElementById('functionalarea'),rolid);
}
function getFunctionalList(rel, rolid)
  {   
	var functionalid= rel.options[rel.selectedIndex].value;
	document.getElementById('Role').options.length = 0;// Empty States select box
		if(functionalid.length>0){
		
			var index = ajax.length;
			ajax[index] = new sack();
			ajax[index].requestFile = '/ajaxphp/candidates/getrole.php?functionalid='+functionalid+'&rolid='+rolid;	// Specifying which file to get
			ajax[index].onCompletion = function(){ createRole(index) };	// Specify function that will be executed after file has been found
			ajax[index].runAJAX();		// Execute AJAX function
		}
}
function createRole(index)
{	var obj = document.getElementById('Role');
	eval(ajax[index].response);	// Executing the response from Ajax as Javascript code	
}

