

function LdapPerson(ldapData) {
    
    // first entry in list is the base LDAP info
    var baseInfo = ldapData.shift();
    // basic info
    this.spid = baseInfo.spid;
    this.name = baseInfo.displayName;
    this.email = baseInfo.mail;
    this.urls = [];
    if(baseInfo.labeledURI) {
        this.urls = this.urls.concat(baseInfo.labeledURI);
    }
    this.phone = baseInfo.telephoneNumber;
    this.campusBox = baseInfo.postOfficeBox;
    // numbers
    this.fax = baseInfo.facsimileTelephoneNumber;
    this.homePhone = baseInfo.homePhone;
    this.mobile = baseInfo.mobile;
    this.pager = baseInfo.pager;
    // is this person a student? If so, grab student data
    this.isStudent =  hasObjectClass(baseInfo.objectClass, "UNCStudent");
    if(this.isStudent) {
        this.college = collegeName[baseInfo.college];
        this.degree = degreeName[baseInfo.degreeIntention];
        this.studentType = baseInfo.uncStudentType;
        this.classOrYear = baseInfo.classOrYear;
    //this.department = baseInfo.ou; // ??
    }
    // parse locations and positions from remaining data
    this.locations = [];
    this.positions = [];
    this.associations = [];
    this.minors = [];
    this.majors = [];
    for(index in ldapData) {
        var subnode = ldapData[index];
        if(hasObjectClass(subnode.objectClass, "UNCLocation")
            && (subnode.street || subnode.telephoneNumber)) {
            subnode.locationName = locationName[subnode.cn]?locationName[subnode.cn]:makeLocationName(subnode.cn);
            this.locations.push(subnode);
        }
        if(hasObjectClass(subnode.objectClass, "UNCEnrollment")) {
            if(subnode.majorRank < 3) {
                this.majors.push(subnode.ou);
            } else {
                this.minors.push(subnode.ou);
            }
        }
        if(hasObjectClass(subnode.objectClass, "UNCPosition")) {
            if(subnode.displayOrder > 0) {
                this.positions.push(subnode);
            }
        }
        if(hasObjectClass(subnode.objectClass, "UNCAssociation")) {
            this.associations.push(subnode);
        }
    }
    this.positions.sort(compareDisplayOrder);

    function compareDisplayOrder(a, b) {
        if(a.displayOrder > b.displayOrder) {
            return 1;
        } else if(b.displayOrder > a.displayOrder) {
            return -1;
        }
        return 0;
    }

    function hasObjectClass(property, className) {
        if(YAHOO.lang.isArray(property)) {
            for (var i = 0; i < property.length; i++) {
                if (property[i] == className) {
                    return true;
                }
            }
            return false;
        } else {
            return property == className;
        }
    }
}

var locationName = {
    "home-location": "Home",
    "alternate-work-location": "Alternate Work Location",
    "campus-location": "Campus Address",
    "local-location": "Local Address",
    "primary-work-location": "Primary Work Location"
}

function makeLocationName(nodeName) {
    return nodeName.replace(/\\-([a-z]+)/, " $1");
}

var collegeName = {
    "AS":"College Of Arts & Sciences",
    "BA":"School Of Business",
    "CS":"Continuing Studies",
    "DN":"School Of Dentistry (DN)",
    "DS":"School Of Dentistry",
    "ED":"School Of Education",
    "GC":"General College",
    "GR":"*Graduate School",
    "GV":"School Of Government",
    "II":"Interinstitutional",
    "JO":"School Of Journalism & Mass Communication",
    "LS":"School Of Information & Library Science",
    "LW":"School Of Law",
    "MA":"Masters Of Accounting Program",
    "MB":"Masters Of Business Administration Program",
    "MD":"School Of Medicine (MD)",
    "MS":"School Of Medicine",
    "NU":"School Of Nursing",
    "OS":"Off Campus Studies",
    "PH":"School Of Public Health",
    "PY":"School Of Pharmacy",
    "RR":"Office Of The University Registrar",
    "SW":"School Of Social Work",
    "SS":"Summer School",
    "UG":"Undergraduate",
    "VS":"Visitors"
}

var degreeName = {
    "AB":"Bachelor Of Arts",
    "ABCA":"Bachelor Of Arts - Creative Arts",
    "ABED":"AB In Education",
    "ABH":"Bachelor Of Arts - Honorary",
    "ABJM":"AB In Journalism & Mass Comm",
    "ABJO":"AB In Journalism",
    "ABLLB":"Bachelor Of Arts And Laws",
    "ABLS":"AB Library Science",
    "ABMUS":"Bachelor Of Arts In Music",
    "ABSC":"Bachelor Of Arts - Special Civil War",
    "ABSU":"Bachelor Of Arts - Special Unearned",
    "ABSW":"Bachelor Of Arts - Special World War",
    "AUD":"Doctor Of Audiology",
    "BA":"Bachelor Of Arts",
    "BACH":"Bachelors Degree",
    "BE":"Bachelor Of Engineering Tech",
    "BENGR":"Bachelor Of Engineering",
    "BFA":"Bachelor Of Fine Arts",
    "BLITT":"Bachelor Of Letters",
    "BMED":"Bachelor Of Music Education",
    "BMUS":"Bachelor Of Music",
    "BS":"Bachelor Of Science",
    "BSADJ":"BS Adm Criminal Justice",
    "BSAMT":"BS In Applied Math",
    "BSASC":"BS In Applied Science",
    "BSBA":"BS Business Administration",
    "BSBAA":"BS Business Admin - Accounting",
    "BSBAC":"BS In Bacteriology",
    "BSBIO":"BS In Biology",
    "BSBOT":"BS In Botany",
    "BSCE":"BS Civil Engineering",
    "BSCH":"BS Chemistry",
    "BSCHE":"BS School Engineering",
    "BSCLS":"BS In Clinical Laboratory Science",
    "BSCOM":"BS In Commerce",
    "BSCS":"BS In Computer Science",
    "BSDAT":"BS Dent Aux Tech/ED",
    "BSDEN":"BS Dentistry",
    "BSDH":"BS In Dental Hygiene",
    "BSDHE":"BS In Dental Hygiene Education",
    "BSEE":"BS Electrical Engineering",
    "BSENS":"BS In Environmental Sciences",
    "BSGEO":"BS In Geology",
    "BSHED":"BS In Health Education",
    "BSHUM":"BS In Human Biology",
    "BSIR":"BS In Industrial Relations",
    "BSIS":"BS In Information Science",
    "BSLLB":"Bachelor Of Science And Law",
    "BSLS":"BS Library Science",
    "BSMAT":"BS In Mathematics",
    "BSMDS":"BS In Mathematical Decision Sciences",
    "BSME":"BS Mechanical Engineering",
    "BSMED":"BS In Medicine",
    "BSMIn":"BS Mining Engineering",
    "BSMS":"BS In Math Sciences",
    "BSMT":"BS Medical Technology",
    "BSMTC":"BS Medical Technology",
    "BSMUS":"BS Music",
    "BSN":"BS In Nursing",
    "BSPA":"BS Personnel Administration",
    "BSPBH":"BS In Public Health",
    "BSPH":"BS In Public Health",
    "BSPHE":"BS Public Health Education",
    "BSPHN":"BS Pub Health Nursing",
    "BSPHR":"BS In Pharmacy",
    "BSPHY":"BS In Physics",
    "BSPSY":"BS In Psychology",
    "BSPT":"BS In Physical Therapy",
    "BSPub":"BS Public Administration",
    "BSRS":"BS Radiologic Science",
    "BSSE":"BS Sanitary Engineering",
    "BSSI":"BS Soil Investigation",
    "BSST":"BS In Science Teaching",
    "BSSTA":"BS In Statistics",
    "BSSW":"BS Social Work",
    "BSZOO":"BS In Zoology",
    "CASIL":"Certificate Adv. Study Info & Lib Science",
    "CAndP":"Candidate In Philosophy",
    "CANED":"Candidate In Education",
    "CEH":"Civil Engineer - Honorary",
    "CERT":"Certificate Program",
    "CGRED":"Certificate In Graduate Education",
    "CMHLT":"Post Mast Certificate In Mental Health",
    "DDH":"Doctor Of Divinity - Honorary",
    "DDS":"Doctor Of Dental Surgery",
    "DFAH":"Doctor Of Fine Arts - Honorary",
    "DMUSH":"Doctor Of Music - Honorary",
    "DOCT":"DoctOral Degree",
    "DPT":"Doctor Of Physical Therapy",
    "DRPH":"Doctor Of Public Health",
    "DPHAR":"Doctor Of Pharmacy",
    "EDD":"Doctor Of Education",
    "ENRDH":"Doctor Of Engineering - Honorary",
    "InTL":"International Degree",
    "JD":"Juris Doctor",
    "LDA":"Licentiate In Dramatic ART",
    "LHDH":"Doctor Of Humanities - Honorary",
    "LICDA":"Licentiate In Drama",
    "LITDH":"Doctor Of Letters - Honorary",
    "LLB":"Bachelor Of Laws",
    "LLBJD":"Bachelor Of Laws -Juris Doctor",
    "LLDH":"Doctor Of Laws - Honorary",
    "MA":"Master Of Arts",
    "MAC":"Master Of Accounting",
    "MACA":"Master Of Arts In Creative Arts",
    "MACOM":"MA In Communication",
    "MACT":"MA College Teaching",
    "MAED":"MA In Education",
    "MAH":"Master Of Arts - Honorary",
    "MAHS":"Master Of Arts - Honorary, Special",
    "MASA":"Master Of Arts - Special Alumni",
    "Mast":"MasterS Degree",
    "MASU":"Master Of Arts - Unearned",
    "MAT":"MA In Teaching",
    "MBA":"Master Of Business Administration",
    "MD":"Doctor Of Medicine",
    "MED":"Master Of Education",
    "MFA":"Master Of Fine Arts",
    "MHA":"Master Of Health Administration",
    "MMUS":"Master Of Music",
    "MPA":"Master Of Public Adm",
    "MPH":"Master Public Health",
    "MPT":"Master Of Physical Therapy",
    "MRP":"Master Regional Planning",
    "MS":"Master Of Science",
    "MSA":"Master Of School Administration",
    "MSBA":"MS In Business Administration",
    "MSCE":"MS In Civil Engineering",
    "MSCHE":"MS In School Engineering",
    "MSEE":"MS In Electrical Engineering",
    "MSEND":"MS In Endodontics",
    "MSENV":"MS Environment Engineer",
    "MSH":"Master Of Science - Honorary",
    "MSIR":"MS In Industrial Relations",
    "MSIS":"MS Information Science",
    "MSL":"Master Of School Librarianship",
    "MSLS":"MS Library Science",
    "MSME":"MS In Mechanical Engineering",
    "MSN":"MS In Nursing",
    "MSOP":"MS In Oral Pathology",
    "MSORT":"MS In Orthodontics",
    "MSOS":"MS In Oral Surgery",
    "MSPA":"MS In Personnel Adm",
    "MSPED":"MS In Pedodontics",
    "MSPER":"MS In Periodontics",
    "MSPH":"MS In Public Health",
    "MSPHN":"MS In Public Health Nursing",
    "MSPHR":"MS In Pharmacy",
    "MSPRO":"MS In Prosthodontics",
    "MSPub":"MS In Public Administration",
    "MSRA":"MS Recreation AdmIn",
    "MSSE":"MS Sanitary Engineer",
    "MSSW":"MS In Social Work",
    "MSW":"Master Social Work",
    "M/DOC":"Masters Continuing To Doctorate",
    "NonDG":"Non-Degree",
    "PD":"Doctor Of Pharmacy",
    "PHB":"Bachelor Of Philosophy",
    "PHCH":"Pharmaceutical Chemist",
    "PHD":"Doctor Of Philosophy",
    "PHDH":"Doctor Of Philosophy - Honorary",
    "PHG":"Pharmacy Graduate",
    "PHM":"Master Of Philosophy",
    "PHRDH":"Doctor Of Pharmacy - Honorary",
    "PROf":"Professional Degree",
    "P/DOC":"Post-DoctOral",
    "SCDH":"Doctor Of Science - Honorary",
    "UNK":"Non-Degree",
    "CCOMM":"Certificate In Communication",
    "CDH":"Certificate In Dental Hygiene",
    "CIR":"Certificate In Industrial Relations",
    "CLAW":"Certificate In Law",
    "CLib":"Certificate In Librarianship",
    "CMED":"Certificate In Medicine",
    "CMT":"Certificate In Medical Technology",
    "CORTH":"Certificate In Orthodontics",
    "CPH":"Certificate In Public Health",
    "CPHN":"Certificate In Public Health Nursing",
    "CPPDA":"Certificate In Professional Dramatic Art",
    "CSW":"Certificate In Social Work"
}