Index: /main/trunk/greenstone3/web/interfaces/default/js/berrybasket/berrybasket.js
===================================================================
--- /main/trunk/greenstone3/web/interfaces/default/js/berrybasket/berrybasket.js	(revision 33258)
+++ /main/trunk/greenstone3/web/interfaces/default/js/berrybasket/berrybasket.js	(revision 33259)
@@ -33,6 +33,12 @@
 
 
+var countFavourites = function(callback) { 
+    // identical AJAX call to countBerries()
+    return countBerries(callback);
+}
+
+
 // adds berries onto page
-var checkout = function(){
+var berryCheckout = function(){
 
 	if ( document.getElementById('berrybasket') == null ) return;
@@ -120,4 +126,75 @@
 }
 
+// display selected favourites (filled-in star icon) on page
+var favouritesCheckout = function(){
+
+	if ( document.getElementById('berrybasket') == null ) return;
+	
+	var request_type = "GET";
+    var url = gs.xsltParams.library_name + "?a=pr&rt=r&ro=1&s=ItemNum&o=XML&hhf="+makeURLComponentSafe("[{\"name\":\"Cache-Control\", \"value\":\"no-cache\"}]")+"&c=";
+
+	var responseSuccess = function(o){
+		
+		var response = o.responseXML;
+		var size = response.getElementsByTagName('size').item(0).getAttribute('value');
+
+		var items = response.getElementsByTagName('item');
+
+		berryList = new Array();
+		for (var i=0;i < items.length ; i++ ){
+
+			var itemID = items[i].getAttribute('collection')+":"+items[i].getAttribute('name');
+			var item = YAHOO.util.Dom.get(itemID);
+
+			if (item != null){
+			        item.src = gs.variables.selected_favourite_icon_url;
+			        item.setAttribute("data-is-favourite","true");
+			}
+			berryList[berryList.length] = items[i];
+		}
+
+		// set favourite images visible
+		// they are set to be invisible to prevent flickering when first loaded (see berry.css)
+
+		var berries = document.getElementsByTagName('img');
+
+		for (var j=0; j < berries.length; j++){
+			var berry = berries[j]; 
+			var parent = berry.parentNode;
+			if (parent !=null && parent.id == "documentberries"){
+				var root = YAHOO.util.Dom.get(berry.id+":root");
+				var section = YAHOO.util.Dom.get(berry.id+":section");
+				if(root!=null && root.id.indexOf(berry.id) !=-1){
+					root.style.visibility ="visible" ;
+				}
+
+				if(section!=null && section.id.indexOf(berry.id) !=-1){
+					section.style.visibility ="visible" ;
+				}
+			}
+
+			if (berry.className && berry.className == 'pick'){
+				berry.style.visibility = "visible";
+				// new ygDDPlayer(berry.id,'basket',berryList); // **** can go 
+			}
+		}
+		updateFavouritesCount();
+	}
+
+	var responseFailure = function(o){
+		console.error("Berry Basket GetItems AJAX call failed:" + url);
+	}
+
+	var callback = {
+		success: responseSuccess,
+		failure: responseFailure
+	}
+
+	//var date = new Date();
+	//url += "&rand=" + date.getTime();
+	YAHOO.util.Connect.asyncRequest(request_type , url , callback);
+}
+
+
 function updateBerryImages(){
 
@@ -171,6 +248,16 @@
 }
 
+function updateFavouritesCount() {
+	var favouritesCountElement = YAHOO.util.Dom.get('favouritesCountDisplay');
+	if ( favouritesCountElement == null ) return;
+	if ( berryList.length == 0 ) {
+		favouritesCountElement.innerHTML = "(0)";
+	} else {
+		favouritesCountElement.innerHTML = "(" + berryList.length + ")";
+	}
+}
+
 function basketUpdate(e) {
-//alert( arguments.callee );
+
 	var target = e.target;
 	if ((target.id.toLowerCase() == 'berrybasket' || target.id.toLowerCase() == 'berries') && !show){
@@ -190,5 +277,5 @@
 
 function showBasket() {
-//alert( arguments.callee );
+
 	var berryBasket = YAHOO.util.Dom.get('berrybasket');
 	var basketHandle = YAHOO.util.Dom.get('baskethandle');
@@ -281,5 +368,4 @@
 
 function hideBasket() {
-//alert( arguments.callee );
 	var i = 0;
 	var berryBasket = YAHOO.util.Dom.get('berrybasket');
@@ -414,5 +500,93 @@
 }
 
-YAHOO.util.Event.addListener(window, 'load', checkout);
+
+
+function addFavourite(el){
+    var addurl = gs.xsltParams.library_name + "?a=pr&rt=r&ro=1&s=AddItem&c=&s1.id=2&o=XML&hhf="+makeURLComponentSafe("[{\"name\":\"Cache-Control\", \"value\":\"no-cache\"}]")+"&s1.item=" + el.id;
+
+	var addSuccess = function(o){
+		var result = o.responseXML;
+		var items = result.getElementsByTagName('item');
+
+		if (items.length > 0){
+		        // assumes that there is only 1 item to add
+			var item = items[0];
+			berryList[berryList.length]= item;
+
+	                updateFavouritesCount();
+		}
+
+	}
+
+	var addFailure = function(o){
+	}
+
+	var addcallback = {
+		success:addSuccess,
+		failure:addFailure
+	}
+	
+	YAHOO.util.Connect.asyncRequest(request_type , addurl , addcallback);
+}
+
+
+function deleteFavourite(el){
+    var delurl = gs.xsltParams.library_name + "?a=pr&rt=r&ro=1&s=DeleteItems&c=&o=XML&hhf="+makeURLComponentSafe("[{\"name\":\"Cache-Control\", \"value\":\"no-cache\"}]")+"&s1.items=" + el.id;
+
+	var delSuccess = function(o){
+
+	        for (var i in berryList) {
+                        var berry = berryList[i];
+		        console.log(berry);
+                        var id = berry.getAttribute('collection')+":"+berry.getAttribute('name');
+
+                        if (id == el.id){
+                                berryList.splice(i,1);
+
+                                break;
+                        }
+
+                }
+	        updateFavouritesCount();
+	    
+	}
+
+	var delFailure = function(o){
+	}
+
+	var delcallback = {
+		success:delSuccess,
+		failure:delFailure
+	}
+	
+	YAHOO.util.Connect.asyncRequest(request_type , delurl , delcallback);
+}
+
+
+
+function toggleFavourite(el)
+{
+    var is_favourite = el.getAttribute("data-is-favourite");
+    if (is_favourite == "true") {
+	deleteFavourite(el);
+	el.src = gs.variables.unselected_favourite_icon_url;
+	el.setAttribute("data-is-favourite","false")
+    }
+    else {
+	addFavourite(el);
+	el.src = gs.variables.selected_favourite_icon_url;
+	el.setAttribute("data-is-favourite","true")
+    }
+}
+
+if(gs.cgiParams.berrybasket == "on")
+{
+    YAHOO.util.Event.addListener(window, 'load', berryCheckout);
+}
+else {
+    // assumption is that favouritesbasket is on 
+    YAHOO.util.Event.addListener(window, 'load', favouritesCheckout);
+}
+
 //YAHOO.util.Event.addListener(window, 'click', basketUpdate);
 
Index: /main/trunk/greenstone3/web/interfaces/default/js/berrybasket/berrycheckout.js
===================================================================
--- /main/trunk/greenstone3/web/interfaces/default/js/berrybasket/berrycheckout.js	(revision 33258)
+++ /main/trunk/greenstone3/web/interfaces/default/js/berrybasket/berrycheckout.js	(revision 33259)
@@ -114,5 +114,5 @@
 		var berry = docList[i];
 		var berry_id = berry['collection'] + ":" + berry['name'];
-		
+				
 		for(var j = searchForNextSelectedIdFromIndex; j >= 0; j--) {
 		    if(idsToDelete[j] == berry_id) {
@@ -148,5 +148,9 @@
 	    }  
 	    content.appendChild(document.createTextNode('Your berry basket is empty.'));
-	
+	    var berryBasketDelOptions = YAHOO.util.Dom.get('delOptions');
+	    if (berryBasketDelOptions != null) {
+		berryBasketDelOptions.setAttribute("style","display:none;");
+	    }
+
 	    var trashbin =  YAHOO.util.Dom.get('trashbin');
 	    if ( trashbin !=null){
@@ -155,8 +159,11 @@
 	}
 
-	// Ensure the select-all, delete-all and delete-selected checkboxes are deselected
-	YAHOO.util.Dom.get('select-all-checkbox').checked = false; 
-	YAHOO.util.Dom.get('delete-selected-checkbox').checked = false;
-	YAHOO.util.Dom.get('delete-all-checkbox').checked = false; 
+	var have_checkboxes = YAHOO.util.Dom.get('select-all-checkbox'); // just pick one for the test
+	if (have_checkboxes) {
+	    // Ensure the select-all, delete-all and delete-selected checkboxes are deselected
+	    YAHOO.util.Dom.get('select-all-checkbox').checked = false; 
+	    YAHOO.util.Dom.get('delete-selected-checkbox').checked = false;
+	    YAHOO.util.Dom.get('delete-all-checkbox').checked = false; 
+	}
     }
 
@@ -173,4 +180,18 @@
     YAHOO.util.Connect.asyncRequest(request_type, delurl , delcallback);
 }
+
+function deleteFavouriteFromCheckout(el)
+{
+    var  delurl = delurlPath; // var delurlPath is declared in ygDDPlayer.js.
+
+    var doc_id = el.getAttribute('id');
+    delurl += doc_id;
+
+    var deleteAll = false;
+    var selectedList = [ el ];
+    var idsToDelete = [ doc_id ];
+    doDelete(deleteAll, delurl, selectedList, idsToDelete);
+}
+
 
 function navigate(e){
@@ -267,5 +288,15 @@
 }
 
-function showFullView(){
+function showFullView() {
+    if (gs.cgiParams.berrybasket == "on") {
+	showFullViewBerries();
+    }
+    else {
+	// assumption is that favouritesbasket is on 
+	showFullViewFavourites();
+    }    
+}
+    
+function showFullViewBerries(){
 
 	var content =  YAHOO.util.Dom.get('berryBasketContent');
@@ -320,11 +351,55 @@
 }
 
+function showFullViewFavourites(){
+
+	var content =  YAHOO.util.Dom.get('berryBasketContent');
+	var fullview =  YAHOO.util.Dom.get('fullview');
+	berryCheckoutPageClear();
+
+        var berryBasketDelOptions = YAHOO.util.Dom.get('delOptions');
+	if (docList.length == 0){
+	    content.appendChild(document.createTextNode(gs.text.berry.empty_basket));
+	    if (berryBasketDelOptions != null) {
+		berryBasketDelOptions.setAttribute("style","display:none;");
+	    }
+
+	    return;
+	}
+        if (berryBasketDelOptions != null) {
+	   berryBasketDelOptions.setAttribute("style","display:block;");
+	}
+
+	var dlist = document.createElement('div');
+	content.appendChild(dlist);
+	var ul = document.createElement('ul');
+	dlist.appendChild(ul);
+
+	ul.setAttribute("id", "berryDocsList");
+        ul.setAttribute("style","list-style: none;");
+
+	for (var i in docList){
+		var doc = docList[i];
+		var li = document.createElement('li');
+	        var img = document.createElement('img');
+		var text ="";
+
+		var doc_id = doc['collection']+":"+ doc['name'];	    
+	    
+		img.setAttribute("src", gs.variables.selected_favourite_icon_url); 
+		img.setAttribute("id", doc_id);
+		img.setAttribute("height", "20px");
+		img.setAttribute("width", "20px");
+	        img.setAttribute("style","padding-right: 5px;"); // **** better to do this with CSS
+		img.setAttribute("onClick", "deleteFavouriteFromCheckout(this)");
+		li.appendChild(img);
+
+		generateDocDisplay(li, doc, doc_id)
+		li.className = 'berrydoc';
+		ul.appendChild(li);
+	}
+
+}
+
 function generateDocDisplay(li, doc, doc_id) {
-    var checkbox = document.createElement('input');
-    checkbox.setAttribute("type", "checkbox");
-    checkbox.setAttribute("id", doc_id+"-checkbox");
-    checkbox.setAttribute("name", "select-berry-checkbox");
-    checkbox.setAttribute("value", "select-"+doc_id);
-    
     var a = document.createElement('a');
     var text="";
@@ -335,5 +410,5 @@
 	li.appendChild(document.createTextNode(doc['root_Title']+": ")); 
     }
-    li.appendChild(checkbox);
+
     li.appendChild(a);
     li.appendChild(document.createTextNode(" ("+doc['collection']+")"));
@@ -348,5 +423,5 @@
 
 }
- 
+
 function showTextView(){
 
Index: /main/trunk/greenstone3/web/interfaces/default/js/classifier_scripts.js
===================================================================
--- /main/trunk/greenstone3/web/interfaces/default/js/classifier_scripts.js	(revision 33258)
+++ /main/trunk/greenstone3/web/interfaces/default/js/classifier_scripts.js	(revision 33259)
@@ -129,4 +129,8 @@
 			url = url + "&berrybasket=on";
 		} 
+		if(gs.cgiParams.favouritesbasket == "on")
+		{
+			url = url + "&favouritesbasket=on";
+		} 
 
 		if(url.indexOf("#") != -1)
@@ -148,7 +152,11 @@
 			if(gs.cgiParams.berrybasket == "on")
 			{
-				checkout();
+			        berryCheckout();
 			}
-			else if(gs.cgiParams.documentbasket == "on")
+			if(gs.cgiParams.favouritesbasket == "on")
+			{
+				favouritesCheckout();
+			}
+			if(gs.cgiParams.documentbasket == "on")
 			{
 				dmcheckout();
Index: /main/trunk/greenstone3/web/interfaces/default/js/facet-scripts.js
===================================================================
--- /main/trunk/greenstone3/web/interfaces/default/js/facet-scripts.js	(revision 33258)
+++ /main/trunk/greenstone3/web/interfaces/default/js/facet-scripts.js	(revision 33259)
@@ -57,5 +57,10 @@
 			$("#resultsArea").html("");
 			$("#resultsArea").html(response.substring(response.indexOf(">") + 1, response.lastIndexOf("<")));
-		        checkout(); // called to add back in berries (if berrybasket active)
+			if(gs.cgiParams.berrybasket == "on") {
+		            berryCheckout(); // called to add back in berries (if berrybasket active)
+			}
+			if(gs.cgiParams.favouritesbasket == "on") {
+		            favouritesCheckout(); // called to add back in favourites icons (if favouritesbasket active)
+			}
 		});
 }
