/*
* Copyright 2009 iKorb Software Inc - Santa Cruz CA 95060. [ empower@ikorb.com ]
* http://www.ikorb.com
* Author: Igor Zingerman [ igor@ikorb.com ]
*
*/

var PHC_RSSControls = Class.create();

PHC_RSSControls.prototype = {
	/**
	*	PHC_RSSControls Class Init
	*/
	initialize: function() {
		var rssXML;
		var count = 0;
		this.RSSControls();
	},

	RSSControls: function(req){
		var opt = {
			method: 'get',
			postBody: '',
			
			// Handle successful response
			onSuccess: function(t) {				
				rss_controls.displayRSS($A((t.responseXML.documentElement).getElementsByTagName("item")));
			},

			// Handle other errors
			onFailure: function(t) {
				return "error";
			}	
		};
		request = 'RSSFeed.php?func=RSSFeed';
		new Ajax.Request(request, opt);
	},
	
	displayRSS: function (rssXML){
		this.rssXML = rssXML;
		this.fillPage();
	},
	
	fillPage: function (){
		if(!this.rssXML[this.count]){
			this.count = 0;
		}

		var myRSS = this.rssXML[this.count].childNodes;
		for(var itor = 0; itor < myRSS.length; itor++){
			try {
				tmp = document.getElementById(myRSS[itor].nodeName);
				if(myRSS[itor].nodeName == "rss_link"){
					tmp.href = myRSS[itor].childNodes[0].data;
				} else {
					tmp.innerHTML = myRSS[itor].childNodes[0].data;
				}
			} catch (e) {}
		}
	},
	
	About: {
		Version:'Pinnacle Health Care - RSSControls v 0.01 beta',
		Copyright:'Copyright 2009 iKorb Software [ empower@ikorb.com ]',
		Author:'Igor Z; [ igor@ikorb.com ]',
		BrowserTest: { XPath: !!document.evaluate },
		about: function (){ alert(this.Version + "\n" + this.Copyright + " \n" + this.Author) }
	}
};

var rss_controls = new PHC_RSSControls;

