/***************************************************************************                                                                                                       
 *   Copyright (C) 2009 by Vitaly Gnidenko                                 *                                                                                                       
 *   lart@rambler.ru                                                       *                                                                                                       
 ***************************************************************************/  
/*$Id: Ajax.js 172 2009-04-22 08:50:05Z admin $*/
YAHOO.util.Ajax=function(){}

YAHOO.util.Ajax.Updater=function(container,href,params){
		this.options=Object.extend({
			method:'GET',
			evalScripts:false,
			post:''
		},params);
		
		this.container=YAHOO.util.Dom.get(container);
		if (this.container){
			YAHOO.util.Connect.asyncRequest(this.options.method,href,{
				success: function(t){
					while(this.container.lastChild) {
         			   this.container.removeChild(this.container.lastChild);
        			}
					this.container.innerHTML=t.responseText;
					if (this.options.evalScripts){
						this.extractScripts(t.responseText).map(function(script) { return eval(script) });	
					}
				},
				scope:this
			},this.options.post);
		}
	}
YAHOO.util.Ajax.Updater.prototype={
	options:{},
	scriptExp:'<script[^>]*>([\\S\\s]*?)<\/script>',
	container:null,
	extractScripts:function(scr) {
	    var matchAll = new RegExp(this.scriptExp, 'img');
	    var matchOne = new RegExp(this.scriptExp, 'im');
	    return (scr.match(matchAll) || []).map(function(scriptTag) {
	      return (scriptTag.match(matchOne) || ['', ''])[1];
	    });
  	}
	
}


//YAHOO.util.Ajax=function(){};
//YAHOO.util.Ajax.