function ScriptCollector(response, id){
	
	this.response = response;
	if (!id || id=='undefined') {
		this.id = 'onLoad';
	} else {
		this.id=id;
	}
	this.rest = response;
	this.lastscp = -1;
	
	this.hasNext = function() {
		if (this.lastscp==-2) return false;
		var sop = this.rest.indexOf('<script');
		if (sop>-1) {
			this.rest = this.rest.substring(sop);
			var scp = this.rest.indexOf('>');
			if (scp>-1) {
				var tagOpener = this.rest.substring(0,scp);
				if (tagOpener.indexOf('id=\"'+this.id+'\"')>-1) {
					this.lastscp = scp;
					return true;
				} else {
					var tgp = this.rest.indexOf('<'+'/script>');
					this.rest = this.rest.substring(tgp+9);
					return this.hasNext();
				}
			}
		}
		this.lastscp = -2;
		return false;
	};
	
	this.nextScript = function() {
		if (this.lastscp ==-2) {
			return;
		}
		if (this.lastscp ==-1) {
			if (!this.hasNext()) {
				return;
			}
		}
		var tgp = this.rest.indexOf('<'+'/script>');
		var tagBody = this.rest.substring(this.lastscp+1,tgp);
		this.rest = this.rest.substring(tgp+9);
		this.lastscp = -1;
		return tagBody;
	};
	
	this.getAsArray = function() {
		var scripts = new Array();
		while (this.hasNext()) {
			scripts.push(this.nextScript());
		}
		return scripts;
	};
}
