%@LANGUAGE="JAVASCRIPT"%>
<%
// work out what values we want to pass in
// just the filename for the people pages
// first grab the path to the script (e.g. /research/employment/current.asp)
URLPath = new String(Request.ServerVariables('SCRIPT_NAME'));
// split it into an array, based on /
URLArray = URLPath.split("/");
// the filename is the last element in the array, and the dir is the last but one
filenameIdx = URLArray.length - 1;
directoryIdx = URLArray.length - 2;
// be lazy and don't learn any more JScript functions,
// so split on the . in the filename (rather than strip off the end .asp)
fileArr = URLArray[filenameIdx].split(".");
// grab the filename (not extension) for the status var
category = fileArr[0];
var default_sql = "SELECT * FROM Person WHERE (person_type = 'researcher' OR person_type = 'support' OR person_type = 'director') AND leave_date IS NULL ORDER BY last_name ASC";
var researcher_sql = "SELECT * FROM Person WHERE person_type = 'researcher' AND leave_date IS NULL ORDER BY last_name ASC";
var other_sql = "SELECT * FROM Person WHERE (person_type = 'support' OR person_type = 'director') AND leave_date IS NULL ORDER BY last_name ASC";
var employment_sql = "SELECT * FROM Person p, Research_Category rc, Person_Research_Category prc WHERE person_type = 'researcher' AND p.person_id = prc.person_id AND prc.category_id = rc.category_id AND rc.research_category_name = 'Employment group' AND p.leave_date IS NULL ORDER BY last_name ASC";
var environment_sql = "SELECT * FROM Person p, Research_Category rc, Person_Research_Category prc WHERE person_type = 'researcher' AND p.person_id = prc.person_id AND prc.category_id = rc.category_id AND rc.research_category_name = 'Environment group' AND p.leave_date IS NULL ORDER BY last_name ASC";
var social_sql = "SELECT * FROM Person p, Research_Category rc, Person_Research_Category prc WHERE person_type = 'researcher' AND p.person_id = prc.person_id AND prc.category_id = rc.category_id AND rc.research_category_name = 'Social Policy group' AND p.leave_date IS NULL ORDER BY last_name ASC";
var wasp_sql = "SELECT * FROM Person p, Research_Category rc, Person_Research_Category prc WHERE person_type = 'researcher' AND p.person_id = prc.person_id AND prc.category_id = rc.category_id AND (rc.research_category_name = 'Employment group' OR rc.research_category_name = 'Social Policy group') AND p.leave_date IS NULL ORDER BY last_name ASC";
var breadcrumb_title = "";
var people = Server.CreateObject("ADODB.Recordset");
people.ActiveConnection = MM_psi_db_STRING;
if (category == "research") {
people.source = researcher_sql;
breadcrumb_title = "Researchers";
} else if (category == "nonresearch") {
people.source = other_sql;
breadcrumb_title = "Other Staff";
} else if (category == "employment") {
people.source = employment_sql;
breadcrumb_title = "Employment";
} else if (category == "environment") {
people.source = environment_sql;
breadcrumb_title = "Environment";
} else if (category == "social") {
people.source = social_sql;
breadcrumb_title = "Social Policy Group";
} else if (category == "wasp") {
people.source = wasp_sql;
breadcrumb_title = "Work and Social Policy Group";
} else {
people.source = default_sql;
breadcrumb_title = "All Staff";
}
people.CursorType = 0;
people.CursorLocation = 2;
people.LockType = 3;
people.Open();
var people_numRows = 0;
%>
<%
var Repeat1__numRows = -1;
var Repeat1__index = 0;
people_numRows += Repeat1__numRows;
%>
<%
// *** Recordset Stats, Move To Record, and Go To Record: declare stats variables
// set the record count
var people_total = people.RecordCount;
// set the number of rows displayed on this page
if (people_numRows < 0) { // if repeat region set to all records
people_numRows = people_total;
} else if (people_numRows == 0) { // if no repeat regions
people_numRows = 1;
}
// set the first and last displayed record
var people_first = 1;
var people_last = people_first + people_numRows - 1;
// if we have the correct record count, check the other stats
if (people_total != -1) {
people_numRows = Math.min(people_numRows, people_total);
people_first = Math.min(people_first, people_total);
people_last = Math.min(people_last, people_total);
}
%>
<%
// *** Recordset Stats: if we don't know the record count, manually count them
if (people_total == -1) {
// count the total records by iterating through the recordset
for (people_total=0; !people.EOF; people.MoveNext()) {
people_total++;
}
// reset the cursor to the beginning
if (people.CursorType > 0) {
if (!people.BOF) people.MoveFirst();
} else {
people.Requery();
}
// set the number of rows displayed on this page
if (people_numRows < 0 || people_numRows > people_total) {
people_numRows = people_total;
}
// set the first and last displayed record
people_last = Math.min(people_first + people_numRows - 1, people_total);
people_first = Math.min(people_first, people_total);
}
%>