/* Lightbox Add Image Callback      
* var request XMLHTTPRequest Object 
*/
function AddToLightboxCallBack(request)
{
	var lightbox_count = document.getElementById("lightbox_count");
	
	switch (request.responseText)
	{
		case "is_redirect":
			location.href = webRoot + 'sign_up';
			break;
		case "is_exists":
			popup_close('info');
			popup('alert', 200, 280, 'The image already exists in your lightbox.', { delay:0.5, duration:1.1 });
			break;
		default:
			popup_close('alert');
			popup('info', 200, 280, 'Image has been added to your lightbox.', { delay:0.5, duration:1.1 });
			if (typeof(lightbox_count) != undefined)
				lightbox_count.innerHTML = request.responseText;
			break;
	}
}

/* Basket Add Image Callback        
* var request XMLHTTPRequest Object 
*/
function AddToBasketCallBack(request, type)
{
	var basket_count = document.getElementById("basket_count");
	
	switch (request.responseText)
	{
		case "is_redirect":
		{
			location.href = webRoot + 'sign_up';
			break;
		}
		case "is_exists":
		{
			popup_close('info');
			
			if (type == 'all')
				popup('alert', 200, 280, 'All images already exist in your basket.', { delay:0.5, duration:1.1 });
			else
				popup('alert', 200, 280, 'The image already exists in your basket.', { delay:0.5, duration:1.1 });
			break;
		}
		default:
		{
			popup_close('alert');
			
			if (type == 'all')
				popup('info', 200, 280, 'All images have been added to your basket.', { delay:0.5, duration:1.1 });
			else
				popup('info', 200, 280, 'Image has been added to your basket.', { delay:0.5, duration:1.1 });
			
			if (typeof(basket_count) != undefined)
				basket_count.innerHTML = request.responseText;
			break;
		}
	}
}

/* Download Image Callback          
* var request XMLHTTPRequest Object 
*/
function DownloadImage(id)
{
	location.href = webRoot + 'orders/download_img/' + id;
}

/* Set Downloaded Status on image   
* var request XMLHTTPRequest Object 
*/
function SetDownloadedStatus(id)
{
	document.getElementById('download_todo_' + id).innerHTML = 'Downloaded';
	return false;;
}