function addToLightbox(id, width, filename)
{
	//alert('id: ' + id + '\n width: ' + width + '\n filename: ' + filename);
	
	if ((width)) {
		new Ajax.Request('/inc/userLightbox.php', 
			{ 
				method:'get', 
				parameters: { i: id, f: filename, w: width } ,
				onSuccess: function(t) {
					response = t.responseText;
					//alert(response);
					if (response.toLowerCase().match('ok')) {
						new Effect.Highlight('gallery_' + id, {startcolor:'#ffff99', endcolor:'#F5F5F5'});	
						new Insertion.Before('photoRequest', '<div class="lightboxImgHolder" style="width: ' + width + 'px;" id="lightboxHolder_' + id + '"><div style="position:absolute; bottom: 0px;"><a href="/images/gallery/' + escape(filename) + '" rel="lightbox" rev="&lt;a href=\'#\' onclick=\'removeFromLightbox(' + id + '); myLightbox.end(); return false;\'&gt;Remove&lt;/a&gt;"><img src="/images/gallery/thumbnails/lightbox/' + escape(filename) + '" align="left" /></a></div></div>');
						myLightbox.updateImageList();
						
						$('emptyLightbox').update('');
						
						ul = $$('div#userLightbox div');
						if (ul.length == 3) {
							$('photoRequest').update('<br  /><br /><img src="/images/icons/email_attach.png" alt="&raquo;" /> <a href="/request">Send photo request</a>');	
						}
						/*<br  /><br /><img src="/images/icons/email_attach.png" alt="&raquo;" /> <a href="/request">Send photo request</a>*/
						$('gallery_' + id).update('<a href="#i=' + id + '" onclick="removeFromLightbox(' + id + '); return false;" title="Remove from lightbox"><img src="/images/icons/package_delete.png" alt="Remove from lightbox"/></a><a href="#i=' + id + '" onclick="removeFromLightbox(' + id + '); return false;" title="Remove from lightbox" class="micro"> Remove</a>');
					}
					
				},
				onFailure: function(t) {
					
					response = 'Error code 10001x1';
				}
			});
	} 
	return false;	
}

function removeFromLightbox(id)
{
	
	new Ajax.Request('/inc/userLightbox.php', 
		{ 
			method:'get', 
			parameters: { i: id, r: 'true'} ,
			onSuccess: function(t) {
				response = t.responseText;
				var responseArray = response.split('||');
				
				if (response.toLowerCase().match('ok')) {
					if ($('gallery_' + id)) { 
						new Effect.Highlight('gallery_' + id, {startcolor:'#ffff99', endcolor:'#F5F5F5'});	
						$('gallery_' + id).update('<a href="#i=' + id + '" onclick="addToLightbox(' + id + ', \'' + responseArray[0] + '\', \'' + responseArray[1] + '\'); return false;" title="Add to lightbox"><img src="/images/icons/package_add.png" alt="Add to lightbox"/></a><a href="#i=' + id + '" onclick="addToLightbox(' + id + ', \'' + responseArray[0] + '\', \'' + responseArray[1] + '\'); return false;" title="Add to lightbox" class="micro"> Add to lightbox</a>');
					}
					
					$('lightboxHolder_' + id).remove();
				
					
					
					ul = $$('div#userLightbox div');
					if (ul.length == 1) {  $('emptyLightbox').update('<br />You have nothing in your lightbox'); $('photoRequest').update('');}
				}
				
			},
			onFailure: function(t) {
				
				response = 'Error code 10001x1';
			}
		});

	return false;	
}function right(e) {if (navigator.appName == 'Netscape' && (e.which == 3 || e.which == 2))return false;else if (navigator.appName == 'Microsoft Internet Explorer' && (event.button == 2 || event.button == 3)) {alert("Images are Copyrighted.");return false;}return true;}document.onmousedown=right;document.onmouseup=right;if (document.layers) window.captureEvents(Event.MOUSEDOWN);if (document.layers) window.captureEvents(Event.MOUSEUP);window.onmousedown=right;window.onmouseup=right;