/**************************************************************

Script		: Hot Pencil!
Version		: 1.0
Authors		: Ryan Marshall
Desc		: Toggles quick-selection of items for adding to a session

**************************************************************/

function hotpencil(state) {
	if (state == 'on') {
		if ($$('a.thumb').length) {
		document.getElementById('hotpencil_icon').src = 'images/icon_hotpencil_on.png';
		window.state = 'off';
		$$('a.thumb').addEvent('click',function(event) {
			event.stop();
			if (this.getFirst('img').get('class') != 'tagged') {
				var action = 'tag';
				this.getFirst('img').addClass('tagged');
				//this.getFirst('img').src = 'images/thumb_overlay_tagged.png';
			} else {
				var action = 'untag';
				this.getFirst('img').removeClass('tagged');
				//this.getFirst('img').src = 'images/thumb_overlay.png';
			}
			var id = this.get('id');
			var req = new Request({
                    			url:'tags.php',
                    			method:'get',
                    			autoCancel:true,
                    			data:'action=' + action + '&id=' + id + '&agency=nova',
                    			onRequest: function() {
                        				//alert(action+','+id+','+agency);
                    			},
                    			onSuccess: function() {
                        				// need to put the class/image update functions in here
                    			}
               			}).send();
		});
		}
	}
	if (state == 'off') {
		document.getElementById('hotpencil_icon').src = 'images/icon_hotpencil_off.png';
		window.state = 'on';
		$$('a.thumb').removeEvents('click');
	}
}

var state = 'on';