/* Miscellaneous Project related Functions
 */


//***************************************************************

function ProjectCreate(pname)
{
        this.ID       = pname;
        this.Name     = "Project";
        this.LongName = "";
        this.Logo     = "";
        this.Title    = "";
        this.Group    = "Ocean Time Series Group";
        this.FundName = "nobody";
        this.FundStr  = "Funded by ";
        this.FundLink = "";
        this.RegName  = "";
        this.RegLink  = "";
        this.Investigators = "";

}

//***************************************************************

function ProjectInit(obj)
{

  switch ( obj.ID.toUpperCase() )
  {

  case "MOVE":

        obj.Name     = "MOVE";
        obj.LongName = "";
        obj.Title    = "Meridional Overturning Experiment";
        obj.FundName = "NOAA";
        obj.FundLink = "http://www.noaa.gov";
        obj.Investigators = "Uwe Send";

        break;

  case "CORC":

        obj.Name     = "CORC";
        obj.LongName = "";
        obj.Title    = "Consortium on the Ocean's Role in Climate";
        obj.FundName = "NOAA";
        obj.FundLink = "http://www.noaa.gov";
        obj.Investigators = "U.Send, R.Davis, D.Rudnick, P.Niiler, B.Cornuelle, D.Roemmich";

        break;

  case "GEOCE":

        obj.Name     = "GEOCE";
        obj.LongName = "";
        obj.Title    = "A Moored Geodetic Seafloor Monitoring System";
        obj.FundName = "NSF";
        obj.FundLink = "http://www.nsf.gov";
        obj.Investigators = "Kevin Brown, Dave Chadwell, Uwe Send, Michael Tryon";

        break;

  case "DELMAR":

        obj.Name     = "Del Mar";
        obj.LongName = "";
        obj.Title    = "Nearshore multidisciplinary real-time observations";
        obj.FundName = "";
        obj.FundLink = "";
        obj.Investigators = "Uwe Send";

        break;

  case "CCE":

        obj.Name     = "California Current Ecosystem";
        obj.LongName = "";
        obj.Logo     = "California Current";
        obj.Title    = "@Interdisciplinary Biogeochemical Moorings";
        obj.FundName = "";
        obj.FundLink = "";
      //obj.FundName = "NSF";
      //obj.FundLink = "http://www.nsf.gov";
        obj.Investigators = "U.Send, M.Ohman, C.Sabine, D. Demer, A. Dickson";

        break;

  case "OOI":

        obj.Name     = "Ocean Observatories Initiative";
        obj.LongName = "";
        obj.Logo     = "OOI";
        obj.Title    = "";
        obj.FundName = "NSF";
        obj.FundLink = "http://www.nsf.gov";
      //obj.FundStr  = "Managed by ";
      //obj.FundName = "Ocean Leadership";
      //obj.FundLink = "http://www.oceanleadership.org/";
        obj.Investigators = "";

        break;

  case "SEACYCLER":

        obj.Name     = "SeaCycler";
        obj.LongName = "";
        obj.Title    = "An autonomous underwater winch profiler";
        obj.FundName = "NSF";
        obj.FundLink = "http://www.nsf.gov";
        obj.Investigators = "U.Send, R.Pinkel, E.Slater, D.Checkley, C.Waldmann, G.Fowler, J.Karstensen";

        break;

  case "MATLAB":

        obj.Name     = "MATLAB<sup><small>&#174;</small></sup>";
        obj.LongName = "";
        obj.Title    = "Numerical Scientific and Technical Computing";
        obj.RegName  = "MathWorks&#153;";
        obj.RegLink  = "http://www.mathworks.com";

        break;

  case "TERMS":

        obj.Name     = "Terms";
        obj.LongName = obj.Name + " and Conditions to Use";
        obj.Title    = "";

        break;

  case "CONTACT":

        obj.Name     = "Contact";
        obj.LongName = obj.Name + " & Directions";
        obj.Title    = "";

        break;

  case "ERROR404":

        obj.Name     = "Error 404";
        obj.LongName = "";
        obj.Title    = "File not found";

        break;

  default:

        obj.Name     = obj.ID;
        
        break;
  }

  return obj
}

//***************************************************************
// ProjectLogo - Returns Logo-String: Name or PNAME
//
// see also: LOGOLINK in MAIN.JS
//

function ProjectLogo(pname,section,mode)
{

// document.write(pname);

var obj = new ProjectCreate(pname); obj = ProjectInit(obj);

var str = obj.Logo;

if ( str == "" ) { str = obj.Name }
if ( str == "" ) { str = pname.toUpperCase() }

return str

}

//***************************************************************
// ProjectLogo - Returns Logo-String: Name or PNAME

function ProjectLogoImage(pname)
{

// document.write(pname);

var obj = new ProjectCreate(pname); obj = ProjectInit(obj);

var str = obj.Logo;

if ( str == "" ) { str = obj.Name }
if ( str == "" ) { str = pname.toUpperCase() }

return str

}

//***************************************************************
// ProjectName - returns LongName, Name or pname

function ProjectName(pname)
{

// document.write(pname);

var obj = new ProjectCreate(pname); obj = ProjectInit(obj);

var str = obj.LongName;

if ( str == "" ) { str = obj.Name }
if ( str == "" ) { str = pname.toUpperCase() }

return str

}

//***************************************************************
// ProjectTitle - returns Title of Projects

function ProjectTitle(pname)
{

// document.write(pname);

var obj = new ProjectCreate(pname); obj = ProjectInit(obj);

var str = obj.Title;

if ( str.slice(0,1) == "@" ) { str = str.slice(1); } 
return str

}

//***************************************************************
// ProjectName - returns LongName, Name or pname

function ProjectTitleBreak(pname)
{

var obj = new ProjectCreate(pname); obj = ProjectInit(obj);

return ( obj.Title.slice(0,1) == "@" );

}

//***************************************************************
// ProjectGroup - returns Group of Projects

function ProjectGroup(pname)
{

// document.write(pname);

var obj = new ProjectCreate(pname); obj = ProjectInit(obj);

var str = obj.Group;

return str

}

//***************************************************************
// ProjectPI - returns Investigators

function ProjectPI(pname,pstr)
{

var obj = new ProjectCreate(pname); obj = ProjectInit(obj);

var str = "";

if ( obj.Investigators != "" )
   { str = obj.Investigators; }

if ( typeof pstr != 'undefined' && str != "" )
   { if ( pstr == "" )
        { pstr = "Investigator";
          res = str.search(/[,]/);
          if ( res != -1 )
             { pstr = pstr + "s"; }
          pstr = pstr + ": ";
        }
     str = pstr + str; 
   }

return str

}

//***************************************************************
// ProjectLink - Creates LongName: "Funded by <FundLink>"

function FundLink(pname)
{

var obj = new ProjectCreate(pname); obj = ProjectInit(obj);

var str = "<hr valign=\"bottom\">";

str = obj.Group;

if ( obj.FundLink != "" ) 
   { str = obj.FundStr  + '<a href=\"' + 
           obj.FundLink + '\" target=\"_blank\">' + 
           obj.FundName + '</a>'; }
else { if ( obj.FundName != "" ) 
          { str = obj.FundStr + obj.FundName } };

document.write(str)

}

//***************************************************************
// ProjectLink - Creates LongName: "Registred Trademark"

function RegLink(pname)
{

var obj = new ProjectCreate(pname); obj = ProjectInit(obj);

var str = obj.Name + ' is a registred Trademark of <a href=\"' + 
          obj.RegLink + '\" target=\"_blank\">' + 
          obj.RegName + '</a>';

document.write(str)

}
