
/* clipboard.js 
	object adds items to the users cliboard
*/ 

var busy = false;
var linkObj = null;
var Clipboard = {
	linkObj:null,
	busy:false,
	resort:false,
	onData:function(data){		
		busy=false;
		if(resort){ 
			linkObj.firstChild.setAttribute("src","/_common/img/added_resort.gif");
			//linkObj.nextSibling.innerHTML = "<strong style='padding:5px;color:#FFF;'>Item added.</strong>";
		}else{		
			linkObj.firstChild.setAttribute("src","/_common/img/view_my_clipboard.gif");			
			linkObj.nextSibling.innerHTML = "<strong style='display:block;padding:5px;'>Item added.</strong>";
		
		}
		linkObj.setAttribute("href","javascript:void(Clipboard.open())");
		linkObj.setAttribute("onclick","javascript:void(0)");		
		
	},
	onError:function(data){
		busy=false;
		alert('There was a problem adding this item to the clipboard. Please try again.');
	},
	add:function(link, category, itemId){
		if(this.busy){ 
				alert('Items are currently being added to or removed from your clipboard, please wait until they have finished.'); 
				return false;
		}
		
		linkObj = link;	
		var req = new Request(this);
			busy = true;
			if(resort){
				linkObj.firstChild.setAttribute("src","/_common/img/adding_resort.gif");
			} else {
				linkObj.firstChild.setAttribute("src","/_common/img/adding.gif");
			}
			req.send("/_includes/clipboard_add.php?action=add&cat="+category+"&id="+itemId);
	},
	open:function(){
		window.open("/clipboard_view/","opener","WIDTH=700,HEIGHT=600,TOOLBAR=NO,SCROLLBARS=YES");
	}
};


