/*****************************************************************************/
/*** browserCheck()                                                        ***/
/*****************************************************************************/
function browserCheck(){
    this.ver=navigator.appVersion
    this.agent=navigator.userAgent
    this.dom=document.getElementById?1:0
    this.opera5=this.agent.indexOf("Opera 5")>-1
    this.ie5=(this.ver.indexOf("MSIE 5")>-1 && this.dom && !this.opera5)?1:0;
    this.ie6=(this.ver.indexOf("MSIE 6")>-1 && this.dom && !this.opera5)?1:0;
    this.ie7=(this.ver.indexOf("MSIE 7")>-1 && this.dom && !this.opera5)?1:0;
    this.ie8=(this.ver.indexOf("MSIE 8")>-1 && this.dom && !this.opera5)?1:0;
    this.ie4=(document.all && !this.dom && !this.opera5)?1:0;
    this.ie=this.ie4||this.ie5||this.ie6
    this.mac=this.agent.indexOf("Mac")>-1
    this.ns6=(this.dom && parseInt(this.ver) >= 5) ?1:0;
    this.ns4=(document.layers && !this.dom)?1:0;
    this.bw=(this.ie8 || this.ie7 || this.ie6 || this.ie5 || this.ie4 || this.ns4 || this.ns6 || this.opera5);
    return this
}
var bw=new browserCheck();


/*****************************************************************************/
/*** Variablen                                                             ***/
/*****************************************************************************/
// Positionsangaben des Image-Scrollers
sLeft = 11;           // Menuposition links
sTop = 100;            // Menuposition oben
sHeight = 220;        // Menuhoehe (je nach Grafikgroesse)
sWidth = 758;        // Menubreite

// Positionsangaben der Steuerungselemente
sArrowLeft = true;   // true=an, false=aus
sArrowRight = true;

sArrowWidth = 0;    // Breite der Grafiken fuer die Controls
sArrowHeight = 0;   // Hoehe der Grafiken fuer Controls

sLeftArrowTop = sTop+sHeight+20;
sLeftArrowLeft = sLeft;
sRightArrowTop = (sHeight+sTop)-sArrowHeight+20;
sRightArrowLeft = sWidth;


bCtrlInMenu = false;  // true=Controls innerhalb / false=ausserhalb des Menus

// Scrolling-Geschwindigkeit
sScrollspeed = 25;   // Geschwindigkeit des Scrolling in ms
sScrollPx = 2;       // Anzahl der Pixel, die pro nScrollSpeed millisekunden gescrollt wird
sScrollExtra = 4;    // Schnelle Geschwindigkeit bei Mausklick auf Controls in Pixel
sScrollNormal = 2;

// Anzahl Bilder (unbedingt setzen)
nImagesWindow = 13;   // Anzahl der Grafiken, ohne Wiederholungen
nImages = 13;        // Anzahl der Grafiken insgesamt

/*****************************************************************************/
/*** Code                                                                  ***/
/*****************************************************************************/
var timer = 0;
var noScroll = true;
var direction = 1;
var stopScrollAtMax = false;
var sArrowSpace = 0;     // Platz für Controls
var neverScroll = false;
var trLeft = 0;
var trRight = 0;

function mvRound() {

   if(!(oMenu.x > -(oMenu.scrollWidth-sWidth-sScrollPx)))
   {
	if(trLeft != 1.0) {
    	    setOpacity(imgArrowLeft, 1.0);
    	    trLeft = 1.0;
    	}
    	if(trRight != 0.2) {
    	    setOpacity(imgArrowRight, 0.2);
    	    trRight = 0.2;
    	}
   }
   else if(!(oMenu.x < -sScrollPx))
   {
	if(trLeft != 0.2) {
    	    setOpacity(imgArrowLeft, 0.2);
    	    trLeft = 0.2;
    	}
    	if(trRight != 1.0) {
    	    setOpacity(imgArrowRight, 1.0);
    	    trRight = 1.0;
    	}
   }
   else {
	if(trLeft != 1.0) {
    	    setOpacity(imgArrowLeft, 1.0);
    	    trLeft = 1.0;
    	}
    	if(trRight != 1.0) {
    	    setOpacity(imgArrowRight, 1.0);
    	    trRight = 1.0;
    	}
   }

   if(!noScroll && !neverScroll) {
      if(direction == 1) {	// nach links fahren
        if(oMenu.x > -(oMenu.scrollWidth-sWidth-sScrollPx))
        {
           oMenu.moveBy(-sScrollPx, null);
        }
	else if(oMenu.scrollWidth > sWidth)
	{
	    help = -(oMenu.scrollWidth - sWidth);
	    oMenu.moveIt(help, null);
	}
      }
      else {	
        if(oMenu.x < -sScrollPx)
        {
           oMenu.moveBy(sScrollPx, null);
        }
	else
	{
	    oMenu.moveIt(0, null);
	}
      }
      /*
      else
      {
         imgHeight = parseInt((oMenu.scrollHeight)/nImages);
         //parseInt(-oMenu.x/imgWidth);
         pos = parseInt(oMenu.y + (nImagesWindow*imgHeight));
         pos -= sScrollPx;
         oMenu.moveIt(null, pos);
      }
      */
   }
    timer = setTimeout("mvRound()", sScrollspeed);
}

function stopFastForward() {
   sScrollPx = sScrollPxOriginal;
}

function stopMove() {
   noScroll = true;
   sScrollPx = sScrollPxOriginal;
}

function makeObj(obj,nest,menu) {
   nest = (!nest) ? "":'document.'+nest+'.';
   this.elm = bw.ns4?eval(nest+"document.layers." +obj):bw.ie4?document.all[obj]:document.getElementById(obj);
   this.css = bw.ns4?this.elm:this.elm.style;
   //this.scrollWidth = bw.ns4?this.css.document.width:this.elm.offsetWidth;
   //this.scrollHeight = (bw.ie4||bw.ie5||bw.ie6||bw.ns6)?this.elm.offsetHeight:bw.ns4?this.elm.clip.height:bw.opera5?this.css.pixelHeight:0;
   this.scrollWidth = (bw.ie4||bw.ie5||bw.ie6||bw.ie7||bw.ie8||bw.ns6)?this.elm.offsetWidth:bw.ns4?this.elm.clip.width:bw.opera5?this.css.pixelWidth:0;
   //this.opacity = (bw.ie4||bw.ie5||bw.ie6||bw.ie7||bw.ie8||bw.ns6||bw.ns4)?this.css.opacity:this.css.opacity;

   this.x = bw.ns4?this.css.left:this.elm.offsetLeft;
   this.y = bw.ns4?this.css.top:this.elm.offsetTop;
   this.moveBy = b_moveBy;
   this.moveIt = b_moveIt;
   this.clipTo = b_clipTo;
   return this;
}

// je nach Browser px hinzufuegen oder nicht...
var px = bw.ns4||window.opera?"":"px";

function b_moveIt(x, y) {
   if(x != null) {
      this.x=x; this.css.left=this.x+px;
   }
   if(y != null) {
      this.y=y; this.css.top=this.y+px;
   }
}

function b_moveBy(x, y) {
    this.x=this.x+x;
    this.y=this.y+y;
    this.css.left=this.x+px;
    this.css.top=this.y+px;
}

function b_clipTo(t, r, b, l) {
   if(bw.ns4) {
      this.css.clip.top=t;
      this.css.clip.right=r;
      this.css.clip.bottom=b;
      this.css.clip.left=l;
   } else {
      this.css.clip="rect("+t+"px "+r+"px "+b+"px "+l+"px)";
   }
}

/*****************************************************************************/
/*** Initialization							   ***/
/*****************************************************************************/
var sScrollPxOriginal = sScrollPx;

function Init() {

   if(bCtrlInMenu) {
      sArrowSpace = 0;
   } else {
      sArrowSpace = sArrowHeight;
   }

   if(sWidth==0) {
      sWidth = (bw.ns4 || bw.ns6 || window.opera)?innerWidth:document.body.clientWidth;
   }

   // Construction of the objects
   oBg = new makeObj('divBackground', 'scroller_content');
   
   oMenu = new makeObj('divMenu','divBackground',1);
   if(sArrowLeft) {
      oArrowLeft = new makeObj('divArrowLeft','divBackground');
      imgArrowLeft = document.getElementById("img_arrowleft");
   }
   if(sArrowRight) {
      oArrowRight = new makeObj('divArrowRight','divBackground');
      imgArrowRight = document.getElementById("img_arrowright");
   }

   // Placing the menucontainer, the layer with links
   oBg.moveIt(sLeft, sTop); //Main div, holds all the other divs.
   oMenu.moveIt(null, sArrowSpace);

   // Placing the controls accordingly to variables
   if(sArrowLeft) {
      oArrowLeft.css.width = sArrowWidth;
      oArrowLeft.moveIt(sLeftArrowLeft, sLeftArrowTop);
   }
   if(sArrowRight) {
      oArrowRight.css.width = sArrowWidth;
      oArrowRight.moveIt(sRightArrowLeft, sRightArrowTop);
   }

   // Setting the width and the visible area of the links.
   if(!bw.ns4) oBg.css.overflow = "hidden";
   if(bw.ns6) oMenu.css.position = "relative";
   oBg.css.width = sWidth+px;

   // Setting controls (in or out of links)
   oBg.clipTo(sArrowSpace, sWidth, sHeight-sArrowSpace, 0); //sArrowSpace)

   oBg.css.visibility = "visible";

    // Buttons ggf. ausblenden
    // Breite aller Bilder: oMenu.scrollWidth
    // Breite des Scrollareas: sWidth
    if(oMenu.scrollWidth <= sWidth)
    {
	oArrowLeft.css.visibility = 'hidden';
	oArrowRight.css.visibility = 'hidden';
    }    

    // let it roll
    timer = setTimeout("mvRound()", sScrollspeed);
}

function setOpacity(obj, value)
{
    var ievalue=value*100;
    //Sets the opacity of "language_selector" div per the passed in value setting (0 to 1 and in between)

    obj.style.filter="progid:DXImageTransform.Microsoft.Alpha(opacity="+ ievalue + ");"; //IE7 opacity
    
    if(obj.filters && obj.filters[0]) //IE syntax
    {
	if(typeof obj.filters[0].opacity=="number") //IE6
	    obj.filters[0].opacity=value*100;
	else //IE 5.5
	    obj.style.filter="alpha(opacity="+value*100+")";
    }
    else if(typeof obj.style.MozOpacity != "undefined") //Old Mozilla syntax
    {
	obj.style.MozOpacity=value;
    }
    else if(typeof obj.style.KHTMLOpacity != "undefined") //Safari syntax
    {
	obj.style.KHTMLOpacity= value;
    }
    else if(typeof obj.style.opacity != "undefined") //Standard opacity syntax
    {
	obj.style.opacity=value;
    }
}
//executing the init function on pageload if the browser is ok.
//if(bw.bw) {
//    onload = Init;
//}
/*****************************************************************************/

