/*
Desc.: Func to support adding concurring note process.
*/

//Global to store sTableLinkId
var sAddConcurTableLinkId_g = "";

function addConcurDialog(siBoxId, siScore1Id, siScore2Id, siScore3Id, siTextAreaId, siIdTableLink){
   this.sBoxId = siBoxId;
   this.sScore1Id = siScore1Id;
   this.sScore2Id = siScore2Id;
   this.sScore3Id = siScore3Id;
   this.sTextAreaId = siTextAreaId;
   this.sTableLinkId = siIdTableLink; //Id of the link item that initiated this dialog.
   sAddConcurTableLinkId_g = siIdTableLink;
   this.show = showAddConcurBox;   
   this.yesSelected = addConcurPressed;
   this.noSelected = addConcurCancelPressed;
   this.privComplete = addConcurComplete;
   this.iRevPropId = 0; //Id of target review.
}

function showAddConcurBox(iiRevPropId){
   this.iRevPropId = iiRevPropId;
   return sm(this.sBoxId , csConcurDialogWidth, csConcurDialogHeight);
}

/*
Desc.:
In:
   iiReviewId: Id of the review to be favorite
   
*/
function addConcurPressed(){
   var url = csServerUrlRoot + '/add_concur_update';   
   var iConcurScore = 1;
   
   if ($(this.sScore1Id).checked){
      iConcurScore = 1;
   }
   else if ($(this.sScore2Id).checked){
      iConcurScore = 2;
   }
   else{
      iConcurScore = 3;
   }
   
   sConcurNote = $(this.sTextAreaId).value;
   
   var myAjax = new Ajax.Request(
      url,
      {
         method: 'post',
         parameters: {rev_prop_id: this.iRevPropId, concur_score: iConcurScore, concur_note: sConcurNote},
         onComplete: this.privComplete
      });
}

/*

Note: All ajax on complete function are callback where only the func is passed and not the obj.  Inside callbacks, you cannot access 
   object data members.
*/
function addConcurComplete(iRequest){   
   if (csAjaxRespPass == iRequest.responseText){
      //Hide the "add as favorite link".        
      //$(sAddConcurTableLinkId_g).style.display = "none";
      notifBoxJsObj.show("Concur note added.");
      setTimeout("",csNotifTimeout);
      window.location.reload();
   }
   else{      
      notifBoxJsObj2.show("An error occured while trying to add a concur note.");
   }   
}

/*
Desc.:
In:

*/
function addConcurCancelPressed(){
   //We just don't proceed if the user presses no.
}
