﻿//
//	http://momche.net
//	mo@momche.net
//	:: feel free to use it BUT
//	:: if you want to use this code PLEASE send a note
//	:: and please keep this disclaimer intact
//
cQuotesService = function()
{
	//the proxy just redirects a XML response
	var sQuoteProxy = 'http-proxy.php';
	var sQuoteClass = 'moQuotes';
	var sHTTPAddress = "http-proxy.php?url=http://www.swanandmokashi.com/HomePage/WebServices/QuoteOfTheDay.asmx/GetQuote";
	var hRL;
	
	function quote( hXML )
	{
		this.quotetext = MO.DomExt.getAllNodeText( hXML.getElementsByTagName( "QuoteOfTheDay" )[ 0 ] );
		this.author = MO.DomExt.getAllNodeText( hXML.getElementsByTagName( "Author" )[ 0 ] );
	}
	
	var hQuote = null;
	var hContainer = null;
	
	return {
		init : function()
		{
			hContainer = MO.Dom.getElementsBySelector( "div[class=" + sQuoteClass + "]" ).getAt( 0 );
			hRL = new cRemoteLoader();
			cQuotesService.getQuote();
		},
		getQuote : function()
		{
			hRL.loadContent( sHTTPAddress, cQuotesService.onLoad );
		},
		onLoad : function()
		{
			hQuote = new quote( this.hXMLHttp.responseXML );
			hContainer.innerHTML = hQuote.quotetext;
		}
	}
}();
MO.Event.DomLoaded.load( cQuotesService.init );
