			var target = "";
			var revert = "";
			function showOptions(what) {
			  if(target != what) {
			    document.getElementById('options_' + what).style.display = "inline";
			    document.getElementById('file_' + what).style.lineHeight = "14px";
			  }
			}
			
			function hideOptions(what) {
			  document.getElementById('options_' + what).style.display = "none";
			  document.getElementById('file_' + what).style.lineHeight = "3.2em";
			}
			function addEntry(id) {
				$.ajax({url: "addentry.php",
						data: {
							add: id
						},
						dataType: "script"
				}); return false;
			}
			function deleteEntry(id, i) {
				$.ajax({url: "delentry.php",
						data: {
							id: id,
							i: i
						},
						dataType: "script"
				}); return false;
			}
			function testDelete(i) {
				var $lol = $('#f'+i+' td');
				$lol.animate({opacity: 0}, 200, function() { $(this).animate({height: "0px", padding: "0px", lineHeight: '0px'}, 200, function() { $(this).empty().remove(); }); });
			}
			function testAdd() {

			var html =	'<tr id="f10000" class="ftr" style="background-image: url(images/menu_ibg.png);" onmouseover="showOptions(\'10000\');setClickable(10000, 10000);$(this).css({backgroundImage: \'url(images/menu_ibg_hover.png)\'});" onmouseout="hideOptions(\'10000\');$(this).css({backgroundImage: \'url(images/menu_ibg.png)\'});">\
							<td id="file_10000" class="icon" style="padding-left: 25px; text-align: left; background-image: url(\'images/text.png\'); background-repeat: no-repeat;">\
								<strong id="edit_10000">Test</strong>\
								<span id="options_10000" style="display: none;"><br /><br /><a href="http://www.fileize.com/">View</a> - <a class="quick" style="cursor: pointer;">Quick Tasks</a> - <a style="cursor: pointer;" onclick="deleteEntry(10000, 10000);">Delete</a></span>\
							</td>\
							<td style="width: 50px;">test</td>\
							<td style="width: 60px;">00/00/00<span id="sh" style="display: none;">00/00/00 00:00:00 AM</span></td>\
							<td style="width: 60px;">0 B</td>\
						</tr>';

			$(".filestable tbody").prepend(html); 
            $(".filestable").trigger("update"); 


			}
			function highlight(field) {
				field.focus();
				field.select();
			}
			function copyText(field){
				$.clipboardReady(function(){
				
						$.clipboard( $(field).val() );
				
						return false;
				
				}, { swfpath: "http://www.fileize.com/jquery.clipboard.swf", debug: true } );
			}
			function roll(img_name, img_src)
			{
				document[img_name].src = img_src;
			}
			
			function updateText(newText)
			{
				document.getElementById('optionsText').innerHTML = newText;
			}
		
			$(document).ready(function() {
				$("#cform").change(function() {
					var v = $("#cform option:selected").val();
					if (v == 4) {
						$('#furl').show();
					} else {
						$('#furl').hide();
					}
				});
				$("#filestable").tablesorter({ 
			        textExtraction: function(node) { 
						var v = $(node).children('strong').text();
						if (!v || v == "") {
							v = $(node).children('#sh').text();
							if (!v || v == "") {
								v = $(node).text();
							}
						}
						return v;
			        },
					dateFormat: "fileize"
			    });
				$('.quick').click(function() {
					if ($(this).parent().parent().children('.qt').is(':hidden')) {
						$(this).parent().parent().children('.qt').slideDown(200);
					}
					//$(this).parent().parent().animate({height: "100px"}, 200);
				});
				$('.ftr').mouseleave(function() {
					if (!$(this).children('.icon').children('.qt').is(':hidden')) {
						$(this).children('.icon').children('.qt').slideUp(200);
					}
				});
				$('.search').typeSearch();
				$('#uploadOutput').hide();
	            var $out = $('#uploadOutput');
				$('#uploadForm').ajaxForm({
			        beforeSubmit: function(a,f,o) {
						var uhtml = '<div style="width: 100%; padding-top: 5px; padding-bottom: 5px; background: #13263b; text-align: center;">Uploading...</div><div style="width: 100%; background: #ccc; padding-top: 10px; padding-bottom: 10px; text-align: center; color: #000;"><img src="http://www.fileize.com/images/8-0.gif" alt="" /></div>';
						if($out.is(":hidden")) {
							$out.html(uhtml);
							$out.slideDown(500);
						} else {
							$out.slideUp(500, function(){
				            	$out.html(uhtml);
							}).animate({height: "67px"}, 500);
						}
			        },
			        success: function(data) {
						$out.slideUp(500, function(){ 
			            	$out.html(data);
							$out.slideDown(500, function() { addEntry(0); });
						});
			        }
			    });
			});
				function setClickable(id, i) {
				  $('#edit_' + id).click(function() {
				    target = id;
				    var textarea = '<div id="edit_'+id+'"><input type="text" class="expand" value="'+$(this).html().replace(/(<([^>]+)>)/ig,"")+'" /></div>';
				    revert = $(this).html();
				
				    $(this).after(textarea).remove();
				    document.getElementById('options_' + id).style.display = "none";
				    document.getElementById('file_' + id).style.lineHeight = "3.2em";
				    $('.expand').keydown(function(e) {
				            if (e.keyCode == 27) {
				                e.preventDefault();
				                saveChanges(id, i, revert);
				            }
				        });
				    $('.expand').blur(function(e) {
				            e.preventDefault();
				            saveChanges(id, i, false);
				        });
				    $('.expand').submit(function(e) {
				            e.preventDefault();
				            saveChanges(id, i, false);
				        });
				    $('.expand').Autoexpand(250);
				    $('.expand').select();
				    $('.expand').focus();
				  })
				  .mouseover(function() {
				    $(this).addClass("editable");
				  })
				  .mouseout(function() {
				    $(this).removeClass("editable");
				  });
				};
				
				function saveChanges(obj, id, cancel) {
				  if(!cancel) {
				    var t = $('.expand').val().replace(/(<([^>]+)>)/ig,"").replace(/[^a-zA-Z 0-9-]+/g,'');
				  } else {
				    var t = cancel.replace(/(<([^>]+)>)/ig,"").replace(/[^a-zA-Z 0-9-]+/g,'');
				  }
				  if(t=='') t='Untitled';
					$.ajax({url: "changename.php",
							data: {
								id: id,
								name: t
							},
							dataType: "script"
					});
				  $('#edit_'+obj).after('<strong id="edit_'+obj+'">'+t+'<strong>').remove();
				  target = "";
				  setClickable(obj);
				}