//var idNo=$F('catid');//the category id
var imageNo;//the image id
var idNo;


function verifyDelete(idNo){
	if(confirm("Are you sure you want to delete this category and all photos within this category?")){

		var poststring='delete=1&id='+idNo;
		var myAjax = new Ajax.Request(
			'process_cats.php', 
			{
				method: 'get', 
				parameters: poststring, 
				onComplete: reload()
			});
		return true;
		}else{
		return false;
	}
	
}

function openCategories(idNo){
window.open(BASE_URL+"gallery/category_manager.php?id="+idNo,"categories","width=580,height=550,scrollbars=yes,resizable=yes,status=yes,location=yes,toolbar=no,menubar=yes");
}

function reload(){

window.location.replace(BASE_URL+"gallery/index.php");
}


function openUploader(){
var winObj=window.open("photo_manager.php","loadPhotos","width=580,height=280,scrollbars=yes,resizable=yes,status=yes,location=yes,toolbar=no,menubar=yes");
//winObj.focus();
}

function editImage(imageId){
var winObj=window.open('slide_manager.php?id='+imageId,"manageslides","width=580,height=280,scrollbars=yes,resizable=yes,status=yes,location=yes,toolbar=no,menubar=yes");
winObj.focus();
}

function deleteImage(imageNo,idNo){
if(confirm('Are you sure you want to delete this image?')==true){
	var poststring='deleteimage=1&photoid='+imageNo+'&cat='+idNo;
	if(Administrator){
		poststring +='&isAdmin='+1;
	}

		var myAjax = new Ajax.Updater(
			'placeholder',
			'process_images.php', 
			{
				method: 'get', 
				parameters: poststring, 
				onComplete: showResponse
			});

	}else{
	return false;
	}
}



function showImages(idNo){
	
	var pars = 'category='+idNo;
		
	if(Administrator){
		pars +='&isAdmin=1';
	}
	
	var myAjax = new Ajax.Updater(
		'placeholder', 
		'process_images.php',
		{ method: 'post',
		parameters: pars,
		evalScripts: true,
		onComplete:showResponse
		}); 

}

function showResponse(req){
	$('placeholder').innerHTML = req.responseText;
	initLightbox();
	Sortable.create('featured',{ onUpdate : updateOrder});
}
