var BrowserType = function(){
	var sBrowserType = navigator.userAgent.toLowerCase();
	var oReturn =  {
		bIsWebKit : sBrowserType.indexOf("applewebkit") > -1,
		bIsSafari : sBrowserType.indexOf("safari") > -1,
		bIsKonq: navigator.product != null && navigator.product.toLowerCase().indexOf("konqueror") > -1,
		bIsOpera : sBrowserType.indexOf("opera") > -1,
		bIsXML : document.contentType != null && document.contentType.indexOf("xml") > -1,
		bUseDOM : true,
		nOperaVersion : null,
		nGeckoBuildDate : null,
		nWebKitVersion : null,

		trace: function() {
			alert('sBrowserType: '+sBrowserType+"\n"
			     +'bIsIE: ' +this.bIsIE +"\n"
			     +'bIsIEMac: ' +this.bIsIEMac +"\n"
			     +'bIsGecko: ' +this.bIsGecko +"\n"
			     +'bIsWebKit: ' +this.bIsWebKit +"\n"
			     +'bIsSafari: ' +this.bIsSafari +"\n"
			     +'bIsKonq: ' +this.bIsKonq +"\n"
			     +'bIsOpera: ' +this.bIsOpera +"\n"
			     +'nOperaVersion: ' +this.nOperaVersion +"\n"
			     +'bIsXML: ' +this.bIsXML +"\n"
			     +'bUseDOM: ' +this.bUseDOM +"\n"
			     +'nGeckoBuildDate: ' +this.nGeckoBuildDate +"\n"
			     +'nWebKitVersion: ' +this.nWebKitVersion +"\n"
			);
		},

		displayTableInline: function() {
			if      ( this.bIsIE || this.bIsIEMac ) {
				return 'block';	
			}
			else if ( this.bIsOpera || this.bIsGecko || this.bIsSafari || this.bIsKonq ) {
				return 'table-row';	
			}
			else {
				return '';
			}
		}
	};
	
	oReturn.bIsKHTML = oReturn.bIsWebKit || oReturn.bIsKonq;
	oReturn.bIsGecko = !oReturn.bIsWebKit && navigator.product != null && navigator.product.toLowerCase() == "gecko";
	if(oReturn.bIsGecko && sBrowserType.match(/.*gecko\/(\d{8}).*/)){ 
		oReturn.nGeckoBuildDate = new Number(sBrowserType.match(/.*gecko\/(\d{8}).*/)[1]) ;
	};
	if(oReturn.bIsOpera && sBrowserType.match(/.*opera(\s|\/)(\d+\.\d+)/)){ 
		oReturn.nOperaVersion = new Number(sBrowserType.match(/.*opera(\s|\/)(\d+\.\d+)/)[2]) ;
	};
	oReturn.bIsIE = sBrowserType.indexOf("msie") > -1 && !oReturn.bIsOpera && !oReturn.bIsKHTML && !oReturn.bIsGecko;
	oReturn.bIsIEMac = oReturn.bIsIE && sBrowserType.match(/.*mac.*/) != null;
	if(oReturn.bIsIE || (oReturn.bIsOpera && oReturn.nOperaVersion < 7.6)){ 
		oReturn.bUseDOM = false ;
	};
	if(oReturn.bIsWebKit && sBrowserType.match(/.*applewebkit\/(\d+).*/)){ 
		oReturn.nWebKitVersion = new Number(sBrowserType.match(/.*applewebkit\/(\d+).*/)[1]) ;
	};

	if(!oReturn.bIsIEMac && !oReturn.bIsGecko && document.createElementNS){
		try {
			document.createElementNS(sNameSpaceURI, "i").innerHTML = "";
		} catch(e){
			oReturn.bIsXML = true;
		};
	};
	
	return oReturn;
}();
//falls keine Inline-Displays auszufuehren sind.
//BrowserType.displayTableInline=function() {return'';}

// basic MANTED(R)-functions
// mouseover topnavigation
var act = 1;
function over01(x){
	if(document.all) x.style.cursor = "hand"; 
	else x.style.cursor = "pointer"; 
		
	if(x.className=="high"){
		act = 0;
		return;
	}
	else{
		act = 1;
	}
	if(!x.childNodes) return;
	if(x.childNodes[0].innerHTML) x.innerHTML=x.childNodes[0].innerHTML;
	x.style.backgroundPosition = "0px -34px";
	x.style.color="#000000";
}

function out01(x){
	if(act==0) return;
	x.style.backgroundPosition = "0px 0px";
	x.style.color="#ffffff";
}



// mouseover leftnavigation
function over02(x){
	if(document.all) x.style.cursor = "hand"; 
	else x.style.cursor = "pointer"; 
	

	if(!x.style) return;
	oldcolor = x.style.backgroundColor;
	x.style.backgroundColor="#FCD116";
}

function out02(x){
	if(!x.style) return;
	x.style.backgroundColor=oldcolor;
}



// mouseover leftnavigation
function over03(x){
	if(!x.style) return;
	if(document.all) x.style.cursor = "hand"; 
	else x.style.cursor = "pointer"; 

	x.style.textDecoration = 'underline';
}

function out03(x){
	if(!x.style) return;
	x.style.textDecoration = 'none';
}


//topnavigation & leftnavigation
function linkme(x){
if(x) document.location.href = x;
else document.location.href = "#";
}

function linkme_blank(x){
	window.open(x,"_blank");
}


//sitemap
function openSitemap(url) {
	satellit =window.open(url,"SiteMap","location=yes,menubar=yes,resizable=yes,scrollbars=yes,status=yes,toolbar=yes");
	satellit.window.focus();
}
//kontakt
if(document.layers){
height00 = 680;
}
else{
height00 = 650;
}
function openKontakt(url) {
	satellit =eval('window.open(url,"Form","location=no,menubar=no,resizable=no,scrollbars=no,status=no,toolbar=no,width=830,height='+height00+'")');
	satellit.window.focus();
}
//zoom
function zoom(img,w,h){
satellit =eval('window.open(img,"Form","location=no,menubar=no,resizable=yes,scrollbars=no,status=no,toolbar=no,width='+w+',height='+h+'")');
	satellit.window.focus();

}

// CI-2007 extensions
function switchMenue(mn,par,nx,modus) {
	var obj;
	var parent;
	var next;

	if ( mn == '' ) { return false; }
	obj = document.getElementById(mn);
	if ( !obj ) { return false; }
	
	if ( modus != 'show' && modus != 'hide' ) {
		modus = 'switch';
	}
	if ( modus == 'switch' ) {
		if ( obj.style.display == 'none' ) {
			modus = 'show';
		}
		else {
			modus = 'hide';
		}
	}

	if ( par != '' ) {parent = document.getElementById(par); }
	if ( next != '' ) {next = document.getElementById(nx); }
	if ( modus == 'show' ) {
		obj.style.display = 'block';
		if ( parent ) {
			parent.style.borderBottom="1px solid #fff";
		}
		if ( next ) {
			next.style.paddingTop="6px";
		}
	}
	else {
		obj.style.display = 'none';
		if ( parent ) {
			parent.style.borderBottom="0px solid #ffffff";
		}
		if ( next ) {
			next.style.paddingTop="0px";
		}
	}

}

// vorbereitung ajax-Extension
// Warenkorb Fahrgestelle
function wk_fz_clicked(aForm, rr_mwf_id) {
	var isAjax;
	isAjax = execAjax_Warenkorb('WK_FZ',rr_mwf_id);
									// konventionelle Form, falls Ajax schief geht.
	if ( ! isAjax ) {
		if ( aForm && aForm.toggle ) {
			aForm.toggle.value = rr_mwf_id;
			aForm.submit();
		}
	}
	return false;
}
function wk_fhs_clicked(aForm, zeichnungs_id) {

	var isAjax;
	isAjax = execAjax_Warenkorb('WK_FHS',zeichnungs_id);
									// konventionelle Form, falls Ajax schief geht.
	if ( ! isAjax ) {
		if ( aForm && aForm.toggle ) {
			aForm.toggle.value = zeichnungs_id;
			aForm.submit();
		}
	}
	return false;
}
function wk_ap_clicked(aForm, zeichnungs_id, idcounter) {

	var isAjax;
	isAjax = execAjax_Warenkorb('WK_AP',zeichnungs_id, idcounter);
									// konventionelle Form, falls Ajax schief geht.
	if ( ! isAjax ) {
		if ( aForm && aForm.toggle ) {
			aForm.toggle.value = zeichnungs_id;
			aForm.submit();
		}
	}
	return false;
}
function wk_wbt_clicked(aForm, wbt_id) {
	var isAjax;
	isAjax = execAjax_Warenkorb('WK_WBT',wbt_id);
									// konventionelle Form, falls Ajax schief geht.
	if ( ! isAjax ) {
		if ( aForm && aForm.toggle ) {
			aForm.toggle.value = wbt_id;
			aForm.submit();
		}
	}
	return false;
}
function wk_rlt_clicked(aForm, rlt_id) {
	var isAjax;
	isAjax = execAjax_Warenkorb('WK_RLT',rlt_id);
									// konventionelle Form, falls Ajax schief geht.
	if ( ! isAjax ) {
		if ( aForm && aForm.toggle ) {
			aForm.toggle.value = rlt_id;
			aForm.submit();
		}
	}
	return false;
}
function wk_sqt_clicked(aForm, sqt_id) {
	var isAjax;
	isAjax = execAjax_Warenkorb('WK_SQT',sqt_id);
									// konventionelle Form, falls Ajax schief geht.
	if ( ! isAjax ) {
		if ( aForm && aForm.toggle ) {
			aForm.toggle.value = sqt_id;
			aForm.submit();
		}
	}
	return false;
}


// createXMLByText kann mit einem Parserfehler fehlschlagen
// - dieser Fehler muss für jeden Browser unterschiedlich ausgewertet werden 
// - da aber das XML-Objekt + eventuell Fehlermeldung zurueckgegeben werden muss, werden beide
//  in einem "Container" zusammengefasst 
// Benutzung:
// var xml = createXMLByTextExtend(xmltext);
// if( ! xml.isError()  ) {
//    var xmlobj = xml.getXML();   // 
//    xmlobj.getElementsByTagName(...);
// }
// else {
//   alert(xml.getError());
// }
function xmlContainer() {
	this.xml;				// XML-Objekt, pruefung mit isValid() ob es gesetzt wurde
	this.error = false;		// gibt an, ob ein Parsererror vorliegt 
	this.errText = '';		// gibt die Fehlermeldung des Parsers an (muss gesetzt werden)
	
	this.isError = function() {
		return this.error;
	};
	this.getXML = function() {
		return this.xml;
	};
	this.getError = function() {
		return this.errText;
	};
	
	this.setXML = function(xmlObject) {
		this.xml = xmlObject;
	};
	this.setError = function(text) {
		this.errText = text;
		this.error = true;
	};
	this.isValid = function() {
		if( typeof this.xml == "undefined" ) { return false; }
		return true;
	};
}

// tja, Funktion kann leider keine 2 Dinge zurueckgeben (XML-Objekt + eventl Fehlermeldung)
// - wenn man also beides will, dann einfach createXMLByTextExtend() nutzen
// - Rueckgabe: 
//   Fehler: 0 
//   Erfolg: XML-Objekt
function createXMLByText(xmlString) {
    var xml = createXMLByTextExtend(xmlString);
	// beibehaltung der alten Schnittstelle
	if( !xml.isError() ) {
		return xml.getXML();
	}
    return 0;
}


// erzeugt ein XML-Objekt (Browserabhängig)
// - gibt ein Container-Objekt zurück, welches sowohl das XML-Objekt als auch die Fehlermeldung enthalten 
//   kann 
// Benutzung: siehe Kommentar "function xmlContainer()"
function createXMLByTextExtend(xmlString) {
    // fuehrende whitespaces entfernen 
    var clearedString = xmlString.replace(/^\s*/g, "");
    var container = new xmlContainer();
    // Firefox, Opera etc...
    if( typeof DOMParser != "undefined" ) {
        var parser = new DOMParser();
        var xmlObject = parser.parseFromString(clearedString, "text/xml");
		// falls ein Parsererror auftrat, dann wird hier ein gültiges XML-Objekt gesetzt, welches nur den 
		// Kindknoten 'parsererror' enthält'
		container.setXML(xmlObject);	
		
		// Parserfehler
		if( xmlObject.getElementsByTagName('parsererror').length > 0 ) {
			var fehler = getNodeValue(xmlObject,'parsererror');
			container.setError(fehler);
		}
    // IE
    } else if( typeof ActiveXObject != "undefined" ) {
        var xmlDoc=new ActiveXObject("Microsoft.XMLDOM");
        xmlDoc.async="false";
        xmlDoc.loadXML(clearedString);
		// falls ein Parsererror auftrat, dann wird hier ein IE-Spezial-Fehlerobjekt gesetzt 
		container.setXML(xmlDoc);
		
		if( xmlDoc.parseError.errorCode != 0 ) {
			var fehler = "Zeile: "+xmlDoc.parseError.line;
			fehler+=" Spalte: " + xmlDoc.parseError.linePos;
			fehler+=" Code: " + xmlDoc.parseError.errorCode;
			fehler+=" Grund: " + xmlDoc.parseError.reason;
			fehler+=" fehlerhafte Zeile: " + xmlDoc.parseError.srcText;
			container.setError(fehler);
		}
    }
    return container;
}


// gibt den Wert eines Knotens 'nodeName' zurueck 
// - dabei werden die Werte aller seiner Kindknoten zusammengefasst
//     - Ein Textknoten wird im XML-Objekt ebenfalls als ein Knoten dargestellt
// - ist dieser Knoten 'nodeName' merfach im XML-Objekt enthalten, dann werden alle Werte zusammengefuegt und 
//   als gesamter Wert zurueckgegeben
// - Hinweis: im Firefox werden aus \n zusätzliche "Textknoten", im IE nicht
function getNodeValue(xmlObject, nodeName) {
    var node = xmlObject.getElementsByTagName(nodeName);
    var childNodes;
    var value = "";
	// IE ignoriert \n in Textknoten 
	// Firefox erzeugt aus jedem \n einen leeren Textknoten (welcher mit der folgenden Schleife wieder zu einem 
	// Wert zusammengefasst wird)
    for( var i = 0; i < node.length; i++ ) {
        childNodes = node[i].childNodes;
        for( var j = 0; j < childNodes.length; j++) {
                value+= childNodes[j].nodeValue;
        }
   }
   return value;
}

