// JavaScript Document
// Show/Hide Pulldown

function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_showHideLayers() { //v6.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
    obj.visibility=v; }
}

function setBookmark()
{
  bookmarkurl = location.href;
  if (document.all) {
     var text = document.title;
     text = text.replace(/:/ ,"");
     text = text.replace(/\*/ ,"");
     text = text.replace(/\?/ ,"");
     text = text.replace(/\\/ ,"");
     text = text.replace(/"/ ,"");
     text = text.replace(/</ ,"");
     text = text.replace(/>/ ,"");
     text = text.replace(/|/ ,"");
     window.external.AddFavorite(bookmarkurl,text);
  } else {
        alert('Your Browser does not support this feature');
  }
}

function zoom(factor)
{
  var size = "100%";
  var obj = document.getElementById("BaseContent");

  if (obj.style.fontSize != null &&
      obj.style.fontSize != "")
    { size = obj.style.fontSize; }

  size = Number(String(size).substring(0, String(size).indexOf("%")))
  if (size > 20 && size < 400) size = size + factor;
  if (factor == 0) size = 100;

  setPersFontSize(size + "%");
  loadZoom();

  if (navigator.appName=="Netscape") {location.reload();}
}

function loadZoom()
{
  var newSize = getPersFontSize();
  var obj = document.getElementById("BaseContent");
  obj.style.fontSize = newSize;
}

function setPersFontSize(fontSize)
{
    document.cookie = "fontSize=" + fontSize + ";";
}

function getPersFontSize()
{
  var fontSize = "100%";

	if (document.cookie)
	{
	  var val = document.cookie
	  var idxStart = val.indexOf("fontSize=")
	  var idxEnd = val.indexOf(";", idxStart);

	  if (idxEnd < 0) { idxEnd = val.length; }
    if (idxStart >= 0) {fontSize = val.substring(idxStart + "fontSize=".length, idxEnd);}
  }
  else
  {
    setPersFontSize(fontSize);
  }

  return fontSize;
}

var selectedreg;
var altselectedreg;

function selecttab(node,pos) {

   var rdiv = document.getElementById("tab_" + node + "_" + pos);
   var rpdiv = document.getElementById("tabcontent_" + node + "_" + pos);
   var rspdiv = document.getElementById("tabcontent_" + node);
   if(!altselectedreg) altselectedreg = "tab_"+ node +"_0";
   var rsdiv = document.getElementById(altselectedreg);

   if(rdiv && rpdiv && rspdiv && rsdiv) {
   	   rspdiv.innerHTML = rpdiv.innerHTML;
	   rdiv.className += "tabselected";
	   rsdiv.className = rsdiv.className.replace(/tabselected/,"");
	   selectedreg = "tab_" + node + "_" + pos;
	   altselectedreg = "tab_" + node + "_" + pos;
   }
}

var END_OF_INPUT = -1;
var base64Chars = new Array(
    'A','B','C','D','E','F','G','H',
    'I','J','K','L','M','N','O','P',
    'Q','R','S','T','U','V','W','X',
    'Y','Z','a','b','c','d','e','f',
    'g','h','i','j','k','l','m','n',
    'o','p','q','r','s','t','u','v',
    'w','x','y','z','0','1','2','3',
    '4','5','6','7','8','9','+','/'
);
var reverseBase64Chars = new Array();
for (var i=0; i < base64Chars.length; i++){
    reverseBase64Chars[base64Chars[i]] = i;
}

var base64Str;
var base64Count;
function setBase64Str(str){
    base64Str = str;
    base64Count = 0;
}
function readBase64(){
    if (!base64Str) return END_OF_INPUT;
    if (base64Count >= base64Str.length) return END_OF_INPUT;
    var c = base64Str.charCodeAt(base64Count) & 0xff;
    base64Count++;
    return c;
}
function encodeBase64(str){
    setBase64Str(str);
    var result = '';
    var inBuffer = new Array(3);
    var lineCount = 0;
    var done = false;
    while (!done && (inBuffer[0] = readBase64()) != END_OF_INPUT){
        inBuffer[1] = readBase64();
        inBuffer[2] = readBase64();
        result += (base64Chars[ inBuffer[0] >> 2 ]);
        if (inBuffer[1] != END_OF_INPUT){
            result += (base64Chars [(( inBuffer[0] << 4 ) & 0x30) | (inBuffer[1] >> 4) ]);
            if (inBuffer[2] != END_OF_INPUT){
                result += (base64Chars [((inBuffer[1] << 2) & 0x3c) | (inBuffer[2] >> 6) ]);
                result += (base64Chars [inBuffer[2] & 0x3F]);
            } else {
                result += (base64Chars [((inBuffer[1] << 2) & 0x3c)]);
                result += ('=');
                done = true;
            }
        } else {
            result += (base64Chars [(( inBuffer[0] << 4 ) & 0x30)]);
            result += ('=');
            result += ('=');
            done = true;
        }
        lineCount += 4;
        if (lineCount >= 76){
            result += ('\n');
            lineCount = 0;
        }
    }
    return result;
}
function readReverseBase64(){
    if (!base64Str) return END_OF_INPUT;
    while (true){
        if (base64Count >= base64Str.length) return END_OF_INPUT;
        var nextCharacter = base64Str.charAt(base64Count);
        base64Count++;
        if (reverseBase64Chars[nextCharacter]){
            return reverseBase64Chars[nextCharacter];
        }
        if (nextCharacter == 'A') return 0;
    }
    return END_OF_INPUT;
}

function ntos(n){
    n=n.toString(16);
    if (n.length == 1) n="0"+n;
    n="%"+n;
    return unescape(n);
}

function decodeBase64(str){
    setBase64Str(str);
    var result = "";
    var inBuffer = new Array(4);
    var done = false;
    while (!done && (inBuffer[0] = readReverseBase64()) != END_OF_INPUT
        && (inBuffer[1] = readReverseBase64()) != END_OF_INPUT){
        inBuffer[2] = readReverseBase64();
        inBuffer[3] = readReverseBase64();
        result += ntos((((inBuffer[0] << 2) & 0xff)| inBuffer[1] >> 4));
        if (inBuffer[2] != END_OF_INPUT){
            result +=  ntos((((inBuffer[1] << 4) & 0xff)| inBuffer[2] >> 2));
            if (inBuffer[3] != END_OF_INPUT){
                result +=  ntos((((inBuffer[2] << 6)  & 0xff) | inBuffer[3]));
            } else {
                done = true;
            }
        } else {
            done = true;
        }
    }
    return result;
}

function get_enc_string()
{
   try
   {
   location.href="mailto:" + decodeBase64(arguments[0]);
   }
   catch(e)
   {
   }
}

$(document).ready(function(){

 $("li.en> a").addClass("selected");
 
  $("#language a").hover(
    function() {$(this).addClass("hover");},
    function() {$(this).removeClass("hover");}
  );

 $("li.de").click(function () { 
zoomVideo('unzoom', 'http://www.imagefilm.bayer.com/downloads/de/Bayer_EoF_de_FL8_640x360.flv', 'http://www.imagefilm.bayer.com/downloads/de/Bayer_EoF_de_FL8_640x360.flv', '/img/image-film/startbild-hi.jpg');
$("#language li> a").removeClass("selected");
$("li.de> a").addClass("selected");
  });

 $("li.en").click(function () { 
zoomVideo('unzoom', 'http://www.imagefilm.bayer.com/downloads/en/Bayer_EoF_en_FL8_640x360.flv', 'http://www.imagefilm.bayer.com/downloads/en/Bayer_EoF_en_FL8_640x360.flv', '/img/image-film/startbild-hi.jpg');
$("#language li> a").removeClass("selected");
$("li.en> a").addClass("selected");
  });
  
 $("li.usa").click(function () { 
zoomVideo('unzoom', 'http://www.imagefilm.bayer.com/downloads/us/Bayer_EoF_us_FL8_640x360.flv', 'http://www.imagefilm.bayer.com/downloads/us/Bayer_EoF_us_FL8_640x360.flv', '/img/image-film/startbild-hi.jpg');
$("#language li> a").removeClass("selected");
$("li.usa> a").addClass("selected");
  });
  
  $("li.fr").click(function () { 
zoomVideo('unzoom', 'http://www.imagefilm.bayer.com/downloads/fr/Bayer_EoF_fr_FL8_640x360.flv', 'http://www.imagefilm.bayer.com/downloads/fr/Bayer_EoF_fr_FL8_640x360.flv', '/img/image-film/startbild-hi.jpg');
$("#language li> a").removeClass("selected");
$("li.fr> a").addClass("selected");
  });

$("li.es").click(function () { 
    zoomVideo('unzoom', 'http://www.imagefilm.bayer.com/downloads/es/Bayer_EoF_sp_FL8_640x360.flv', 'http://www.imagefilm.bayer.com/downloads/es/Bayer_EoF_sp_FL8_640x360.flv', '/img/image-film/startbild-hi.jpg');
	$("#language li> a").removeClass("selected");
	    $("li.es> a").addClass("selected");
	      });
	      
	      $("li.it").click(function () { 
	        zoomVideo('unzoom', 'http://www.imagefilm.bayer.com/downloads/it/Bayer_EoF_it_FL8_640x360.flv', 'http://www.imagefilm.bayer.com/downloads/it/Bayer_EoF_it_FL8_640x360.flv', '/img/image-film/startbild-hi.jpg');
		    $("#language li> a").removeClass("selected");
			$("li.it> a").addClass("selected");
			  });
			  
			  $("li.pt").click(function () { 
			    zoomVideo('unzoom', 'http://www.imagefilm.bayer.com/downloads/pt/Bayer_EoF_po_FL8_640x360.flv', 'http://www.imagefilm.bayer.com/downloads/pt/Bayer_EoF_po_FL8_640x360.flv', '/img/image-film/startbild-hi.jpg');
				$("#language li> a").removeClass("selected");
				    $("li.pt> a").addClass("selected");
				      });
				      
				      $("li.br").click(function () { 
				        zoomVideo('unzoom', 'http://www.imagefilm.bayer.com/downloads/br/Bayer_EoF_br_FL8_640x360.flv', 'http://www.imagefilm.bayer.com/downloads/br/Bayer_EoF_br_FL8_640x360.flv', '/img/image-film/startbild-hi.jpg');
					    $("#language li> a").removeClass("selected");
						$("li.br> a").addClass("selected");
						  });
						  
						  $("li.cn").click(function () { 
						    zoomVideo('unzoom', 'http://www.imagefilm.bayer.com/downloads/cn/Bayer_EoF_chi_FL8_640x360.flv', 'http://www.imagefilm.bayer.com/downloads/cn/Bayer_EoF_chi_FL8_640x360.flv', '/img/image-film/startbild-hi.jpg');
							$("#language li> a").removeClass("selected");
							    $("li.cn> a").addClass("selected");
							      });
							      
							      
							      
							      
							      })
							      
