window.onload = function() {
    // do this stuff when the page is done loading
$('#editInPlace_standards').load('list802.php.php');
};

$(document).ready(function(){
				setClickable();
			  });

function setClickable() {
	$('#editInPlace_standards').click(function() {
		var textarea = '<div><div id="editlist">'+$(this).html()+'</div><div id="addeditlist"></div>';
		var button	 = '<div id="editarea"><input type="button" value="SAVE" class="saveButton" /> OR <input type="button" value="CANCEL" class="cancelButton" /></div></div>';
		var revert = $(this).html();
        	$(this).after(textarea+button).remove();
		$('.saveButton').click(function(){saveChanges(this, false);});
		$('.cancelButton').click(function(){saveChanges(this, revert);});
		$('#editlist').load('list802.php.php?edit=1');
	        $('#addeditlist').load('addnew_chipset.php?edit=1');
                $('.adamsaveButton').click(function(){adamsaveChanges();});
 
	})

.mouseover(function() {
	$(this).addClass("editable");
})

.mouseout(function() {
	$(this).removeClass("editable");
	});
};

function removechipset(myid){
$.post('list802.php.php?delete=' + myid + '&yes=yes');
 $('#editlist').load('list802.php.php?edit=1');
 $('#addeditlist').load('addnew_chipset.php?edit=1');

}

function adamsaveChanges(){
	var myTest  = selectchipset.chipsetid.options[selectchipset.chipsetid.selectedIndex].value;
	alert("test");
	var site ='list802.php.php?edit=1&Addnew=Add&chipsetid='+ myTest + '&driverlist_id=1';
	$('#editlist').load(site,function(txt){ alert( txt);});

return false;  
}
function saveChanges(obj, cancel) {
	if(!cancel) {
	var myTest  = selectchipset.chipsetid.options[selectchipset.chipsetid.selectedIndex].value;
	var site ='list802.php.php?edit=1&Addnew=Add&chipsetid='+ myTest + '&driverlist_id=1&edit=1';

		var t = $(obj).parent().siblings(0).val();

		$.post("test2.php",{
		 	 content: t
			},function(txt){
			alert( txt);
  			});
	        var myTest  = selectchipset.chipsetid.options[selectchipset.chipsetid.selectedIndex].value;

	 $('#editInPlace_standards').load(site);
 	$('#addeditlist').load('addnew_chipset.php?edit=1');

	}else {
		var t = cancel;
	}
	if(t=='') t='(click to add text)';
	$(obj).parent().parent().after('<div id="editInPlace_standards">'+t+'</div>').remove();
	 $('#editInPlace_standards').load('list802.php.php');

	setClickable();
}	


