////////////////////////////////////////////////////////////////////////////////////////////////////
// this is an object that comes with JOUST but it's useful for the whole app!
////////////////////////////////////////////////////////////////////////////////////////////////////
function browserInfo() {
	this.code = 'unknown';
	this.version = 0;
	this.platform = 'win';
	var ua = navigator.userAgent;
	var i = ua.indexOf('WebTV');
	if (i >= 0) {
		this.code = 'WebTV';
		i += 6;
	} else {
		i = ua.indexOf('MSIE');
		if (i >= 0) {
			this.code = 'MSIE';
			i += 5;
		} else {
			i = ua.indexOf('Opera');
			if (i >= 0) {
				this.code = 'OP';
				i = ua.indexOf(') ') + 2;
			} else {
				i = ua.indexOf('Mozilla/');
				if (i >= 0) {
					this.code = 'NS';
					i += 8;
				}
			}
		}
	}
	this.version = parseFloat(ua.substring(i, i+4));
	if ( this.code == 'NS' ) {
		if ( this.version >= 5 ) { this.ns5 = true; this.ns4 = false; }
		else { this.ns4 = true; this.ns5 = false; }
		this.ie = false;
	} else if ( this.code == 'MSIE' ) {
		this.ie = true; this.ns4 = false; this.ns5 = false;
	}
	if (ua.indexOf('Mac') >= 0) {this.platform = 'Mac';}
	if (ua.indexOf('OS/2') >= 0) {this.platform = 'OS/2';}
	if (ua.indexOf('X11') >= 0) {this.platform = 'UNIX';}
	var v = this.version;
	var p = this.platform;
	var NS = (this.code == 'NS');
	var IE = (this.code == 'MSIE');
	var WTV = (this.code == 'WebTV');
	var OP = (this.code == 'OP');
	var OP32up = (OP && (v >= 3.2));
	var IE4up = (IE && (v >= 4));
	var NS3up = (NS && (v >= 3));
	this.canCache = NS3up || IE4up || OP32up || WTV;
	this.canOnMouseOut = this.canCache;
	this.canOnError = NS3up || IE4up || OP32up;
	this.canJSVoid = !((NS && !NS3up) || (IE && !IE4up) || (OP && (v < 3.5)));
	this.lineByLine = (v < 4);
	this.mustMoveAfterLoad = NS3up || (IE4up && (p != 'Mac')) || WTV;
	if (NS3up || IE4up || WTV) {
		this.reloadMethod = 'replace';
	} else {
		this.reloadMethod =  (NS && (v == 2.01) && (p != 'Win')) ? 'timeout' : 'href';
	}
	this.canFloat = NS || (IE && !((p == 'Mac') && (v >= 4) && (v < 5)));
	this.hasDHTML = ((NS || IE) && (v >= 4)) && !(IE && (p == 'Mac') && (v < 4.5));
	this.needLM = NS || (IE && (p == 'Mac') && (v >= 4.5));
	this.DHTMLRange = IE ? '.all' : '';
    this.DHTMLStyleObj = IE ? '.style' : '';
	this.DHTMLDivHeight = IE ? '.offsetHeight' : '.clip.height';
}
top.theBrowser = new browserInfo;
////////////////////////////////////////////////////////////////////////////////////////////////////
// this is needed to get handles to correct coordinates etc. of the various windows
////////////////////////////////////////////////////////////////////////////////////////////////////
function writeBody( hDocP, sOnLoadP, bgColorP, sTopP, bgImageP, bNeutralP ) {
	( sTopP ) ? sTopP = sTopP : sTopP = 'top';
	( bNeutralP ) ? bNeutralP = bNeutralP : bNeutralP = 'override';
	bgColorP = (bgColorP)?((bgColorP.substr(0,1)=='#')?'BGCOLOR="'+bgColorP+'"':'BACKGROUND="'+bgColorP+'"'):'#ffffff';
	if ( sOnLoadP ) { ( sOnLoadP == '' ) ? sOnLoadP = null : sOnLoadP = sOnLoadP }
	if ( top.theBrowser.ie || top.theBrowser.ns5 ) { 
		sLcl = '<BODY ' + bgColorP + ' STYLE="width:100%;height:100%';
		if ( bNeutralP == 'override' ) { sLcl += ';margin-top:0px;margin-left:0px'; }
		sLcl += '" ONLOAD="javascript:' + sTopP + '.getXY(window)' + ( ( sOnLoadP ) ? ';' + sOnLoadP : '' ) + '" ONRESIZE="javascript:window.location.reload()">\n';
		sLcl += '<DIV ID="shine" STYLE="position:absolute;z-index:10;left:0px;top:0px;width:0px;height:0px;"></DIV>';
	} else if ( top.theBrowser.ns4 ) {
		var sLcl = '<BODY ' + bgColorP;
		if ( bNeutralP == 'override' ) { sLcl += ' MARGINWIDTH="0" MARGINHEIGHT="0"'; }
		sLcl += ' ONLOAD="javascript:' + sTopP + '.getXY(window)' + ( ( sOnLoadP ) ? ';' + sOnLoadP : '' ) + '">\n';
	}
	hDocP.write( sLcl );
}
function writeDivStyle( hDocP, sDivIDP, sBgColorP, sShowP, bCanScrollP, sWrapColorP, sHandleColorP ) {
	var bCanScroll = ( bCanScrollP ) ? bCanScrollP : false;
	var sShow = ( sShowP == 'hidden' ) ? 'visibility:hidden;' : '';
	var sBgColor = ( ( sBgColorP == '#none' ) ? '' : 'layer-background-color:' + sBgColorP + ';background-color:' + sBgColorP + ';' );
	hDocP.writeln( '#' + sDivIDP + ' {position:absolute;' + sShow + 'border:1px none;' + sBgColor + '}' );
	if ( bCanScroll ) {
		hDocP.writeln( '#' + sDivIDP + 'w {position:absolute;border:1px none;' + ((sWrapColorP!='#none')?'layer-background-color:' + sWrapColorP + ';background-color:' + sWrapColorP : '') + ';}' );
		hDocP.writeln( '#' + sDivIDP + 'u {position:absolute;border:1px none;' + ((sHandleColorP!='#none')?'layer-background-color:' + sHandleColorP + ';background-color:' + sHandleColorP : '') + ';}' );
		hDocP.writeln( '#' + sDivIDP + 'd {position:absolute;border:1px none;' + ((sHandleColorP!='#none')?'layer-background-color:' + sHandleColorP + ';background-color:' + sHandleColorP : '') + ';}' );
		hDocP.writeln( '#' + sDivIDP + 'b {position:absolute;border:1px none;' + ((sWrapColorP!='#none')?'layer-background-color:' + sWrapColorP + ';background-color:' + sWrapColorP : '') + ';}' );
		hDocP.writeln( '#' + sDivIDP + 'h {position:absolute;border:1px none;' + ((sHandleColorP!='#none')?'layer-background-color:' + sHandleColorP + ';background-color:' + sHandleColorP : '') + ';}' );
	}
}
function writeFontStyle( hDocP, sFontIDP, sNameP, sColorP, sSizeP, sWeightP, sStyleP, sDecorationP, bIsAP, sAColorP ) {
	var bIsA = ( bIsAP ) ? bIsAP : false;
	hDocP.writeln( '#' + sFontIDP + ' {font-family:' + sNameP + ';color:' + sColorP + ';font-size:' + sSizeP + ';font-weight:' + sWeightP + ';font-style:' + sStyleP + ';text-decoration:' + sDecorationP + ';}' );
	if ( bIsA ) {
		var sAColor = ( sAColorP ) ? sAColorP : sColorP;
		hDocP.writeln( '#' + sFontIDP + ' A:link {font-family:' + sNameP + ';color:' + sAColor + ';font-size:' + sSizeP + ';font-weight:' + sWeightP + ';text-decoration:' + sDecorationP + ';}' );
		hDocP.writeln( '#' + sFontIDP + ' A:visited {font-family:' + sNameP + ';color:' + sAColor + ';font-size:' + sSizeP + ';font-weight:' + sWeightP + ';text-decoration:' + sDecorationP + ';}' );
		hDocP.writeln( '#' + sFontIDP + ' A:active {font-family:' + sNameP + ';color:' + sAColor + ';font-size:' + sSizeP + ';font-weight:' + sWeightP + ';text-decoration:' + sDecorationP + ';}' );
		hDocP.writeln( '#' + sFontIDP + ' A:hover {font-family:' + sNameP + ';color:' + sAColor + ';font-size:' + sSizeP + ';font-weight:' + sWeightP + ';text-decoration:' + sDecorationP + ';}' );
	}
}
function showImage( sImgP, sTitleP ) {
	var sOptions = 'resizable=yes,menubar=no,left=0,top=0';
	var sUrl = 'showimage.html?img=' + sImgP + '&title=' + escape( sTitleP );
	top.hImageWindow = window.open( sUrl, 'imageWindow', sOptions );
	top.hImageWindow.focus( );
}
function getFormHandle( hDocP, sFormNameP ) {
	if ( top.theBrowser.ie || top.theBrowser.ns5 ) { hFormHandle = hDocP.getElementById( sFormNameP ) }
	else {
		var i = 0;
		var hFormHandle = -1;
		var bNotFound = true;
		// if the DIV is in the current document level, assign it and return it.
		if ( hDocP[sFormNameP] ) {
			hFormHandle = hDocP[sFormNameP];
			bNotFound = false;
		}
		// otherwise, browse through all the layers in this document and check these with the same routine.
		else {
			while ( ( i < hDocP.layers.length ) && ( hFormHandle < 0 ) ) {
				hFormHandle = this.getFormHandle( hDocP.layers[i].document, sFormNameP );
				i++;
			}
		}
	}
	return hFormHandle;
}
////////////////////////////////////////////////////////////////////////////////////////////////////
// processes entries into Warenkorb forms. Params are: Doc where the form is located,
// name of the form, page to be executed, name of Div array where the doc is to be loaded into.
// if this param is 'window', then open a new browser window for the Warenkorb.
// if this is anything else, then an additional param indicates the name of the target div.
////////////////////////////////////////////////////////////////////////////////////////////////////
function readFormData( hDocP, sFormNameP ) {
	var hForm = null;
	hForm = top.getFormHandle( hDocP, sFormNameP );
	var sLcl = '';
	if ( hForm ) {
		with ( hForm ) {
			for ( var i = 0; i < elements.length; i++ ) {
				if ( ( elements[i].type != 'submit' ) && ( elements[i].type != 'reset' ) && ( elements[i].type != 'checkbox' ) ) {
					if ( ( top.theBrowser.ns4 ) && ( elements[i].value == null ) ) { // NS treats combos .....
						sLcl += elements[i].name + '=' + escape( elements[i].options[elements[i].selectedIndex].value ) + '&';
					}
					else {
						sLcl += elements[i].name + '=' + escape( elements[i].value ) + '&';
					}
				}
				else if ( elements[i].type == 'checkbox' ) {
					sLcl += elements[i].name + '=' + ( ( elements[i].checked ) ? 'on' : 'off' ) + '&';
				}
			}
		}
	}
	sLcl = sLcl.substr( 0, sLcl.length - 1 );
	return sLcl;
}
function hideHelp( ) {
	if ( top.hHelpWindow ) {
		if ( ! top.hHelpWindow.closed ) { top.hHelpWindow.close( ) }
	}
}
////////////////////////////////////////////////////////////////////////////////////////////////////
// this functions gets called by the machine-generated BODY tags. so be sure to always use
// top.writeBody() if you want to use the width and height coordinates of a doc also with IE!!!!
////////////////////////////////////////////////////////////////////////////////////////////////////
function getXY( hWindowP ) {
	if ( top.theBrowser.ns4 || top.theBrowser.ns5 ) { 
		hWindowP.document.nWidth = hWindowP.innerWidth + ((top.theBrowser.ns4)?3:0);
		hWindowP.document.nHeight = hWindowP.innerHeight + (((top.theBrowser.platform=='win')&&top.theBrowser.ns4)?4:0);
		hWindowP.document.nMaxWidth = Math.max( hWindowP.document.width, hWindowP.document.nWidth );
		hWindowP.document.nMaxHeight = Math.max( hWindowP.document.height, hWindowP.document.nHeight );
	}
	else if ( top.theBrowser.ie ) { 
		hWindowP.document.nWidth = hWindowP.document.body.style.pixelWidth;
		hWindowP.document.nHeight = hWindowP.document.body.style.pixelHeight;
		hWindowP.document.nMaxWidth = Math.max( hWindowP.document.body.scrollWidth, hWindowP.document.nWidth );
		hWindowP.document.nMaxHeight = Math.max( hWindowP.document.body.scrollHeight, hWindowP.document.nHeight );
	}
}
