var Slider =
{

slider_auto: true,
slider_height: 164,
slider_width: 137,
slider_image: {width:110, height:110},
slider_offset: 15,
slider_speed: 1,
slider_type: 1,
slider_timeout: 0,
slider_interval: 50,
slider_autotime: 10000,
slider_folder: "",
slider_html_img: "",
slider_html_txt: "",
slider_frame: new Object(),
slider_images: new Array(),

addImage:
  function(s,t,u)
  {
    if ( u.indexOf('?') > 0 )
    {
      u += '&slider=true';
    }
    else
    {
      u += '?slider=true';
    }
    this.slider_images.push( { src:s, title:t, url:u } );
  },
  
setFolder:
  function(folder)
  {
    this.slider_folder = folder;
  },

setAutoMode:
  function(status)
  {
    this.slider_auto = status;
    if ( status == true )
    {
      setTimeout("Slider._autoMove();",this.slider_autotime);
    }
  },

doZoomIn:
  function(obj)
  {
    if ( typeof(obj) == "string" ) obj = this.getElement(obj);
    for( i=0; i<=11; i++ )
    {    
      setTimeout("Slider._zoom('"+obj.id+"','"+i+"');",i*10);
    }
  },

doZoomOut:
  function(obj)
  {
    if ( typeof(obj) == "string" ) obj = this.getElement(obj);
    for( i=11; i>=0; i-- )
    {
      setTimeout("Slider._zoom('"+obj.id+"','"+i+"');",(11-i)*10);
    }
  },

doMoveTop:
  function()
  {
    this.slider_auto = false;
    for(i=0;i<this.slider_height;i++)
    {
      setTimeout("Slider._moveTop(1);",i*3);
    }
  },

doMoveBottom:
  function()
  {
    this.slider_auto = false;
    for(i=0;i<this.slider_height;i++)
    {
      setTimeout("Slider._moveBottom(1);",i*3);
    }
  },

doMoveLeft:
  function()
  {
    for(i=0;i<this.slider_width;i++)
    {
      setTimeout("Slider._moveLeft(1);",i*3);
    }
  },

doMoveRight:
  function()
  {
    for(i=0;i<this.slider_width;i++)
    {
      setTimeout("Slider._moveRight(1);",i*3);
    }
  },
  
_zoom:
  function(id,z)
  {
    var obj = this.getElement(id);
    obj.style.margin = (11-z)+"px";
    obj.style.width  = (this.slider_image.width+(2*z))+"px";
    obj.style.height = (this.slider_image.height+(2*z))+"px";
  },

_checkLimits:
  function()
  {
    var limit = 0;
    
    /*version 2 for horizontal slider*/
    if ( this.slider_type == 2 )
    {
      limit = parseInt( this.slider_frame.style.left );
      /*move whole image block right, if left end reached*/
      if( limit <= -(this.slider_width * this.slider_images.length ) )
      {
        limit += ( this.slider_width * this.slider_images.length );
      }
      /*move whole image block left, if right end reached*/
      else if ( limit >= 0 )
      {
        limit -= ( this.slider_width * this.slider_images.length );
      }
    }
    else /*version 1 for vertical slider*/
    {
      limit = parseInt( this.slider_frame.style.top );
      /*move whole image block right, if top end reached*/
      if( limit <= -(this.slider_height * this.slider_images.length ) )
      {
        limit += ( this.slider_height * this.slider_images.length );
      }
      /*move whole image block top, if right end reached*/
      else if ( limit >= 0 )
      {
        limit -= ( this.slider_height * this.slider_images.length );
      }
    }
    
    /*return fixed position*/
    return limit;
  },

_autoMove:
  function(d)
  {
    if ( this.slider_auto == true )
    {
      for(i=0;i<this.slider_height*2;i++)
      {
        setTimeout("Slider._moveTop(1);",i*3);
      }
      setTimeout("Slider._autoMove();",this.slider_autotime);
    }
  },
  
_moveTop:
  function(dx)
  {
    dx = parseInt(dx);
    this.slider_frame.style.top = ( this._checkLimits() + dx ) + "px";
  },
  
_moveBottom:
  function(dx)
  {
    dx = parseInt(dx);
    this.slider_frame.style.top = ( this._checkLimits() - dx ) + "px";
  },

_moveLeft:
  function(dx)
  {
    dx = parseInt(dx);
    this.slider_frame.style.left = ( this._checkLimits() + dx ) + "px";
  },
  
_moveRight:
  function(dx)
  {
    dx = parseInt(dx);
    this.slider_frame.style.left = ( this._checkLimits() - dx ) + "px";
  },
  
getElement:
  function( id )
  {
    if ( document.getElementById ) return document.getElementById(id);
    if ( document.layers )	return document.layers[id];
    if ( document.all ) return document.all[id];
    return null;
  },

appendHTML:
  function( i, h )
  {
    var id   = ( h*100 ) + i;
    var src  = this.slider_folder+'/'+this.slider_images[i].src;
    
    if ( this.slider_type == 2 )
    {
      this.slider_html_img += '<div class="slider2_image"><a href="'+this.slider_images[i].url+'" title="'+this.slider_images[i].title+'">';
      this.slider_html_img += '<img id="slimg'+id+'" onmouseover="Slider.doZoomIn(this);" onmouseout="Slider.doZoomOut(this);" ';
      this.slider_html_img += ' alt="'+this.slider_images[i].title+'" title="'+this.slider_images[i].title+'"';
      this.slider_html_img += ' src="'+src+'" width="'+this.slider_image.width+'" height="'+this.slider_image.height+'" />';
      this.slider_html_img += '</a></div>';

      this.slider_html_txt += '<div class="slider2_text"><div class="hellgrau" style="width:122px;margin:2px;padding:2px;text-align:center;">';
      this.slider_html_txt += '<a style="font-weight:bold;font-size:11px;" href="'+this.slider_images[i].url+'" title="'+this.slider_images[i].title+'">';
      this.slider_html_txt += this.slider_images[i].title;
      this.slider_html_txt += '</a></div></div>';      
    }
    else
    {
      this.slider_html_img += '<div class="slider_image"><a href="'+this.slider_images[i].url+'" title="'+this.slider_images[i].title+'">';
      this.slider_html_img += '<img id="slimg'+id+'" onmouseover="Slider.doZoomIn(this);" onmouseout="Slider.doZoomOut(this);" ';
      this.slider_html_img += ' alt="'+this.slider_images[i].title+'" title="'+this.slider_images[i].title+'"';
      this.slider_html_img += ' src="'+src+'" width="'+this.slider_image.width+'" height="'+this.slider_image.height+'" />';
      this.slider_html_img += '</a></div>';
      this.slider_html_img += '<div class="slider_text"><div class="hellgrau" style="width:94%;margin:2px;padding:2px;text-align:center;">';
      this.slider_html_img += '<a style="font-weight:bold;font-size:11px;" href="'+this.slider_images[i].url+'" title="'+this.slider_images[i].title+'">';
      this.slider_html_img += this.slider_images[i].title;
      this.slider_html_img += '</a></div></div>';
    }
  },
  
init:
	function()
	{
    /*store slider frame pointer*/
    this.slider_frame = this.getElement("slider_frame");
    
    /*check if slider 1 (vertical) or 2 (horizontal)*/
    if ( ! this.slider_frame )
    {
      this.slider_frame = this.getElement("slider2_frame");
      /*fix slider offset for version 2 (horizontal)*/
      this.slider_offset = 20;
      this.slider_type   = 2;
      /*move whole frame 2 times left and maximize width*/
      this.slider_frame.style.left  = ( this.slider_offset - ( this.slider_width * this.slider_images.length ) ) + "px";
      this.slider_frame.style.width = ( 3 * this.slider_width * this.slider_images.length ) + "px";
    }
    else
    {
      /*move whole frame 2 times left and maximize width*/
      this.slider_frame.style.top   = ( this.slider_offset - ( this.slider_height * this.slider_images.length ) ) + "px";
      this.slider_frame.style.width = ( 3 * this.slider_height * this.slider_images.length ) + "px";
    }
    
    /*fill frame 3 times with images*/
    for( h=1; h<3; h++ )
    {
      for( i=0; i<this.slider_images.length; i++ )
      {
        this.appendHTML(i,h);
      }
    }
    
    /*horizontal slider consists of images and text (as newline)*/
    if ( this.slider_type == 2)
    {
      this.slider_frame.innerHTML += this.slider_html_img;
      this.slider_frame.innerHTML += '<br clear="all"/>';
      this.slider_frame.innerHTML += this.slider_html_txt;
    }
    else /*vertical slider consists of images and text at once*/
    {
      this.slider_frame.innerHTML = this.slider_html_img;
    }
	}

};
