/**
 * ====================================================================
 * About
 * ====================================================================
 * COMRàdio tickers library 
 * @version 1.0
 * @author: Francesc Vila 01/02/2005
 *
 * COMRàdio tickers is a XML-based system for reading ticker information from www.comradio.com.
 * The library supports Gecko based browsers like Mozilla and Firefox,
 * Internet Explorer (5.5+ with MSXML3.0+).
 *
 * COMRàdio tickers uses free Sarissa utility class.
 *
 * ====================================================================
 * Licence
 * ====================================================================
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 or
 * the GNU Lesser General Public License version 2.1 as published by
 * the Free Software Foundation (your choice of the two).
 *
 * This program 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 or GNU Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * or GNU Lesser General Public License along with this program; if not,
 * write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 * or visit http://www.gnu.org
 *
 */

/**
 * Returns a DOM Document object.
 * @param url when opened the url given returns XML-formatted text
 */
function loadDomDoc(url) {
	var oDomDoc = Sarissa.getDomDocument();
	oDomDoc.async = false;
	oDomDoc.load(url);
	return oDomDoc;
}

/**
 * Parses tickers document. Extracts useful text from XML tags.
 * Called when COMRàdio tickers are read.
 * @param strXML XML contents string
 * @param rootElemName name of XML document root element
 * @param elemName name of XML document ticker element
 * @param separator text between tickers to be written
 */
function getContent(strXML, rootElemName, elemName, separator) {
	var start = strXML.indexOf("<" + rootElemName + ">") + rootElemName.length + 2;
	var end   = strXML.indexOf("</" + rootElemName + ">");
	var strResult = strXML.slice(start, end);
	var arrContent = strResult.split("<" + elemName + ">");
	for (i=0; i < arrContent.length; i++) {
		end = arrContent[i].indexOf("</" + elemName + ">");
		arrContent[i] = arrContent[i].substring(0, end);
	}
	var strContent = "";
	for (i=1; i < arrContent.length; i++) {
		strContent = strContent + arrContent[i] + separator;
	}
	return strContent;
}

/**
 * Marquee object initialization.
 * @param id marquee identifier
 * @param width marquee width in pixels
 * @param height marquee height in pixels
 * @param speed marquee scrolling speed
 * @param direction marquee scrolling direction. Values: left, right, up, down
 * @param contents marquee contents
 */
function marquee(id, width, height, speed, direction, contents) {
	this.id        = id;
	this.width     = width;
	this.height    = height;
	this.speed     = speed;
	this.direction = direction;
	this.contents  = contents;
	this.show      = show;
}

/**
 * Writes html marquee initialized object.
 */
function show() {
	document.write('<marquee id=' + this.id + ' width=' + this.width + ' height=' + this.height + ' scrollAmount=' + this.speed + ' direction=' + this.direction + ' onmouseover="this.stop()" onmouseout="this.start()">' + this.contents + '</marquee>');
}
