// JavaScript Document
function createImage(node) {
	// get file name and extension
	var file = $(node).parent().parent().find("td.name").text();
	var extension = file.substr(file.lastIndexOf("."));
	if(extension == ".jpg" || extension == ".bmp" || extension == ".gif" || extension == ".png") {
		// add the option to the right side to preview the image
		//$(node).parent().parent().next("tr.filedetails").find("ul").append("<li class='preview'>Preview</li>").find("li.preview").hover(function(){$(node).toggleClass('hover')}, function(){$(node).toggleClass('hover')}).click(showOption);
		
		// get the file location from the link tag
		var imageFile = $(node).parent().next().find("a").attr("href");
		
		// create the image node
		$(node).parent().parent().next("tr.filedetails").find("form").after("<img src="+imageFile+" width=100 style='float:left; padding-left: 7px;' />");
	}
}

function previewAction(file, newval, node, section) {
	var extension = file.substr(file.lastIndexOf("."));
	if(extension == ".jpg" || extension == ".gif" || extension == ".png" || extension == ".bmp") {
		var image = $(node).parent().parent().find("img");
	}
	if(section == "preview") {
		// hide the form and show the image
		newval.parent().hide();
		image.show();
	} else if(extension == ".jpg" || extension == ".gif" || extension == ".png" || extension == ".bmp"){
		// show the form and hide the image, only if the current file is an image
		newval.parent().show();
		image.hide();
	}
}