function DxImageSlideShowImage( src, width, height, wrapperPaddingTop, href, text, alt )
{
    this.Img = document.createElement("img");
    this.Img.alt = alt;
    this.Img.src = src;

    this.Src = src;
    this.Text = text;
	this.Href = href;
	this.Width = width;
	this.Height = height;
	this.WrapperPaddingTop = wrapperPaddingTop;
}

function DxImageSlideShow( id, interval, autoStart, showControlPanel, height )
{
	this.Id = id;
	this.Images = new Array();
	this.CurrentImageIndex = 0;
	this.Interval = interval;
	this.IsPlaying = false;
	this.TimeoutId = null;
	this.ShowControlPanel = showControlPanel;
	this.Height = height;

	this.__ImageDom = null;
	this.__LinkDom = null;
	this.__TextDom = null;
	this.__WrapperDom = null;
	this.__StartButtonDom = null;
	this.__StatusDom = null;
	
	if (autoStart)
	{
		this.Start();
	}
}

DxImageSlideShow.prototype.GetImageDom = function()
{
    if (this.__ImageDom === null)
    {
        this.__ImageDom = document.getElementById(this.Id + "Image");
    }
    return this.__ImageDom;
}

DxImageSlideShow.prototype.GetStatusDom = function()
{
    if (this.__StatusDom === null)
    {
        this.__StatusDom = document.getElementById(this.Id + "Status");
    }
    return this.__StatusDom;
}

DxImageSlideShow.prototype.GetTextDom = function()
{
    if (this.__TextDom === null)
    {
        this.__TextDom = document.getElementById(this.Id + 'Text');
    }
    return this.__TextDom;
}

DxImageSlideShow.prototype.GetStartButtonDom = function()
{
    if (this.__StartButtonDom === null)
    {
        this.__StartButtonDom = document.getElementById(this.Id + 'StartButton');
    }
    return this.__StartButtonDom;
}

DxImageSlideShow.prototype.GetWrapperDom = function()
{
    if (this.__WrapperDom === null)
    {
        this.__WrapperDom = this.GetLinkDom().parentNode.parentNode;
    }
    return this.__WrapperDom;
}

DxImageSlideShow.prototype.GetLinkDom = function()
{
    if (this.__LinkDom === null)
    {
        this.__LinkDom = this.GetImageDom().parentNode;
    }
    return this.__LinkDom;
}

DxImageSlideShow.prototype.ImageCount = function()
{
	return this.Images.length;
}


DxImageSlideShow.prototype.ChangeImage = function(delta)
{
    //    if (this.ImageDom === null || this.LinkDom === null)
    //        return;

    this.CurrentImageIndex += delta;

    if (this.CurrentImageIndex >= this.ImageCount())
        this.CurrentImageIndex = 0;
    else if (this.CurrentImageIndex < 0)
        this.CurrentImageIndex = this.ImageCount() - 1;

    var imgDom = this.GetImageDom();
    
    var img = this.Images[this.CurrentImageIndex];
    img.Img.className = imgDom.className;

    imgDom.parentNode.replaceChild(img.Img, imgDom);
    this.__ImageDom = img.Img;

    this.GetLinkDom().href = img.Href;

    var wrapperDom = this.GetWrapperDom();
    wrapperDom.style.paddingTop = img.WrapperPaddingTop + "px";
    wrapperDom.style.height = (this.Height - img.WrapperPaddingTop) + "px";

    this.GetTextDom().innerHTML = img.Text;

    if (this.ShowControlPanel)
    {
        this.GetStatusDom().innerHTML =
            DxImageSlideShowElementResources.ImageCount.replace("{0}", this.CurrentImageIndex + 1).replace("{1}", this.ImageCount());
    }

}

DxImageSlideShow.prototype.Start = function()
{
    if (this.IsPlaying)
    {
        this.IsPlaying = false;
        if (this.ShowControlPanel )
            this.GetStartButtonDom().value = DxImageSlideShowElementResources.Start;
        window.clearTimeout(this.TimoutId)
    }
    else
    {
        this.IsPlaying = true;
        this.StartTimeOut();
        if (this.ShowControlPanel )
            this.GetStartButtonDom().value = DxImageSlideShowElementResources.Stop; 
    }
}

DxImageSlideShow.prototype.StartTimeOut = function()
{
	this.TimoutId = window.setTimeout( this.Id + '.Play()', this.Interval );
}

DxImageSlideShow.prototype.Play = function()
{
    if (this.IsPlaying)
        this.ChangeImage(1);

    this.StartTimeOut();
}

if (typeof (DxNotifyScriptsLoaded) !== "undefined" && typeof (Sys) !== "undefined") Sys.Application.notifyScriptLoaded();