function cm_bwcheck(){
	//In theory we should use object detection, but this script needs work-arounds for almost every browser...
	this.ver=navigator.appVersion
	this.agent=navigator.userAgent.toLowerCase()
	this.dom=document.getElementById?1:0
	this.ns4=(!this.dom && document.layers)?1:0;
	this.op=window.opera
	this.moz = (this.agent.indexOf("gecko") > -1 || window.sidebar)
	this.ie=this.agent.indexOf("msie")>-1 && !this.op
	if(this.op){
		this.op5=(this.agent.indexOf("opera 5")>-1 || this.agent.indexOf("opera/5")>-1)
		this.op6=(this.agent.indexOf("opera 6")>-1 || this.agent.indexOf("opera/6")>-1)
		this.op7=this.dom&&!this.op5&&!this.op6 //So all higher opera versions will use it
	}else if(this.moz) this.ns6 = 1
	else if(this.ie){
		this.ie4 = !this.dom && document.all
  	this.ie5 = (this.agent.indexOf("msie 5")>-1)
  	this.ie55 = (this.ie5 && this.agent.indexOf("msie 5.5")>-1)
  	this.ie6 = this.dom && !this.ie4 && !this.ie5 && ! this.ie55
	}
	this.mac=(this.agent.indexOf("mac")>-1)
	this.bw=(this.ie6 || this.ie5 || this.ie4 || this.ns4 || this.ns6 || this.op5 || this.op6 || this.op7)
  this.usedom= this.ns6||this.op7//Use dom creation
  this.reuse = this.ie||this.op7||this.usedom //Reuse layers
  this.px=this.dom&&!this.op5?"px":""
	return this
}

var bw = new cm_bwcheck();
/*Variable declaration*/

// switching index2.html
rld = true;
if ((bw.ie && !bw.mac) || bw.op || bw.moz) rld = false;

// skript -> flash menu item zeigen
function mOn(txt) {
	if(frames['rightiframe'].document.getElementById("field")) frames['rightiframe'].document.getElementById("field").innerHTML = strings[txt];
}

// skript -> flash menu item verstecken
function mOf() {
	if(frames['rightiframe'].document.getElementById("field")) frames['rightiframe'].document.getElementById("field").innerHTML = frames['rightiframe'].document.getElementById("def").value
}

// skript -> wechsel thumbnail und textbild - zeigen
function wt(num) {
	document.getElementById("p"+num).style.color = '#333';
	document.getElementById("t"+num).src  = eval("tnb"+num+".src");
}

// skript -> wechsel thumbnail und textbild - verstecken
function zt(num) {
	document.getElementById("p"+num).style.color = '#999';
	document.getElementById("t"+num).src  = tnb0.src;
}

// skript -> wechsel thumbnail auf der detailseite - zeigen
function ts(num) { document.getElementById("t"+num).src  = eval("tnb"+num+".src") }

// skript -> wechsel thumbnail auf der detailseite - verstecken
function te(num) { 	document.getElementById("t"+num).src  = tnb0.src; }

// skript -> wechsel produktbild/sortebild
function sr(path) { document.getElementById("produktbild").src = path }

// skript -> zurueck produktbild 
function st() { document.getElementById("produktbild").src = p0.src }

// skript -> oefnet popup fenster
function popup(url) {
	detail = window.open(url,'','copyhistory=no,directories=no,width=640,height=445,top=240,left=340,location=no,menubar=no,resizable=yes,scrollbars=no,status=no');
	// detail.focus();
}

// skript -> setVariable
function doPassVar(nr) {
	if(rld == false) {
		parent.window.document.quality.SetVariable("myVar", nr);
	}
}

// skript -> Show Detail Page (change if mac == true)
function sdp(winlink,maclink,ton) {
	if(rld == false) parent.rightiframe.location.href = winlink;
	else parent.location.href = maclink + '&ton=' + ton;
}

// skript -> flah objekt finden
function findeFlash (flash) {
    if (document.all) {
      if (document.all[flash]) { return document.all[flash]; }
      if (document.opera) {
        var movie = eval(window.document + flash);
        if (movie.SetVariable) { return movie; }
      }
      return;
    }
    if(document.layers) {
      if(document.embeds) {
        var movie = document.embeds[flash];
        if (movie.SetVariable) { return movie; }
      }
      return;
    }
    if (!document.getElementById) { return; }
    var movie = document.getElementById(flash);
    if (movie.SetVariable) { return movie; }
    var movies = movie.getElementsByTagName('embed');
    if (!movies || !movies.length) { return; }
    movie = movies[0];
    if (movie.SetVariable) { return movie; }
    return;
}

/* ### Navigation ### */
function init(it) {
	
	// product preview
	simple = (document.getElementById("bcover") ? false : true);
	dr = false; tstart = 0; tstop  = 0; tact = 0;

	// sniffer
	ie = null;
	agent = navigator.appName.toLowerCase();
	if(agent.indexOf('explorer')>-1) { ie = true; }
	else ie = false;

	// A part
	acoverW = 350; ainnerW = it*35; apos = 0; apart = 35;
	document.getElementById('acover').style.width = (acoverW-5) + 'px';
	document.getElementById('ainner').style.width = ainnerW + 'px';
	adiff = ainnerW-acoverW;
	if(ainnerW > 350) { document.getElementById('rs').style.visibility = "visible"; }

	// B part
	if(!simple) {
		bcoverH = 250; binnerH = it*25; bpos = 0; bpart = 25;
		document.getElementById('bcover').style.height = bcoverH + 'px';
		document.getElementById('binner').style.height = binnerH + 'px';
		bdiff = binnerH-bcoverH;
		
		// track
		if(it > 10) {
			tpos = 86; trackpoint = 218/it;
			document.getElementById('bar').style.visibility = "visible";		
			document.getElementById('track').style.height = trackpoint*10;
			document.getElementById('track').style.visibility = "visible";
		}
		
		// events
		// if(!ie) document.captureEvents(Event.MOUSEMOVE);
		document.onmousemove = mouse;
	}
}

function mouse(e) {
	if(ie == true) temp = event.clientY + document.body.scrollTop;
	else temp = e.clientY;
	if (temp < 0) { temp = 0; }  
	tact = temp;
	if(dr == true) {
		if(temp > tstart) {
			if((temp - tstart) > trackpoint) {
				tstart = temp;
				goscroll(0); goscroll(2);
			}
		}
		if(temp < tstart) {
			if(Math.abs((temp - tstart)) > trackpoint) {
				tstart = temp;
				goscroll(0); goscroll(1);
			}
		}
	}
	return true;
}

function goscroll(on) { run=on; if(run==1) left(); if(run==2) right() }

function left() {
	if(apos < 0 && run) {
		apos += apart;
		document.getElementById("ainner").style.left = apos + 'px';
		if(simple == false) {
			bpos += bpart;
			tpos -= trackpoint;
			document.getElementById("binner").style.top = bpos + 'px';
			document.getElementById("track").style.top = tpos + 'px';
		}
		checkButtons(apos);
		if(dr == false) setTimeout('left()',250);
	}
}

function right() {
	if(Math.abs(apos) <= adiff-apart && run) {
		apos -= apart;
		document.getElementById("ainner").style.left = apos + 'px';
		if(simple == false) {
			bpos -= bpart;
			tpos += trackpoint;
			document.getElementById("binner").style.top = bpos + 'px';
			document.getElementById("track").style.top = tpos + 'px';
		}
		checkButtons(apos);
		if(dr == false) setTimeout('right()',250);
	}
}

function startDrg() { dr = true; tstart = temp }
function stopDrg()  { dr = false; tstop = temp }

function checkButtons(x) {
	if(apos < 0) document.getElementById('ls').style.visibility = "visible";
	else document.getElementById('ls').style.visibility = "hidden";

	if(Math.abs(apos) < ainnerW - acoverW) document.getElementById('rs').style.visibility = "visible";
	else document.getElementById('rs').style.visibility = "hidden";
}

function correct() {
	if(frames['rightiframe'].document.getElementById("ta") && bw.mac == true) {
		frames['rightiframe'].document.getElementById("ta").style.height = "75px";
	}
}

function sendKontaktForm()
{
	if (!checkForm())
		return false;
	
	if (document.getElementById("thema").value == "0")
	{
		alert(unescape("Bitte w%E4hlen Sie einen Betreff aus."));
		return false;
	}
				
	document.feedback.submit();
}

