// ------------------------------- project tag object ----------------------------------------
function projectTag(text,compObj,actNum) {
   //if (compObj.name=="Realbygg") alert(text);
   if (text.indexOf("start=")!=NOTFOUND || text.indexOf("=start")!=NOTFOUND) {
      text=_removeBoundary(text,"start");
      this.isStart=true;
   } else {
      this.isStart=false;
      if (text.indexOf("end=")!=NOTFOUND || text.indexOf("=end")!=NOTFOUND) {
         text=_removeBoundary(text,"end");
         this.isEnd=true;
      } else this.isEnd=false;
   }
   if (text.indexOf("@")!=NOTFOUND) {
      this.isConfirmation=true;
      if (text.indexOf("=")!=NOTFOUND) {
         var posAt=text.indexOf("@");
         var posEq=text.indexOf("=");
         if (posEq<posAt) {
            this.meeting=text.slice(posEq+1);
            text=text.slice(0,posEq);
         } else {
            this.meeting=text.slice(0,posEq);
            text=text.slice(posEq+1);
         }
      } else {
         // error - incorrect meeting tag (no project)
      }
   } else {
      this.isConfirmation=false;
      this.meeting="";      
   }
   if (text.indexOf(":")!=NOTFOUND) {
      var pos=text.indexOf(":");
      var sub=text.slice(pos+1);
      text=text.slice(0,pos);
   } else var sub="";
   // find project
   var found=new Array();
   var prName;
   for (var i=0;i<compObj.projectRelations.length;i++) {
      prName=compObj.projectRelations[i].toLowerCase();
      if (prName.indexOf(text.toLowerCase())!=NOTFOUND) found.push(i);
   }
   //if (compObj.name=="Realbygg") alert("midpoint");
   if (found.length==0) { 
      this.project=UNKNOWN;
      this.subProject="";
   } else {
      // generate error if found.length>1 ????????
      this.project=found[0];
      if (compObj.projectRelations[this.project]==compObj.project) {
         if (sub!="") {
            // find sub project, or create if doesn't exist
            var sbFound=NOTFOUND;
            for (var i=0;i<compObj.subProjects.length && sbFound==NOTFOUND;i++) {
               //alert("=="+compObj.subProjects[i].name);
               if (_icmp(compObj.subProjects[i].name,sub)) sbFound=i;
            }
            if (sbFound==NOTFOUND) {
               var projStart=(this.isStart) ?actNum :compObj.activities.length-1;
               var projEnd=(this.isEnd) ?actNum :0;
               sub=sub.charAt(0).toUpperCase()+sub.slice(1);
               compObj.addSubProject(sub,true,projStart,projEnd);
               this.subProject=sub;
            } else {
               this.subProject=compObj.subProjects[sbFound].name;
            }
         } else {
            this.subProject="";     // with .subProject[0].isSubProject=false
            var projStart=(this.isStart) ?actNum :compObj.activities.length-1;
            var projEnd=(this.isEnd) ?actNum :0;
            if (compObj.subProjects.length==0) compObj.addSubProject("",false,projStart,projEnd);
         }
      }
   }
   //if (compObj.name=="Realbygg") alert("proj="+this.project+" | sub='"+this.subProject+"'");
}