function addToSelectedLightbox(form){
	if(form.create[1].checked == true){
		javascript:addLightBoxAjax(form.name.value)
	}
	else{
		javascript:changeLightBoxItem('add', form.imageId.value, form.albumId.value, '', form.lightBoxId.value);
	}
	overlayclose('subcontentlightbox'); 
	return false;
}
var curImageId;
function addLightBoxAjax(name, description) {
 // submit the form using Ajax
 	new Ajax.Request("remoterequest.php", {
 	parameters : 'method=addlightbox&name=' + name,
   	onComplete :  processReqAddLightBox
 });
} 
function processReqAddLightBox(resp, json){
	var j = evalResponse(resp);
	javascript:changeLightBoxItem('add', topform.imageId.value, topform.albumId.value, '', j.lightBoxId);

}
function getUsersLightBoxesAjax() {
 // submit the form using Ajax
 	new Ajax.Request("remoterequest.php", {
 	parameters : 'method=getuserslightboxes',
   	onComplete :  processReqGetUsersLightBoxes
 });
} 
function processReqGetUsersLightBoxes(resp, json){
	var j = evalResponse(resp);
	var t =0;
	j.lightBoxes.each(function(x){
		topform.lightBoxId[t++] = new Option(x.name + '(' + x.numberItems + ')', x.id)
	});
}

evalResponse = function(request) {
    try {
        return eval('('+request.responseText+')');
    } catch (e) {}
}




function processReq(resp, json){

	var j = evalResponse(resp);
	
	if(document.getElementById('lightboxtextadd') || document.getElementById('lightboxtextremove')){
		if(j.method == 'add'){
			document.getElementById('lblink'+ j.imageId).innerHTML = document.getElementById('lightboxtextremove').innerHTML;
		}
		else{
			document.getElementById('lblink' + j.imageId).innerHTML = document.getElementById('lightboxtextadd').innerHTML;
		}
	}
	else if(document.getElementById('lightboxicon'+j.imageId)){
		if(j.method == 'add'){
			document.getElementById('lightboxicon'+j.imageId).className = 'lightboxiconin';
		}
		else{
			document.getElementById('lightboxicon'+j.imageId).className = 'lightboxicon';
		}
	}
	
	hideloadingsmall();
}
