//*****************************************************************
// Healy Hudson Script Library
// helper tools
//
// Copyright 2000 Healy Hudson. All Rights Reserved.
//*****************************************************************
var ctl_date												//control to place date
var ary				= new Array(100);						//Preise für Konfigurator
var arybez			= new Array(100);						//Bezeichnungnen für Konfigurator
var ary_art_id		= new Array(100);
var ary_deliverytime= new Array(100);
var ary_deliverymax = new Array(100);
var ary_const		= new Array(100);
var ary_aufpreis    = new Array(100);						//addiert für jedes feature den Aufpreis (über die quantitylinks)

var oj;												//Übergabe von loaddoc zu setstatetimer
var wait;

//*****************************************************************
// browser versions
//*****************************************************************

av           = navigator.appVersion;
iMSIE        = parseInt(av.indexOf("MSIE"));
var bVer5    = false;
bVer5        = (parseInt(av.charAt(iMSIE+5)) >=5);
var NS4      = (document.layers ? true : false);

var isNS6=navigator.userAgent.indexOf("Gecko")!=-1?true:false;
var isIE;
var isIE=document.all?true:false;

function alert2 (d) {

    var regexp= /\&\#[0-9]{3};/g
    var erg=d.match(regexp);
    var ret = d; 
    var e = '';
    if (erg) {
        for (var i = 0; i < erg.length; i++) {
            e=erg[i];
            d = d.replace(e,dx(e.substr(2,3)));
        }
        alert(unescape(d)) ;
    } else {
        alert(d);
    }
}    
    
function dx (d) {

  var z = new Array("0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "A", "B", "C", "D", "E", "F");
  var x = "";
  var i = 1, v = d, r = 0;
  while (v > 15) {
    v = Math.floor(v / 16);
    i++;
  }
  v = d;
  for (j=i; j >= 1; j--) {
    x = x + z[Math.floor(v / Math.pow(16, j-1))];
    v = v - (Math.floor(v / Math.pow(16, j-1)) * Math.pow(16, j-1));
  }
  var l = x.length;
  if (l==2) {x='%u00' + x} else {x='%u0' + x}
  
  return x;
}

function getE(elem)
	{if (document.getElementById) {x=document.getElementById(elem)}
	 else if (document.all) {x=eval('document.all.'+elem)}
	 else {x=null}
	return x}

var cancel2   = 0;
var konfig   = 0;
var mnuSelected = '';

function pick_date()
{
var newWindow;
var urlstring = 'calendar.asp'
newWindow = window.open(urlstring,'','height=200,width=280,toolbar=no,minimize=no,status=no,memubar=no,location=no,scrollbars=no')
}



//*****************************************************************
// function calc_price()
// called by bildundLangtext.asp/showArtikeldetails
// 
//*****************************************************************

function calc_price(id,pa_id) {

	var dl2 = 0;
	var ql_alt = 0;
	var ql = 0;
	var quantityinterval = 1;
	var msgcount=0;


	if (cancel2!=-1) {
		//preis bestimmen
		pricefield=window.document.getElementById('p_netto'+id); //preisfeld bestimmen
		pricefield.innerHTML=window.document.getElementById('p_basisnetto'+id).innerHTML; //price reset auf basispreis
		preis=pricefield.innerHTML.replace(',','.');
		
		
		//lieferzeit
		deliverytimefield=window.document.getElementById('p_deliverytime'+id); //preisfeld bestimmen
		deliverytimefield.innerHTML=window.document.getElementById('p_basisdeliverytime'+id).innerHTML;
		deliverytime=deliverytimefield.innerHTML
	
		//eingabefelder (object)
		f = document.Boxes['feature'+pa_id];   //nicht mit getElementById(), da die funktion nur das erste element der auflistung zurückgibt!
		d = window['div_feature'+pa_id];       // DIV um die felder
		t = window['tr_feature'+pa_id];       // TR um die felder
		p = window['p_pricelink'];			// Feld für Aufpreis
		u = window['p_unitlink'];			// Feld für Einheit
		q = window['p_pricequantitylink'];  // Feld für Preismenge und Einheit
	
	
		//ausblenden aller felder
					
		for (i=1;i<f.length;i++) {
			
			if (ary[i] && f[i] && f[i].tagName!='TEXTAREA') { //preisarray, features müssen da sein, textboxen werden ignoriert
				// preis aus array oder input ziehen. bei selectboxen in abhängigkeit vom selectedindex 
				if (f[i].length) { 					
					

					if (f[i]) {
						for (i1=0;i1<f[i].options.length;i1++) {
							if (f[i].options[i1].quantitylink) {
								ary_ql=f[i].options[i1].quantitylink.split(',');
								if (ary_ql.length) {ary_ql_len=ary_ql.length} else {ary_ql_len=1}
								for (a=0;a<ary_ql_len;a++) {
									if (ary_ql[a]) {
										if (t[ary_ql[a]]) {
											//('hide' + f[i].title + '-' + ary_ql[a]);
											t[ary_ql[a]].style.display='none';
											f[ary_ql[a]].style.display='none';
											
											//hier wird die Mutter gesetzt
											ary_parent[ary_ql[a]]=i;	
											//alert('set ' + ary_ql[a] + '=' + i);
										}
									}
								}
							}
						}
					}	
				}
			}
		}


		//Loop über alle features
		
		
		for (i=1;i<f.length;i++) {
			
			if (ary[i] && f[i] && f[i].tagName!='TEXTAREA') { //preisarray, features müssen da sein, textboxen werden ignoriert
				// preis aus array oder input ziehen. bei selectboxen in abhängigkeit vom selectedindex 
				if (f[i].length) { 
			
					c=f[i].selectedIndex;
					mp=ary[i][c]; //Preis
					dl=ary_deliverytime[i][c];
					
					mp2=mp		  //für preisanzeige später
					quantity=1;
					//NS unterstützt anscheinend keine selbstdefinierten attribute?
					if (f[i].options[f[i].selectedIndex].quantitylink) {
						ql=f[i].options[f[i].selectedIndex].quantitylink;	
						ql1=ql;			
						if (f[ql].options) { //evtl. ein weiterer quantitylink?
							if (f[ql].options[f[ql].selectedIndex].quantitylink) {
								ql=f[ql].options[f[ql].selectedIndex].quantitylink;
								ql_alt=0; //gilt nicht weil ein zweistufiger verweis beim preis vorrang vor dem einstufigen hat 
							}
							else {
								ql1=i //zurücksetzen, da Einheit und Preismenge direkt vom aktuellen feature verwendet werden.
							}
						}
						else {
							ql1=i //zurücksetzen, da Einheit und Preismenge direkt vom aktuellen feature verwendet werden.
						}
					} 
					else {
						ql='';						
					}
					
					//Preismenge vom aktuellen feature 
					quantityinterval=1
					if (!isNaN(ary_quantity[i][c]) && ary_quantity[i][c]!=0) {
						mp=mp2/ary_quantity[i][c];
						quantityinterval=ary_quantity[i][c];
					}


					if (ql!='' && ql!=ql_alt) { //falls schonmal davor das Mengenfeld verwendet wurde, dann nicht
						ary_ql=ql.split(',');
						if (ary_ql.length) {ary_ql_len=ary_ql.length} else {ary_ql_len=1}
						for (a=0;a<ary_ql_len;a++) {
							ql=ary_ql[a];
							//preismenge vom feature auf das verwiesen wird
							quantityinterval=1;
							if (!isNaN(ary_quantity[ql1][c]) && ary_quantity[ql1][c]!=0) { //ql1 da evtl. 2mal verwiesen wird
								mp=mp2/ary_quantity[ql1][c];
								quantityinterval=ary_quantity[ql1][c];
							}
					
							if (f[i].options[f[i].selectedIndex].activelink==-1 || f[i].options[f[i].selectedIndex].activelink==-2) {

								if (String(f[ql].value)=='' && ql_alt!=ql) {							
									if (msgcount==0) {alert2(l['Zusätzliche Eingabe erforderlich! Feld'] + ': [' + URLDecode(f[ql].title) + ']')}
									msgcount=msgcount+1;
								}
								t[ql].style.display='inline';
								f[ql].style.display='inline';
								
								if (msgcount==1) {try{f[ql].focus()} catch(e) {}};
								
								// min max und unit vom hauptfeature übernehmen
								if (!isNaN(ary_parent[i])) {
									 //alert( ary_parent[i] + ',' + a + ',' + f[ary_parent[i]].selectedIndex);

									 try
										{
										ary_min[ql][1]=ary_minmax[ary_parent[i]][a][0][f[ary_parent[i]].selectedIndex];  //i=parent   [0] muss parametrisiert werden
										ary_max[ql][1]=ary_minmax[ary_parent[i]][a][1][f[ary_parent[i]].selectedIndex];  //[0] muss parametrisiert werden
										ary_unit[ql][1]=ary_unit[ary_parent[i]][f[ary_parent[i]].selectedIndex];  //[0] muss parametrisiert werden
										window['min' + ql].innerHTML='&nbsp;Min.:' + ary_min[ql][1];
										window['max' + ql].innerHTML='&nbsp;Max.:' + ary_max[ql][1];
										window['p_unitlink' + ql].innerHTML='&nbsp;' + ary_unit[ql][1] + '&nbsp;';
										fo('unit' + pa_id)[ql].value=ary_unit[ql][1];
										
										}
									catch ( e )
										{
										}
									}
								if (t[ql1]) {
									t[ql1].style.display='inline';
									f[ql1].style.display='inline';
								}

								if (f[i].options[f[i].selectedIndex].activelink==-1) {

										if (f[ql].tagName=='INPUT') {	//es kann auch ein verweis auf ein selectfeld sein, dann gibt es erstmal kein aufpreis
										if (ary_unit[i][c]) {u[ql].innerHTML=ary_unit[ql1][c]} else {u[ql].innerHTML=''}
										if (mp2!=0 && f[i].options[f[i].selectedIndex].activelink!=-2) {
											p[ql].innerHTML= '&nbsp;' + l['Aufpreis'] + '&nbsp;' + String(mp2).replace('.',',') + '&nbsp;' + waehrung + '&nbsp;';
											if (ary_quantity[ql1][c]!=0 && ary_unit[ql1][c]!='' && f[i].options[f[i].selectedIndex].activelink!=-2) {q[ql].innerHTML='&nbsp;/&nbsp;' + String(ary_quantity[ql1][c]).replace('.',',') + '&nbsp;' + ary_unit[ql1][c];} else {q[ql].innerHTML=''}
										} else {
											p[ql].innerHTML=''
										}
										
										
										if (f[ql1].tagName=='SELECT') {
											if (ary_max[ql1][f[ql1].selectedIndex]==ary_min[ql1][f[ql1].selectedIndex]) {
												//min und max sind gleich, also anders prüfen
												if (f[ql].value!='' && f[ql].value!=ary_min[ql1][f[ql1].selectedIndex]) {
													alert2(l['Eingabewert in Feld'] + ' [' + URLDecode(f[ql].title) + '] ' + l['ist falsch'] + '!')
													msgcount++;
												} else {
													f[ql].value=ary_max[ql1][f[ql1].selectedIndex];
												}
											}
											
											else if(!IsFloat(f[ql],l['Eingabewert in Feld'] + ' [' + URLDecode(f[ql].title) + '] ' + l['ist falsch'] + '! ')) {
													msgcount++;
													cancel=-1;
													docheck();
											}

											else if(f[ql].value>ary_max[ql1][f[ql1].selectedIndex]) {
											
												if (f[ql].value!='' && f[ql].value.replace(',','.')>ary_max[ql1][f[ql1].selectedIndex]) {
													alert2(l['Eingabewert in Feld'] + ' [' + URLDecode(f[ql].title) + '] ' + l['ist zu gross'] + '! ' + l['Maximum'] + '=' + ary_max[ql1][f[ql1].selectedIndex]);
													msgcount++;
													f[ql].value='';
													cancel=-1;
													docheck();
												}
											}
											else if(f[ql].value<ary_min[ql1][f[ql1].selectedIndex]) {
												if (f[ql].value!='' && f[ql].value.replace(',','.')<ary_min[ql1][f[ql1].selectedIndex]) {
													alert2(l['Eingabewert in Feld'] + ' [' + URLDecode(f[ql].title) + '] ' + l['ist zu klein'] + '" ' + l['Minimum'] + '=' + ary_min[ql1][f[ql1].selectedIndex]);
													f[ql].value='';
													msgcount++;
													f[ql].value='';
													cancel=-1;
													docheck();
												}

												
												//f[ql].value=ary_min[ql1][f[ql1].selectedIndex];
											}
										}

										
										quantity=f[ql].value.replace(',','.');		
										//preis je pricelink berechnen
										preis=Number(preis);
										//alert(quantity);
										if (!isNaN(quantity)) {
											//if (quantity/quantityinterval!=Math.round(quantity/quantityinterval)) {
												//alert(Math.ceil(quantity/quantityinterval)*quantityinterval)
											//}
											mp=mp*(Math.ceil(quantity/quantityinterval)*quantityinterval);
											//alert(mp);
											//alert(quantity);
										}
										if (!isNaN(mp)) {preis=preis + mp};
										mp=0;
										quantity='';

									}
								} else {
									//nur Zusatzinfo
									quantity=1;
								}

							} 
							else {
								//es werden jetzt standardmässig vorher alle tr ausgeblendet
								//if (d[ql]) {d[ql].style.display='none'}; //todo an NS anpassen
							}
							
						}	
					}
					
				} 
				else {
					c=1;
					mp=ary[i][c];
					dl=ary_deliverytime[i][c];
					quantity=f[i].value.replace(',','.');					
				} 
				
				//berechnen und ausgeben...
				preis=Number(preis);
				deliverytime=Number(deliverytime);
				//alert(quantity);
				
				if (f[i].title.substr(0,3)!='TAG') {
					//if (!isNaN(quantity) && quantity!='') {mp=mp*(Math.ceil(quantity/quantityinterval)*quantityinterval)}
				}
				
				if (f[i].style.display=='none') {
					mp=0;
				}

				if (f[i].title.substr(0,3)=='TAG' && show_multi_tags!=true) {
					mp=0;
					//alert(0);
				} 
				
				if (!isNaN(mp)) {preis=preis + mp};
				if (!isNaN(dl)) {if (dl>dl2) {dl2=dl}}; //es wird die max. Lieferzeit verwendet
				
				preis=Math.round(preis*100)/100 + '';
				//pricefield.innerHTML=preis.replace('.',','); //formatnumber(preis,2);
				pricefield.innerHTML=formatnumber(preis,2).replace('.',','); //formatnumber(preis,2);
				if (!isNaN(dl2) && !isNaN(deliverytime)) {deliverytimefield.innerHTML=deliverytime + dl2};
			}
			ql_alt=ql
		} //end for 
		
		
		//ende preis bestimmen

		//artikelnummer bestimmen
		window.document.Boxes.art_id.value=window.document.Boxes.basis_art_id.value;
		if (f.length) {
			for (i=1;i<f.length;i++) {
				if (ary_art_id[i][f[i].selectedIndex] && f[i] && f[i].tagName!='INPUT' && f[i].tagName!='TEXTAREA') {
					mp=ary_art_id[i][f[i].selectedIndex];
					if (ary_feldtyp[i][f[i].selectedIndex]=='') {
						window.document.Boxes.art_id.value=window.document.Boxes.art_id.value + mp
					} else {
						
					}
				}
				else if (f[i].selectedIndex==0) {
					t='__________';
					window.document.Boxes.art_id.value=window.document.Boxes.art_id.value + t.substr(0,ary_art_id[i][1].length)
				}
				else if (f[i].tagName=='INPUT') {
					if (ary_art_id[i][1]!='') {
						window.document.Boxes.art_id.value=window.document.Boxes.art_id.value + ary_art_id[i][1];
						// Keine manuellen Eingaben in die Artikelnummer schreiben: window.document.Boxes.art_id.value=window.document.Boxes.art_id.value + ary_art_id[i][1];
					} 
					else {
						// Keine manuellen Eingaben in die Artikelnummer schreiben: window.document.Boxes.art_id.value=window.document.Boxes.art_id.value + f[i].value;
					}
				}
			}
		}
		//end artikelnummer bestimmen

		//min max bestimmen
		cancel2=0;
		if (f.length) {
			for (i=1;i<f.length;i++) {
				if (f[i].tagName=='INPUT'  ) { 
					
					//bei prüfung auf numerisch müsste vorher das feld das numerisch deklariert werden
					//if (isNaN(f[i].value.replace(',','.')) && f[i].value!='') {
					//			if (msgcount==0) {alert(l['Eingabewert in Feld'] + ' [' + URLDecode(f[i].title) + '] ' + l['ist nicht numerisch'] );msgcount++}
					var v ;
					if (f[i].value!='' && ary_max[i][1]!=999999999) {						
						v = parseFloat(f[i].value.replace(',','.'));
						if (isNaN(v)) {
							alert2('Es dürfen nur Zahlen verwendet werden.');
							v='';
							try{f[i].focus()} catch(e) {};
						} else if (v!=f[i].value.replace(',','.')) {
							alert2('Es dürfen nur Zahlen verwendet werden. Die restliche Eingabe wird abgeschnitten.');
							f[i].value=v;
							try{f[i].focus()} catch(e) {};
						}
					} else {
						v='';
					}
					
					if (f[i].value=='') {
								//if (msgcount==0) {alert(l['Zusätzliche Eingabe erforderlich! Feld'] + ' [' + URLDecode(f[i].title) + '] ');msgcount++}
					} else if (f[i].value!='' && v>ary_max[i][1] && ary_max[i][1]!=999999999) {
						if (msgcount>=0) {
							alert2(l['Eingabewert in Feld'] + ' [' + URLDecode(f[i].title) + '] ' + l['ist zu gross'] + '! ' + l['Maximum'] + '=' + ary_max[i][1]);
							try{f[i].focus()} catch(e) {};
							msgcount++;
						}
						cancel=-1;
						//f[i].value=ary_max[i][1];
						f[i].value='';
						docheck();
					}
					
					//if (isNaN(f[i].value.replace(',','.')) && f[i].value!='') {
					//	if (msgcount==0) {alert(l['Eingabewert in Feld'] + ' [' + URLDecode(f[i].title) + '] ' + l['ist nicht numerisch'] );msgcount++}
					if (f[i].value=='') {
						//if (msgcount==0) {alert(l['Zusätzliche Eingabe erforderlich! Feld'] + ' [' + URLDecode(f[i].title) + '] ');msgcount++}
		
					} else if (f[i].value!='' && v<ary_min[i][1] && ary_max[i][1]!=-999999999) {
						if (msgcount>=0) {
							alert2(l['Eingabewert in Feld'] + ' [' + URLDecode(f[i].title) + '] ' + l['ist zu klein'] + '! ' + l['Minimum'] + '=' + ary_min[i][1])
							try{f[i].focus()} catch(e) {};
							msgcount++;
						}
						cancel=-1;
						//f[i].value=ary_min[i][1];
						f[i].value='';
						docheck();
					}
					
					
					//max workaround
					//es muss noch eine logig her, die regelt ob inputs zusammenhängen und wie die grösser-kleiner beziehung aussieht.
					if (true || f[i].value=='' || i==0) {
						//if (msgcount==0) {alert(l['Zusätzliche Eingabe erforderlich! Feld'] + ' [' + URLDecode(f[i].title) + '] ');msgcount++}
				    } else if ( !f[i-1] ) {
						// es gibt kein feld davor	

					} else if ( f[i].title.substring(0,13)==f[i-1].title.substring(0,13) ) {
							//sind im max feld und es gibt ein min feld
							
						if ( f[i-1].value!='' && f[i].value!='' && v<=f[i-1].value.replace(',','.') ) {
							if (msgcount==0) {
								alert2(l['Eingabewert in Feld'] + ' [' + URLDecode(f[i].title) + '] ' + 'ist kleiner als der im Feld' + ' [' + URLDecode(f[i-1].title) + '] ');
								try{f[i].focus()} catch(e) {};
								msgcount++;
							}
							cancel=-1;
							//f[i].value=ary_min[i][1];
							//f[i].value='';
							docheck();
						}
					}

					//min workaround, wird eigentlich nicht benötigt da die max proüfung immer schon vorher zieht
					
					if (true || f[i].value=='' || i==0) {
						//if (msgcount==0) {alert(l['Zusätzliche Eingabe erforderlich! Feld'] + ' [' + URLDecode(f[i].title) + '] ');msgcount++}
					} else if ( !f[i+1] ) {
						// es gibt kein feld davor	

					} else if ( f[i].title.substring(0,13)==f[i+1].title.substring(0,13) ) {
							//sind im max feld und es gibt ein min feld
							
						if ( f[i+1].value!='' && f[i].value!='' && v>=f[i+1].value.replace(',','.') ) {
							if (msgcount==0) {
								alert2(l['Eingabewert in Feld'] + ' [' + URLDecode(f[i].title) + '] ' + 'ist größer als der im Feld' + ' [' + URLDecode(f[i+1].title) + '] ');
								try{f[i+1].focus()} catch(e) {};
								msgcount++;
							}
							cancel=-1;
							//f[i].value=ary_min[i][1];
							//f[i].value='';
							docheck();
						} else {
							if (msgcount==0) {try{f[i+1].focus()} catch(e) {}};
						}
					}
					
					
				}
				else if (f[i].tagName=='SELECT') {

					if (f[i].options[f[i].selectedIndex].quantitylink && f[i].options[f[i].selectedIndex].activelink==-1) { //es gibt einen verweis auf ein eingabe feld, dass geprüft werden muss
						ql=f[i].options[f[i].selectedIndex].quantitylink;
						if (f[ql] && f[ql].tagName=='INPUT') {
							//if (isNaN(f[ql].value.replace(',','.')) && f[ql].value!='') {
							//	alert2(l['Eingabewert in Feld'] + ' [' + URLDecode(f[ql].title) + '] ' + l['ist nicht numerisch'] );
							if (f[ql].value=='') {
								//if (msgcount==0) {alert2(l['Zusätzliche Eingabe erforderlich! Feld'] + ' [' + URLDecode(f[ql].title) + '] ');msgcount++}

							} else if(!IsFloat(f[ql],l['Eingabewert in Feld'] + ' [' + URLDecode(f[ql].title) + '] ' + l['ist falsch'] + '! ')) {
									msgcount++;
									cancel=-1;
									docheck();
								
							} else if(f[ql].value.replace(',','.')>ary_max[i][f[i].selectedIndex]) {
								if (msgcount==0) {
									alert2(l['Eingabewert in Feld'] + ' [' + URLDecode(f[ql].title) + '] ' + l['ist zu gross'] + '! ' + l['Maximum'] + '=' + ary_max[i][f[i].selectedIndex]);
									msgcount++;
								}
								cancel=-1;
								//f[ql].value=ary_max[i][f[i].selectedIndex];
								f[ql].value='';
								docheck();

							} else if (f[ql].value.replace(',','.')<ary_min[i][f[i].selectedIndex]) {
								if (msgcount==0) {
									alert2(l['Eingabewert in Feld'] + ' [' + URLDecode(f[ql].title) + '] ' + l['ist zu klein'] + '! ' + l['Minimum'] + '=' + ary_min[i][f[i].selectedIndex]);
									msgcount++;
								}
								cancel=-1;
								//f[ql].value=ary_min[i][f[i].selectedIndex];
								f[ql].value='';
								docheck();
							}
						}
					}
				}
			}
		}
		//end min max bestimmen
	}
	else {
		cancel2=0
	} //end cancel2

} //end function


//*****************************************************************
// function multitag()
// called by 
// 
//*****************************************************************

function multitag(t) {

if (Boxes['multi_TAG']) {
	z=1;
	if (Boxes['multi_TAG'].length) {z=Boxes['multi_TAG'].length};
	for (j=0;j<z;j++) {
		//alert2(Boxes['multi_TAG'][j].value);
		multi=window[Boxes['multi_TAG'][j].value];
		
		for (i=0;i<multi.length;i++) {
			multi[i].style.display='none';
		}
		
		if (show_multi_tags==true) {
			x=t.value;
			if (is_bundle==-1) {document.getElementById('multi_bundle').value='-1'};
		} else {
			x=0;
			document.getElementById('multi_bundle').value='';
		}
		if (x>multi.length) {x=multi.length}

		for (i=0;i<x;i++) {
			multi[i].style.display='block';
		}
	}

	docheck();
} 	
}

//*****************************************************************
// function checkconfig()
// called by 
// 
//*****************************************************************

function checkconfig(checkstring,pa_id,currentTag) {
	

	max=0;	
	d=document;
	p=window;
		
	if (cancel2!=-1) {
		if (d.fo) {
			fo=d.fo
			}
		else {
			fo=d.Boxes
			}
	
			
				 f=fo('feature'+pa_id);
				 
				 
				if (currentTag.selectedIndex) {
					if (currentTag.options[currentTag.selectedIndex].text.substr(0,3) == '###') { //nur falls noch nicht markiert	
						//alert2(URLDecode(f[s1].title) + ' = [' + URLDecode(f[s1].options[f[s1].selectedIndex].outerText) + ']\nkann nicht mit\n' + URLDecode(f[s2].title) + ' = [' + URLDecode(f[s2].options[f[s2].selectedIndex].outerText) + ']\nkombiniert werden');
						alert2(l['Variante kann nicht kombiniert werden mit'] + ':\n' + currentTag.label);
						//currentTag.options[currentTag.selectedIndex].style.color='red';
						currentTag.selectedIndex=0;
						return false;
					}
				}
						
				 
				 
				 
					for (i = 1; i < f.length; i++) {
						//alert2(f[i].tagName);
						//images aktualisieren
						if (f[i].tagName=='SELECT') {
							if (arybez[i] && f[i]) {
								t=arybez[i][f[i].selectedIndex]; 
								if (t && t!='') {
									endung=t.substr(t.length-4,t.length);
									if (endung=='.gif'||endung=='.jpg') {
										getE('p_img' + i).src=t;
									}
								}
							}
						}
					}

				 
					 for (i = 1; i < f.length; i++) {
						//Aufräumen: vorher gesetzte Inkompatibilitätshinweise entfernen!
						for (j = 1; j < f.length; j++) {
							//alle anderen selectboxen durchgeben und auf kompatibilität prüfen
							if (f[j].length) {
								for (k = 1; k < f[j].length; k++) {
									if (f[j].options[k].text.substr(0,3) == '###') {
										z = f[j].options[k].text.lastIndexOf('###');
										if (z!=-1) {f[j].options[k].text = f[j].options[k].text.substring(z+3,f[j].options[k].text.length)};
									}
								}
							}
						}
					}	
					
					for (s1 = 1; s1 < f.length; s1++) {																			//erster feature loop.	selectbox wählen s1 = erste selectbox
						var incomp = new Array(100000); //alle aktiven inkompatibilitäten
						var incompcount = new Array(100000); 
						var incompselected = new Array(100000); 
						var incompcounter=0;
						var incompary = new Array(100000);
						
						
																	//f.length nicht mit -1 da sonst letztes feature nicht berücksichtigt wird! 
						for (s2 = 1; s2 < f.length; s2++) {																	//zweiter feature loop
																																	//alle anderen selectboxen durchgeben und auf kompatibilität prüfen. s2 = zweite selectbox
							if (s1!=s2 && f[s1].length && f[s2].length) {															//selectboxen? nicht ein feature mit sich selbst vergleichen
								
								for (v2 = 1; v2 <= f[s2].length; v2++) {															//bei ersten feature werdendie ausschlusskrit der ausgewählten vaariante verwendet bei den anderen, die dagegen verglichen werden werden allen varianten durchgeloopt  (v2)
									if (f[s1].selectedIndex && f[s1].selectedIndex>0) {n1=f[s1].selectedIndex} else {n1=0};			//n1= ausgewählte variante
									if (f[s2].selectedIndex && f[s2].selectedIndex>0) {n2=f[s2].selectedIndex} else {n2=0};									
									if (ary_const[s1] && ary_const[s2]) {															//sind beide arrays vorhanden?
										if (s1!=s2 && ary_const[s1][n1]!='') {														//nicht eine select box mit sich selbst vergleichen und prüfen, dass ausschluss array vorhanden
											if (ary_const[s1][n1]) {																			//ist ein array mit ausschlusskriterien für die ausgewählte variante des ersten features da
												for (a1 = 0; a1 < ary_const[s1][n1].length; a1++) {												//alle ausschlusskriterien der ausgewählten variante des ersten features durchgehen
													if (ary_const[s2][v2]) {
														for (a2 = 0; a2 < ary_const[s2][v2].length; a2++) {
															//aktuelle Auswahl prüfen
															if (n1>0 && n2>0) {																	//sind bei beiden features varianten ausgewählt?
																if (cancel2==0 && s2>s1 && ary_const[s1][n1][a1]==ary_const[s2][n2][a2]) {		//ausschlusskrit der aktuell ausgewählten varianten prüfen
																	//alert2(URLDecode(f[s1].title) + ' = [' + URLDecode(f[s1].options[f[s1].selectedIndex].outerText) + ']\nkann nicht mit\n' + URLDecode(f[s2].title) + ' = [' + URLDecode(f[s2].options[f[s2].selectedIndex].outerText) + ']\nkombiniert werden');
																	//if (currentTag.selectedIndex) {currentTag.selectedIndex=0};
																	
																}
															}
															//alle Möglichkeiten prüfen
															if (ary_const[s1][n1][a1]==ary_const[s2][v2][a2]) { 
																if (f[s2].options[v2].text.substr(0,3) != '###') { //nur falls noch nicht markiert
																	//info=URLDecode(f[s1].options[f[s1].selectedIndex].outerText)
																	info=URLDecode(f[s1].title); //nicht auf value gehen! enthält @id
																	//info=info.substr(0,15) + '...'
																	//if (info!='...') {f[s2].options[v2].text = '###' + info + '###' + f[s2].options[v2].text} 
																	if (typeof f[s2].label=='undefined') {f[s2].label= ''}
																	if (f[s2].label.indexOf(info)==-1) {
																		f[s2].label=f[s2].label + '-' + info + '\n' ;
																	}
																	
																	incompary[incompcounter]=ary_const[s1][n1][a1];
																	incompcounter++;

																	if (isNaN(incompcount[Number(ary_const[s1][n1][a1])])) {
																		incompcount[Number(ary_const[s1][n1][a1])]=1
																	} else {
																		incompcount[Number(ary_const[s1][n1][a1])]=incompcount[Number(ary_const[s1][n1][a1])]+1
																	}
																	//alert2('count' + incompcount[Number(ary_const[s1][n1][a1])])
																	
																	if (typeof incomp[Number(ary_const[s1][n1][a1])]=='undefined') {incomp[Number(ary_const[s1][n1][a1])]=''};
																	if (n2==v2) {
																		if (isNaN(incompselected[Number(ary_const[s1][n1][a1])])) {
																			incompselected[Number(ary_const[s1][n1][a1])]=1
																		} else {
																			incompselected[Number(ary_const[s1][n1][a1])]=incompselected[Number(ary_const[s1][n1][a1])]+1
																		}
																		incomp[Number(ary_const[s1][n1][a1])]='false;';
																		//alert2('selected' + incompselected[Number(ary_const[s1][n1][a1])])
																	} else {
																		incomp[Number(ary_const[s1][n1][a1])]=incomp[Number(ary_const[s1][n1][a1])] + 'f['+s2+'].options['+v2+'].text = \'###' + info + '###\' + f['+s2+'].options['+v2+'].text\n';
																	}
																	max=Math.max(max,Number(ary_const[s1][n1][a1]));
																}
															}
														}
													}
												}
											}
										}
									}
								} 
							}
						}	 
						//alert2(max);
						//for (p=0;p<=max;p++) {
						
						
						for (r=0;r<=incompcounter;r++) {
							p=incompary[r];

							if (typeof incomp[p]!='undefined') {
								//alert2(incompcount[p] + ':' + incompselected[p]+1);
								
								if (incompcount[p]==1 || incompcount[p]==incompselected[p]+1) {
									//alert2(typeof incomp[p] + p + '/' + incomp[p]);									
									eval(incomp[p]);
								}
							}
 						}
				 }	
				 						

	}
	else {
		cancel2=0;
	} //end cancel2
}


//*****************************************************************
// function saveconfig()
// creates URL for adding an item to the current basket
//*****************************************************************

function saveconfig(s_id,pa_id) {
			
	calc_price(1,pa_id) ;
	tmp='';
	d=document;
	p=window;
	cancel2=0;
	
	//if (show_multi_tags==false) {getElementById('multi_Bundle').value=''}
	
	if (d.fo) {
		fo=d.fo
		}
	else {
		fo=d.Boxes
		}
	
    f = document.Boxes['feature'+pa_id];

	if (p.top.cancel!=-1) {
		check=true;
		if (warning==-1 && show_multi_tags==true) {check=confirm('Hinweis:\n'+URLDecode(msg2)+'\n\nTrotzdem speichern?')}
		if (check) {
		    var ne=getE('p_netto' + 1).innerHTML;
		    ne=ne.replace(',','.');
			hre='pca3.asp?form=saveconfig&S_ID='  + s_id + '&PA_ID=' + pa_id;
			hre = hre + '&netto=' + ne
			hre = hre + '&art_id=' + getE('art_id').value
			hre = hre + '&quantity=' + getE('quantity'+1).value
			hre = hre + '&deliverytime=' + getE('p_deliverytime'+1).innerHTML
			hre = hre + '&show_multi_tags=' + show_multi_tags

			Boxes.action=hre;
			Boxes.submit();
		
			
			//document.location.href=hre;
			if (refresh_cart==-1) {window.open('pca3.asp?Form=Produktauswahl&todo=nothing','MAIN')}
			if (refresh_cart==-2) {opener.open('banfshow.asp?reloadconfig=true&s_id='+s_id+'&banfid='+banfid+'&banfdetailid='+banfdetailid,'_self');} 
			if (refresh_cart==-3) {opener.open('TaskDispatcher.asp?reloadconfig=true&s_id='+s_id+'&w_id='+w_id+'&xxxo_id='+o_id+'&banfid='+banfid+'&banfdetailid='+banfdetailid,'_self');} 
			//p.C_MENU.location.reload();
			alert2(l['Gespeichert']+'!');
			window.close();
			//r.close();
		}
	}
	else {
		alert2(l['Speichern nicht möglich! Bitte ändern Sie die Konfiguration'] + '. \n' + URLDecode(msg))
	}
}

//*****************************************************************
// function savearticle()
// called by 
// 
// saves eclass attributes of an article
//*****************************************************************

function savearticle(pa_id,tabelle,pg_id) {
	
	d=document;
	p=window;
	
	if (d.fo) {
		fo=d.fo
		}
	else {
		fo=d.Boxes
		}
	
	if (p.top.cancel!=-1) {
	
		hre='Eclass.asp?action=edit&pg_id=' + pg_id + '&tabelle=' + tabelle + '&PA_ID=' + pa_id;
		
			
				 f=fo('feature'+pa_id);
				 
				 for (i = 1; i < f.length; i++) {
					 //alert2(f[i].tagName);
					 v=''; 					 
					 v=f[i].value					 					 
					 if (v!='') {
						u=fo('unit'+pa_id);
						hre=hre + '&featurename=' + f[i].title + '&featurevalue=' + v + '&featureunit=' + u[i].value;
					 }
				 }
		//hre = hre + '&pa_id='+pa_id+'&PG_ID='+pg_id+'&Produktgruppe='+Produktgruppe+'&Service=Nein';
		hre = hre + '&netto=' + getE('p_netto' + pa_id).innerHTML
		//alert2(hre);
		window.open(hre,'DUMMY');
		//p.C_MENU.location.reload();
		alert2('Gespeichert!');
		window.close();
	}
	else {
		alert2(l['Speichern nicht möglich! Bitte ändern Sie die Konfiguration'] + '. \n' + URLDecode(msg))
	}
}

//*****************************************************************
// function order()
// called by 
// works in IE4 only
// creates URL for adding an item tu the current basket
//*****************************************************************

function order(pa_id,pg_id,Produktgruppe,s_id,art_id,id, limitpg_id) {
	

	if (s_id && s_id!='') {id=s_id} else {if (!id) {id=pa_id}}
	
	
	if (opener) {
		p=opener.parent;
		d=opener.top.CONTENT.MAIN;
		}
	else {
		p=parent;
		d=top.CONTENT.MAIN;
		} 
	if (p.top.cancel!=-1) {
		bolOK=true;
		

		if (bolOK) {
			p='';	
			
			if (getE('p_netto'+id)) {p=getE('p_netto'+id).innerHTML};
			m=1;
			if (getE('quantity'+id)) {m=getE('quantity'+id).value};
			if(m=='') m='1';

			hre='pca3.asp?form=Produktauswahl&Preis_extern=' + p + '&menge=' + m;
			
			hre = hre + '&pa_id='+pa_id+'&artnr='+art_id+'&s_id='+s_id+'&limitPG_ID='+limitpg_id+'&PG_ID='+pg_id+'&Produktgruppe='+Produktgruppe+'&Service=Nein';
			
			window.open(hre,'DUMMY');
			//p.C_MENU.location.reload();
			if (opener) {window.close()};
			//alert2(top.document.title);
		}
	}
	else {
		alert2(l['Bestellen nicht möglich! Bitte ändern Sie die Konfiguration'] + '. ' + top.MODUL.MAIN.msg)
	}
	return true;
}

function multiarticle_order() {
    d=top.CONTENT.MAIN.document;
	f=d.getElementsByName('ID');
	hre='';
	bolOK=true;
	anz=0;
	if (!f.length) { 
		bolOK=false;

		var quantity = d.getElementById('quantity'+f.value);
		var temp;
		if (d.getElementById('temporary')==null){
			temp="0";
		} else {
			if (!d.getElementById('temporary').length){
				temp = d.getElementById('temporary').value;
			} else {
				temp = d.getElementById('temporary')[0].value;
			}
		}

		if (quantity){
			m=quantity.value.replace(',','.');
			switch (temp){
				case "0":	//saved cart
	 				if(f.checked) { 
						if(m=='') m='1';
						f.checked=false;
						hre=hre+'&S_ID='+f.value+'&menge='+m+'&temp=0&pa_id='+f.pa_id+'&PG_ID='+f.pg_id+'&limitPG_ID='+f.limitpg_id;anz=1;
					}
					break;
				//case "1":	//temporary cart
				//		break;
				case "2":	//standard cart
	 				if(f.checked) { 
						if(m=='') m='1';
						f.checked=false;
						hre=hre+'&S_ID='+f.value+'&temp=2&menge='+m+'&pa_id='+f.pa_id+'&PG_ID='+f.pg_id+'&limitPG_ID='+f.limitpg_id;anz=1;
					}
					break;

				case "3":	//catalog
	 				if(f.checked || m>0) { 
						if(m=='') m='1';
						f.checked=false;
						//No S_Id in catalog
						hre=hre+'&menge='+m+'&pa_id='+f.pa_id+'&PG_ID='+d.getElementById('PG_ID'+f.value).value+'&limitPG_ID='+f.limitpg_id;anz=1;
					}
					break;
				default:
	 				if(f.checked || m>0) { 
						if(m=='') m='1';
						f.checked=false;
						hre=hre+'&S_ID='+f.value+'&menge='+m+'&pa_id='+f.pa_id+'&PG_ID='+f.pg_id+'&limitPG_ID='+f.limitpg_id;anz=1;
					}

			}
		}

	} else {
		for (i = 0; i < f.length; i++) {
			var quantity = d.getElementById('quantity'+f[i].value);
			if (quantity){
				if (quantity.value!=""){
					if (!IsNumeric(quantity,'Die Menge ist nicht ganzzahlig oder numerisch!')) {
						bolOK=false;
						break;
					}
				}
			}
		}
		
		if (bolOK) {
			anz=0;
			var temp;
			if (d.getElementById('temporary')==null){
				temp="0";
			} else {
				if (!d.getElementById('temporary').length){
					temp = d.getElementById('temporary').value;
				} else {
					temp = d.getElementById('temporary')[0].value;
				}
			}

			for (i = 0; i < f.length; i++) {
				var quantity = d.getElementById('quantity'+f[i].value);
				
				if (quantity){
					m=quantity.value.replace(',','.');
					
					switch (temp){
						case "0":	//saved cart
	 						if(f[i].checked) { 
								if(m=='') m='1';
								f[i].checked=false;
								//top.CONTENT.MAIN.order(f[i].pa_id, f[i].pg_id, f[i].tab)
								//hre=hre+'&S_ID='+f[i].value+'&menge='+m+'&pa_id='+f[i].pa_id+'&PG_ID='+f[i].pg_id;anz=anz+1;
								hre=hre+'&S_ID='+f[i].value+'&menge='+m+'&temp=0&pa_id='+f[i].pa_id+'&PG_ID='+f[i].pg_id+'&limitPG_ID='+f[i].limitpg_id;anz=anz+1;
							}
							break;
//						case "1":	//temporary cart
//							break;
						case "2":	//standard cart
	 						if(f[i].checked) { 
								if(m=='') m='1';
								f[i].checked=false;
								//top.CONTENT.MAIN.order(f[i].pa_id, f[i].pg_id, f[i].tab)
								hre=hre+'&S_ID='+f[i].value+'&temp=2&menge='+m+'&pa_id='+f[i].pa_id+'&PG_ID='+f[i].pg_id+'&limitPG_ID='+f[i].limitpg_id;anz=anz+1;
							}
							break;

						case "3":	//catalog
	 						if(f[i].checked || m>0) { 
								if(m=='') m='1';
								f[i].checked=false;
								//No S_Id in catalog
								hre=hre+'&menge='+m+'&pa_id='+f[i].pa_id+'&PG_ID='+d.getElementById('PG_ID'+f[i].value).value+'&limitPG_ID='+f[i].limitpg_id;anz=anz+1;
							}
							break;
						default:
	 						if(f[i].checked || m>0) { 
								if(m=='') m='1';
								f[i].checked=false;
								//top.CONTENT.MAIN.order(f[i].pa_id, f[i].pg_id, f[i].tab)
								hre=hre+'&S_ID='+f[i].value+'&menge='+m+'&pa_id='+f[i].pa_id+'&PG_ID='+f[i].pg_id+'&limitPG_ID='+f[i].limitpg_id;anz=anz+1;
							}

					}

				}
			}
		}
	}
	
	
	if(hre!='') {
		hre='pca3.asp?form=Produktauswahl'+hre;
		hre=hre+'&anzahl='+anz+'&multi_article=1';
		window.open(hre,'DUMMY');
	}

}


//*****************************************************************
// function roll()
// called by onMousemove="roll(this)"
// works in IE4 only
// changes color of button text
//*****************************************************************

function roll(hrefRoll) {
	if (document.all) hrefRoll.style.color = "#C2AA8E";
	} // end roll

function unRoll(hrefRoll) {
	if (document.all) hrefRoll.style.color = "white";
	} // end unRoll

function replace (v,sStr,rStr) {	
	var s = v;
	var chStart = s.indexOf(sStr);
	if (chStart != -1) {
		if (rStr != null) {
			s = s.substring(0,chStart) + escape(rStr) + s.substring(chStart+rStr.length,s.length+1);
		}
	}
	return s;
}

function SetVergleich (pa_id,tabelle,pg_id,t) {
	if (opener) {if(opener!='[object Window]') {x=opener.top.DUMMY}
		}
	else {x=top.DUMMY
		}
	x.location.href='sessionvar.asp?vergleich=' + pa_id + '@' + tabelle + '@' + pg_id + '&concat=' + t.checked
    }


   


//*****************************************************************
// function formatnumber(n,d) as string
// called by 
// formats a number with d decimals
//*****************************************************************

function formatnumber(n,d) {
var g;

if (isNaN(d)) {d=0}
x = String(n).lastIndexOf(',');
if (x==-1) {n=String(n).replace('.',',')}
x = String(n).lastIndexOf(',');
if (x==-1) {n=n+',';x=n.length}

y = String(n).length
if (x+d>y) {for (g=1;g<x+d-y+1;g++) {n=n+'0'}}
else {n=String(n).substr(0,x+d)+ Math.round(Number(String(n).charAt(x+d)))}
return n;
}  

//*****************************************************************
// function URLDecode(s) as string
// called by 
// 
//*****************************************************************

function URLDecode(s) {
var a;
for (a=1;a<8;a++) {
	s = s.replace('%2F','/');
	s = s.replace('%2D','-');
	s = s.replace('%22','"');
	s = s.replace('%FC','ü');
	s = s.replace('%E4','ä');
	s = s.replace('%F6','ö');
	s = s.replace('%2E','.');
	s = s.replace('%2C',',');
	s = s.replace('%3B',';');
	s = s.replace('%0D','');
	s = s.replace('%0A','');
	s = s.replace('%2A','*');
	s = s.replace('%28','(');
	s = s.replace('%29',')');
	s = s.replace('%DF','ß');
	s = s.replace('%5B','[');
	s = s.replace('%5D',']');
	s = s.replace('%3A',':');
	s = s.replace('%E9','é');
	s = s.replace('%EE','î');
	s = s.replace('%E2','â');

	s = s.replace('+',' ');
	s = s.replace('%2B','+');
}
return s
}

//*****************************************************************
// function toggle_tabdiv()
// called by makeframe
// schaltet den aktiven tab im makeframe
//*****************************************************************

function toggle_tabdiv(tabindex,prefix) {
    if (typeof(prefix)=='undefined') {prefix=''};
	if (tabindex=='') {tabindex=0};
	selected_tabindex=tabindex;
	t=document.getElementsByName(prefix+'tab_div');

	if (t) {
	
		for (i=0;i<t.length;i++) {
			t[i].style.display='none'; 
		}
		if (t[tabindex]) {
		
			t[tabindex].style.display='block';
		}
	}

	w=document.getElementsByName(prefix+'tab');
	
	if (w) {
		for (i=0;i<w.length;i++) {
			w[i].className='tab'
			
		}
		
		if (w[tabindex]) {w[tabindex].className='tab_selected'};
	}
	
	
	//assistent step highlight
	w=document.getElementsByName('text_td');
	l=document.getElementsByName('line_td');
	if (w) {
		for (i=0;i<w.length;i++) {
			w[i].className=''; 
			l[i].className=''; 
		}
		if (w[tabindex]) {
			w[tabindex].className='workflowstepselected'
			l[tabindex].className='workflowstepselected'
		};
	}
	
	
	//Buttons
	f=document.getElementsByName('fo');
	if (f) {
		n=document.getElementById('nextbutton');
		b=document.getElementById('backbutton');
		if (n) {
			if(tabindex<=0) {b.disabled=true} else {b.disabled=false} ;
			if(tabindex>stepcount-1) {n.disabled=true} else {n.disabled=false} ;
		}
	}
	
	//INPUT tabindex setzen
	t=document.getElementById(prefix+'tabindex');
	if(t) {t.value=tabindex;}
	
}


//*****************************************************************
// function togglemenu2()
// called by makeframe
// schaltet den aktiven tab im makeframe
//*****************************************************************

var mnuSelected;
var mnuTabSelected;

function togglemenu2(t, evnt) {
	//0=hide
	
	//1=show
	var m=document.getElementsByName('menutd');
	var tab=document.getElementsByName('menutable');
	
	if (tab) {
		if (tab[t.title]) {
			tab[t.title].className='menudivsub';
			mnuTabSelected=tab[t.title];
		}
	}

	if (mnuSelected) {
		mnuSelected.style.display='none';
		//zurücksetzen
		document.getElementById(mnuSelected.id.replace(/_sub/,'')).className='menudiv';
	}
	
	
	tmp=t.id
	caller='submenu';
	if (tmp.lastIndexOf('_sub')==-1) {tmp=t.id+'_sub';caller='menu'}
	
	
	mnuSelected = document.getElementById(tmp);
	
	if (mnuSelected) {
		
		if (m[t.title]) {mnuSelected.style.left=m[t.title].offsetLeft+31}
		if(m[t.title])
			mnuSelected.style.top = m[t.title].offsetTop+26;
		
	
	};
	
	trigger=document.getElementById(tmp.replace(/_sub/,''));
	
	
	switch(evnt) {
	case 0:
		
		if (trigger) {trigger.className='menudiv'};
		if (mnuSelected) {mnuSelected.style.display='none'};
		if (mnuTabSelected && caller=='submenu') {mnuTabSelected.className='menu'};
		
		break;
	case 1:

		if (trigger) {
			trigger.className='menudivsub';
		
			if(trigger.id.substring(0,1)!='x' && mnuSelected) {
				mnuSelected.style.display='block';
				mnuSelected.className='menudivsub';
				if (mnuTabSelected) {mnuTabSelected.className='menudivsub'};
			}
		}
		break;
	}

}

function togglemenu3(t, evnt) {
	//0=hide	
	//1=show
	
	var m = document.getElementsByName('menutd');	
	if (mnuSelected) {
		mnuSelected.style.display='none';
		//zurücksetzen
		//document.getElementById(mnuSelected.id.replace(/_sub/,'')).className='menudiv';
	}
	tmp=t.id
	caller='submenu';
	if (tmp.lastIndexOf('_sub')==-1) {tmp=t.id+'_sub';caller='menu'}
	// Submenu wird geholt
	mnuSelected = document.getElementById(tmp);		
	tableWithHead = document.getElementById('MenuTableWithHead');
	tableWithoutHead = document.getElementById('MenuTableWithOutHead');	
	
	// Submenu wird positioniert
	if (mnuSelected) {		
		if(m[t.title]) {mnuSelected.style.left = m[t.title].offsetLeft+31}
		var offset
		var table
		if(tableWithHead){
			offset = 60;
			table = tableWithHead;
		}else if(tableWithoutHead){
			offset = 31;
			table = tableWithoutHead;
		}		
		if(m[t.title] && table) {mnuSelected.style.top = table.offsetTop + offset}
	}
	
	trigger=document.getElementById(tmp.replace(/_sub/,''));
	
	switch(evnt) {
	case 0:		
		//if (trigger) {trigger.className='menudiv'};
	
		if (mnuSelected) {mnuSelected.style.display='none'};
		if (mnuTabSelected && caller=='submenu') {mnuTabSelected.className='menu'};		
		break;
	case 1:
	
		if (trigger) {
			//trigger.className='menudivsub';
		
			if(trigger.id.substring(0,1)!='x' && mnuSelected) {
				mnuSelected.style.display='inline';
				//mnuSelected.className='menudivsub';
				//if (mnuTabSelected) {mnuTabSelected.className='menudivsub'};
			}
		}
		break;
	}
}
	
//*****************************************************************
// function hover()
// called by <tr>
// highlighted die tr
//*****************************************************************

var oldclass='';

function hover(tag) {
	x=tag.className;
	if (oldclass=='') {oldclass='article2'}
	if (tag.className=='articlehover') {	
		tag.className=oldclass;
	} else {
		tag.className='articlehover';
	}
	oldclass=x;
}

function selected(tag) {
	x=tag.className;
	if (oldclass=='') {oldclass='article2'}
	if (tag.className=='article3') {	
		tag.className=oldclass;
	} else {
		tag.className='articleselected';
	}
	oldclass=x;
}

//*****************************************************************
// function isFloat()
// called by <input onchange
// 
//*****************************************************************

function chkFloat (control,digits) {
	if (isEmpty(control.value)) {
		return true;
	} else if (!isFloat (control,digits)) {
		alert2('Falsche Eingabe. Bitte geben Sie nur Zahlen mit Komma und max. ' + digits + ' Nachkommastellen ein');
		return false;
	} else {
		return true;
	}
		
}

function isFloat (control,digits)
{   
	var s = control.value;
	var decimalPointDelimiter = ",";
	var i;
	var countDecimal = 0;
    var seenDecimalPoint = false;
	s = s.replace('.','');
	s = s.replace('.','');
	
    
    if (isEmpty(digits)) digits=2;


    if (s == decimalPointDelimiter) return false;

    // Search through string's characters one by one
    // until we find a non-numeric character.
    // When we do, return false; if we don't, return true.

    for (i = 0; i < s.length; i++)
    {   
        // Check that current character is number.
        var c = s.charAt(i);

        if ((c == decimalPointDelimiter) && !seenDecimalPoint) seenDecimalPoint = true;
        else if (!isDigit(c)) return false;
        else if (seenDecimalPoint && countDecimal<digits+1) countDecimal++;
        else if (seenDecimalPoint && countDecimal>digits) return false;
    }
    
    if (countDecimal>digits) return false;
    if (countDecimal==0) control.value=control.value + ',';
    for (i = 0; i < digits-countDecimal; i++) {
		control.value=control.value + '0';
	}
    

    // All characters are numbers.
    return true;
}

function isDigit (c)
{   return ((c >= "0") && (c <= "9"))
}
function isEmpty(s)
{   return ((s == null) || (s.length == 0))
}
