// JavaScript Document

var ajax = new Array();
function getAreas(){
	document.getElementById('pp_areaSelect').options.length = 0; // Empty  select 1 box
	var index = ajax.length;
							
	ajax[index] = new sack();
	
	ajax[index].requestFile = '../includes/ppGetRepresentatives.php?select=areas'; // Specifying which file to get
	ajax[index].onCompletion = function(){
		returnAreas(index)
	}; // Specify function that will be executed after file has been found
	ajax[index].runAJAX(); // Execute AJAX function
}			
function returnAreas(index){
	var obj = document.getElementById('pp_areaSelect');
	eval(ajax[index].response); // Executing the response from Ajax as Javascript code
}

function getRep(sel){
    var repID = sel.options[sel.selectedIndex].value;
    if (repID.length > 0) {
        var index = ajax.length;
        
		ajax[index] = new sack();
        
        ajax[index].requestFile = '../includes/ppGetRepresentatives.php?select=reps&repID=' + repID; // Specifying which file to get
        ajax[index].onCompletion = function(){
            returnRep(index)
        }; // Specify function that will be executed after file has been found
        ajax[index].runAJAX(); // Execute AJAX function
    }
}

function returnRep(index){
    var obj = document.getElementById('pp_representative');
    eval(ajax[index].response); // Executing the response from Ajax as Javascript code	
}
