function editInPlace() {
	// find all the edit elements and find this functionality
	$('.edit').bind("click", function(e){

		// remove the edit_this mark
		$(this).children(".edit_mark").remove();

		// capture some information about the selected element
		var parentId = this.parentNode.id;
		var editType = this.parentNode.className
		var revert = this.innerHTML;

		// check to see if this is a textarea or inputbox
		//   note the save and cancel buttons are added along with the input or textarea
		if (editType == "textarea")
				html = "<textarea id=\"input_" + parentId + "\" >" + revert + "</textarea> <a class=\"prodSave\" onclick=\"update_value('" + parentId + "', true);\" value=\"Save\"   ><img src=\"http://cdn.priceplease.com/img/btn-save.jpg\" width=\"79\" height=\"33\" border=\"0\" /></a> <a id=\"cancel_" + parentId + "\" href=\"javascript:void(0);\">Cancel</a>";
		else
				html = "<table cellspacing=\"0\"><tr><td><input type=\"input\" id=\"input_" + parentId + "\" value=\"" + revert + "\" onblur=\"\" /></td><td><a class=\"prodSave\" value=\"Save\"   ><img onclick=\"update_value('" + parentId + "', true);\" src=\"http://cdn.priceplease.com/img/btn-save.jpg\" width=\"79\" height=\"33\" border=\"0\" /></a></td><td><a id=\"cancel_" + parentId + "\" href=\"javascript:void(0);\">Cancel</a></td></tr></table>";
    
    if (parentId == 'prodPrice') {
      html = "<table cellspacing=\"0\"><tr><td>$<input type=\"input\" id=\"input_" + parentId + "\" value=\"" + revert + "\" onblur=\"\" /></td><td><a class=\"prodSave\" value=\"Save\"   ><img onclick=\"update_value('" + parentId + "', true);\" src=\"http://cdn.priceplease.com/img/btn-save.jpg\" width=\"79\" height=\"33\" border=\"0\" /></a></td><td><a id=\"cancel_" + parentId + "\" href=\"javascript:void(0);\">Cancel</a></td></tr></table>";
    }
    
    // Rewrite the html
     $('#' + parentId).html(html);
     
		//set the focus on the newly embedded input box if it's the date picker
		if(parentId == "prodDate") {
		  var cal = new Date();
		  var startDay = cal.getDate();
		  startDay = '0' + startDay; // Add a leading 0
		  startDay = startDay.substring(startDay.length-2, startDay.length); // reduce to 2 digits
		  var startMonth = cal.getMonth();
		  startMonth++; // JS months begin with 0
		  startMonth = '0' + startMonth; // Add a leading 0
		  startMonth = startMonth.substring(startMonth.length-2, startMonth.length); // reduce to 2 digits		  
		  var startYear = cal.getFullYear();
		  startYear--; // last year	  
		  var endDay = cal.getDate();
		  endDay = '0' + endDay; // Add a leading 0
		  endDay = endDay.substring(endDay.length-2, endDay.length); // reduce to 2 digits
		  var endMonth = cal.getMonth();
		  endMonth++; // JS months begin with 0
		  endMonth = '0' + endMonth; // Add a leading 0
		  endMonth = endMonth.substring(endMonth.length-2, endMonth.length); // reduce to 2 digits
		  var endYear = cal.getFullYear();
		  var startDateString = ""+startMonth+'/'+startDay+'/'+startYear;
      var endDateString = ""+endMonth+'/'+endDay+'/'+endYear;
      
			$('#input_prodDate').datePicker({
				startDate:startDateString,
				endDate:endDateString,
				clickInput:true,
				createButton:false
			})
			.bind(
				'focus',
				function()
				{
					$(this).dpDisplay();
				}
			)
			.dpSetOffset(20, $.dpConst.POS_LEFT)
			.val(new Date().asString()).trigger('change');
		}

		$("#input_" + parentId)[0].focus();
		$("#input_" + parentId)[0].select();

		//bind the cancel functionality to the cancel button
		$("#cancel_" + parentId).click(function() {
						update_value(parentId, revert);
		});
	return false;

	});
}

// this function sends the updated value back to the server    
function update_value(id, update) {
	if (update == true) {
			if (id == 'prodPrice'){
			  result = '$' + $('#input_' + id).val();
		  }
		  else {
		    result = $('#input_' + id).val();
		  }
			// alert(id);
			// alert(result);
			$("#hid_" + id).val(result);

			/*
			$.ajax({
					type: "POST",
					url: "[UPDATE_THIS]",
					data: "user_id=<?=$user['id']?>&field=" + id + "&value=" + result,
					error: function()
							{ alert("There was a problem, please let us know.") }
			});
			*/
	} else {
			// in the case of a cancel, update is the "revet" value 
			result = update;
	}
	$('#' + id).html("<span class=\"edit\">" + result + "<span class=\"edit_mark\"> ( <a href=\"#\">change</a> )</span></span>");
	editInPlace();
}

/**
 * jQuery
 */
$(document).ready(function() {

	/**
	 * edit in place for Step 2
	 */
	editInPlace();
	
	Date.firstDayOfWeek = 7;
	Date.format = 'mm/dd/yyyy';
	$(".bigInput").bind("click focus", function(e) {
		if (
					this.value == "paste the product URL here" ||
					this.value == "enter your email address" ||
					this.value == "type in a password"
				) {
					this.value = "";
			}
		});

  /**
   * Cancel Convert

	function cancelConvert() {
		$(".cancel").click( function () {
			var cnt = '<img src="http://cdn.priceplease.com/img/shell/s.gif" width="1" height="1" />';
			$(this).parents("td").html(cnt);
			return false;
		});
	}
   */
  /**
   * Convert to Refund Alert

	$(".convertToRA").click( function () {
		var cnt = '<td colspan="7"><span>You are about to convert this product to a "Refund Alert". Are you sure you want to do this?</span><div class="convertBtns"><a href="#"><img src="http://cdn.priceplease.com/img/btn-convert.png" width="100" height="33" border="0" /></a>&nbsp;&nbsp;&nbsp;<a class="cancel" href="#cancel">Cancel</a></div></td>';
		$(this).parents("tr").next().html(cnt);
		cancelConvert();
		return false;
	});
   */
}); // jQuery
  