function delete_image(id)
	{
		$("body").append('<div id="delete">Are you sure? <br /><a href="javascript:continue_delete('+id+')">yes</a> | <a href="javascript:end_delete('+id+')">no</a></div>');
		
		$("#delete").top(posY+"px").left(posX+"px").fadeIn();
	}
	
	function end_delete(id)
	{
		
		$("#delete").fadeOut('fast',function(){
		//$("#event_"+id).fadeOut();
		$("#delete").remove();
		
		});
	}
	
	function continue_delete(id)
	{
		var p = {};
		p['id'] = id;
		jQuery.post('index.php?/ajax_manager/ajax_delete_image',p,function(str){
			$("#image_"+id).fadeOut('fast',function(){
				$("#image_"+id).remove();
				end_delete(id);
			});
			
	
		});
	}
	
	
	function  open_gallery(id)
	{
		var href= $("#expand_"+id).attr('href');
		var html = $("#expand_"+id).html();
		
		href = href.replace(/open/,'close');
		html = html.replace(/open/,'close');
		
		$("#expand_"+id).attr('href',href);
		$("#expand_"+id).html(html);
		
		$("#album_"+id).show();
	}
	
	function  close_gallery(id)
	{
		var href= $("#expand_"+id).attr('href');
		var html = $("#expand_"+id).html();
		
		href = href.replace(/close/,'open');
		html = html.replace(/close/,'open');
		
		$("#expand_"+id).attr('href',href);
		$("#expand_"+id).html(html);
		
		$("#album_"+id).hide();
	}
	
	
	var imgCount = 1; // give unique id to each image
	function newImage(url, image, id, title)
	{
		$("#image_list").prepend('<div id="image_'+id+'" class="gallery_image gallery_new"><div class="image"><a href="javascript:expand_image('+id+')	">'+image+'</a></div><h4>'+title+'<br />(<a href="javascript:delete_image('+id+')">delete</a>)</h4></div>');
		$("#image_"+id).fadeIn();
		imgCount++;
	}
	
	
	function expand_image(id)
	{
		 $("#loading").top(posY+"px").left(posX+"px").fadeIn('fast');
		if($("#opacity")) $("#opacity").remove();
		if($("#gallery")) $("#gallery").remove();
		pageSize = getPageSize();
		browserHeight = pageSize[1];
		browserWidth = pageSize[0];
		scrollHeight = parseInt(document.body.scrollHeight)+30;
		scrollWidth = parseInt(document.body.scrollWidth);
		if(scrollHeight > browserHeight) {var width = browserWidth - 20;var opHeight = scrollHeight}
		else {var width = browserWidth; var opHeight = browserHeight;}
		var p={};
		p['id'] = id;
		jQuery.post('index.php?/hallandale/ajax_get_image',p,function(str){
									
		 $("#loading").fadeOut();
		results = str.split('SPLIT');
		image = results[0];
		title = results[1];
			$("body").append('<div id="opacity"></div><div id="gallery"><div id="image_in_gallery"><img src="" alt="Gallery Image" id="gallery_image" /></div><div class="title">'+title+'</div></div>');
		$("#gallery_image").src("/images/upload/full/"+image);
		
		$("#gallery").top(opHeight/2-250+'px').left(width/4+'px');
		$("#opacity").height(opHeight+"px").width(scrollWidth+"px");
		$("#opacity").fadeIn('fast');
		$("#gallery").fadeIn('fast',function(){
		
			$("#opacity").click(function(){
				$("#opacity").fadeOut('fast');
				$("#gallery").fadeOut('fast');
			})
			
			$("#gallery").click(function(){
				$("#opacity").fadeOut('fast');
				$("#gallery").fadeOut('fast');
			})
		
		});
		
		});
		
	}


