﻿
// ####################################
// ########## School Object ##########
// ####################################

function School()
{  
    this.VEShapeLayer = _schoolLayer; // VEShapeLayer
    this.VEShape = null;
    this.SchoolId = null;
	this.InstitutionType = null;
    this.DistrictName = null;
    this.SchoolType = null;
    this.CountyName = null;
    this.Latitude = null;
    this.Longitude = null;
    this.SchoolName = null;
    this.Address = null;
    this.City = null;
    this.State = null;
    this.PostalCode = null;
    this.Phone = null;
    this.EducationalClimate = null;
    this.AdvancedPlacement = null;
    this.BeforeAndAfterSchoolPrograms = null;
    this.BlueRibbonSchool = null;
    this.CoalitionOfEssentialSchools = null;
    this.CharterSchool = null;
    this.GiftedAndTalented = null;
    this.MagnetSchool = null;
    this.GradeSpan = null;
    this.StudentCount = null;
}
School.prototype.Populate = function(schoolItems)
{
    this.SchoolId = schoolItems[0];
    this.InstitutionType = schoolItems[1];
    this.DistrictName = schoolItems[2];
    this.SchoolType = schoolItems[3];
    this.CountyName = schoolItems[4];
    this.Latitude = schoolItems[5];
    this.Longitude = schoolItems[6];
    this.SchoolName = schoolItems[7];
    this.Address = schoolItems[8];
    this.City = schoolItems[9];
    this.State = schoolItems[10];
    this.PostalCode = schoolItems[11];
    this.Phone = schoolItems[12];
    this.EducationalClimate = schoolItems[132];
    this.AdvancedPlacement = schoolItems[14];
    this.BeforeAndAfterSchoolPrograms = schoolItems[15];
    this.BlueRibbonSchool = schoolItems[16];
    this.CoalitionOfEssentialSchools = schoolItems[17];
    this.CharterSchool = schoolItems[18];
    this.GiftedAndTalented = schoolItems[19];
    this.MagnetSchool = schoolItems[20];
    this.GradeSpan = schoolItems[21];
    this.StudentCount = schoolItems[22];
}
School.prototype.DisplayShapeArray = function(array) 
{   
    this.VEShapeLayer.AddShape(array);
}
School.prototype.GetShape = function()
{
    this.VEShape = new VEShape(VEShapeType.Pushpin, new VELatLong(this.Latitude, this.Longitude));
    this.VEShape.SetTitle(this.SchoolName); 
    var descrip = this.Address+"<br />"+this.City + ", " + this.State + " " + this.PostalCode+"<br />";
        descrip += "<a href=\"javascript:popUpCenteredWindow(\'SchoolDetail.aspx?SchoolID="+this.SchoolId+"\');\">Click to view Details..</a><br /><br />";
        descrip += "<li>Grades "+this.GradeSpan+"<li>"+this.StudentCount+" students";
        descrip += (this.SchoolType!='Unknown')?this.SchoolType:"";
        descrip += (this.AdvancedPlacement!='False')?"<li>Advanced Placement":"";
        descrip += (this.BeforeAndAfterSchoolPrograms!='False')?"<li>After School Programs":"";
        descrip += (this.BlueRibbonSchool!='False')?"<li>Blue Ribbon School":"";
        descrip += (this.CharterSchool!='False')?"<li>Charter School":"";
        descrip += (this.GiftedAndTalented!='False')?"<li>Gifted and Talented":"";
        descrip += (this.MagnetSchool!='False')?"<li>Magnet School":"";
        descrip +="<br /><br /><img src=\"../App_Themes/Default/Images/Map/onboard.png\"><span style=\"font-size:.7em;\"><br />Information Powered by On Board LLC. ";
		descrip +="Copyright &copy; 2007 On Board LLC.</span>";
    
    this.VEShape.SetDescription(descrip); 
    this.VEShape.SetCustomIcon("../App_Themes/Default/Images/Map/icon_school.gif");
    return this.VEShape;
}
School.prototype.GetGridRowData = function(n)
{
    var addr = this.Address+'<br />'+this.City+',&nbsp;'+this.State+'&nbsp;'+this.PostalCode;
    var row = "<div><span style=\"font-size:.75em;color:#646464;\"><a style=\"color:#3f4065\" href=\"javascript:popUpCenteredWindow(\'SchoolDetail.aspx?SchoolID="+this.SchoolId+"\');\">"+this.SchoolName+"</a></span></div>"
            + "<div><span style=\"font-size:.75em;color:#a4a4a4;\">"+addr+"</span></div><br />";
	return row;
}
School.prototype.DisplayGridArray = function(array)
{
    document.getElementById('divSchoolResults').innerHTML = array.join('');
}