// Javascript Fehler unterdruecken
onerror = stopError;
function stopError()
{
return true;
}



// Umgebungsvariablen auslesen

	// convert all characters to lowercase to simplify testing
    var agt=navigator.userAgent.toLowerCase();

    // *** BROWSER VERSION ***
    // Note: On IE5, these return 4, so use is_ie5up to detect IE5.
    var is_major = parseInt(navigator.appVersion);
    var is_minor = parseFloat(navigator.appVersion);

    // Note: Opera and WebTV spoof Navigator.  We do strict client detection.
    // If you want to allow spoofing, take out the tests for opera and webtv.
    var is_nav  = ((agt.indexOf('mozilla')!=-1) && (agt.indexOf('spoofer')==-1)
                && (agt.indexOf('compatible') == -1) && (agt.indexOf('opera')==-1)
                && (agt.indexOf('webtv')==-1) && (agt.indexOf('hotjava')==-1));
    var is_nav2 = (is_nav && (is_major == 2));
    var is_nav3 = (is_nav && (is_major == 3));
    var is_nav4 = (is_nav && (is_major == 4));
    var is_nav4up = (is_nav && (is_major >= 4));
    var is_navonly      = (is_nav && ((agt.indexOf(";nav") != -1) ||
                          (agt.indexOf("; nav") != -1)) );
    var is_nav6 = (is_nav && (is_major == 5));
    var is_nav6up = (is_nav && (is_major >= 5));
    var is_gecko = (agt.indexOf('gecko') != -1);


    var is_ie     = ((agt.indexOf("msie") != -1) && (agt.indexOf("opera") == -1));
    var is_ie3    = (is_ie && (is_major < 4));
    var is_ie4    = (is_ie && (is_major == 4) && (agt.indexOf("msie 4")!=-1) );
    var is_ie4up  = (is_ie && (is_major >= 4));
    var is_ie5    = (is_ie && (is_major == 4) && (agt.indexOf("msie 5.0")!=-1) );
    var is_ie5_5  = (is_ie && (is_major == 4) && (agt.indexOf("msie 5.5") !=-1));
    var is_ie5up  = (is_ie && !is_ie3 && !is_ie4);
    var is_ie5_5up =(is_ie && !is_ie3 && !is_ie4 && !is_ie5);
    var is_ie6    = (is_ie && (is_major == 4) && (agt.indexOf("msie 6.")!=-1) );
    var is_ie6up  = (is_ie && !is_ie3 && !is_ie4 && !is_ie5 && !is_ie5_5);

    // KNOWN BUG: On AOL4, returns false if IE3 is embedded browser
    // or if this is the first browser window opened.  Thus the
    // variables is_aol, is_aol3, and is_aol4 aren't 100% reliable.
    var is_aol   = (agt.indexOf("aol") != -1);
    var is_aol3  = (is_aol && is_ie3);
    var is_aol4  = (is_aol && is_ie4);
    var is_aol5  = (agt.indexOf("aol 5") != -1);
    var is_aol6  = (agt.indexOf("aol 6") != -1);

    var is_opera = (agt.indexOf("opera") != -1);
    var is_opera2 = (agt.indexOf("opera 2") != -1 || agt.indexOf("opera/2") != -1);
    var is_opera3 = (agt.indexOf("opera 3") != -1 || agt.indexOf("opera/3") != -1);
    var is_opera4 = (agt.indexOf("opera 4") != -1 || agt.indexOf("opera/4") != -1);
    var is_opera5 = (agt.indexOf("opera 5") != -1 || agt.indexOf("opera/5") != -1);
    var is_opera5up = (is_opera && !is_opera2 && !is_opera3 && !is_opera4);

    var is_webtv = (agt.indexOf("webtv") != -1); 

    var is_TVNavigator = ((agt.indexOf("navio") != -1) || (agt.indexOf("navio_aoltv") != -1)); 
    var is_AOLTV = is_TVNavigator;

    var is_hotjava = (agt.indexOf("hotjava") != -1);
    var is_hotjava3 = (is_hotjava && (is_major == 3));
    var is_hotjava3up = (is_hotjava && (is_major >= 3));


myload=0;

imageUrl="http://www.magnettech.net/images/";

// blur focus

function bluur(x)
	{
	if(x.blur)x.blur();
	}

// Per onClick zu einer anderen Seite

function urlopen(url)
	{
	location.href=url;
	return false;
	}

// preload images, mouseover



function initImages()
	{
	
	// Header-Bg löschen
	
	posImages(0);
	
	imo = new Array(); // Mouseover-Bilder
	ino = new Array(); // Normal-Zustand-Bilder
	if (document.images)
		{
		for (i=0;i<50;i++) 
			{
			ll=0;
			if (is_nav4) ll=document.layers.length;
			for (l=-1; l<ll; l++)
				{
				dok=document;
				if ((is_nav4)*(l!=-1)) dok=document.layers[l].document;
				if (dok.images["b"+i])
					{
					// Folder ermitteln
					url=dok.images["b"+i].src;
					found=url.split("/");
					nfound=found[found.length-1].split(".");
					nlength=nfound[0].length-1;
					folder=url.replace(found[found.length-1],"");
					name=nfound[0].substr(0,nlength);
					imo[i] = new Image(); imo[i].src = folder+name+"1."+nfound[1];
					ino[i] = new Image(); ino[i].src = url;
					}
				}
			}
		}
	}

var imgline = new Array();
imgline=[211,55,127,213,116,83,132,178,211,55,127,213,116,83,132,178];

	
function posImages(walt)
	{
	if (checkElement("headerbg"))
		{
		useElement("headerbg").style.backgroundImage="none";
		
		// Header - Fotos gleichmäßig verteilen
		
		maxw=getWindowWidth()-358;
		if (maxw!=walt)
			{
			for(i=1;i<17;i++)
				{
				useElement("himg"+i).style.visibility="hidden";
				useElement("himg"+i).style.left=0;
				}
			w=0;
			for (i=1;i<17;i++)
				{
				w=w+imgline[i-1]+10;
				if (w+imgline[i]>maxw)
					 {
					 space=(maxw-w)/(i-1);
					 ww=14;
					 for (ii=1;ii<=i;ii++)
					 	{
						useElement("himg"+ii).style.left=Math.round(ww)+"px";
						useElement("himg"+ii).style.visibility="visible";
						ww=ww+imgline[(ii-1)]+10+space;
						}
					i=17;
					}
				}
			}
		}
	setTimeout("posImages("+maxw+")",500);
	}



function over(x,lay) // x=Bildnummer lay=Ebenen-id
	{
	if (myload==0) return;
	dok=document;
	if (lay) dok=getdok(lay);
	xx="b"+x;
	dok.images[xx].src = imo[x].src;
	}

function out(x,lay)
	{
	if (myload==0) return;
	dok=document;
	if (lay) dok=getdok(lay);
	xx="b"+x;
	if (dok.images[xx].src.indexOf("1.")>-1) dok.images[xx].src = ino[x].src;
	}
	
// Navigationsbutton Rollover

function checkElement(el)
	{
	if (!is_ie4)
		{
		if (document.getElementById(el)) return true;
		}
	else
		{
		if (document.all[el]) return true;
		}
	return false;
	}

function useElement(el)
	{
	if (is_ie4) return document.all[el];
	return document.getElementById(el);
	}

function nover(x) // x=id 
	{
	if (myload==0) return;
	if (checkElement("navi_"+x))
		{
		useElement("navi_"+x).style.backgroundImage="url("+imageUrl+"navig/navi_ro.gif)";
		}
	}

function nout(x,t) // x=id, t=Navigationstiefe 0..1
	{
	if (myload==0) return;
	if (checkElement("navi_"+x))
		{
		useElement("navi_"+x).style.backgroundImage="url("+imageUrl+"navig/navi"+t+".gif)";
		}
	}


// Seitenbreite feststellen

function getWindowWidth()
	{
	if ((is_nav)+(is_opera5up)) 
		{
		return window.innerWidth;
		}
	else
		{
		return document.body.clientWidth;
		}
	}

	
// PopUp Fenster öffnen

var ioWindow;

function openWindow(url,x,y)
	{
	if (ioWindow) {if (!ioWindow.closed) ioWindow.close()}
	h=screen.availHeight-30;
	w=screen.availWidth-30;
	t=(h-y)/2; if (t<0) t=0;
	u=(w-x)/2; if (w<0) w=0;
	ioWindow = window.open(url,"popup",'width='+x+',height='+y+',left='+u+',top='+t+',scrollbars=yes');
	ioWindow.focus();
	}




	
// Ebenen ansprechen nach Browserversion

function getLayerStyleRef(layname)
	{
	if (is_nav4) return document.layers[layname];
	if (is_ie4) return document.all[layname].style;
	if (is_ie5up) return document.getElementById(layname).style;
	if (is_opera5up) return document.getElementById(layname).style;
	if (is_nav6up) return document.getElementById(layname).style;
	return null;
	}
	

	

// Lesezeichen setzen

function Bookmark()
	{
	url=document.URL;
	title=document.title;
	if (is_nav4) alert('Bitte drücken Sie die beiden Tasten "Strg"+"d" gleichzeitig, um ein Lesezeichen für diese Seite anzulegen.')
	else if (is_nav6up) alert('Bitte drücken Sie die beiden Tasten "Strg"+"g" gleichzeitig, um ein Lesezeichen für diese Seite anzulegen.')
	else if (is_opera) alert('Bitte drücken Sie die beiden Tasten "Strg"+"t" gleichzeitig, um ein Lesezeichen für diese Seite anzulegen.')
	else window.external.AddFavorite(url,title)
	}

	

	
// Form PopUp Fenster öffnen

var formWindow;

function openFormWindow(url,x,y)
	{
	if (formWindow) {if (!formWindow.closed) formWindow.close()}
	h=screen.availHeight-30;
	w=screen.availWidth-30;
	t=(h-y)/2; if (t<0) t=0;
	u=(w-x)/2; if (w<0) w=0;
	formWindow = window.open(url,"formpopup",'width='+x+',height='+y+',left='+u+',top='+t+',scrollbars=yes');
	formWindow.focus();
	}
	
// Formular-Buttons Rollover

function butover(x)
	{
	if (is_nav4) return;
	url=x.src;
	found=url.split("/");
	nfound=found[found.length-1].split(".");
	nlength=nfound[0].length-1;
	folder=url.replace(found[found.length-1],"");
	name=nfound[0].substr(0,nlength);
	x.src = folder+name+"1."+nfound[1];
	}
	
function butout(x)
	{
	if (is_nav4) return;
	url=x.src;
	found=url.split("/");
	nfound=found[found.length-1].split(".");
	nlength=nfound[0].length-1;
	folder=url.replace(found[found.length-1],"");
	name=nfound[0].substr(0,nlength);
	x.src = folder+name+"0."+nfound[1];
	}
	

	

