// Copyright (c) 2007 Lucky E. Santoso

function ajaxRequest(url, data, id) {
	if (typeof(id) == 'undefined') var id = 'result';
  	var aj = new Ajax.Request(url, { 
		method: 'post', 
		parameters: data, 
		onComplete: function(oReq) { 
			$(id).innerHTML = oReq.responseText;
			yft(id, 0x99);
			loadScript(id);
		}
	});
    $(id).innerHTML = '<img src="/tools/loading.gif">';
}

function yft(e, c) {
    if (c < 0xff) {
      	$(e).style.backgroundColor = '#ffff' + c.toString(16);
        c += 0x11;
        setTimeout("yft('" + $(e).id + "', " + c + ")", 200);
		if (c >= 0xff) $(e).style.backgroundColor = "transparent";
  	}
}

loadScript = function(id) {
	var e = $(id).getElementsByTagName('script');
	var l = e.length;
	for (var i = 0; i < l; i++) { 
		var s = document.createElement('script'); 
      	s.type = "text/javascript"; 
      	s.text = e[i].text; 
		$(id).appendChild(s); 
	} 
}
