/*
 * Fix for Mootools Request.HTML update option.
 * We use response.html insead of response.tree to inject the html, so IE can adopt "invalid html"
 * (Example, tables without tbody / thead), and keep the "onclick/onsubmit/etc" attributes
 * 
 * This fix is for mootools 1.2
 * 
 * Boris POPOFF , http://gueschla.com , 09/07/2008
 * 
 */

Request.HTML.implement({
	success: function(text){
		var options = this.options, response = this.response;
		
		response.html = text.stripScripts(function(script){
			response.javascript = script;
		});
		
		var temp = this.processHTML(response.html);
		
		response.tree = temp.childNodes;
		response.elements = temp.getElements('*');
		
		if (options.filter) response.tree = response.elements.filter(options.filter);
		
		// Changed this line so we can adopt the html directly like in the old versions.
		//if (options.update) $(options.update).empty().adopt(response.tree);
		if (options.update) $(options.update).empty().set('html',response.html);
		
		if (options.evalScripts) $exec(response.javascript);
		
		this.onSuccess(response.tree, response.elements, response.html, response.javascript);
	}

});
