fixing remove action
diff --git a/Res/main.js b/Res/main.js
index 7f1142d..feb94c6 100755
--- a/Res/main.js
+++ b/Res/main.js
@@ -210,6 +210,12 @@
   try {

     var onSuccess = function(contacts) {

       debugPrint("Found "+contacts.length+" contacts.");

+//      var contacts = navigator.service.contacts.results;

+//      var contactStr = "IDs found: "

+//      for(i in contacts) {

+//        contactStr += contacts[i].id + " ";

+//      }

+//      debugPrint(contactStr);

     };

     var onFailure = function() {

       debugPrint("ERROR");

@@ -228,8 +234,9 @@
     var onFailure = function(result) {

       debugPrint("ERROR in Removing Contact: "+result.message);

     };

-    for(c in navigator.service.contacts.results) {

-      c.remove(onSuccess, onFailure);

+    var toRemove = navigator.service.contacts.results;

+    for(i in toRemove) {

+      toRemove[i].remove(onSuccess, onFailure);

     }

   } catch(e) {

     debugPrint("Error Occured in remove Contact: "+e.message);

diff --git a/Res/phonegap/contact.js b/Res/phonegap/contact.js
index 216b0fd..d382ecc 100644
--- a/Res/phonegap/contact.js
+++ b/Res/phonegap/contact.js
@@ -255,7 +255,6 @@
 	if(contact) {
 		try {
       this.results.push(this.create(contact));
-      console.log("contact added");
 		} catch(e){
 			console.log("Error parsing contact");
 		}
diff --git a/inc/Contacts.h b/inc/Contacts.h
index 90070ee..bf95102 100755
--- a/inc/Contacts.h
+++ b/inc/Contacts.h
@@ -25,7 +25,6 @@
 private:

 	String callbackId;

 private:

-	void SetUserId(Contact& contact);

 	void SetNickname(Contact& contact, const int cid);

 	void SetFirstName(Contact& contact, const int cid);

 	void SetLastName(Contact& contact, const int cid);

diff --git a/src/Contacts.cpp b/src/Contacts.cpp
index e63929f..98bd7e8 100755
--- a/src/Contacts.cpp
+++ b/src/Contacts.cpp
@@ -43,21 +43,17 @@
 			strTok.GetNextToken(filter);

 			AppLogDebug("Method %S callbackId %S filter %S", method.GetPointer(), callbackId.GetPointer(), filter.GetPointer());

 			Find(filter);

+		} else if(method == L"com.phonegap.Contacts.remove" && !callbackId.IsEmpty()) {

+			String id;

+			strTok.GetNextToken(id);

+			AppLogDebug("Method %S callbackId %S ID to remove %S", method.GetPointer(), callbackId.GetPointer(), id.GetPointer());

+			Remove(id);

 		}

 

 	}

 }

 

 void

-Contacts::SetUserId(Contact& contact) {

-	// FIXME: generate random number

-	int value = 14;

-	Integer userId(value);

-	AppLogDebug("Setting User ID %S", userId.ToString().GetPointer());

-	contact.SetValue(CONTACT_PROPERTY_ID_USER_ID, userId.ToString());

-}

-

-void

 Contacts::SetNickname(Contact& contact, const int cid) {

 	String* value = NULL;

 	String eval;

@@ -397,7 +393,6 @@
 	}

 

 	Contact contact;

-	SetUserId(contact);

 	SetNickname(contact, cid);

 	SetFirstName(contact, cid);

 	SetLastName(contact, cid);

@@ -428,17 +423,17 @@
 Contacts::UpdateSearch(Contact* pContact) const {

 	// TODO: update this add other fields too (emails, urls, phonenumbers, etc...)

 	String eval, displayName, firstName, lastName;

-	UserId userId;

+	RecordId recordId = pContact->GetRecordId();

+	LongLong test(recordId);

 	pContact->GetValue(CONTACT_PROPERTY_ID_DISPLAY_NAME, displayName);

 	pContact->GetValue(CONTACT_PROPERTY_ID_FIRST_NAME, firstName);

 	pContact->GetValue(CONTACT_PROPERTY_ID_LAST_NAME, lastName);

-	pContact->GetValue(CONTACT_PROPERTY_ID_USER_ID, userId);

 	eval.Format(256, L"navigator.service.contacts._findCallback({id:'%S', displayName:'%S', name:{firstName:'%S',lastName:'%S'}})",

-				userId.GetPointer(),

+				test.ToString().GetPointer(),

 				displayName.GetPointer(),

 				firstName.GetPointer(),

 				lastName.GetPointer());

-	AppLogDebug("%S user ID: %S", eval.GetPointer(), userId.GetPointer());

+	//AppLogDebug("%S", eval.GetPointer());

 	pWeb->EvaluateJavascriptN(eval);

 }

 

@@ -558,7 +553,7 @@
 Contacts::Remove(const String& idStr) {

 	String eval;

 	Addressbook addressbook;

-	long long id;

+	RecordId id;

 	result r = addressbook.Construct();

 	if(IsFailed(r))

 	{

@@ -569,11 +564,14 @@
 	if(IsFailed(r)) {

 		AppLogException("Could not parse ID");

 	} else {

+		AppLogDebug("Trying to remove contact with ID %S", idStr.GetPointer());

 		r = addressbook.RemoveContact(id);

 		if(IsFailed(r)) {

+			AppLogDebug("Contact Could be removed %s", GetErrorMessage(r), r);

 			eval.Format(128, L"PhoneGap.callbacks['%S'].fail({message:'%s', code:%d})", callbackId.GetPointer(), GetErrorMessage(r), r);

 			pWeb->EvaluateJavascriptN(eval);

 		} else {

+			AppLogDebug("Contact %S removed", idStr.GetPointer());

 			eval.Format(128, L"PhoneGap.callbacks['%S'].success({message:'Contact with ID %d removed', code:01})", callbackId.GetPointer(), id);

 			pWeb->EvaluateJavascriptN(eval);

 		}