/**
 * Copyright (C) 2007 by http://www.snyke.net .
 *
 * @author	Christian Decker <decker.christian@gmail.com>
 *
 * YouPipe is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This software is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with Foobar; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */
// ==========================================================================
/**
 * Class that represents the pipe.
 */
var YPipe = Class.create();
YPipe.prototype = {
	id: "",

	initialize: function(u,p){
		if(!u){
			throw "No valid ID specified."
		}
		this.id = u;
		if(p){
			for(att in p){
				this[att] = p[att];
			}
		}
		this.loadFeed();
	},
	
	buildURL: function(){
		var str = "http://pipes.yahoo.com/pipes/pipe.run?";
		str += "_id=" + this.id;
		str += "&_render=json&_callback=window.activePipe.onsuccess";
		
		return str;
	},
	
	loadFeed: function(){
		window.activePipe = this;
		var headTag = document.getElementsByTagName('head')[0]; 
		var script = document.createElement("script");
		script.src = this.buildURL();
		script.language = "JavaScript";
		headTag.appendChild(script);
	},

	onsuccess: function(c){}
};
