// ------------------------------- contact object ----------------------------------------

// $contacts[]=array("$contactId", "$contactName","$contactTitle","$contactPhone","$contactMobile","$contactEmail",
// "$contactWebsite","$contactCountry", "$contactAssigned", $contactRelated,);

function contact(data) {
   this.id=data[0];
   this.name=data[1];
   if (data[0]=="NOTINSOLVE") {
      // data=[NOTINSOLVE,name,project]
      this.position="";
      this.phone="";
      this.mobile="";
      this.email="";
      this.website="";
      this.country="";
      this.assignedto="";
      // this.categoryTags=new Array();   -------- not implememented yet
      this.projectRelations=new Array();
      for (var i=0;i<data[2].length;i++) this.projectRelations.push(data[2][i]);
   } else {
      this.position=data[2];
      this.phone=data[3];
      this.mobile=data[4];
      this.email=data[5];
      this.website=data[6];
      this.country=data[7];
      this.assignedto=data[8];
      // this.categoryTags=new Array();   -------- not implememented yet
      this.projectRelations=new Array();
      for (var i=0;i<data[9].length;i++) this.projectRelations.push(data[9][i]);
   }   

   // methods
   this.correctErrors=correctErrors;
   this.findErrors=findErrors;
   this.getReportName=getReportName;
   this.getProjectRelationsList=getProjectRelationsList;
   this.checkThisProject=checkThisProject;
   
   // method functions
   function checkThisProject(projName) {
      var found=false;
      for (var i=0;i<this.projectRelations.length;i++) {
         if (this.projectRelations[i]==projName) found=true;
      }
      return found;
   }
   
   function getProjectRelationsList(projName) {
      var listText="";
      for (var i=0;i<this.projectRelations.length;i++) {
         if (this.projectRelations[i]!=projName) {
            if (listText!="") listText+=", ";
            listText+=this.projectRelations[i];
         }
      }
      return listText;
   }
   
   function findErrors() {
      // look for missing data in contact
   }
   
   function correctErrors() {
      // updates Solve
      // returns true if company refresh is needed
   }
   
   function getReportName() {
      // not sure what the fuck this is for(?)
   }
}