/* I N I T */
function init() {
	init_nav();
	melInitSlideShow('tst',3000,9000,'','auto');

}

/* E X P L O R E R */
function init_nav() {
   for(i = 0; i < document.getElementsByTagName('ul').length; 
       i++) {
      if(document.getElementsByTagName('ul')[i].className == 
      "opened") {
         id = 
         document.getElementsByTagName('ul')[i].parentNode.id;
         togglenav(id, false);
      }
   }
   if(window.name.length > 0)       
      load_nav();
}

function togglenav(id, save) {
   ul = "ul_" + id;
   img = "img_" + id;
   ul_element = document.getElementById(ul);
   img_element = document.getElementById(img);
   if(ul_element) {
       if(ul_element.className == 'closed') {
          ul_element.className = "opened";
          img_element.src = "http://www.inew-cs.com/web/images/arrow_invers_down.gif";
       } 
       else {
          ul_element.className = "closed";
          img_element.src = "http://www.inew-cs.com/web/images/arrow_invers.gif";
       }
   }
   if(save == true) save_nav();
}

function save_nav() {
   var save = "";
   for(var i = 0; i < document.getElementsByTagName('ul').length;
   i++) {
      if((document.getElementsByTagName('ul')[i].className == 
      "opened" || 
      document.getElementsByTagName('ul')[i].className == 
      "closed") && document.getElementsByTagName('ul')[i].id != 
      'root') 
         save = save + document.getElementsByTagName('ul')[i].id 
         + "=" + document.getElementsByTagName('ul')[i].className 
         + ",";
   }
   if(save.lastIndexOf(",") > 0) 
      save = save.substring(0, save.lastIndexOf(","));
   window.name = save;
}

function load_nav() {
   var items = window.name.split(",");
   if(items.length > 0) {
      for(var i = 0; i < items.length; i++) {        
         id_value = items[i].split("=");         
         if(id_value.length == 2) {
            id = id_value[0];  
            value = id_value[1];
            document.getElementById(id).className = value;
            img = "img_" + id.substring(3, id.length);
            img_element = document.getElementById(img);
            if(value == "closed")
               img_element.src = "http://www.inew-cs.com/web/images/arrow_invers.gif";  
            else
               img_element.src = "http://www.inew-cs.com/web/images/arrow_invers_down.gif";
         }
      }
   }
}

//Fade in fade out of textbubbles for References
function opacity(id, opacStart, opacEnd, millisec) {
    //speed for each frame
    var speed = Math.round(millisec / 100);
    var timer = 0;

    //determine the direction for the blending, if start and end are the same nothing happens
    if(opacStart > opacEnd) {
        for(i = opacStart; i >= opacEnd; i--) {
            setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed));
            timer++;
        }
    } else if(opacStart < opacEnd) {
        for(i = opacStart; i <= opacEnd; i++)
            {
            setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed));
            timer++;
        }
    }
}

//change the opacity for different browsers
function changeOpac(opacity, id) {
    var object = document.getElementById(id).style;
    object.opacity = (opacity / 100);
    object.MozOpacity = (opacity / 100);
    object.KhtmlOpacity = (opacity / 100);
    object.filter = "alpha(opacity=" + opacity + ")";
} 

function shiftOpacity(id, millisec) {
    //if an element is invisible, make it visible, else make it ivisible
    if(document.getElementById(id).style.opacity == 0) {
        opacity(id, 0, 101, millisec);
    } else {
        opacity(id, 101, 0, millisec);
    }
} 

function shiftOpacityUp(id, millisec) {
    //element is invisible, make it visible
        opacity(id, 0, 101, millisec);
} 


function shiftOpacityDown(id, millisec) {
    //element is visible, make it invisible	
        opacity(id, 101, 0, millisec);
} 

// Function for displaying and hiding of the content areas "info" and "products" when activating any product hyperlink in the explorer menu.

function prodEin() {
	var x = document.getElementById("info");
	var y = document.getElementById("prod");
		x.style.display="none";
		y.style.display="block";
	}
	
function picWeg() {
	Effect.toggle('toggle_vid', 'appear');
	Effect.toggle('picweg', 'appear', { duration: 0.5 });
}
	
//	Folgende Funktion wird nicht verwendet
//function prodAus() {
//	var x = document.getElementById("info");
//	var y = document.getElementById("prod");
//	if (y.style.display="block") {
//		y.style.display="none";		
//		x.style.display="block";
//	}



/* PIC ROTATOR */

//  Anleitung:
// DIV muss eindeutigen id namen haben und CSS styles die position entweder relativ oder absolut
// Bilder müssen absolut postioniert werden und top und left von 0
// Bilder können in Links eingebettet werden.
// wenn kein href angegeben sondern nut title der title wird zu myfunction übergeben und angezeigt

/* Beispleie Bilderlinks:

<a href="http://www.einLink.at/" ><img title="Picture 2" src="http://www.einLink.at/StdImages/Two.gif" width="200" height="200" /></a>
<a title="MyFunction" ><img title="Call function MyFunction" src="../web/scripts/www.einLink.at/StdImages/Three.gif" width="200" height="200" /></a>
<img title="Picture 4" src="http://www.einLink.at/StdImages/Four.gif" width="200" height="200" />

*/

//  Initialisierung
// normalerweise vom <body> tag aus mit onload
// melInitSlideShow(melid,melspd,melhold,meltxt,melauto)
// parameter 0 = eindeutiger ID name von übergeordnetem DIV                       (string)
// parameter 1 = (optional) Geschwindigkeit des fade effekts in milliSekunden.    (digits, default 1000)
// parameter 2 = (optional) Zeit die bei einem Bild gewartet wird bis zum nächsten(digits, default 4000)
// parameter 3 = (optional) Klassenname des DIVS das die Bilder Titel enthält     (string)
// parameter 4 = (optional) um die rotation automatisch zu starten                (string)
//
// Nachfolgende aufrufe der melInitSlideShow dürfen parameter 1 und 2 ändern.

// **** Anleitung Steuerung (Rotate)
// Die Slideshow wird gestartet wenn folgende Funktion aufgerufen wird:
// melSlideShow('tst',1,'auto');
// erklärung:
// parameter 0 = Eindeutige ID vom umgebdenen DIV                                       (string)
// parameter 1 = 1 rotiere forwärts, -1 to rotiere rückwärts, 0 um rotation anzuhalten. (1, -1 or 9)
// parameter 2 = (optional) um automatisch rotieren zu lassen.                                             (string)

// **** Anleitung Steuerung (GoTo)
// Die Slideshow kann angewiesen werden zu einem gewissen Bild zu springen indem folgende Funktion aufgerufen wird:
// melSlideShowGoTo('tst',0);
// erklärung:
// parameter 0 = Eindeutige ID vom umgebdenen DIV                                      (string)
// parameter 1 = die Bildnummer zu der gesprungen werden soll                                                    (1 to n)

/* Beispiele Abspielfunktionen links:
<input type="button" value="Forward" onclick="melSlideShow('tst',1);" />
<input type="button" value="Auto Forward" onclick="melSlideShow('tst',1,'auto');" />
<input type="button" value="Auto Stop" onclick="melSlideShow('tst',0,'auto');" />
<input type="button" value="Auto Back" onclick="melSlideShow('tst',-1,'auto');" />
<input type="button" value="Back" onclick="melSlideShow('tst',-1);" />

*/

// NACHFOLGENDES NICHT ÄNDERN!

function melBAnimator(melmde,melobj,melsrt,melfin,meltime){
 if (typeof(melobj)=='string'){ melobj=document.getElementById(melobj); }
 if (!melobj||(!melsrt&&!melfin)) return;
 var meloop=melobj[melmde.replace(/[-#]/g,'')+'oop'];
 if (meloop){
  clearTimeout(meloop.to);
  if (meloop.srtfin[0]==melsrt&&meloop.srtfin[1]==melfin&&melmde.match('#')) meloop.update([meloop.data[0],(meloop.srtfin[0]==meloop.data[2])?melfin:melsrt],meltime);
  else meloop.update([melsrt,melfin],meltime);
 }
 else melobj[melmde.replace(/[-#]/g,'')+'oop']=new melBAnimatorOOP(melmde,melobj,melsrt,melfin,meltime);
}

function melBAnimatorOOP(melmde,melobj,melsrt,melfin,meltime){
 this.srtfin=[melsrt,melfin];
 this.to=null;
 this.obj=melobj;
 this.mde=melmde.replace(/[-#]/g,'');
 this.update([melsrt,melfin],meltime);
}

melBAnimatorOOP.prototype.update=function(melsrtfin,meltime){
 this.time=meltime||this.time||2000;
 if (melsrtfin[0]==melsrtfin[1]) return;
 this.data=[melsrtfin[0],melsrtfin[0],melsrtfin[1]];
 this.srttime=new Date().getTime();
 this.cng();
}

melBAnimatorOOP.prototype.cng=function(){
 var melms=new Date().getTime()-this.srttime;
 this.data[0]=(this.data[2]-this.data[1])/this.time*melms+this.data[1];
 if (this.mde!='opacity') this.obj.style[this.mde]=this.data[0]+'px';
 else  this.opacity(this.data[0]);
 if (melms<this.time) this.to=setTimeout(function(meloop){return function(){meloop.cng();}}(this), 10);
 else {
  if (this.mde!='opacity') this.obj.style[this.mde]=this.data[2]+'px';
  else  this.opacity(this.data[2]);
 }
}

melBAnimatorOOP.prototype.opacity=function(melopc){
 if (melopc<0||melopc>100){ return; }
 this.obj.style.filter='alpha(opacity='+melopc+')';
 this.obj.style.opacity=this.obj.style.MozOpacity=this.obj.style.KhtmlOpacity=melopc/100-.001;
}

function melInitSlideShow(melid,melspd,melhold,meltxt,melauto){
 var melp=document.getElementById(melid);
 if (!melp.slideshow) melp.slideshow=new melSlideShowOOP(melp,melspd,melhold,meltxt,melauto);
 else {
  var meloop=melp.slideshow;
  meloop.spd=melspd||meloop.spd;
  meloop.hold=melhold||meloop.hold;
 }
}

function melSlideShowOOP(melp,melspd,melhold,meltxt,melauto){
 this.imgs=melp.getElementsByTagName('IMG');
 for (var mel0=0;mel0<this.imgs.length;mel0++){
  melBAnimator('opacity',this.imgs[mel0],(mel0==0)?90:10,(mel0==0)?100:0,10);
  melES(this.imgs[mel0],{zIndex:(mel0>0)?'0':'1',left:(melp.offsetWidth-this.imgs[mel0].offsetWidth)/2+'px',top:(melp.offsetHeight-this.imgs[mel0].offsetHeight)/2+'px',cursor:(this.imgs[mel0].parentNode.tagName.toUpperCase()=='A')?'pointer':'default'});
  if (this.imgs[mel0].style.cursor=='pointer'){
   this.imgs[mel0].link=this.imgs[mel0].parentNode.href||this.imgs[mel0].parentNode.title||null;
   this.imgs[mel0].parentNode.removeAttribute('title');
   this.imgs[mel0].onclick=function(){
     if (window[this.link]) window[this.link](this);
     else if (this.link) window.top.location=this.link;
    }
  }
  if (meltxt){
   this.imgs[mel0].txt=melES('DIV',{visibility:(this.imgs[mel0].title)?'visible':'hidden'},melp,this.imgs[mel0].title||'');
   this.imgs[mel0].txt.className=meltxt;
   melBAnimator('opacity',this.imgs[mel0].txt,(mel0==0)?90:10,(mel0==0)?100:0,10);
   this.imgs[mel0].removeAttribute('title');
  }
 }
 this.p=melp;
 this.cnt=0;
 this.spd=melspd||1000;
 this.hold=melhold||this.spd*4;
 this.to=null;
 if (melauto) this.to=setTimeout(function(meloop){return function(){meloop.auto(1);}}(this),this.hold);
}

melSlideShowOOP.prototype.rotate=function(melud,melgoto){
 melES(this.imgs[this.cnt],{zIndex:'0'});
 melBAnimator('opacity',this.imgs[this.cnt],this.imgs[this.cnt]['opacityoop'].data[0],0,this.spd)
 if (this.imgs[this.cnt].txt) melBAnimator('opacity',this.imgs[this.cnt].txt,this.imgs[this.cnt].txt['opacityoop'].data[0],0,this.spd)
 this.cnt+=melud||0;
 if (melgoto) this.cnt=melgoto-1;
 if (this.cnt>=this.imgs.length) this.cnt=0;
 if (this.cnt<0) this.cnt=this.imgs.length-1;
 melES(this.imgs[this.cnt],{zIndex:'1'});
 melBAnimator('opacity',this.imgs[this.cnt],this.imgs[this.cnt]['opacityoop'].data[0],100,this.spd)
 if (this.imgs[this.cnt].txt) melBAnimator('opacity',this.imgs[this.cnt].txt,this.imgs[this.cnt].txt['opacityoop'].data[0],100,this.spd)
}

melSlideShowOOP.prototype.auto=function(melud){
 this.rotate(melud);
 this.to=setTimeout(function(meloop){return function(){meloop.auto(melud);}}(this),this.hold);
}

function melES(melele,melstyle,melp,meltxt){
 if (typeof(melele)=='string'){ melele=document.createElement(melele); }
 for (key in melstyle){ melele.style[key]=melstyle[key]; }
 if (melp){ melp.appendChild(melele); }
 if (meltxt){ melele.appendChild(document.createTextNode(meltxt)); }
 return melele;
}

function melSlideShow(melid,melud,melauto){
 var meloop=document.getElementById(melid).slideshow;
 if (!meloop) return false;
 clearTimeout(meloop.to);
 if (!melauto) meloop.rotate(melud);
 else if (melud) meloop.auto(melud);
}

function melSlideShowGoTo(melid,melnu){
 var meloop=document.getElementById(melid).slideshow;
 if (!meloop||!meloop.imgs[melnu-1]) return false;
 clearTimeout(meloop.to);
 meloop.rotate(0,melnu)
}


function MyFunction(img){
 alert(img.src);
}

// POPUP 

// www.web-toolbox.net , W. Jansen
// Übergabeparameter: bildquelle, -breite und -höhe
// hand over parameters for source, width and height

//Aufruf erfolgt z.B. durch:
//<a href="javascript:BildFenster02('foto-gross.jpg','240','180')">kleines Foto</a>


function BildFenster02(bildurl,b,h)
{
var eigenschaften,sbreite,shoehe,fenster,b,h;

// wenn eine feste Position für die Anzeige gewünscht wird
// dann für die Variable 'FestePosition' ein "ja" eintragen
// und die X- / Y-Werte (linke obere Ecke) hier eintragen

var FestePosition = "ja";  // "ja" oder "nein" eintragen
VonLinks = 20;
VonOben = 20;

if(FestePosition == "ja") {
x = VonLinks;
y = VonOben;

} else {

// stellt die Bildschirmabmessungen fest
var ns6 = (!document.all && document.getElementById);
var ie4 = (document.all);
var ns4 = (document.layers);

if(ns6||ns4) {
sbreite = innerWidth;
shoehe = innerHeight;
}
else if(ie4) {
sbreite = document.body.clientWidth;
shoehe = document.body.clientHeight;
//shoehe = document.documentElement.clientHeight;
}

alert("festgestellte Höhe: " + shoehe);

x = (sbreite-b)/2;
y = (shoehe-h)/2;

}

eigenschaften="left="+x+",top="+y+",screenX="+x+",screenY="+y+",width="+b+",height="+h+",menubar=no,toolbar=no,statusbar=0";

fenster=window.open("","",eigenschaften);
fenster.focus();
fenster.document.open();
with (fenster) {
  document.write("<html><head>");
  // geändert 2004 für Mozilla
  document.write('<scr' + 'ipt type="text/javascr' + 'ipt" language="JavaScr' + 'ipt">');
  // bei click  schliessen , on click close
  document.write("function click() { window.close(); } ");
  document.write("document.onmousedown=click ");
  // geändert 2004 für Mozilla
  document.write('</scr' + 'ipt>');
  document.write("<title>klick to close</title></head>");
  // bei Focusverlust schliessen, close if window looses focus
  // Zeile geändert Aug 2003 (Dreamweaver machte Probleme)
  document.write("<" + "body onblur='window.close()';");
  document.write("marginwidth='0' marginheight='0' leftmargin='0' topmargin='0'>");
  document.write("<img src='"+ bildurl +"' border='0'>");
  document.write("</body></html>");
  fenster.document.close();
}
}
