function akedit(url, element_id, settings)
{
	if(document.getElementById('frm'+element_id))
		return false; //form is already thier so no need to do it again. 10:40 PM 1/4/2008 amit singh
    
	//if(document.getElementById('akebutton'))
	//	reset(old_content,objtoedit);//another button is already their so reset the content as new 'Edit' has been clicked.
    objtoedit = document.getElementById(element_id);
    old_content = objtoedit.innerHTML.replace("\r\n","");
    objtoedit.innerHTML = '';
    /* create the form object */
    var f = document.createElement('form');
	f.id='frm'+element_id;
    /*  main input element */
    var i;
    if ('textarea' == settings.type) {
		i = document.createElement('textarea');
		if (settings.rows) {
			i.rows = settings.rows;
		} else {
			i.rows =4;
		}
		if (settings.cols) {
			i.cols = settings.cols;
		} else {
			i.cols=30;
		}

	}
	else {
		i = document.createElement('input');
		i.type  = settings.type;
		i.setAttribute('autocomplete','off');
	}
	i.name  = settings.name;
	i.id	= 'txt'+element_id;
	i.value = old_content;
	i.style.width = settings.width
	f.appendChild(i);
	var button = document.createElement('input');
    button.type = 'button';
    button.value = 'save';
	button.style.zIndex = '20';
	button.style.position = 'absolute';
	button.style.backgroundColor='#ff6666';
	button.style.color='#ffffff';
	f.appendChild(button);
	objtoedit.appendChild(f);
	i.focus();
	i.onkeydown=function(e){	
		if (e.keyCode == 27) {
			e.preventDefault();
			reset(old_content,objtoedit);
		}
		if(e.keyCode == 13) {
			var p = {};
			p[i.name] = $(i).val();
			p['id'] = element_id;
			/* show the saving indicator */
			objtoedit = document.getElementById(element_id);
			//objtoedit.innerHTML="Saving.....";
			$.post(url, p, function(str) {
				objtoedit.innerHTML=str;
			});
		}
	};
	button.onclick = function(){
//		alert('asdasd');
		var p = {};
		p[i.name] = $(i).val();
		p['id'] = element_id;

		/* show the saving indicator */
		objtoedit = document.getElementById(element_id);
		//objtoedit.innerHTML="Saving.....";
		$.post(url, p, function(str) {
			objtoedit.innerHTML=str;
		});
	}

	i.onclick = function() {
		this.focus();
	}
}

function reset(oldContent,objtoreset) {
            objtoreset.innerHTML = oldContent;
}