// Carrousel JScript source code
function Carrousel(name)
{
	this.Name = name;
	this.ServerPage = ""; // relative virtual path from root to xmlhttp aspx
	this.StyleSheet = ""; // relative virtual path from root to xsl
	this.Page = 1;
	this.PageCount = 0;	  // Total number of pages
	this.PageSize = 4;	  // Number of items per scrollarea
	this.Count = 0;
	this.ApplicationPath = applicationPath;
	this.Debug = false;
}

Carrousel.prototype.ScrollArea =
function ()
{
	return document.getElementById(this.Name + "_scroll");
}

Carrousel.prototype.OnScrollLeft =
function ()
{
	if (this.Page > 1)
		this.Load(--this.Page);
}

Carrousel.prototype.OnScrollRight =
function ()
{
	if (this.Page < this.PageCount)
		this.Load(++this.Page);
}

Carrousel.prototype.Load = 
function (page)
{
	var xmlDocument,
		scrollArea;
	
	if ((scrollArea = this.ScrollArea()) != null)
	{
		try
		{
			if ((xmlDocument = this.LoadXMLFromURL(this.ServerPage, page)) != null)
			{
				if (this.PageCount == 0)
					this.PageCount = parseInt(xmlDocument.firstChild.attributes.getNamedItem("pagecount").nodeValue, 10);
				this.Count = parseInt(xmlDocument.firstChild.attributes.getNamedItem("count").nodeValue, 10);
				scrollArea.innerHTML = xmlDocument.getElementsByTagName("html")[0].childNodes[0].nodeValue;
			}
		}
		catch (exception)
		{
			scrollArea.innerHTML = exception;
		}
	}
}

Carrousel.prototype.LoadXMLFromURL = 
function (url, page) 
{ 
	var httpRequest,
		request;
	
	if ((httpRequest = XmlHttpObject()) != null)
	{
		httpRequest.open("POST", url, false); 
		request = "<parameters stylesheet=\"" + this.StyleSheet + "\" page=\"" + page.toString() +  "\" pagesize=\"" + this.PageSize.toString() + "\" />";
		httpRequest.send(request); 
		/**************************************/
		if (this.Debug)
			alert(httpRequest.responseText);
		/**************************************/
		if (httpRequest.status == 200)
			return httpRequest.responseXML; 
		else
			alert(httpRequest.status + ": " + httpRequest.statusText);
	} 
} 

Carrousel.prototype.IE = 
function ()
{
	try
	{
		var test = new XSLTProcessor();
		return false;
	}
	catch (ie)
	{
		return true;
	}
}

Carrousel.prototype.EvaluateXPath =
function (contextNode, xpath)
{
	var value = null;
	try
	{
		var node;
		if ((node = contextNode.selectSingleNode(xpath)) != null)
			value = node.text;
	}
	catch (mozilla)
	{
		var document;
		if (contextNode.nodeType != 9)
			document = contextNode.ownerDocument;
		else
			document = contextNode;
		value = document.evaluate(xpath, contextNode, null, 2, null).stringValue;
	}
	return value;
}

