function display_pic() {
	setTimeout("document.getElementById('the_new_pic').src='http://www.megaministore.com/images/' + document.getElementById('inp_newfilename').value", 5000);
}

function format_it_img() {
	new_fn = document.getElementById('inp_newfilename').value;
	img = new Image();
	img.src = "http://www.megaministore.com/images/" + new_fn;
	
	the_area = document.getElementById('id_articletext');
	the_tag = "<div class='blurbpic ";
	
	float_left = document.getElementById('img_info').elements['pic_float'][0].checked;
	if (float_left) the_tag += "blurbpicleft"; else the_tag += "blurbpicright";
	the_tag += "' style='width: " + img.width + "px'><img src='" + img.src + "' width='" + img.width + "' height='" + img.height + "' alt='" + document.getElementById('inp_pic_caption').value.replace(/'/g, '&apos;') + "' />";
	if (document.getElementById('inp_pic_caption').value) the_tag += "<br />" + document.getElementById('inp_pic_caption').value;
	the_tag += "</div>";
	
	if (img.height && img.width) {
		if (document.selection) {
			str = document.selection.createRange().text 
			document.selection.createRange().text = the_tag;
		}
		else {
			var startPos = the_area.selectionStart;
			var endPos = the_area.selectionEnd;
			var str = the_area.value.substring(startPos, endPos);
			the_area.value = the_area.value.substring(0, startPos) + the_tag + the_area.value.substring(endPos, the_area.value.length);
		}
	}
	document.getElementById('img_info').style.display='none';
	the_area.focus();
}

function quickedit(info) {
	parts = info.split("|");
	newvalue = document.getElementById('newvalue|'+info).value;
	var dataString = 'quickedit=1&newvalue='+ encodeURIComponent(newvalue) + '&table=' + parts[0]  + '&rowname=' + parts[1]  + '&c_id=' + parts[2];
	if (parts[3]) dataString += '&whererowname=' + parts[3];
	$.ajax({
		type: "POST",
		url: "http://www.megaministore.com/quickedit.php",
		data: dataString,
		success: function(response) {
			document.getElementById("blurb|" + info).innerHTML = newvalue.replace(/\n/g, '<br />');
			document.getElementById("editblurb|" + info).style.display = "none";
		}
	});
}
